User:Odie5533/SnipManager.user.js: Difference between revisions

Content deleted Content added
fix template preview (WP update their code?)
m Remove legacy globals per phab:T72470 (via WP:JWB)
 
(14 intermediate revisions by 3 users not shown)
Line 1:
// <pre><nowiki>
// ==UserScript==
// @name SnippetManager SnipManager
// @namespaceid http://en.wikipedia.org/* snipmanager
// @includeauthor http://en.wikipedia.org/* odie5533
// @description SnipManager is a script for Wikipedia which adds a toolbar to the top of the edit box for holding complex signatures, templates, or other pieces of text. It is compatible with wikEd (and TW/HW).
// @include https://secure.wikimedia.org/*
// @homepage http://en.wikipedia.org/wiki/User:Odie5533/SnipManager
// @screenshot http://upload.wikimedia.org/wikipedia/commons/2/29/SnipManager.png
// @namespace http://en.wikipedia.org/*
// @include http://*.wikipedia.org/*
// @include https://*.wikipedia.org/*
// @include https://secure.wikimedia.org/*
// @updateURL http://en.wikipedia.org/w/index.php?action=raw&ctype=text/javascript&title=User:Odie5533/SnipManager.user.js
// @grant none
// ==/UserScript==
//
Line 11 ⟶ 19:
//
// Credit also to wikiEd for coding examples
//
// Changelog:
// 2014-06-13 - Updated some of the citation templates
// 2014-05-23 - Fix insertions not working with wikEd (insertTags); added Cite press release
// 2012-11-09 - Cleanup code; fix bug in insertTags when using wikiEd
// 2012-11-07 - Updated {{cite web}}
 
if (typeof(SnippetManagerWrapper) == 'undefined') { window.SnippetManagerWrapper = {}; }
window.SnippetManagerWrapper = function() {
 
Line 18 ⟶ 33:
if (typeof(smConfig['smTextWidth']) == 'undefined') { window.smConfig['smTextWidth'] = '220px'; }
if (typeof(smConfig['smSingleForm']) == 'undefined') { window.smConfig['smSingleForm'] = true; }
if (typeof(smConfig['smMenussmTemplateurl']) == 'undefined') { window.smConfig['smTemplateurl'] = '//en.wikipedia.org/wiki/Template:'; }
window.smConfig['smMenus'] = { '+Citations &or;':{ 'Web':'Cite web', 'News':'citenews',
'Book':'citebook', 'Journal':'citejournal', 'Video':'Cite video',
'Show Refs':'showrefs','Ref Errors':'referrs', 'DOI Bot':'doicite' },
'General &or;':{ 'Cleanup':'cleanup', 'Copy Edit':'copyedit'},
'Intro &or;':{ 'Too long':'intro-toolong', 'Too short':'intro-tooshort',
'Rewrite':'intro-rewrite', 'Missing':'intro-missing' },
'References &or;':{ 'No refs':'unreferenced', 'More refs':'Refimprove',
'No notes':'No footnotes', 'More notes':'More footnotes',
'Cite check':'citecheck', 'Prim Sources':'Primarysources'
},
'Fact':'fact',
'Weasel term':'weasel-inline',
'uw-csd':'uw-csd'
};
}
if (typeof(smConfig['smForms']) == 'undefined') {
window.smConfig['smForms'] = {
'doicite' : [ { 'httpeval':[ 'http://tools.wikimedia.de/~verisimilus/Bot/DOI_bot/doibot.php?edit=false&slow=1&page=%s', "escape(mw.config.get('wgPageName')).replace('&', '%26');" ] } ],
'cleanup' : [ { 'inserttext':'{{Cleanup}}' } ],
'copyedit' : [ { 'inserttext':'{{Copyedit}}' } ],
Line 55:
'fact' : [ { 'inserttext':'{{Fact|{{subst:DATE}}}}' } ],
'weasel-inline' : [ { 'inserttext':'{{Weasel-inline|{{subst:DATE}}}}' } ],
'Primarysources' : [ { 'inserttext':'{{PrimarysourcesPrimary sources|{{subst:DATE}}}}' } ],
'Notability' : [ { 'inserttext':'{{Notability|{{subst:DATE}}}}' } ],
'One source' : [ { 'inserttext':'{{One source|{{subst:DATE}}}}' } ],
'showrefs' : [ { 'evaluate':'easyCiteMain();citeNamedRef();' } ],
'referrs' : [ { 'evaluate':'easyCiteMain();dispErrors();' } ],
Line 64 ⟶ 66:
{'title':'Additional text', 'code':'4' }
],
'Cite web' : [ { 'prepend':'<ref>{{Cite web', 'append':'}}</ref>', 'description':'This template is used to cite online sources in Wikipedia articles. {{<a href="/wiki/Template:Cite_news" title="Template:Cite news">Cite news</a>}} can also be used when citing a news source; for general information about citations in Wikipedia articles, see <a href="/wiki/Wikipedia:CITECiting%20sources" title="" class="mw-redirect">Wikipedia:citeCiting sources</a>.' },
{'title':'<strong>Title:</strong>', 'code':'title', 'help':'titleTitle of the web articlepage. Displays in quotes'},
{'title':'<strong>URL:</strong>', 'code':'url', 'help':'urlURL of an online ___location where the webtext sourceof the publication can be found. Cannot be used if title is wikilinked. If applicable, the link may point to the specific page(s) referenced. Do not link to any commercial booksellers such as Amazon.com; see WP:PAGELINKS.'},
{'title':'First name:', 'code':'first', 'help':'FirstGiven nameor first names of author, including title(s); for example: Firstname Middlename or Firstname M. or Dr. Firstname M., Sr. Do not wikilink—use authorlink instead. Aliases: first, first1.'},
{'title':'Last name:', 'code':'last', 'help':'Last nameSurname of author. Do not wikilink—use authorlink instead. Where the surname is usually written first—as in Chinese—or for corporate authors, simply use last to include the same format as the source. Aliases: last, author, authors, last1, author1'},
{'title':'Publication date:', 'code':'date', 'help':'Full date of source being referenced in the articlesame format as other publication dates in the citations. Do not wikilink. Displays after the authors and enclosed in parentheses. If there is no author, then displays wasafter publishedpublisher.'},
{'title':'Access dateWork:', 'code':'accessdate', 'defeval':'smGetTime()work', 'help':'FullTitle dateof whenwebsite; itemcan wasbe accessed,wikilinked into ISOan 8601existing YYYY-MM-DDWikipedia format,article foror exampleurl "accessdatemay =be 2009-03-13".used to Mustadd an external link, but not beboth. wikilinkedDisplays in italics.'},
{'title':'AuthorPublisher:', 'code':'authorpublisher', 'help':'AuthorName of publisher; may be wikilinked if relevant. Not normally included for periodicals. Corporate designations such as "Ltd", "Inc" or "GmbH" are not usually included. Displays after title.'},
{'title':'Author linkYear:', 'code':'authorlinkyear', 'help':'works either with author or with last & first to link to the appropriate wikipedia article. Does not workyear withof URLs.publication'},
{'title':'Original year', 'code':'origyear', 'help':'Original publication year; displays after the date or year. For clarity, please supply specifics; example: |origyear=First published 1859 or |origyear=Composed 1904.'},
{'title':'Coauthors:', 'code':'coauthors', 'help':'allows additional authors'},
{'title':'PublicationAccess yeardate:', 'code':'yearaccessdate', 'defeval':'smGetTime()', 'help':'yearFull date when URL was accessed; use the same format as other access and archive dates in the citations;[1] do not wikilink. Can be hidden by ofregistered publicationeditors.'},
{'title':'PublicationAuthor monthlink:', 'code':'monthauthorlink', 'help':'monthTitle of publicationexisting Wikipedia article about the author—not the author\'s website; do not wikilink. Aliases: authorlink, authorlink1, author-link, author1-link.'},
{'title':'Others:', 'code':'others', 'help':'To record other contributors to the work, such as "Illustrated by John Smith" or "Translated by John Smith."'},
{'title':'Format:', 'code':'format', 'help':'e.g. PDF. HTML is implied'},
{'title':'WorkSeries:', 'code':'workseries', 'help':'IfWhen thisthe itemsource is part of a larger "work"series, such as a book, periodicalseries or website,a writejournal where the nameissue ofnumbering thathas workrestarted.'},
{'title':'Type:', 'code':'type', 'help':'Provides additional information about the media type of the source; format in sentence case. Displays in parentheses following the title. Examples: Thesis, Booklet, CD liner, Press release.'},
{'title':'Publisher:', 'code':'publisher', 'help':'Publisher, if any—for example if the website is hosted by a government service, educational institution, or company'},
{'title':'Location:', 'code':'___location', 'help':'Geographical place of publication; generally not wikilinked; omit when the name of the work includes the ___location; examples: The Boston Globe, The Times of India. Displays preceding publisher.'},
{'title':'PagesPage:', 'code':'pagespage', 'help':'pp.Page 5–7: first page and optional last page. This is for listingin the pagessource relevantthat tosupports the citation,content. notDisplays thepreceded totalwith numberp. of pages in theunless book|nopp=y.'},
{'title':'LanguagePages:', 'code':'languagepages', 'help':'languagePages ofin publicationthe source that supports the content; separate page ranges with an en dash (don\'t–); specifyseparate "English"non-sequential aspages thiswith isa thecomma default(,); do not use to indicate the total number of pages in the source. Displays preceded with pp. unless |nopp=y.'},
{'title':'At:', 'code':'at', 'help':'For sources where a page number is inappropriate or insufficient. Overridden by |page= or |pages=. Examples: page (p.) or pages (pp.); section (sec.), column (col.), paragraph (para.); track; hours, minutes and seconds; act, scene, canto, book, part, folio, stanza, back cover, liner notes, indicia, colophon, dust jacket, verse.'},
{'title':'Language:', 'code':'language', 'help':'The language the source is written in, if not English. Displays in parentheses with "in" before the language name. Use the full language name; do not use icons or templates.'},
{'title':'DOI:', 'code':'doi', 'help':'A digital object identifier for the document, such as 10.1038/news070508-7'},
{'title':'Archive url:', 'code':'archiveurl', 'help':'The URL of an archived copy of thea web page, if (or in case) the url becomes unavailable. Typically used to refer to services like WebCite and Thethe Internet Archive.; Requiresrequires archivedate.'},
{'title':'Archive date:', 'code':'archivedate', 'help':'Date when the item was archived; (requiresuse archiveurl),the same format as other access and archive dates in ISOthe 8601citations; YYYY-MM-DDdo format,not e.gwikilink. 2006-02-17.Displays Mustpreceded notby "archived from the beoriginal wikilinkedon".'},
{'title':'DateDead formaturl?:', 'code':'dateformatdeadurl', 'help':'FormatsWhen the dateURL inis astill consistentlive, fashion.but Possiblepreemptively values: nonearchived, dmy,then ymd, mdy,set iso|deadurl=no. PrecedingThis changes the valuedisplay order with anthe \'l\'title (e.g.retaining liso,the ldmy)original willlink wikilinkand the date.archive Seelinked Template:Dateat the end.'},
{'title':'Quote:', 'code':'quote', 'help':'Relevant quote from online item.'},
],
'citenews' : [ { 'prepend':'<ref>{{cite news', 'append':'}}</ref>' },
Line 94 ⟶ 99:
{'title':'Last name:', 'code':'last', 'help':'Last name of the author'},
{'title':'Publication date:', 'code':'date', 'help':'Date of publication. Use the same format as the main text of the article.'},
{'title':'Work:', 'code':'work', 'help':'The publication that ran the item, e.g. Newsweek. Can also be used for the name of a column or subpart of an issue. Do not italicize.'},
{'title':'Author link:', 'code':'authorlink', 'help':'works either with author or with last & first to link to the appropriate Wikipedia article. Does not work with URLs.'},
{'title':'Author:', 'code':'author', 'help':'Author'},
{'title':'Coauthors:', 'code':'coauthors', 'help':'Allows additional authors.'},
{'title':'Format:', 'code':'format', 'help':'e.g. PDF. HTML is implied. Specify as "fee required" if free access is no longer available. Specify as "Reprint" if you use a full original version but not hosted by the original publisher.'},
{'title':'Agency:', 'code':'agency', 'help':'The news agency (wire service) that provided the content, e.g. Associated Press, Reuters, etc. Spell out and link the full name.'},
{'title':'Work:', 'code':'work', 'help':'The publication that ran the item, e.g. Newsweek. Can also be used for the name of a column or subpart of an issue. Do not italicize.'},
{'title':'Location:', 'code':'___location', 'help':'Place of the publication, e.g. Toronto for The Globe and Mail. For student newspapers, include the name of the school.'},
{'title':'Publisher:', 'code':'publisher', 'help':'The company or organization that publishes the news source. Not necessary for major publications like The New York Times, but may add credibility for local papers that are part of a family of publications like The McClatchy Company.'},
Line 106 ⟶ 110:
{'title':'Pages:', 'code':'pages', 'help':'The page(s) on which the article is found. page inserts the abbreviation "p." before the number; pages inserts "pp." Use only one of these parameters. If numbers are entered for both, pages overrides page.'},
{'title':'Publication year:', 'code':'year', 'help':'year of publication'},
{'title':'Publication month:', 'code':'month', 'help':'month of publication'},
{'title':'Access date:', 'code':'accessdate', 'defeval':'smGetTime()', 'help':'Full date when item was accessed, in ISO 8601 YYYY-MM-DD format, for example "accessdate = 2009-03-13". Must not be wikilinked.'},
{'title':'Language:', 'code':'language', 'help':'The language in which the source is written. If English (the default) do not use this parameter.'},
Line 117 ⟶ 120:
{'title':'First name:', 'code':'first', 'help':'First name(s) of author, including title(s) (e.g. Firstname Middlename or Firstname M. or Dr. Firstname M., Snr.). Don\'t wikilink (use authorlink instead). '},
{'title':'Author link:', 'code':'authorlink', 'help':'Title of Wikipedia article about author. Article should already exist. Must not be wikilinked itself. Do not use this on its own, but along with "author" or "first" and "last".'},
{'title':'Coauthors:', 'code':'coauthors', 'help':'Full name of additional author or authors, separated by ", " (e.g. Joe Bloggs, John F. Kennedy, H. R. Dent).'},
{'title':'Editor:', 'code':'editor', 'help':'Name of editor/editors. Do not Wikilink any values in the editor field but use "editor-link" instead. The template automatically adds "ed." after the editor\'s name unless the "chapter" parameter is used in which case the template adds "in" before the editor\'s name which appears after the chapter and before the title.'},
{'title':'Other Contribs:', 'code':'others', 'help':'To record other contributors to the work, such as "illustrated by Smith" or "trans. Smith".'},
Line 130 ⟶ 132:
{'title':'Orig publication year:', 'code':'origyear', 'help':'Original publication year, for display alongside the date or year. For clarity, please specify as much information as possible, for instance "First published 1859" or "Composed 1904". This parameter only displays if a there is a value for "year" or "date".'},
{'title':'Publication year:', 'code':'year', 'help':'Year of publication edition being referenced, and month: Name of the month of publication. If you also have the day, use date instead. Must not be wikilinked.'},
{'title':'Publication month:', 'code':'month', 'help':'Year of publication edition being referenced, and month: Name of the month of publication. If you also have the day, use date instead. Must not be wikilinked.'},
{'title':'Publisher:', 'code':'publisher', 'help':'Publisher should not include corporate designation such as "Ltd" or "Inc". '},
{'title':'Location:', 'code':'___location', 'help':'Geographical place of publication.'},
Line 156 ⟶ 157:
{'title':'First name:', 'code':'first', 'help':'last works with first to produce last, first'},
{'title':'Author Wikilink:', 'code':'authorlink', 'help':'authorlink works either with author or with last & first to link to the appropriate article (interwiki link)'},
{'title':'Coauthors:', 'code':'coauthors', 'help':'allows additional authors'},
{'title':'Publication date:', 'code':'date', 'help':'January 1, 2006. Full date of publication.'},
{'title':'Publication year:', 'code':'year', 'help':'2006. Year of publication (ignored if the date field is used).'},
{'title':'Publication month:', 'code':'month', 'help':'January. Month of publication (ignored if the date field is used, or if the year field is not used).'},
{'title':'Publication day:', 'code':'day', 'help':'31. Day of month of publication (ignored if the date field is used, or if the month field is not used).'},
{'title':'Title:', 'code':'title', 'help':'Title of article. This is the only required parameter. All other parameters are optional.'},
{'title':'Journal:', 'code':'journal', 'help':'Name of the journal or periodical.'},
Line 186 ⟶ 184:
],
'Cite video' : [ { 'prepend':'<ref>{{Cite video', 'append':'}}</ref>' },
{'title':'People:', 'code':'people', 'help':'May be anyone associated with the film. Add role in parentheses (Producer, Director, Actor, etc).'},
{'title':'ISO Date:', 'code':'date2', 'help':'Full date when production was first released or aired, in ISO 8601 YYYY-MM-DD format, eg. 2000-01-31 (January 01, 2000). Use only if full date is known. Must not be wikilinked.'},
{'title':'Year:', 'code':'year2', 'help':'Year when production was first released or aired. Use if full date is not known. '},
{'title':'Month:', 'code':'month2', 'help':'Month when production was first released or aired. May only be used with year2.'},
{'title':'Title:', 'code':'title', 'help':'Title of the production. This is the only required field.'},
{'title':'Date:', 'code':'date', 'help':'Date of source being referenced. Can be full date (day, month, and year) or partial date (month and year, season and year, year). Use same format as other publication dates in the citations.'},
{'title':'Last:', 'code':'last', 'help':'Surname of author. Do not wikilink—use authorlink instead. Where the surname is usually written first—as in Chinese—or for corporate authors, simply use last to include the same format as the source.'},
{'title':'First:', 'code':'first', 'help':'Given or first names of author, including title(s); for example: Firstname Middlename or Firstname M. or Dr. Firstname M., Sr. Do not wikilink—use authorlink instead. Aliases: first1. Requires last; first name will not display if last is empty.'},
{'title':'Url:', 'code':'url', 'help':'Provides a link to either the production\'s website or to its entry at IMDb. May wikilink to an article rather than provide a URL.'},
{'title':'Format:', 'code':'format', 'help':'File format of the URL link if containing digital media. For example, "mov" or "avi".'},
Line 197 ⟶ 194:
{'title':'Location:', 'code':'___location', 'help':'Physical ___location of the publisher, formatted as either "City, State" or "City, Country". For example, "New York, NY" or "London, England".'},
{'title':'Access date:', 'code':'accessdate', 'defeval':'smGetTime()', 'help':'Full date when url was accessed, in ISO 8601 YYYY-MM-DD format, eg. 2005-01-31 (January 01, 2005). Required when url field is used to link a url. (Must not be wikilinked.) '},
{'title':'Access year:', 'code':'accessyear', 'help':'Year of access, and accessmonth: Name of the month of access. If you also have the day, use accessdate instead. Must not be wikilinked.'},
{'title':'Access month:', 'code':'accessmonth', 'help':'Year of access, and accessmonth: Name of the month of access. If you also have the day, use accessdate instead. Must not be wikilinked.'},
{'title':'Time:', 'code':'time', 'help':'Roughly what time, if accessible, a scene occurs with-in a production. Useful for citing specific scenes, quotations or data.'},
{'title':'Id:', 'code':'id', 'help':'A unique identifier, used if none of the above are applicable. In this case, you need to specify the kind of identifier you are using, preferably with a template like {{ISSN}}. (Use one of the more specialized parameters if possible; they are linked automatically. In other words, don\'t use id = ISBN 1-111-22222-9 anymore. Use isbn = 1-111-22222-9.)'},
Line 204 ⟶ 199:
{'title':'OCLC:', 'code':'oclc', 'help':'Online Computer Library Center ID number, such as 3185581.'},
{'title':'Quote:', 'code':'quote', 'help':'information source quotation of pertinent data like is the likely reason for citing the media in the first place!'},
],
'Cite press release' : [ {'prepend':'<ref>{{Cite press release', 'append':'}}</ref>' },
{'title':'First', 'code':'first', 'help':'Given or first names of author, including title(s); for example: Firstname Middlename or Firstname M. or Dr. Firstname M., Sr. Do not wikilink—use authorlink instead. Aliases: first1. Requires last; first name will not display if last is empty.'},
{'title':'Last', 'code':'last', 'help':'Surname of author. Do not wikilink—use authorlink instead. Where the surname is usually written first—as in Chinese—or for corporate authors, simply use last to include the same format as the source.'},
{'title':'Title', 'code':'title', 'help':'Title of source. Can be wikilinked to an existing Wikipedia article or url may be used to add an external link, but not both. Displays in quotes.'},
{'title':'URL', 'code':'url', 'help':'URL of an online ___location where the text of the publication can be found. Cannot be used if title is wikilinked. If applicable, the link may point to the specific page(s) referenced. Remove spurious tracking parameters from URLs, e.g. #ixzz2rBr3aO94 or ?utm_source=google&utm_medium=...&utm_term=...&utm_campaign=.... Do not link to any commercial booksellers, such as Amazon.com. See: WP:PAGELINKS.'},
{'title':'Date', 'code':'date', 'help':'Date of source being referenced. Can be full date (day, month, and year) or partial date (month and year, season and year, year). Use same format as other publication dates in the citations. Required when year is used to disambiguate {{sfn}} links to multiple-work citations by the same author in the same year. Do not wikilink. Displays after the authors and is enclosed in parentheses. If there is no author, then displays after publisher.'},
{'title':'Place (___location)', 'code':'place', 'help':'Geographical place of publication; generally not wikilinked; omit when the name of the work includes the ___location; examples: The Boston Globe, The Times of India. Displays after the title; if work is defined, then ___location is enclosed in parentheses. Alias: ___location'},
{'title':'Publisher', 'code':'publisher', 'help':'Name of publisher; may be wikilinked if relevant. The publisher is the company that publishes the work being cited. Do not use the publisher parameter for the name of a work (e.g., a book, encyclopedia, newspaper, magazine, journal, website). Not normally used for periodicals. Corporate designations such as "Ltd", "Inc" or "GmbH" are not usually included. Omit where the publisher\'s name is substantially the same as the name of the work (for example, The New York Times Co. publishes The New York Times newspaper, so there is no reason to name the publisher). Displays after title; if work is defined, then publisher is enclosed in parentheses.'},
{'title':'Agency', 'code':'agency', 'help':'The news agency (wire service) that provided the content; examples: Associated Press, Reuters, Agence France-Presse. May be wikilinked if relevant.'},
{'title':'Format', 'code':'format', 'help':'Format of the work referred to by url; for example: PDF, DOC, or XLS; displayed in parentheses after title. HTML is implied and should not be specified. Does not change the external link icon. Note: External link icons do not include alt text; thus, they do not add format information for the visually impaired.'},
{'title':'Trans. title', 'code':'trans_title', 'help':'English translation of the title if the source cited is in a foreign language. Displays in square brackets after title; if url is defined, then trans_title is included in the link. Use of the language parameter is recommended.'},
{'title':'Language', 'code':'language', 'help':'The language the source is written in, if not English. Displays in parentheses with "in" before the language name. Use the full language name or ISO 639-1 code; use of ISO 639-1 also adds appropriate language categorization; do not use icons or templates.'},
{'title':'Page', 'code':'page', 'help':'The number of a single page in the source that supports the content. Use either |page= or |pages=, but not both. Displays preceded by p. unless |nopp=y.'},
{'title':'Pages', 'code':'pages', 'help':'A range of pages in the source that supports the content. Use either |page= or |pages=, but not both. Separate using an en dash (–); separate non-sequential pages with a comma (,); do not use to indicate the total number of pages in the source. Displays preceded by pp. unless |nopp=y. Hyphens are automatically converted to en dashes; if hyphens are appropriate, for example: pp. 3-1–3-15, use |at=.'},
{'title':'Dead URL?', 'code':'deadurl', 'help':'When the URL is still live, but pre-emptively archived, then set |deadurl=no. This changes the display order with the title retaining the original link and the archive linked at the end.'},
{'title':'Archive url', 'code':'archiveurl', 'help':'The URL of an archived copy of a web page, if or in case the url becomes unavailable. Typically used to refer to services like WebCite (see: Wikipedia:Using WebCite) and Internet Archive (see: Wikipedia:Using the Wayback Machine); requires archivedate and url.'},
{'title':'Archive date', 'code':'archivedate', 'help':'Date when the original URL was archived; preceded by default text "archived from the original on". Use the same format as other access and archive dates in the citations. This does not necessarily have to be the same format that was used for citing publication dates. Do not wikilink.'},
{'title':'Access date', 'code':'accessdate', 'defeval':'smGetTime()', 'help':'Full date when original URL was accessed; use the same format as other access and archive dates in the citations; requires url. Do not wikilink. Not required for web pages or linked documents that do not change; mainly for use of web pages that change frequently or have no publication date. Can be hidden or styled by registered editors.'},
{'title':'Via', 'code':'via', 'help':'e.g. [[HighBeam Research]]'},
{'title':'Subscription', 'code':'subscription', 'help':'For online sources that require a subscription, set |subscription=yes; supersedes registration if both are set.'},
{'title':'Quote', 'code':'quote', 'help':'Relevant text quoted from the source. Displays enclosed in quotes. When supplied, the citation terminator (a period by default) is suppressed, so the quote needs to include terminating punctuation.'},
{'title':'First1', 'code':'first1', 'help':'for multiple authors, use last1, first1 through lastn, firstn where n is any consecutive number for an unlimited number of authors (each firstn requires a corresponding lastn). By default, if nine authors are defined, then only eight will show and "et al." will show in place of the last author.'},
{'title':'Last1', 'code':'last1', 'help':''},
{'title':'First2', 'code':'first2', 'help':''},
{'title':'Last2', 'code':'last2', 'help':''},
],
'Infobox Military Conflict' : [ { 'prepend':'{{Infobox Military Conflict', 'append':'}}', 'description':'' },
Line 357 ⟶ 378:
};
}
 
if (smConfig['smCustomForms'] != 'undefined') {
for (key in smConfig['smCustomForms']) {
Line 365 ⟶ 387:
window.smRibbon = new Ribbon('smRibbon',{
"Rows":"2",
"defaultItemImage":"http://upload.wikimedia.org/wikipedia/commons/thumb/5/5a/Button_Icon_BlueSky.svg/10px-Button_Icon_BlueSky.svg.png",
"MainClass":"HStrip",
"GroupClass":"HStripB",
Line 411 ⟶ 433:
[
{
"Image":"http://upload.wikimedia.org/wikipedia/en/thumb/9/99/Question_book-new.svg/35px-Question_book-new.svg.png",
"Items":["Web","Book","News","Journal","Video","Press release", "DOI Bot"],
"ItemCodes":["Cite web","citebook","citenews","citejournal","Cite video","Cite press release", "doicite"]
}
]
Line 423 ⟶ 445:
"Tabs": [
{
"Items":["No refs","More refs","No notes","More notes","Cite check","Prim sources","Notability","One source"],
"ItemCodes":["unreferenced","Refimprove","No footnotes","More footnotes","citecheck","Primarysources","Notability","One source"]
}
]
Line 435 ⟶ 457:
[
{
"Image":"http://upload.wikimedia.org/wikipedia/commons/thumb/2/2c/Broom_icon.svg/35px-Broom_icon.svg.png",
"Items":["Cleanup","Copy Edit"],
"ItemCodes":["cleanup","copyedit"]
Line 479 ⟶ 501:
// Taken from [[User:Mr.Z-man/refToolbar.js]]
// All credit for this function goes to him
/*window.smGetTime = function() {
var time = new Date();
var nowdate = time.getUTCDate();
if (nowdate<10) { nowdate = "0"+ nowdate.toString(); }
var nowmonth = time.getUTCMonth()+1;
if (nowmonth<10) { nowmonth = "0"+ nowmonth.toString(); }
var nowyear = time.getUTCFullYear();
newtime = nowyear + '-' + nowmonth + '-' + nowdate;
return (newtime);
}*/
 
// Gets the current time in the format Sep 7, 2014
window.smGetTime = (function() {
var m = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
return function() {
var t = new Date();
return m[t.getUTCMonth()] + " " + t.getUTCDate() + ", " + t.getUTCFullYear();
}
})();
 
window.smVisibleMenu = 0;
 
// Creates theSnipManager's menu on the page
function createMenu() {
// support wikiEd if it is installed
var toolbar = document.getElementById('toolbar');
if (!toolbar) {
window.smFormPanelvar toolbar = document.createElementgetElementById('divwikiEditor-ui-toolbar');
}
smFormPanel.style.clear = 'both';
if (toolbar) {
var cleardiv = document.createElement('div');
// All output is added to the sm_panel div
cleardiv.style.clear = 'both';
var sm_panel = document.createElement('div');
sm_panel.id = 'snipmanager-panel';
//toolbar.insertBefore(sm_panel, toolbar.childNodes[0]); // alt. insertion
toolbar.appendChild(sm_panel); // added to the bottom of toolbar
// the actual ribbon bar is constructed
var ribbonStrip = document.createElement('div');
ribbonStrip.className = 'HStrip';
var ribbonMenu = document.createElement('div');
ribbonMenu.className = 'HMenu';
//a place to display forms to the user
window.smFormPanel = document.createElement('div');
smFormPanel.id = 'snipmanager-form-panel';
smFormPanel.style.clear = 'both';
// All these items are added to sm_panel
toolbar.insertBefore(smFormPanel, toolbar.childNodes[0]);
sm_panel.appendChild(ribbonMenu);
//toolbar.insertBefore(cleardiv, toolbar.childNodes[0]);
toolbarsm_panel.insertBeforeappendChild(ribbonStrip, toolbar.childNodes[0]);
sm_panel.appendChild(smFormPanel);
toolbar.insertBefore(ribbonMenu, toolbar.childNodes[0]);
window.smRibbon.configuration.Menu[0].Default='true';
//toolbar.insertBefore(menulist, toolbar.childNodes[0]);
window.smRibbon.Initialize(ribbonStrip,ribbonMenu);
toolbar.style.height = 'auto';
window.smRibbon.state = 'load';
window.smRibbon.configuration.Menu[0].Default='true'Render();
smRibbon.Initialize(ribbonStrip,ribbonMenu);
smRibbon.state = 'load';
smRibbon.Render();
}
}
Line 526 ⟶ 565:
while (formFieldSet.className != 'smForm')
formFieldSet = formFieldSet.parentNode;
formFieldSet.parentNode.removeChild(formFieldSet);
}
 
function smCompileTemplate(formFieldSet) {
var templTable = formFieldSet.getElementsByTagName('table')[0];
var inputs = templTable.getElementsByTagName('input');
 
var formName = formFieldSet.formName;
var form = smConfig['smForms'][formName];
 
var insertText = new Array(form[0]['prepend']);
for (var i in inputs) {
var inp = inputs[i];
if (inp.value && inp.value.length > 0) {
if (inp.className == "%ref") {
insertText[0] = insertText[0].replace(/<ref>/, '<ref name="' + inp.value + '">');
inp.value + '">');
continue;
}
insertText.push('|' + inp.className + '=' + inp.value);
}
}
}
}
insertText.push(form[0]['append']);
return insertText.join('');
}
 
// Called whenever SnipManager needs to insert text into the edit area
// adds the template to the edit box using insertTags
function smInsertTags(insert_text) {
// called form the add template button on the form
insertTags(insert_text, '', '');
}
 
// Adds the template to the edit box using smInsertTags
// Called from the Add Template button on the form
window.smAddTemplate = function(sender) {
var formFieldSet = sender;
Line 558 ⟶ 603:
formFieldSet = formFieldSet.parentNode;
 
insertTags( var insert_text = smCompileTemplate(formFieldSet), '', '');
smInsertTags(insert_text);
}
 
Line 582 ⟶ 628:
if (templateCode.indexOf('</ref>') != -1)
templateCode = templateCode.replace(/<\/?ref.*?>/g, '');
smWikiPreview(templateCode, function(content) {
previewDiv.innerHTML = content; });
}
 
Line 594 ⟶ 641:
}
 
// Called by the Ribbon when a Ribbon button is clicked.
// code refers to a form or function
// and name is the name of the form displayed at the top of the form
window.smExecuteCode = function(code, name) {
var form = smConfig['smForms'][code];
if (!form || !form['length'] || form['length'] < 1) {
return;
}
if (form[0]['inserttext']) {
insertTagssmInsertTags(form[0]['inserttext'], '', '');
} else if (form[0]['inserteval']) {
var text = sprintf(form[0]['inserteval'][0], form[0]['inserteval']);
smInsertTags(text, '', '');
} else if (form[0]['httplink']) {
window.open(form[0]['httplink']);
// httpeval is used to open websites with dynamically generated urls
} else if (form[0]['httpeval']) {
var url = sprintf(form[0]['httpeval'][0], form[0]['httpeval']);
window.open(url);
} else if (form[0]['inserteval']) {
var text = sprintf(form[0]['inserteval'][0], form[0]['inserteval']);
insertTags(text, '', '');
} else if (form[0]['evaluate']) {
eval(form[0]['evaluate']);
Line 630 ⟶ 678:
// Creates a fieldset and adds it to the form panel
var form = smConfig['smForms'][formName];
var formFields = smGetFormFields(form);
 
var fieldSet = document.createElement('fieldset');
fieldSet.formName = formName;
smFormPanel.appendChild(fieldSet);
Line 639 ⟶ 687:
fieldSet.className = 'smForm'; //class is used to find the fieldset by
// crawling up from a button node
legend.innerHTML = '<a href="http://en.wikipedia.org/wiki/Template:'+smConfig['smTemplateurl']+formName+'" target="_blank">'+title+'</a>';
 
if (typeof(form[0]['description']) != 'undefined') {
var formDesc = document.createElement('div');
Line 646 ⟶ 694:
fieldSet.appendChild(formDesc);
}
 
// Creates the table for all the text fields
var table = document.createElement('table');
table.cellspacing = 5;
fieldSet.appendChild(table);
 
var maxcols = smConfig['smColumns'];
 
var col = 99;
var currentTr = 0;
 
// loop creates the table cells going from left to right maxcols
// and then top to bottom
for (var i = 0; i < formFields.length; i++) {
if (col++ >= maxcols) {
col = 1;
currentTr = document.createElement('tr');
table.appendChild(currentTr);
}
}
var td1 = document.createElement('td');
td1.innerHTML = formFields[i]['title'];
 
var td2 = document.createElement('td');
var textField;
var textField = createTextField(formFields[i]['code']);
if (formFields[i]['defevalcode']) {
textField.value = evalcreateTextField(formFields[i]['defevalcode']);
} else {
} else if (formFields[i]['default']) {
textField.value = createTextField('ERROR: ' + formFields[i]['defaulttitle'] + ' has no code field');
continue;
}
}
textField.title = formFields[i]['help'];
// Allows for default values or functions to be passed and their
td2.appendChild(textField);
// return value becomes the default value for the form field
if (formFields[i]['defeval']) {
textField.value = eval(formFields[i]['defeval']);
} else if (formFields[i]['default']) {
textField.value = formFields[i]['default'];
}
textField.title = formFields[i]['help'];
td2.appendChild(textField);
// each field has two TDs: one for the title and one for the text field
currentTr.appendChild(td1);
currentTr.appendChild(td2);
}
}
// buttons are added to the bottom of the fieldset as a table
Line 689 ⟶ 745:
var buttonRow = document.createElement('tr');
buttonTable.appendChild(buttonRow);
 
var addTemplateButton = addOption("smAddTemplate(this)", "Add Template");
buttonRow.appendChild(document.createElement('td').appendChild(addTemplateButton));
 
var previewTemplateButton = addOption("smPreviewTemplate(this)", "Preview Template");
buttonRow.appendChild(document.createElement('td').appendChild(previewTemplateButton));
 
var closeButton = addOption("smCloseForm(this)", "Close Form");
buttonRow.appendChild(document.createElement('td').appendChild(closeButton));
 
var previewPanel = document.createElement('div');
previewPanel.className = 'formPreview';
Line 708 ⟶ 764:
// Called when showing a form
function smGetFormFields(form) {
var formFields = new Array();
for (var i in form) {
if (!form[i]['title'] || !form[i]['code']) continue;
formFields.push(form[i]);
}
}
return formFields;
}
 
Line 730 ⟶ 786:
// Called when showing a form
function addOption(script, text) {
option = document.createElement('input');
option.setAttribute('type', 'button');
option.setAttribute('onclick', script);
option.setAttribute('value', text);
option.setAttribute('tabIndex', 1);
return option;
}
 
// simpleSimple wrapper function for wiki markup preview
// give it the markup and a function(content)
// and it will call the function with the returned preview's HTML content
Line 744 ⟶ 800:
// from within the page's JS scope
window.smWikiPreview = function(wiki_markup, func) {
var form = document.editform;
var addr = "http://enmw.wikipediaconfig.org/w/indexget('wgServer') + mw.phpconfig.get('wgScript') + "?title=" + mw.config.get('wgPageName') + "&action=submit&wpPreview=true&live=true";
"&action=submit&wpPreview=true&live=true";
var qwxmlhttp = sajax_init_object(null);
var qwxmlhttp.overrideMimeType = sajax_init_object('text/xml'null);
qwxmlhttp.openoverrideMimeType('POSTtext/xml', addr, true);
qwxmlhttp.open('POST', addr, true);
var boundary = '--(fR*3briuStOum6#v)--';
var boundary = '--(fR*3briuStOum6#v)--';
qwxmlhttp.setRequestHeader('Content-type','multipart/form-data; boundary=' + boundary);
qwxmlhttp.setRequestHeader('Content-type','multipart/form-data; boundary=' +
qwxmlhttp.onload = function(event) {
boundary);
var content = unescape(qwxmlhttp.responseText.replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&amp;/g,"&").replace(/&quot;/g,'"'));
qwxmlhttp.onload = function(event) {
var match = /<hr \/><\/div>([\w\W\n]*)<\/preview>/.exec(content);
var content = unescape(qwxmlhttp.responseText.replace(
func(match[1]);
/&gt;/g,">").replace(/&lt;/g,"<").replace(
};
/&amp;/g,"&").replace(/&quot;/g,'"'));
var postData = '--' + boundary + '\nContent-Disposition: form-data; name="wpTextbox1"\n\n' + wiki_markup + '\n--' + boundary;
var match = /<hr \/><\/div>([\w\W\n]*)<\/preview>/.exec(content);
qwxmlhttp.send(postData);
func(match[1]);
};
var postData = '--' + boundary +
'\nContent-Disposition: form-data; name="wpTextbox1"\n\n' +
wiki_markup + '\n--' + boundary;
qwxmlhttp.send(postData);
}
 
Line 789 ⟶ 851:
for (var i=0;i<this.configuration.Menu.length;i++)
{
if (this.configuration.Menu[i].Default != undefined && this.configuration.Menu[i].Default.toUpperCase() == 'TRUE')
{
this.selected = this.configuration.Menu[i];
Line 1,217 ⟶ 1,279:
}
 
mw.util.addCSS('div#snipmanager-panel{}\
div.HMenuParent{clear:both;font-size:8pt;width:100%;height:25px;border-bottom:1px solid #eee;}\
div.HMenuParent div{float:left;padding-top:4px;margin:3px 3px -3px 3px;text-align:center;width:94px;height:18px}\
div.HMenuParent div.selected{padding-top:3px;margin:3px 2px -3px 2px;background-color:#c3d6e1;border:1px solid black;border-bottom:0} /*the selected tab*/\
div.HMenuParent div.hover{padding-top:3px;margin:3px 2px -3px 2px;border:1px dashed black;border-bottom:0;background-color:#eee} /*hovering on a tab*/\
div.HStrip table tr td div{text-align:center}div.HStrip table tr td{vertical-align:middle}\
div.HStrip table tr td.HStripPC{vertical-align:middle}\
div.HStrip table tr td div div{height:18px;text-align:left;margin-bottom:1px;padding-left:5px;padding-right:8px;white-space:nowrap}\
div.HStrip table tr td div div img{margin-right:4px}\
div.HStrip table tr td div div.hover{text-decoration:underline;cursor:pointer;}/*hover on button*/\
div.HStrip {clear:both;border-top:0;margin-bottom:1px}\
div.HStrip table{background:#fafafa; margin:2px 0 2px 2px} /*just button area*/\
td.HStripS{width:2px}\
td.HStripP{padding:0 15px 0 5px;margin:0}\
td.HStripPC{padding:0 0 0 5px;margin:0}\
td.HStripLR{border-right:1px solid #c3d6e1;padding-left:5px;margin-left:8px}\
td.HStripL{ border-left:1px solid #c3d6e1;padding:0 5px 0 5px;margin:0}\
td.HStripR{border-right:1px solid #c3d6e1;padding:0 0 0 5px;margin:0}\
td.HStripB{font-size:0.8em; background:#c3d6e1;border-top:1px solid #c3d6e1;text-align:center;color:black}\
.HStripE td.HStripPC{vertical-align:middle; font-family:sans-serif;font-size:8pt; padding:0px 0px 0px 0px;margin:0px 0px 0px 0px}\
#snipmanager-form-panel{background:#fafafa;}');
 
//
// wrapper for addEventListener (http://ejohn.org/projects/flexible-javascript-events/)
//
 
var AddEventListener = function(domElement, eventType, eventHandler, useCapture) {
 
if (domElement == null) {
 
return;
var cssNode = document.createElement('style');
}
cssNode.type = 'text/css';
if (typeof(domElement.addEventListener) == 'function') {
cssNode.innerHTML = 'div.HMenuParent{clear:both;font-size:8pt;background-color:#eee;width:100%;height:25px;border-bottom:2px solid #bbb}div.HMenuParent div{float:left;padding-top:4px;margin:3px 3px -3px 3px;text-align:center;width:94px;height:18px}div.HMenuParent div.selected{padding-top:3px;margin:3px 2px -3px 2px;background-color:#ccc;border:1px solid black;border-bottom:0}div.HMenuParent div.hover{padding-top:3px;margin:3px 2px -3px 2px;border:1px dashed black;border-bottom:0;background-color:#ddd}div.HStrip table tr td div{text-align:center}div.HStrip table tr td{vertical-align:middle}div.HStrip table tr td.HStripPC{vertical-align:middle}div.HStrip table tr td div div{height:18px;text-align:left;margin-bottom:1px;padding-left:5px;padding-right:8px;white-space:nowrap}div.HStrip table tr td div div img{margin-right:4px}div.HStrip table tr td div div.hover{background-color:#ddd}div.HStrip{clear:both;border:1px solid #ccc;border-top:0;margin-bottom:1px}div.HStrip table{background:#eee !important;margin:2px 0 2px 2px}div.HStrip{background:#eee}td.HStripS{width:2px}td.HStripP{padding:0 15px 0 5px;margin:0}td.HStripPC{padding:0 0 0 5px;margin:0}td.HStripLR{border-right:1px solid #ccc;padding-left:5px;margin-left:8px}td.HStripL{ border-left:1px solid #ccc;padding:0 5px 0 5px;margin:0}td.HStripR{border-right:1px solid #ccc;padding:0 0 0 5px;margin:0}td.HStripB{font-size:0.8em; background:#ccc;border-top:1px solid #ccc;text-align:center;color:black}.HStripE td.HStripPC{vertical-align:middle; font-family:arial,helvetica;font-size:8pt; padding:0px 0px 0px 0px;margin:0px 0px 0px 0px}';
domElement.addEventListener(eventType, eventHandler, useCapture);
document.getElementsByTagName("head")[0].appendChild(cssNode);
hookEvent("load", createMenu);
}
 
if (window.parent == window) {
// append wrapper to head if run under Greasemonkey
if (typeof(GM_getValue) == 'function') {
var script = document.createElement('script');
script.id = 'SnippetManager';
script.type = 'text/javascript';
script.text = 'smHeadWrapper = ' + SnippetManagerWrapper.toString() + '; smHeadWrapper();';
document.getElementsByTagName('head')[0].appendChild(script);
}
// otherwise run installation directly
else {
domElement['wikEd' + eventType + eventHandler] = eventHandler;
SnippetManagerWrapper();
domElement[eventType + eventHandler] = function() {
var eventRootElement = document;
if (document.addEventListener == null) {
eventRootElement = window;
}
domElement['wikEd' + eventType + eventHandler](eventRootElement.event);
};
domElement.attachEvent('on' + eventType, domElement[eventType + eventHandler] );
}
return;
};
 
AddEventListener(window, 'load', createMenu, false);
}
 
SnippetManagerWrapper.startup = function() {
if (document.title == '')
return;
SnippetManagerWrapper();
}
 
SnippetManagerWrapper.startup();
 
 
// </nowiki></pre>