Jump to content

User:ProveIt GT/ProveIt.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by ProveIt GT (talk | contribs) at 03:48, 6 October 2010 (Deploy latest version of ProveIt, commit 70bd2c4ee36e.). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
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.
/* ProveIt, commit 70bd2c4ee36e, Copyright 2010, Georgia Tech
   Available under the GNU Free Documentation License, Creative Commons Attribution/Share-Alike License 3.0, and the GNU General Public License 2
   This is a minified version.  Changes can be made through our Google Code Project (http://code.google.com/p/proveit-js/) */
if(typeof proveit!="undefined")throw Error("proveit already exists");
window.proveit={HALF_EDIT_BOX_HEIGHT:200,LANG:"en",NEW_PARAM_PREFIX:"newparam",EDIT_PARAM_PREFIX:"editparam",STATIC_BASE:"http://proveit-js.googlecode.com/hg/static/",log:function(a){typeof console==="object"&&console.log&&console.log("[ProveIt] %o",a)},isSupportedEditPage:function(){return(wgCanonicalNamespace==""||wgPageName=="Wikipedia:Sandbox")&&(wgAction=="edit"||wgAction=="submit")},getRefBox:function(){return $("#refs")},getPosition:function(a){var c=0,b=0;do{c+=a.offsetLeft;b+=a.offsetTop}while(a=
a.offsetParent);return{left:c,top:b}},highlightLengthAtIndex:function(a,c){if(a<0||c<0)this.log("highlightStringAtIndex: invalid negative arguments");var b=this.getMWEditBox(),f=$(b).val();this.getPosition(this.getMWEditBox());var g=a+c;$(b).val(f.substring(0,a));b.scrollTop=1E6;var d=b.scrollTop;b.value+=f.substring(a);if(d>0)b.scrollTop=d+this.HALF_EDIT_BOX_HEIGHT;b.focus();b.setSelectionRange(a,g);return true},highlightTargetString:function(a){var c=this.getMWEditBox();c=$(c).val().indexOf(a);
if(c==-1){this.log('Target string "'+a+'" not found.');return false}return this.highlightLengthAtIndex(c,a.length)},getMWEditBox:function(){return $("#wpTextbox1")[0]},getMWEditForm:function(){return $("#editform")[0]},addOnsubmit:function(a){var c=this.getMWEditForm();if(!c)throw Error("No edit form, possibly due to protected page.");c.addEventListener("submit",a,false)},getEditSummary:function(){return $("#wpSummary")[0]},summaryFunctionAdded:false,shouldAddSummary:true,includeProveItEditSummary:function(){if(this.shouldAddSummary&&
!this.summaryFunctionAdded)try{var a=this;this.addOnsubmit(function(){var b=a.getEditSummary();if(b.value.indexOf("ProveIt")==-1)b.value+=" (edited by [[User:Superm401/ProveIt|Proveit]])"});this.summaryFunctionAdded=true}catch(c){this.log("Failed to add onsubmit handler. e.message: "+c.message)}},proveitonload:function(){this.summaryFunctionAdded=false;this.isSupportedEditPage()&&this.createGUI();return true},clearRefBox:function(){var a=this.getRefBox();if(a==null){this.log("Ref box is not loaded yet.");
return false}a=$("tr:not('tr#dummyRef')",a);$(a).remove()},insertRefIntoMWEditBox:function(a,c){var b=this.getMWEditBox();if(!b){this.log("insertRefIntoMWEditBox: txtarea is null");return false}var f=a.getInsertionText(c),g=b.scrollTop;b.focus();var d=b.selectionStart,h=b.selectionEnd;b.value.substring(d,h);b.value=b.value.substring(0,d)+f+b.value.substring(h,b.value.length);b.selectionStart=d;b.selectionEnd=b.selectionStart+f.length;b.scrollTop=g;this.includeProveItEditSummary()},changeRefFromEditPane:function(a,
c){var b=$("div.input-row",c),f=$("#editrefname").val();a.name=f!=""?f:null;a.params={};var g,d;for(f=0;f<b.length;f++){g=b[f];d=g.getElementsByClassName("paramvalue")[0];g=$(g).hasClass("addedrow")?g.getElementsByClassName("paramdesc")[0].value.trim():d.id.substring(this.EDIT_PARAM_PREFIX.length);this.log("paramName: "+g);d=d.value.trim();this.log("paramVal: "+d);if(g!=""&&d!="")a.params[g]=d}if(a.toString()!=a.orig)a.save=false;a.update();return a},saveRefFromEdit:function(a){if(!a.save){var c=
this.makeRefboxElement(a,true),b=$(".selected",this.getRefBox()).get(0);this.log("newRichItem: "+c+", oldRichItem: "+b+"oldRichItem.parentNode: "+b.parentNode);var f=$("td.number",b).text();$("td.number",c).text(f);b.parentNode.replaceChild(c,b);$(c).addClass("selected");a.updateInText();this.includeProveItEditSummary()}},updateEditPane:function(a){$("#editrefname").val(a.name||"");var c={};for(e in a.params)c[e]=a.params[e];for(var b=a.getDefaultParams(),f=0;f<b.length;f++)c[b[f]]||(c[b[f]]="");
b=a.getRequiredParams();var g=[];for(item in c)g.push(item);(f=a.getSorter())?g.sort(f):g.sort();$("#edit-fields").children(".paramlist").children().remove("div:not(.hidden)");for(f=0;f<g.length;f++)this.addPaneRow($("#edit-pane").get(),c,a.getDescriptions(),g[f],b[g[f]],true);var d=$("#edit-buttons .accept"),h=function(){proveit.log("Entering acceptEdit");proveit.changeRefFromEditPane(a,$("#edit-pane").get());proveit.saveRefFromEdit(a);d.unbind("click",h);$("#edit-pane").hide();$("#view-pane").show()};
setTimeout(function(){$("#edit-fields").scrollTop(0)},0);d.click(h);$(".tab-link").one("click",function(){d.unbind("click",h)})},addPaneRow:function(a,c,b,f,g,d){var h=$("#"+(d?"preloadedparamrow":"addedparamrow")).clone();$(h).attr("id","");var i=$(".paramdesc",h).eq(0),j=$(".paramvalue",h).eq(0);$(".paramlist",a).append(h);if(g){$(i).addClass("required");$(".delete-field",h).remove()}else this.activateRemove(h);if(d){i.attr("for",this.EDIT_PARAM_PREFIX+f);j.attr("id",this.EDIT_PARAM_PREFIX+f);a=
b[f];if(!a){this.log("Undefined description for param: "+f+".  Using directly as description.");a=f}$(i).text(a);$(i).attr("title",f);$(j).val(c[f]);$(h).show()}else{$(h).show("highlight",{},"slow");$(".inputs",a).scrollTop(1E5)}},togglestyle:true,toggleinsert:false,splitNameVals:function(a){var c={};c.nameSplit=a.substring(a.indexOf("|")+1).split(/=(?:[^|]*?(?:\[\[[^|\]]*(?:\|(?:[^|\]]*))?\]\])?)+(?:\||\}\})/);c.valSplit=a.substring(a.indexOf("|"),a.indexOf("}}")).split(/\|[^|=]*=/);return c},scanForRefs:function(){this.log("Entering scanForRefs.");
var a=this.getMWEditBox();if(!a)throw Error("scanForRefs: MW edit box is not defined.");this.clearRefBox();var c=$(a).val(),b;a={};var f=[];c.match(/<[\s]*ref[^\/>]*>/gi);if(c=c.match(/<[\s]*ref[^>]*>(?:[^<]*<[\s]*\/[\s]*ref[\s]*>)?/gi))for(var g=0;g<c.length;g++){var d=this.makeRef(c[g]);if(d)(b=d.name)||f.push(d);else b=(b=c[g].match(this.REF_REGEX))&&(b[1]||b[2]||b[3]);if(b){if(!a[b]){a[b]={};if(!a[b].strings)a[b].strings=[]}if(d&&!a[b].citation){a[b].citation=d;f.push(d)}a[b].strings.push(c[g])}}for(c=
0;c<f.length;c++){f[c].name&&f[c].setCitationStrings(a[f[c].name].strings);this.addNewElement(f[c])}},REF_REGEX:/<[\s]*ref[\s]*name[\s]*=[\s]*(?:(?:\"(.*?)\")|(?:\'(.*?)\')|(?:(.*?)))[\s]*\/?[\s]*>/,makeRef:function(a){var c=/<[\s]*ref[^>]*>[^<]*\S[^<]*<[\s]*\/[\s]*ref[\s]*>/.test(a);this.log("refText: "+a+"; isReference: "+c);if(!c)return null;c=a.match(/{{[\s]*cite/i)?this.CiteReference:a.match(/{{[\s]*Citation/i)?this.Citation:this.RawReference;if(c!=this.RawReference){var b=a.match(/{{[\s]*(cite|Citation)[^}]*}}/i)[0],
f=a.match(this.REF_REGEX);if(f&&f!=null)var g=f[1]||f[2]||f[3];f=b.split(/\|/g);if(c==this.CiteReference){var d=f[0].toLowerCase().indexOf("e"),h=f[0].indexOf("}");d=f[0].substring(d+1,h!=-1?h:f[0].length).trim()}}a=new c({name:g,type:d,save:true,inMWEditBox:true,orig:a});if(c!=this.RawReference){c=this.splitNameVals(b);b=c.nameSplit;c=c.valSplit;for(g=0;g<b.length-1;g++){f=b[g].trim().replace(/(?:\s*\|)*(.*)/,"$1");d=c[g+1].trim();if(d!="")a.params[f]=d}}return a},AbstractReference:function(a){if(!this.setType)this.setType=
function(b){this.type=b};this.update=function(){var b=this.toString(),f=this.getCitationStrings();if(f.length>0)for(var g=0;g<f.length;g++){if(f[g]==this.orig){proveit.log("Updating "+f[g]+" to "+b);f[g]=b}}else if(this.name!=null){proveit.log("Adding "+b+" to citationStrings");f.push(b)}};this.name=a.name!=""?a.name:null;this.setType(a.type);this.save=a.save;this.inMWEditBox=a.inMWEditBox;this.orig=a.orig;this.params={};var c={en:{name:"Name",author:"Author (L, F)",last:"Last name",last2:"Last name (auth. two)",
last3:"Last name (auth. three)",last4:"Last name (auth. four)",last5:"Last name (auth. five)",last6:"Last name (auth. six)",last7:"Last name (auth. seven)",last8:"Last name (auth. eight)",last9:"Last name (auth. nine)",first:"First name",first2:"First name (auth. two)",first3:"First name (auth. three)",first4:"First name (auth. four)",first5:"First name (auth. five)",first6:"First name (auth. six)",first7:"First name (auth. seven)",first8:"First name (auth. eight)",first9:"First name (auth. nine)",
authorlink:"Author article name",title:"Title",publisher:"Publisher",year:"Year",location:"Location",place:"Location of work",isbn:"ISBN",id:"ID",doi:"DOI",page:"Page",pages:"Pages",quote:"Quote",month:"Month",journal:"Journal",edition:"Edition",volume:"Volume",issue:"Issue",url:"URL",date:"Publication date (YYYY-MM-DD)",accessdate:"Access date (YYYY-MM-DD)",coauthors:"Co-authors",booktitle:"Title of Proceedings",contribution:"Contribution/Chapter",encyclopedia:"Encyclopedia",newsgroup:"Newsgroup",
version:"Version",site:"Site",newspaper:"Newspaper","publication-place":"Publication location",editor:"Editor (L, F)",article:"Article",pubplace:"Publisher location",pubyear:"Publication year",inventor:"Inventor (L, F)","issue-date":"Issue date (YYYY-MM-DD)","patent-number":"Patent number","country-code":"Country code (XX)",work:"Work",format:"Format",issn:"ISSN",pmid:"PMID",chapter:"Chapter",web:"Web",book:"Book",conference:"Conference",news:"News",paper:"Paper","press release":"Press release",interview:"Interview",
subject:"Subject",subjectlink:"Subject article name",subject2:"Subject two",subject2link:"Subject two article name",subject3:"Subject three",subject3link:"Subject three article name",subject4:"Subject four",subject4link:"Subject four article name",interviewer:"Interviewer",cointerviewers:"Co-interviewers",type:"Type",program:"Program",callsign:"Call sign",city:"City",archiveurl:"Archive URL",archivedate:"Date archived",episode:"Episode",episodelink:"Episode article name",series:"Series",serieslink:"Series article name",
credits:"Credits",network:"Network",station:"Station",airdate:"Airdate",began:"Start date",ended:"End date",season:"Season number",seriesno:"Season number",number:"Number",minutes:"Minutes",transcript:"Transcript",transcripturl:"Transcript URL",video:"Video",people:"People",medium:"Production medium",language:"Language",time:"Time",oclc:"OCLC",ref:"Anchor ID"}};this.getSorter=function(){var b=this;return function(f,g){var d=b.getSortIndex(f),h=b.getSortIndex(g);return d!=-1&&h!=-1?d-h:f<g?-1:f==g?
0:1}};this.getDescriptions=function(){return c[proveit.LANG]};this.isValid=function(){return true};this.getLabel=function(){var b="";if(this.params.author)b=this.params.author+"; ";else if(this.params.last){b=this.params.last;if(this.params.first)b+=", "+this.params.first;b+="; "}if(this.params.title)b+=this.params.title;if(b==""){for(var f in this.params)break;if(f)b=f}return b};this.getInsertionText=function(b){proveit.log("getInsertionText");if(b)return this.toString();else if(this.name)return'<ref name="'+
this.name+'" />';else throw Error("getInsertionText: ref.name is null");};this.updateInText=function(){var b=proveit.getMWEditBox();if(!(!b||b==null)){b.focus();var f=b.value;f=f.replace(this.orig,this.toString());b.value=f;this.orig=this.toString();this.save=true;proveit.highlightTargetString(this.toString())}};this.toStringInternal=function(b,f){var g=this.name?'<ref name="'+this.name+'">':"<ref>";g+="{{"+b+(f?" "+this.type:"");for(var d in this.params)g+=" | "+d+"="+this.params[d];g+="}}</ref>";
return g};this.citationStrings=[];this.setCitationStrings=function(b){this.citationStrings=b};this.getCitationStrings=function(){return this.citationStrings};this.getIcon=function(){return proveit.STATIC_BASE+"page_white.png"}},CiteReference:function(a){var c={web:"web",book:"book",journal:"journal",conference:"conference",encyclopedia:"encyclopedia",news:"news",newsgroup:"newsgroup",paper:"journal","press release":"press release",pressrelease:"press release",interview:"interview",episode:"episode",
video:"video"};this.setType=function(d){var h=c[d];this.type=h!=null?h:d};proveit.AbstractReference.call(this,a);this.getSortIndex=function(d){return["url","title","accessdate","author","last","first","subject","subjectlink","author2","last2","first2","subject2","subectlink2","author3","last3","first3","subject3","subjectlink3","author4","last4","first4","subject4","author5","last5","first5","author6","last6","first6","author7","last7","first7","author8","last8","first8","author9","last9","first9",
"authorlink","coauthors","interviewer","cointerviewers","type","program","episodelink","series","serieslink","credits","network","station","callsign","city","airdate","began","ended","season","seriesno","number","minutes","transcript","transcripturl","people","date","year","month","format","medium","work","publisher","location","pages","language","isbn","oclc","doi","id","archiveurl","archivedate","time","quote","ref"].indexOf(d)};this.toString=function(){return this.toStringInternal("cite",true)};
var b={web:{url:true,title:true},book:{title:true},journal:{title:true},conference:{title:true},encyclopedia:{title:true,encyclopedia:true},news:{title:true},newsgroup:{title:true},"press release":{title:true},interview:{last:true},episode:{title:true},video:{title:true}};this.getRequiredParams=function(){var d=b[this.type];return d?d:{}};var f={web:["url","title","author","accessdate","work","publisher","date","pages"],book:["title","author","authorlink","year","isbn","publisher","location","pages"],
journal:["title","author","journal","volume","issue","year","month","pages","url","doi"],conference:["conference","title","booktitle","author","editor","year","month","url","id","accessdate","location","pages","publisher"],encyclopedia:["title","encyclopedia","author","editor","accessdate","edition","year","publisher","volume","location","pages"],news:["title","author","url","publisher","date","accessdate","pages"],newsgroup:["title","author","date","newsgroup","id","url","accessdate"],"press release":["title",
"url","publisher","date","accessdate"],interview:["last","first","subjectlink","interviewer","title","callsign","city","date","program","accessdate"],episode:["title","series","credits","airdate","city","network","season"],video:["people","date","url","title","medium","location","publisher"]};this.getDefaultParams=function(){var d=f[this.type];return d?d:[]};this.isValid=function(){if(this.type=="")return false;var d=this.getRequiredParams(),h=true;for(reqParam in d)if(d[reqParam]){h&=reqParam in
this.params;if(!h)break}return h};this.getEditLabel=function(){return"cite "+this.type};var g={web:"page_white_world.png",book:"book.png",journal:"page_white_text.png",news:"newspaper.png",newsgroup:"comments.png","press release":"transmit_blue.png",interview:"comments.png",episode:"television.png",video:"film.png"};this.getIcon=function(){var d=g[this.type];if(d)return proveit.STATIC_BASE+d;return proveit.AbstractCitation.getIcon.call(this)}},Citation:function(a){proveit.AbstractReference.call(this,
a);var c={},b={web:["url","author","title","date","accessdate"],news:["author","title","newspaper","url","publication-place","volume","issue","date","pages"],encyclopedia:["author","editor","contribution","title","publisher","place","year","volume","pages"],book:["author","title","publisher","place","year"],journal:["author","title","journal","volume","issue","year","pages"],patent:["inventor","title","issue-date","patent-number","country-code"]};this.getSortIndex=function(f){return["last","first",
"url","author","editor","contribution","author-link","last2","first2","author2-link","publication-date","inventor","title","issue-date","patent-number","country-code","journal","volume","newspaper","issue","date","publisher","place","year","edition","publication-place","series","pages","page","id","isbn","doi","oclc","accessdate"].indexOf(f)};this.toString=function(){return this.toStringInternal("Citation",false)};this.getRequiredParams=function(){return c};this.getDefaultParams=function(){return this.type?
b[this.type]:["url","title","author","date","publisher"]};this.getEditLabel=function(){return"Citation"}},RawReference:function(a){proveit.AbstractReference.call(this,a);this.type="raw";this.toString=function(){return this.orig};this.params.title=this.orig;this.getIcon=function(){return proveit.STATIC_BASE+"raw.png"}},citationObjFromAddPopup:function(a){this.log("Entering citationObjFromAddPopup");var c=a.id;c=new (this.togglestyle?this.CiteReference:this.Citation)({name:$("#addrefname").val(),type:c});
var b;a=a.getElementsByClassName("paramlist")[0];for(var f=$("div",a),g=0;g<f.length;g++){b=f[g];this.log("citationObjFromAddPopup: i: "+g+", paramRow: "+b);var d=b.getElementsByClassName("paramvalue")[0];a=$(b).hasClass("addedrow")?b.getElementsByClassName("paramdesc")[0].value.trim():d.id.substring(this.NEW_PARAM_PREFIX.length);this.log("citationObjFromAddPopup: paramRow.childNodes.length: "+b.childNodes.length);this.log("citationObjFromAddPopup: valueTextbox.tagName: "+d.tagName);this.log("citationObjFromAddPopup: valueTextbox.id: "+
d.id);b=d.value.trim();this.log("citationObjFromAddPopup: paramName: "+a+"; paramVal: "+b);if(a!=""&&b!="")c.params[a]=b}c.update();this.log("Exiting citationObjFromAddPopup");return c},addCitation:function(a){this.addNewElement(a);a.orig=a.toString();this.insertRefIntoMWEditBox(a,true);a.save=true;a.inMWEditBox=true;this.includeProveItEditSummary();this.highlightTargetString(a.orig)},clearCitePanes:function(a){a.hasChildNodes()&&a.removeChild(a.firstChild)},activateRemove:function(a){$(".delete-field",
a).click(function(){$(a).hide("highlight",{},"slow",function(){$(a).remove()})})},changeCite:function(a){$("#add-fields").scrollTop(0);$(a.parentNode).show();var c=$(".addpanes",a.parentNode.parentNode).get(0);this.clearCitePanes(c);var b=a.value,f=document.getElementById("dummyCitePane").cloneNode(true);f.id=b;$(".ref-name-row",f).children("input").attr("id","addrefname");$(".ref-name-row",f).children("label").attr("for","addrefname");a=a.id=="citemenu"?new this.CiteReference({}):new this.Citation({});
a.type=b;b=a.getDescriptions();var g=a.getDefaultParams().slice(0);g.sort(a.getSorter());for(var d=0;d<g.length;d++)a.params[g[d]]="";this.log("changeCite: newCite: "+a);g=[];for(j in a.params)g.push(j);g.sort(a.getSorter());var h=a.getRequiredParams(),i=f.getElementsByClassName("paramlist")[0];for(d=0;d<g.length;d++){var j=g[d],k;if(b[j]){k=document.getElementById("preloadedparamrow").cloneNode(true);var l=$(".paramdesc",k);if(h[j]){l.addClass("required");$(".delete-field",k).remove()}else this.activateRemove(k);
l.text(b[j]);l.attr("for",this.NEW_PARAM_PREFIX+j);j=="accessdate"&&$(".paramvalue",k).val(this.formatDate(new Date))}else{k=document.getElementById("addedparamrow").cloneNode(true);k.getElementsByClassName("paramdesc")[0].setAttribute("value",j)}k.id="";this.activateRemove(k);k.getElementsByClassName("paramvalue")[0].id=this.NEW_PARAM_PREFIX+j;this.log("changeCite: param: "+j+"; newCite.params[param]: "+a.params[j]);$(k).show();i.appendChild(k)}$(f).show();c.insertBefore(f,c.firstChild);this.log("Exiting changeCite")},
createGUI:function(){importStylesheetURI("http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.3/themes/base/jquery-ui.css");importStylesheetURI(this.STATIC_BASE+"styles.css");var a=$("<div/>",{id:"proveit"}),c=$("<div/>",{id:"tabs"}),b=$("<h1/>"),f=$("<a/>",{title:"Created by the ELC Lab at Georgia Tech",href:"http://www.cc.gatech.edu/elc",target:"_blank"}),g=$("<img/>",{src:this.STATIC_BASE+"logo.png",alt:"ProveIt",height:30,width:118});f.append(g);b.append(f);f=$("<button/>",{text:"show/hide"});b.append(f);
c.append(b);b=$("<ul/>");g=$("<li/>");var d=$("<a/>",{id:"view-link","class":"tab-link",href:"#view-tab"});d.append("References (");var h=$("<span/>",{id:"numRefs"}).append("0");d.append(h).append(")");g.append(d);b.append(g);g=$("<li/>");d=$("<a/>",{id:"add-link","class":"tab-link",href:"#add-tab"}).append("Add a Reference");g.append(d);b.append(g);c.append(b);h=$("<div/>",{id:"view-tab"});b=$("<div/>",{id:"view-pane"});g=$("<div/>",{"class":"scroll",style:"height: 210px;"});d=$("<table/>",{id:"refs"});
var i=$("<tr/>",{id:"dummyRef",style:"display: none;"});i.append($("<td/>",{"class":"number"})).append($("<td/>",{"class":"type"})).append($("<td/>",{"class":"title"}));var j=$("<td/>",{"class":"edit"}).append($("<button/>",{text:"edit"}));i.append(j);d.append(i);g.append(d);b.append(g);h.append(b);j=$("<div/>",{id:"edit-pane",style:"display: none"});b=$("<div/>",{id:"edit-fields","class":"inputs scroll",style:"height: 170px",tabindex:0});i=$("<div/>",{"class":"ref-name-row",tabindex:-1});g=$("<label/>",
{"for":"editrefname",title:"This is a unique identifier that can be used to refer to this reference elsewhere on the page.","class":"paramdesc"}).append("&lt;ref&gt; name");i.append(g);i.append($("<input/>",{id:"editrefname","class":"paramvalue"}));g=$("<div/>",{"class":"paramlist"});b.append(i);b.append(g);j.append(b);var k=$("<div/>",{id:"edit-buttons"});b=$("<button/>",{style:"margin-right: 50px;"}).append("add field");k.append(b);b=$("<span/>",{"class":"required",text:"bold"});k.append(b).append(" = required field");
g=$("<button/>",{"class":"right-side accept",text:"update edit form"});k.append(g);d=$("<button/>",{"class":"right-side cancel",text:"cancel"});k.append(d);j.append(k);h.append(j);c.append(h);h=$("<div/>",{id:"dummyCitePane","class":"typepane",style:"display: none"});i=i.clone();h.append(i);h.append($("<div/>",{"class":"paramlist"}));c.append(h);h=$("<div/>",{id:"preloadedparamrow","class":"preloadedrow input-row",style:"display: none"}).append($("<label/>",{"class":"paramdesc"}));i=$("<input/>",
{"class":"paramvalue",tabindex:-1});h.append(i);j=$("<button/>",{"class":"delete-field"}).append("delete field");h.append(j);c.append(h);h=$("<div/>",{id:"addedparamrow","class":"addedrow input-row",style:"display: none"}).append($("<input/>",{"class":"paramdesc",tabindex:-1})).append(i.clone()).append(j.clone());c.append(h);h=$("<div/>",{id:"add-tab"});i=$("<div/>",{id:"add-fields","class":"inputs scroll",style:"height: 170px"});var l=$("<div/>",{style:"display: none",id:"cite","class":"input-row"}),
m=$("<label/>",{"for":"citemenu","class":"paramdesc required",text:"Reference type"});l.append(m);var p=$("<select/>",{id:"citemenu",change:function(){proveit.changeCite(p.get(0))}}),n=this.CiteReference.getTypes();j=(new this.AbstractReference({})).getDescriptions();for(k=0;k<n.length;k++)p.append($("<option/>",{value:n[k],text:j[n[k]]}));l.append(p);i.append(l);i.append($("<div/>",{"class":"addpanes",id:"citepanes",tabindex:0}));l=$("<div/>",{style:"display: none",id:"citation","class":"input-row"});
m=m.clone().attr("for","citationmenu");l.append(m);var o=$("<select/>",{id:"citemenu",change:function(){proveit.changeCite(o.get(0))}});m=["web","book","journal","encyclopedia","news","patent"];for(n=0;n<m.length;n++)o.append($("<option/>",{value:m[k],text:j[m[k]]}));l.append(o);i.append(l).append($("<div/>",{"class":"addpanes",id:"citationpanes",style:"display: none;"}));h.append(i);i=$("<div/>",{id:"add-buttons"});i.append($("<button/>",{style:"margin-right: 50px;",text:"add field"})).append(b.clone()).append(" = required").append(g.clone().text("insert into edit form")).append(d.clone());
h.append(i);c.append(h);a.append(c);$(document.body).prepend(a);var q=function(){$("#edit-pane").hide();$("#view-pane").show()};$("#tabs").tabs({selected:0,show:function(s,r){switch(r.index){case 1:q();proveit.changeCite(document.getElementById(proveit.togglestyle?"citemenu":"citationmenu"))}}});$("#view-link").click(q);$("#add-buttons button:first").button({icons:{primary:"ui-icon-circle-plus"}}).click(function(){proveit.addPaneRow(document.getElementById("add-tab"))}).next().next().button({icons:{primary:"ui-icon-circle-check",
secondary:"ui-icon-circle-arrow-e"}}).click(function(){proveit.addCitation(proveit.citationObjFromAddPopup($("#add-tab .typepane").get(0)));$("#tabs").tabs({selected:"#view-tab"});$("div.scroll, #view-pane").scrollTop(1E5)}).next().button({icons:{primary:"ui-icon-circle-close"}}).click(function(){$("#tabs").tabs({selected:"#view-tab"})});$("button.cancel").click(q);$("#edit-buttons button:first").button({icons:{primary:"ui-icon-circle-plus"}}).click(function(){proveit.addPaneRow($("#edit-pane"))}).next().next().button({icons:{primary:"ui-icon-circle-check"}}).next().button({icons:{primary:"ui-icon-circle-close"}});
$(".delete-field").button({icons:{primary:"ui-icon-close"},text:false});f.button({icons:{primary:"ui-icon-triangle-1-s"},text:false});f.toggle(function(){$("#view-tab, #add-tab").hide();$(this).button("option","icons",{primary:"ui-icon-triangle-1-n"})},function(){$("#view-tab, #add-tab").show();$(this).button("option","icons",{primary:"ui-icon-triangle-1-s"})});this.scanForRefs();$("#refs tr").eq(0).click().click();$("#refs tr:even").addClass("light");$("#refs tr:odd").addClass("dark")},makeRefboxElement:function(a,
c){var b=$('<tr><td class="number"></td><td class="type"></td><td class="title"></td><td class="edit"></td></tr>').get(0);a.isValid()||$(b).addClass("invalid");$(".edit button",b).get(0);var f=this,g="",d="";if(a.params.title!=null){g=a.params.title;d=this.truncateTitle(g)}$("td.title",b).text(d);$("td.title",b).attr("title",g);g="";if(a.params.year)g=a.params.year;else if(a.params.date)if(d=a.params.date.match(/^([12]\d{3})/))g=d[1];var h="";if(a.params.author)h=a.params.author;else if(a.params.last)h=
a.params.last;if(a.params.coauthors||a.params.last2)h+=" <i>et al.</i>";var i=a.getIcon(),j="";d=a.type;switch(d){case "web":j=a.params.url;break;case "book":if(a.params.isbn!=null)j=wgServer+"/w/index.php?title=Special%3ABookSources&isbn="+a.params.isbn;break;case "journal":case "conference":if(a.params.doi!=null)j="http://dx.doi.org/"+a.params.doi;break;case "news":j=a.params.url}$("td.type",b).css("background-image","url("+i+")");$("td.type",b).attr("title",a.type);var k=i="",l="";if(h!="")i='By: <span class="author">'+
h+"</span>";if(g!="")k='Date: <span class="date">'+g+"</span>";if(d!=null){if(j!="")d='<a href="'+j+'" target="_blank">'+d+"</a>";l='Type: <span class="type">'+d+"</span>"}h="";if(d=="raw")h=l+" | "+a.toString();else if(i!="")h=k!=""?l!=""?i+" | "+k+" | "+l:i+" | "+k:l!=""?i+" | "+l:i;else if(k!="")h=l!=""?k+" | "+l:k;else if(l!="")h=l;h="<p>"+h+"</p>";g=$("<div />",{"class":"expanded"});$(g).append(h);$("td.title",b).append(g);if(!c){d=$("#refs tr").length;$("td.number",b).text(d);$("#numRefs").text(d)}$(b).click(function(){f.highlightTargetString(a.orig);
$("#refs tr").removeClass("selected");$(b).addClass("selected")});d=function(){f.updateEditPane(a);$("#view-pane").hide();$("#edit-pane").show()};var m=a.getCitationStrings();h=$('<span class="all-pointers" />');for(j=0;j<m.length;j++){i=j+1;for(k="";i>0;){l=--i%26;k=String.fromCharCode(97+l)+k;i=Math.floor(i/26)}i=$('<a href="#">'+k+"</a>");k=function(p){return function(){var n=0,o=0,q=$(proveit.getMWEditBox()).val();for(o=0;o<p;o++){n=q.indexOf(m[o],n);if(n==-1){proveit.log("pointStrings["+o+"]: "+
m[o]+" not found.  Returning.");return false}n+=m[o].length}n=q.indexOf(m[p],n);n==-1?proveit.log("pointStrings["+p+"]: "+m[p]+" not found."):proveit.highlightLengthAtIndex(n,m[p].length);return false}}(j);i.click(k);h.append(i)}if(m.length>1){j=$("<p />");j.append('This reference appears in the article <span class="num-pointers">'+m.length+" times</span>: ").append(h);g.append(j)}if(a.type!="raw"){h=$("<button />",{text:"edit"});$(h).button({icons:{primary:"ui-icon-pencil"},text:false});h.click(d);
$(".edit",b).append(h);h=$("<button />",{"class":"edit",text:"edit this reference"});$(h).button({icons:{primary:"ui-icon-pencil"},text:true});h.click(d);g.append(h);$(b).dblclick(d)}else $(".edit",b).append("&nbsp;");if(m.length>0){d=$("<button />",{"class":"insert",text:"insert this reference at cursor"});$(d).button({icons:{primary:"ui-icon-arrowthick-1-e"},text:true});d.click(function(){f.insertRefIntoMWEditBox(a,false);return false});g.append(d)}return b},truncateTitle:function(a){var c=a;if(a.length>
86){c=c.substring(0,86);a=c.lastIndexOf(" ");if(a!=-1){c=c.substr(0,a);c+=" ..."}}return c},formatDate:function(a){return a.getFullYear()+"-"+(a.getMonth()<9?"0":"")+(a.getMonth()+1)+"-"+(a.getDate()<10?"0":"")+a.getDate()},addNewElement:function(a){var c=this.getRefBox();$(c).append(this.makeRefboxElement(a,false))}};proveit.CiteReference.getTypes=function(){return["web","book","journal","conference","encyclopedia","news","newsgroup","press release","interview","episode","video"]};
if(!String.prototype.trim)String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")};
(function(){var a=document.getElementsByTagName("head")[0],c=document.createElement("script");c.src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js";var b=false;c.onload=c.onreadystatechange=function(){if(!b&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")){b=true;$.getScript("http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.3/jquery-ui.min.js",function(){addOnloadHook(function(){proveit.proveitonload()})});c.onload=c.onreadystatechange=null;a&&c.parentNode&&
a.removeChild(c)}};a.appendChild(c)})();