This page is loaded as a part of the refToolbarBase gadget, a hidden gadget.
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.
// Global objectif(typeofCiteTB=='undefined'){varCiteTB={"Templates":{},// All templates"Options":{},// Global options"UserOptions":{},// User options"DefaultOptions":{},// Script defaults"ErrorChecks":{}// Error check functions};}if(typeofmw.usability=='undefined'){mw.usability={};mw.usability.getMsg=function(m){returnmw.messages.get(m);}mw.usability.addMessages=function(msgs){mw.messages.set(msgs);};}// Object for cite templatesfunctionciteTemplate(templatename,shortform,basicfields,expandedfields){// Propertiesthis.templatename=templatename;// The template name - "cite web", "cite book", etc.this.shortform=shortform;// A short form, used for the dropdown boxthis.basic=basicfields;// Basic fields - author, title, publisher...// Less common - quote, archiveurl - should be everything the template supports minus the basic onesthis.extra=expandedfields;// Add it to the listCiteTB.Templates[this.templatename]=this;// Methodsthis.makeFormInner=function(fields){vari=0;vartrs=newArray();for(i=0;i<fields.length;i++){varfieldobj=fields[i];varfield=fieldobj.field;varad=false;if($.inArray(field,CiteTB.getOption('autodate fields'))!=-1){im=$('<img />').attr('src','//upload.wikimedia.org/wikipedia/commons/thumb/7/7b/Nuvola_apps_date.svg/20px-Nuvola_apps_date.svg.png');im.attr('alt',mw.usability.getMsg('cite-insert-date')).attr('title',mw.usability.getMsg('cite-insert-date'));varad=$('<a />').attr('href','#');ad.append(im);ad.attr('id','cite-date-'+CiteTB.escStr(this.shortform)+'-'+field);$('#cite-date-'+CiteTB.escStr(this.shortform)+'-'+field).live('click',CiteTB.fillAccessdate);}if(fieldobj.autofillid){varautotype=fieldobj.autofillid;im=$('<img />').attr('src','//upload.wikimedia.org/wikipedia/commons/thumb/1/17/System-search.svg/20px-System-search.svg.png');im.attr('alt',mw.usability.getMsg('cite-autofill-alt')).attr('title',mw.usability.getMsg('cite-autofill-alt'));varad=$('<a />').attr('href','#');ad.append(im);ad.attr('id','cite-auto-'+CiteTB.escStr(this.shortform)+'-'+field+'-'+autotype);$('#cite-auto-'+CiteTB.escStr(this.shortform)+'-'+field+'-'+autotype).live('click',CiteTB.initAutofill);}vardisplay=mw.usability.getMsg('cite-'+field+'-label');vartooltip=fieldobj.tooltip?$('<abbr />').attr('title',mw.usability.getMsg(fieldobj.tooltip)).html('<sup>?</sup>'):false;varinput='';if(ad){input=$('<input tabindex="1" style="width:85%" type="text" />');}else{input=$('<input tabindex="1" style="width:100%" type="text" />');}input.attr('id','cite-'+CiteTB.escStr(this.shortform)+'-'+field);if(fieldobj.autofillprop){input.addClass('cite-'+CiteTB.escStr(this.shortform)+'-'+fieldobj.autofillprop);}varlabel=$('<label />');label.attr('for','cite-'+CiteTB.escStr(this.shortform)+'-'+field).text(display);if(tooltip){label.append(tooltip);}varstyle='text-align:right; width:20%;';if(i%2==1){style+=' padding-left:1em;';}else{vartr=$('<tr />');}vartd1=$('<td class="cite-form-td" />').attr('style',style);td1.append(label);tr.append(td1);vartd2=$('<td class="cite-form-td" style="width:30%" />');td2.append(input);if(ad){td2.append(ad);}tr.append(td2);if(i%2==0){trs.push(tr);}}returntrs;}// gives a little bit of HTML so the open form can be identifiedthis.getInitial=function(){varhidden=$('<input type="hidden" class="cite-template" />');hidden.val(this.templatename);returnhidden;}// makes the form used in the dialog boxesthis.getForm=function(){varmain=$("<div class='cite-form-container' />");varform1=$('<table style="width:100%; background-color:transparent;" class="cite-basic-fields" />');vari=0;vartrs=this.makeFormInner(this.basic);for(vari=0;i<trs.length;i++){form1.append(trs[i]);}varform2=$('<table style="width:100%; background-color:transparent; display:none" class="cite-extra-fields">');trs=this.makeFormInner(this.extra);for(vari=0;i<trs.length;i++){form2.append(trs[i]);}main.append(form1).append(form2);varform3=$('<table style="width:100%; background-color:transparent;padding-top:1em" class="cite-other-fields">');vartr=$('<tr />');vartd1=$('<td class="cite-form-td" style="text-align:right; width:20%" />');varlabel1=$('<label />');label1.attr('for',"cite-"+CiteTB.escStr(this.shortform)+'-name').text(mw.usability.getMsg('cite-name-label'));td1.append(label1);vartd2=$('<td class="cite-form-td" style="width:30%" />');varinput1=$('<input tabindex="1" style="width:100%" type="text" />');input1.attr('id','cite-'+CiteTB.escStr(this.shortform)+'-name');td2.append(input1);vartd3=$('<td class="cite-form-td" style="text-align:right; padding-left:1em; width:20%">');varlabel2=$('<label />');label2.attr('for','cite-'+CiteTB.escStr(this.shortform)+'-group').text(mw.usability.getMsg('cite-group-label'));td3.append(label2);vartd4=$('<td class="cite-form-td" style="width:30%" />');varinput2=$('<input tabindex="1" style="width:100%" type="text" />');input2.attr('id','cite-'+CiteTB.escStr(this.shortform)+'-group');td4.append(input2);tr.append(td1).append(td2).append(td3).append(td4);form3.append(tr);main.append(form3);varextras=$('<div />');extras.append('<input type="hidden" class="cite-form-status" value="closed" />');varhidden=$('<input type="hidden" class="cite-template" />');hidden.val(this.templatename);extras.append(hidden);varspan1=$('<span class="cite-preview-label" style="display:none;" />');span1.text(mw.usability.getMsg('cite-raw-preview'));extras.append(span1).append('<div class="cite-ref-preview" style="padding:0.5em; font-size:110%" />');varspan2=$('<span class="cite-prev-parsed-label" style="display:none;" />');span2.text(mw.usability.getMsg('cite-parsed-label'));extras.append(span2).append('<div class="cite-preview-parsed" style="padding-bottom:0.5em; font-size:110%" />');varlink=$('<a href="#" class="cite-prev-parse" style="margin:0 1em 0 1em; display:none; color:darkblue" />');link.text(mw.usability.getMsg('cite-form-parse'));extras.append(link);main.append(extras);returnmain;}}/* Class for error checks FIXME: DOCS OUT OF DATE type - type of error check - current options: * 'refcheck' - apply a function on each ref individually * function should accept a ref object, return a string * 'reflist' - apply a function on the entire ref list * function should accept an array of ref objects, return an array of strings * 'search' - apply a function ro the page text * function should accept the page text as a string, return an array of strings The strings returned by the function should be valid HTML func - The function described above testname - Name of the error check, must not contain spaces desc - A short description of the test*/functionciteErrorCheck(obj){this.obj=objCiteTB.ErrorChecks[this.obj.testname]=this;this.run=function(){varerrors=[];switch(this.obj['type']){case"refcheck":CiteTB.loadRefs();for(vari=0;i<CiteTB.mainRefList.length;i++){vare=this.obj.func(CiteTB.mainRefList[i]);if(e){errors.push(e);}}break;case"reflist":CiteTB.loadRefs();errors=this.obj.func(CiteTB.mainRefList);break;case"search":varfunc=this.obj.funcCiteTB.getPageText(function(text){errors=func(text);});break;}returnerrors;}this.getRow=function(){varrow=$("<li />");varcheck=$("<input type='checkbox' name='cite-err-test' />");check.attr('value',this.obj.testname);varlabel=$("<label />").html(mw.usability.getMsg(this.obj.desc));label.attr('for',this.obj.testname);row.append(check).append(' – ').append(label);returnrow;}}$('head').trigger('reftoolbarbase');