User:Smallman12q/Snipemanager.user.js

Source: Wikipedia, the free encyclopedia.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// <pre><nowiki>
// ==UserScript==
// @name           Multi Snippet Manager
// @namespace      http://en.wikipedia.org/User:Smallman12q/*
// @include        http://en.wikipedia.org/*
// @include        https://secure.wikimedia.org/* 
// @description    A wikipedia javascript that provides access to a number of various templates
// ==/UserScript==
//
// Author:Smallman12q
// Created: May 15, 2009
// Last Modified: May 15, 2009
// Version: 1.0.0
//
// This script is to serve as an easy method to adding citation, warning, welcome, and other 
// templates.
//
// May 15, 2009-copied over from [[User:Odie5533/SnipManager.user.js]]
//
// This script is based off of [[User:Mr.Z-man/refToolbar.js]]
// It would have been a lot harder without the work he did
//
// Credit also to wikiEd for coding examples

window.SnippetManagerWrapper = function() {

if (typeof(smConfig) == 'undefined') { window.smConfig = new Object(); }
if (typeof(smConfig['smColumns']) == 'undefined') { window.smConfig['smColumns'] = 2; }
if (typeof(smConfig['smTextWidth']) == 'undefined') { window.smConfig['smTextWidth'] = '220px'; }
if (typeof(smConfig['smSingleForm']) == 'undefined') { window.smConfig['smSingleForm'] = true; }
if (typeof(smConfig['smMenus']) == 'undefined') {
  window.smConfig['smMenus'] = { '+Citations &or;':{ 'Web':'citeweb', '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'
  };
}
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(wgPageName).replace('&', '%26');" ] } ],
        'cleanup' : [ { 'inserttext':'{{Cleanup}}' } ],
        'copyedit' : [ { 'inserttext':'{{Copyedit}}' } ],
        //'intro-toolong' : [ { 'inserttext':'{{Intro-toolong}}' } ],
        'intro-toolong' : [ { 'intro-toolong' : [ { 'inserttext':'{{Intro-toolong}}' } ],'inserttext':'{{Intro-toolong}}' } ],
        'intro-tooshort' : [ { 'inserttext':'{{Intro-tooshort}}' } ],
        'intro-rewrite' : [ { 'inserttext':'{{Intro-rewrite}}' } ],
        'intro-missing' : [ { 'inserttext':'{{Intro-missing}}' } ],
        'No footnotes' : [ { 'inserttext':'{{No footnotes|{{subst:DATE}}}}' } ],
        'More footnotes' : [ { 'inserttext':'{{More footnotes|{{subst:DATE}}}}' } ],
        'Refimprove' : [ { 'inserttext':'{{Refimprove|{{subst:DATE}}}}' } ],
        'unreferenced' : [ { 'inserttext':'{{Unreferenced|{{subst:DATE}}}}' } ],
        'citecheck' : [ { 'inserttext':'{{Citecheck|article|{{subst:DATE}}}}' } ],
        'fact' : [ { 'inserttext':'{{Fact|{{subst:DATE}}}}' } ],
        'weasel-inline' : [ { 'inserttext':'{{Weasel-inline|{{subst:DATE}}}}' } ],
        'Primarysources' : [ { 'inserttext':'{{Primarysources|{{subst:DATE}}}}' } ],
        'showrefs' : [ { 'evaluate':'easyCiteMain();citeNamedRef();' } ],
        'referrs' : [ { 'evaluate':'easyCiteMain();dispErrors();' } ],
        'citeweb' : [ { 'prepend':'<ref>{{cite web', 'append':'}}</ref>' },
                    {'title':'Title:', 'code':'title', 'help':'title of the web article'},
                    {'title':'URL:', 'code':'url', 'help':'url of the web source'},
                    {'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':'Author:', 'code':'author', 'help':'Author'},
                    {'title':'Last name:', 'code':'last', 'help':'Last name of the author'},
                    {'title':'First name:', 'code':'first', 'help':'First name of author'},
                    {'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':'Coauthors:', 'code':'coauthors', 'help':'allows additional authors'},
                    {'title':'Publication date:', 'code':'date', 'help':'date the article was published'},
                    {'title':'Publication year:', 'code':'year', 'help':'year of publication'},
                    {'title':'Publication month:', 'code':'month', 'help':'month of publication'},
                    {'title':'Format:', 'code':'format', 'help':'e.g. PDF. HTML is implied'},
                    {'title':'Work:', 'code':'work', 'help':'If this item is part of a larger "work", such as a book, periodical or website, write the name of that work.'},
                    {'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.'},
                    {'title':'Pages:', 'code':'pages', 'help':'pp. 5–7: first page and optional last page. This is for listing the pages relevant to the citation, not the total number of pages in the book.'},
                    {'title':'Language:', 'code':'language', 'help':'language of publication (don\'t specify "English" as this is the default).'},
                    {'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 the page, if (or in case) the url becomes unavailable. Typically used to refer to services like WebCite and The Internet Archive. Requires archivedate.'},
                    {'title':'Archive date:', 'code':'archivedate', 'help':'Date when the item was archived (requires archiveurl), in ISO 8601 YYYY-MM-DD format, e.g. 2006-02-17. Must not be wikilinked.'},
                    {'title':'Date format:', 'code':'dateformat', 'help':'Formats the date in a consistent fashion. Possible values: none, dmy, ymd, mdy, iso. Preceding the value with an \'l\' (e.g. liso, ldmy) will wikilink the date. See Template:Date.'},
                    {'title':'Quote:', 'code':'quote', 'help':'Relevant quote from online item.'}
                  ],
        'citenews' : [ { 'prepend':'<ref>{{cite news', 'append':'}}</ref>' },
                    {'title':'First name:', 'code':'first', 'help':'First name of author'},
                    {'title':'Last name:', 'code':'last', 'help':'Last name of the author'},
                    {'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':'Title:', 'code':'title', 'help':'required, rest is optional. Note that title must be on one line in order for the hyperlink to display properly. Do not enclose it in quotations marks, italics or other formatting, though it may be wikilinked.'},
                    {'title':'URL:', 'code':'url', 'help':'Link to the news item if available online (note this is not for a link to the main web page of the work of publisher, but only to a copy of the item specified in title). Start the url with the communications protocol e.g. http://. '},
                    {'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':'Larger 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':'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.'},
                    {'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':'Identifier:', '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 {{ASIN}} or {{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.)'},
                    {'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':'Page:', 'code':'page', '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 date:', 'code':'date', 'help':'Date of publication. Use the same format as the main text of the article.'},
                    {'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.'},
                    {'title':'Quote:', 'code':'quote', 'help':'Relevant quotation. Adding a quotation can help locate online copies of the item using a text search, especially if the original link goes dead.'},
                    {'title':'Archive url:', 'code':'archiveurl', 'help':'URL of the archive location of the item; this is for archives (such archive.org and WebCite); for back-issues and the like that are on file at the publisher\'s site, use the "url" parameter (requires archivedate).'},
                    {'title':'Archive date:', 'code':'archivedate', 'help':'Date when the item was archived (requires archiveurl), in ISO 8601 YYYY-MM-DD format, e.g. 2006-02-17. Must not be wikilinked.'},
                    {'title':'Curly Quotes:', 'code':'curly', 'help':'y causes the title to be enclosed in true curved quotes, not typewriter quotes. Currently has no effect on the quotation specified in quote.'}
                  ],
        'citebook' : [ { 'prepend':'<ref>{{cite book', 'append':'}}</ref>' },
                    {'title':'Last name:', 'code':'last', 'help':'Surname of author. Don\'t wikilink (use authorlink instead).'},
                    {'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".'},
                    {'title':'title:', 'code':'title', 'help':'Title of book. This is the only required parameter. Can be wikilinked only to an existing Wikipedia article. Do not use italics.'},
                    {'title':'URL:', 'code':'url', 'help':'URL of an online location where the book can be found. Cannot be used if you wikilinked title. If applicable, can point to the specific page(s) referenced.'},
                    {'title':'Format:', 'code':'format', 'help':'Format, e.g. PDF. HTML implied if not specified.'},
                    {'title':'Access date:', 'code':'accessdate', 'defeval':'smGetTime()', 'help':'Full date when url was accessed. Required when url field is used. Must not be wikilinked.'},
                    {'title':'Edition:', 'code':'edition', 'help':'When the book has more than one edition. e.g.: "2nd." (note that " ed." is placed after this field, so edition=2nd produces "2nd ed.").'},
                    {'title':'Series:', 'code':'series', 'help':'When the book is part of a series of publications'},
                    {'title':'Volume:', 'code':'volume', 'help':'For one book published in several volumes. However, this template displays the text in this field in bold type after the "title" and "series" parameters. An alternative is to include the volume information in the "title" field after the main title (see example below). (NB: there is a separate {{Cite encyclopedia}} template).'},
                    {'title':'Publication date:', 'code':'date', 'help':'Full date of publication edition being referenced, in the same format as the main text of the article. Must not be wikilinked.'},
                    {'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.'},
                    {'title':'Language:', 'code':'language', 'help':'The language the book is written in, if it is not English. The template automatically puts parentheses around the text and adds "in" before the language name.'},
                    {'title':'ISBN:', 'code':'isbn', 'help':'International Standard Book Number such as 1-111-22222-9. Note that "isbn", like all field names, must be in lowercase.'},
                    {'title':'OCLC:', 'code':'oclc', 'help':'Online Computer Library Center ID number, such as 3185581'},
                    {'title':'DOI:', 'code':'doi', 'help':'A digital object identifier such as 10.1016/j.coi.2004.08.001.'},
                    {'title':'Bibcode:', 'code':'bibcode', 'help':'A nineteen character Bibcode identifier.'},
                    {'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 {{ASIN}} or {{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.)'},
                    {'title':'Page:', 'code':'page', 'help':'"|pages= 5–7" produces pp. 5–7, while "|page= 5" produces p. 5. The "pp." notation indicating multiple pages, and "p." notation indicating a single page, are placed automatically when you choose between the plural (pages) or singular (page) form of the parameter. These parameters are for listing the pages relevant to the citation, not the total number of pages in the book.'},
                    {'title':'Pages:', 'code':'pages', 'help':'"|pages= 5–7" produces pp. 5–7, while "|page= 5" produces p. 5. The "pp." notation indicating multiple pages, and "p." notation indicating a single page, are placed automatically when you choose between the plural (pages) or singular (page) form of the parameter. These parameters are for listing the pages relevant to the citation, not the total number of pages in the book.'},
                    {'title':'No PP.:', 'code':'nopp', 'help':'using "page" or "pages", automatically places the p. or pp. notations. If this is inappropriate—for instance, if page=Front cover, placing any value after nopp will hide the p. or pp. notation.'},
                    {'title':'Chapter:', 'code':'chapter', 'help':'The chapter of the book, written in full. Punctuation other than quotes should be included in the value passed to the parameter, e.g. chapter = Meet Dick and Jane. produces "Meet Dick and Jane." ahead of title.'},
                    {'title':'Chapter URL:', 'code':'chapterurl', 'help':'URL of an individual chapter of online book. Should be at the same site as url, if any.'},
                    {'title':'Quote:', 'code':'quote', 'help':'Relevant quote from the book.'},
                    {'title':'Link Ref:', 'code':'ref', 'help':'use this parameter to make the reference linkable. The variable is placed after the # in a hyperlink (the fragment identifier). Such a linkable reference can be made the target of wikilinks to full references, especially useful in short citations like shortened notes and author-date referencing. See an example for using ref field in citation templates below.'},
                    {'title':'Lay summary URL:', 'code':'laysummary', 'help':'Link to a non-technical summary (or review) of the book '},
                    {'title':'Lay summary date:', 'code':'laydate', 'help':'Date of summary'},
                    {'title':'Separator:', 'code':'separator', 'help':'The separator to use in lists of authors, editors, etc. Defaults to ".", but "," may be useful also.'}, 
                    {'title':'Postscript:', 'code':'postscript', 'help':'The closing punctuation for the citation. Defaults to ".", but "" may be useful also.'}, 
                    {'title':'Last Author Sep (&):', 'code':'lastauthoramp', 'help':'The separator to use between the last two names in lists of authors. Defaults to "", but "&" may be useful also.'}
                  ],
        'citejournal' : [ { 'prepend':'<ref>{{cite journal', 'append':'}}</ref>' },
                    {'title':'Last name:', 'code':'last', 'help':'last works with first to produce last, first'}, 
                    {'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.'}, 
                    {'title':'Volume:', 'code':'volume', 'help':'Volume number of the journal in which the article is found'}, 
                    {'title':'Issue:', 'code':'issue', 'help':'Journal\'s issue number, or issue name.'}, 
                    {'title':'Series:', 'code':'series', 'help':'According to the 14th edition of Chicago Manual of Style p. 576, "As in the case of book series, some journals have attained such longevity that they have begun a new series of volumes or issues. Identification of the series (n.s., 2d ser., 3d ser., ser. b) must be made in citations to these journals."'},
                    {'title':'Pages:', 'code':'pages', 'help':'45–47: first page, and optional last page (separated by an en dash –). Manually prepend with p. or pp. if desired.'}, 
                    {'title':'Publisher:', 'code':'publisher', 'help':'Publisher of journal or periodical; should not include corporate designation such as "Ltd" or "Inc". Only include if ISSN and DOI are unavailable.'}, 
                    {'title':'Location:', 'code':'location', 'help':'Place of publication for journal or periodical.'}, 
                    {'title':'ISSN:', 'code':'issn', 'help':'The publication\'s International Standard Serial Number such as 1111-2220. Only include if a DOI is unavailable.'}, 
                    {'title':'PMID:', 'code':'pmid', 'help':'The document\'s PubMed Unique Identifier, such as 15128012'}, 
                    {'title':'PMC:', 'code':'pmc', 'help':'The document\'s PubMed Central article number for full-text free repository of an article, such as 246835'}, 
                    {'title':'DOI:', 'code':'doi', 'help':'A digital object identifier for the document, such as 10.1130/0091-7613(1990)018<1153:TAFSIA>2.3.CO;2.'}, 
                    {'title':'Bibcode:', 'code':'bibcode', 'help':'The document\'s bibcode in the Astrophysics Data System, e.g., 1924MNRAS..84..308E'}, 
                    {'title':'OCLC:', 'code':'oclc', 'help':'The periodical\'s Online Computer Library Center ID number, such as 3185581'}, 
                    {'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 {{US patent}}, {{MR}} / {{MathSciNet}}, {{Zbl}}, {{arXiv}} or {{JFM}}. (Use one of the more specialized parameters if possible; they are linked automatically. In other words, don\'t use id = PMID 15128012 anymore. Use pmid = 15128012.)'}, 
                    {'title':'URL:', 'code':'url', 'help':'This should point to, in descending order of preference: 1. A free online version of the full text  2. An online version of the full text, for which subscription is required  3. An abstract or information page, if no DOI or PMID record is available. If a DOI or PMID is available, the URL should only be specified if it would point to a different page to that which a DOI or PMID would redirect to.'}, 
                    {'title':'Language:', 'code':'language', 'help':'Language, e.g. Finnish. (English is assumed and should not be specified.)'}, 
                    {'title':'Format:', 'code':'format', 'help':'Format, e.g. PDF. Don\'t specify for HTML (implied as default). Specify as "fee required" if free access no longer available. Specify as "Reprint" if a full original version but not hosted by the original publisher.'}, 
                    {'title':'Access date:', 'code':'accessdate', 'defeval':'smGetTime()', 'help':'Full date when URL was last checked.'}, 
                    {'title':'Lay summary URL:', 'code':'laysummary', 'help':'URL of a lay summary, which could be in a popular science magazine or newspaper. '}, 
                    {'title':'Lay source:', 'code':'laysource', 'help':'Name of the source, e.g. The Guardian (UK newspaper) or New Scientist.'}, 
                    {'title':'Lay summary date:', 'code':'laydate', 'help':'Date of publication or, where this is not available, date of retrieval of the lay summary.'}, 
                    {'title':'Quote:', 'code':'quote', 'help':'Relevant excerpt from the journal.'}
                ],
        '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':'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".'},
                    {'title':'Medium:', 'code':'medium', 'help':'Type of production being sourced. (Motion picture, Television production, Documentary, Videotape, DVD, Trailer, Video game.)'},
                    {'title':'Publisher:', 'code':'publisher', 'help':'Name of the individual or group releasing the production, or airing the broadcast. For example, "Paramount Pictures" or "Disney" or "History Channel International". '},
                    {'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.)'},
                    {'title':'ISBN:', 'code':'isbn', 'help':'International Standard Book Number such as 1-111-22222-9.'},
                    {'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!'},
                ]
    };
}
if (smConfig['smCustomForms'] != 'undefined') {
	for (key in smConfig['smCustomForms']) {
		smConfig['smForms'][key] = smConfig['smCustomForms'][key];
	}
}

window.smGetShortDate = function() {
  months = ['January', 'February', 'March', 'April', 'May', 'June', 'July',
            'August', 'September', 'October', 'November', 'December'];
  return months[(new Date()).getMonth()] +' '+ (new Date()).getDate();
}

// 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);
}

window.smVisibleMenu = 0;

function createLi() {
  var option = document.createElement('li');
  option.style.cssFloat = 'left';
  option.style.listStyle = 'none';
  option.style.backgroundColor = '#EEEEEE';
  option.style.textAlign = 'center';
  option.style.padding = '0 8px';
  option.style.border = '1px solid #555555';
  option.style.marginRight = '-1px';
  option.style.cursor = "pointer";
  option.setAttribute('onmouseover', "this.style.backgroundColor='#CCCCCC';");
  option.setAttribute('onmouseout', "this.style.backgroundColor='#EEEEEE';");
  return option;
}

function addButton(text) {
  var anchor = document.createElement('a');
  anchor.style.color = '#000000';
  anchor.innerHTML = text;
  anchor.style.textDecoration = 'none';

  var li = createLi();
  li.appendChild(anchor);
  return li;
}

window.smMenuHover = function(menuItem) {
	if (window['smVisibleMenu'] != 0) {
		smVisibleMenu.style.visibility="hidden";
	}
	smVisibleMenu = menuItem.childNodes[1];
	smVisibleMenu.style.visibility = 'visible';
}

window.smMenuOut = function(menuItem) {
  menuItem.childNodes[1].style.visibility = 'hidden';
}

window.smSubMenuClickOption = function(subMenuItem, code, name) {
	subMenuItem.parentNode.style.visibility = 'hidden';
	smClickOption(code, name);
}

// creates a drop-down menu
function addMenu(text, menu, menuIndex) {
  var hiddenLinks = document.createElement('div');
  hiddenLinks.id = 'smHidden' + String(menuIndex);
  hiddenLinks.style.zIndex = 3;
  hiddenLinks.style.position = 'absolute';
  hiddenLinks.style.visibility = 'hidden';
  hiddenLinks.style.margin = '0';
  hiddenLinks.style.marginLeft = '-9px';
  hiddenLinks.style.padding = '0';
  hiddenLinks.style.border = '1px solid #555555';
  
  for (var key in menu) {
	var anchor = document.createElement('a');
	anchor.innerHTML = key;
	anchor.style.display = 'block';
	anchor.style.position = 'relative';
	anchor.style.margin = '0';
	anchor.style.padding = '3px 10px';
	anchor.style.width = 'auto';
	anchor.style.textAlign = 'left';
	anchor.style.textDecoration = 'none';
	anchor.style.background = '#FFFFEE';
	anchor.style.color = '#000000';
    anchor.setAttribute('onmouseover', "this.style.backgroundColor='#6699CC'");
    anchor.setAttribute('onmouseout', "this.style.backgroundColor='#FFFFEE'");
	anchor.setAttribute('onclick', 'smClickOption("'+menu[key]+'", "'+key+'");this.parentNode.style.visibility = "hidden";');
	hiddenLinks.appendChild(anchor);
  }
  
  var li = addButton(text);
  li.appendChild(hiddenLinks);
  var mover = li.getAttribute('onmouseover');
  li.setAttribute('onmouseover', mover + 'smMenuHover(this);');
  var mout = li.getAttribute('onmouseout');
  li.setAttribute('onmouseout', mout + 'smMenuOut(this);');
  return li;
}

// Creates the menu on the page
function createMenu() {
  var toolbar = document.getElementById('toolbar');
  if (toolbar) {
    var menulist = document.createElement('ul');
	menulist.style.display = 'block';
	menulist.style.zIndex = 30;
	menulist.style.padding = '0';
	menulist.style.margin = '0';
	
	var smMenus = smConfig['smMenus'];
	var menuCount = 0;
	for (var key in smMenus) {
		if (typeof(smMenus[key]) == 'string') {
			var button = addButton(key);
			button.setAttribute('onclick', "smClickOption('"+smMenus[key]+"','"+key+"')");
			menulist.appendChild(button);
		} else {
			menuCount++;
			menulist.appendChild( addMenu(key, smMenus[key], menuCount) );
		}
	}

	window.smFormPanel = document.createElement('div');
	smFormPanel.style.clear = 'both';
	var cleardiv = document.createElement('div');
	cleardiv.style.clear = 'both';
	toolbar.insertBefore(cleardiv, toolbar.childNodes[0]);
	toolbar.insertBefore(smFormPanel, toolbar.childNodes[0]);
	toolbar.insertBefore(menulist, toolbar.childNodes[0]);
    toolbar.style.height = 'auto';
  }
}

// closes the form that calls it (called from the Close Form button)
window.smCloseForm = function(sender) {
	var closeThisForm = sender.parentNode.parentNode;
	closeThisForm.parentNode.removeChild(closeThisForm);
}

// adds the template to the edit box using insertTags
window.smAddTemplate = function(sender) {
	var templTable = sender.parentNode.childNodes[1];
	var inputs = templTable.getElementsByTagName('input');
	
	var formName = sender.id;
	var form = smConfig['smForms'][formName];
	
	var insertText = form[0]['prepend'];
	for (var i in inputs) {
		var inp = inputs[i];
		if (inp.value && inp.value.length > 0) {
			insertText += '|' + inp.id + '=' + inp.value;
		}
	}
	insertText += form[0]['append'];
	insertTags(insertText, '', '');
}

function smGetFormFields(formName) {
	var form = smConfig['smForms'][formName];
	var formFields = new Array();
	for (var i in form) {
		if (!form[i]['title'] || !form[i]['code']) continue;
		formFields.push(form[i]);
	}
	return formFields;
}

function textEval(template, replacements) {
    for (var i = 1; i < replacements.length; i++) {
        var sub = eval(replacements[i]);
        template = template.replace('%s', sub);
    }
    return template;
}

window.smClickOption = function(code, name) {
	var form = smConfig['smForms'][code];
    if (!form || !form['length'] || form['length'] < 1) {
        return;
    }
    if (form[0]['inserttext']) {
        insertTags(form[0]['inserttext'], '', '');
    } else if (form[0]['httplink']) {
        window.open(form[0]['httplink']);
    } else if (form[0]['httpeval']) {
        var url = textEval(form[0]['httpeval'][0], form[0]['httpeval']);
        window.open(url);
    } else if (form[0]['inserteval']) {
        var text = textEval(form[0]['inserteval'][0], form[0]['inserteval']);
        insertTags(text, '', '');
    } else if (form[0]['evaluate']) {
        eval(form[0]['evaluate']);
    } else {
        smShowForm(code, name);
    }
}

// Display a template form
window.smShowForm = function(formName, title) {
    if (smConfig['smSingleForm']) {
        for (var i = 0; i < smFormPanel.childNodes.length; i++) {
            smFormPanel.removeChild(smFormPanel.childNodes[i]);
        }
    }

	var formFields = smGetFormFields(formName);
	
	var formDiv = document.createElement('div');
	formDiv.innerHTML = '<fieldset><legend>'+title+'</legend></fieldset>';
    smFormPanel.appendChild(formDiv);
	var table = document.createElement('table');
	table.cellspacing = 5;
	formDiv.childNodes[0].appendChild(table);
	
	var maxcols = smConfig['smColumns'];
	
	var col = 99;
	var currentTr = 0;
	
	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 = createTextField(formFields[i]['code']);
		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);
		
		currentTr.appendChild(td1);
		currentTr.appendChild(td2);
	}
	
	var addTemplateButton = addOption("smAddTemplate(this)", "Add Template");
	addTemplateButton.id = formName;
	addTemplateButton.style.cssFloat = 'left';
	formDiv.childNodes[0].appendChild(addTemplateButton);
	
	var closeButton = addOption("smCloseForm(this)", "Close Form");
	closeButton.style.cssFloat = "right";
	formDiv.childNodes[0].appendChild(closeButton);
}

function createTextField(id) {
	var inp = document.createElement('input');
	inp.type = 'text';
	inp.id = id;
	inp.tabIndex = 1;
	inp.style.width = smConfig['smTextWidth'];
	return inp;
}

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;
}

hookEvent("load", createMenu);

}

// append wrapper to head if run under Greasemonkey
if (window.parent == window) {
	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 {
		SnippetManagerWrapper();
	}
}
// </nowiki></pre>