MediaWiki:Gadget-ProveIt.js
Apparence
Note : après avoir enregistré la page, vous devrez forcer le rechargement complet du cache de votre navigateur pour voir les changements.
Mozilla / Firefox / Konqueror / Safari : maintenez la touche Majuscule (Shift) en cliquant sur le bouton Actualiser (Reload) ou pressez Maj-Ctrl-R (Cmd-R sur Apple Mac) ;
Firefox (sur GNU/Linux) / Chrome / Internet Explorer / Opera : maintenez la touche Ctrl en cliquant sur le bouton Actualiser ou pressez Ctrl-F5./* _____________________________________________________________________________
* | |
* | === WARNING: GLOBAL GADGET FILE === |
* | Changes to this page affect many users. |
* | Please discuss changes on the talk page or on [[WT:Gadget]] before editing. |
* |_____________________________________________________________________________|
*
* ProveIt, Copyright 2011, Georgia Tech
* Available under the GNU Free Documentation License, Creative Commons Attribution/Share-Alike License 3.0, and the GNU General Public License version 2
*
* Imported from Mercurial commit 930696884fe7 as of 2011-04-12 from http://code.google.com/p/proveit-js/
* This is a minified version. Changes should be made through that project.
*
* ProveIt is a powerful GUI tool for viewing, adding, editing, and inserting references.
* See [[User:ProveIt GT]] for more information.
*/
window.proveit=jQuery.extend({HALF_EDIT_BOX_HEIGHT:200,
LANG:"en",
NEW_PARAM_PREFIX:"newparam",
EDIT_PARAM_PREFIX:"editparam",
STATIC_BASE:"http://proveit-js.googlecode.com/hg/static/",
JQUERYUI_SCRIPT_URL:"http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.3/jquery-ui.min.js",
JQUERYUI_STYLES_URL:"http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.3/themes/base/jquery-ui.css",
descriptions:{en:{name:"Name",
author:"Author (L, F)",
author2:"Author two (L, F)",
author3:"Author three (L, F)",
author4:"Author four (L, F)",
author5:"Author five (L, F)",
author6:"Author six (L, F)",
author7:"Author seven (L, F)",
author8:"Author eight (L, F)",
author9:"Author nine (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",
accessdate:"Access date",
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",
"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",
subjectlink2:"Subject two article name",
subject3:"Subject three",
subjectlink3:"Subject three article name",
subject4:"Subject four",
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",
months:["January","February","March","April","May","June","July","August","September","October","November","December"]
}
},
getDescriptions:function(){
return this.descriptions[proveit.LANG]
},
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 jQuery("#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){
(a<0||c<0)&&this.log("highlightStringAtIndex: invalid negative arguments");
var b=this.getMWEditBox(),d=b.value,e=this.getPosition(b).top;b.value=d.substring(0,a);b.focus();
b.scrollTop=1E6;
e=b.scrollTop;
b.value+=d.substring(a);
if(e>0) b.scrollTop=e+this.HALF_EDIT_BOX_HEIGHT;
jQuery(b).focus().textSelection("setSelection",{start:a,end:a+c});
e=this.getPosition(b).top;window.scroll(0,e);
return!0
},
highlightTargetString:function(a){
var c=this.getMWEditValue().indexOf(a);
if(c==-1) return this.log('Target string "'+a+'" not found.'),!1;
return this.highlightLengthAtIndex(c,a.length)
},
getMWEditBox:function(){
return jQuery("#wpTextbox1")[0]
},
getMWEditValue:function(){
var a=this.getMWEditBox(),c=a.value;
!a.selectionStart&&document.selection&&(c=c.replace(/\r\n/g,"\n"));
return c
},
getMWEditForm:function(){
return jQuery("#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,!1)
},
getEditSummary:function(){
return jQuery("#wpSummary")[0]
},
summaryFunctionAdded:!1,
shouldAddSummary:!0,
loadMaximized:!1,
includeProveItEditSummary:function(){
if(this.shouldAddSummary&&!this.summaryFunctionAdded)
try{
var a=this;
this.addOnsubmit(function(){
var c=a.getEditSummary();
c.value.indexOf("ProveIt")==-1&&(c.value+=" (edited with [[User:ProveIt_GT|ProveIt]])")
});
this.summaryFunctionAdded=!0
}catch(c){
this.log("Failed to add onsubmit handler. e.message: "+c.message)
}
},
load:function(){
this.summaryFunctionAdded=!1;
this.isSupportedEditPage()&&jQuery.getScript(proveit.JQUERYUI_SCRIPT_URL,function(){
addOnloadHook(function(){
proveit.createGUI()
})
});
return!0
},
clearRefBox:function(){
var a=this.getRefBox();
if(a==null) return this.log("Ref box is not loaded yet."),!1;
a=jQuery("tr:not('tr#dummyRef')",a);
jQuery(a).remove()
},
insertRefIntoMWEditBox:function(a,c){
var b=this.getMWEditBox();
if(!b) return this.log("insertRefIntoMWEditBox: txtarea is null"),!1;
var b=jQuery(b),d=a.getInsertionText(c);
b.textSelection("encapsulateSelection",{peri:d,replace:!0});
b=b.textSelection("getCaretPosition",{startAndEnd:!0});
this.highlightLengthAtIndex(b[0],b[1]-b[0]);
this.includeProveItEditSummary()
},
changeRefFromEditPane:function(a,c){
var b=jQuery("div.input-row",c),d=jQuery("#editrefname").val();
a.name=d!=""?d:null;
a.params={};
for(var e,f,d=0;d<b.length;d++)
e=b[d],f=jQuery(".paramvalue",e)[0],e=jQuery(e).hasClass("addedrow")?jQuery(".paramdesc",e)[0].value.trim():f.id.substring(this.EDIT_PARAM_PREFIX.length),this.log("paramName: "+e),f=f.value.trim(),this.log("paramVal: "+f),e!=""&&f!=""&&(a.params[e]=f);
if(a.toString()!=a.orig)a.save=!1;
a.update();
return a
},
saveRefFromEdit:function(a){
if(!a.save){
var c=this.makeRefBoxRow(a,!0),b=jQuery(".selected",this.getRefBox()).get(0);
this.log("newRichItem: "+c+", oldRichItem: "+b+"oldRichItem.parentNode: "+b.parentNode);
var d=jQuery("td.number",b).text();
jQuery("td.number",c).text(d);
b.parentNode.replaceChild(c,b);
jQuery(c).addClass("selected");
a.updateInText();
this.includeProveItEditSummary()
}
},
updateEditPane:function(a){
jQuery("#editrefname").val(a.name||"");
var c={},b;
for(b in a.params)c[b]=a.params[b];
var d=a.getDefaultParams();
for(b=0;b<d.length;b++)c[d[b]]||(c[d[b]]="");
var d=a.getRequiredParams(),e=[],f;
for(f in c)e.push(f);
(f=a.getSorter())?e.sort(f):e.sort();
jQuery("#edit-fields").children(".paramlist").children().remove("div:not(.hidden)");
for(b=0;b<e.length;b++)this.addPaneRow(jQuery("#edit-pane").get(),c,this.getDescriptions(),e[b],d[e[b]],!0);
var g=jQuery("#edit-buttons .accept"),i=function(){
proveit.log("Entering acceptEdit");
proveit.changeRefFromEditPane(a,jQuery("#edit-pane").get());
proveit.saveRefFromEdit(a);
g.unbind("click",i);
jQuery("#edit-pane").hide();
jQuery("#view-pane").show()
};
setTimeout(function(){
jQuery("#edit-fields").scrollTop(0)
},0);
g.click(i);
jQuery(".tab-link").one("click",function(){
g.unbind("click",i)
})
},
addPaneRow:function(a,c,b,d,e,f){
var g=jQuery("#"+(f?"preloadedparamrow":"addedparamrow")).clone();
jQuery(g).attr("id","");
var i=jQuery(".paramdesc",g).eq(0),j=jQuery(".paramvalue",g).eq(0);
jQuery(".paramlist",a).append(g);
e?(jQuery(i).addClass("required"),jQuery(".delete-field",g).remove()):this.activateRemoveField(g);
f?(i.attr("for",this.EDIT_PARAM_PREFIX+d),j.attr("id",this.EDIT_PARAM_PREFIX+d),a=b[d],a||(this.log("Undefined description for param: "+d+". Using directly as description."),a=d),jQuery(i).text(a),jQuery(i).attr("title",d),jQuery(j).val(c[d]),jQuery(g).show()):(jQuery(g).show("highlight",{},"slow"),jQuery(".inputs",a).scrollTop(1E5))},togglestyle:!0,toggleinsert:!1,split:function(a,c,b){if(Object.prototype.toString.call(c)!=="[object RegExp]")return proveit.split._nativeSplit.call(a,c,b);
var d=[],e=0,f=(c.ignoreCase?"i":"")+(c.multiline?"m":"")+(c.sticky?"y":""), c=RegExp(c.source,f+"g"),g,i,j;
a+="";
proveit.split._compliantExecNpcg||(g=RegExp("^"+c.source+"$(?!\\s)",f));
if(b===void 0||+b<0) b=Infinity;
else if(b=Math.floor(+b),!b) return[];
for(;i=c.exec(a);){
f=i.index+i[0].length;
if(f>e&&(d.push(a.slice(e,i.index)),!proveit.split._compliantExecNpcg&&i.length>1&&i[0].replace(g,function(){
for(var a=1;a<arguments.length-2;a++)arguments[a]===void 0&&(i[a]=void 0)}),i.length>1&&i.index<a.length&&Array.prototype.push.apply(d,i.slice(1)),j=i[0].length,e=f,d.length>=b))break;c.lastIndex===i.index&&c.lastIndex++}e===a.length?(j||!c.test(""))&&d.push(""):d.push(a.slice(e));
return d.length>b?d.slice(0,b):d
},
splitNameVals:function(a){
var c={};
c.names=proveit.split(a.substring(a.indexOf("|")+1),/=(?:[^|]*?(?:\[\[[^|\]]*(?:\|(?:[^|\]]*))?\]\])?)+(?:\||\}\})/);
c.names.length--;
c.values=proveit.split(a.substring(a.indexOf("=")+1,a.indexOf("}}")),/\|[^|=]*=/);
return c
},
scanForRefs:function(){
this.log("Entering scanForRefs.");
this.clearRefBox();
var a=this.getMWEditValue(),c,b={},d=[];
a.match(/<[\s]*ref[^\/>]*>/gi);
if(a=a.match(/<[\s]*ref[^>]*>(?:[^<]*<[\s]*\/[\s]*ref[\s]*>)?/gi))
for(var e=0;e<a.length;e++){
var f=this.makeRef(a[e]);
f?(c=f.name)||d.push(f):c=(c=a[e].match(this.REF_REGEX))&&(c[1]||c[2]||c[3]);
if(c){
if(!b[c]&&(b[c]={},!b[c].strings)) b[c].strings=[];
if(f&&!b[c].reference) b[c].reference=f,d.push(f);
b[c].strings.push(a[e])
}
}
for(a=0;a<d.length;a++)
d[a].name&&d[a].setCitationStrings(b[d[a].name].strings),this.addNewElement(d[a])
},
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.CitationReference:this.RawReference;
if(c!=this.RawReference){
var b=a.match(/{{[\s]*(cite|Citation)[\s\S]*?}}/i)[0],d=a.match(this.REF_REGEX);
if(d&&d!=null) var e=d[1]||d[2]||d[3];
d=b.split(/\|/g);
if(c==this.CiteReference)
var f=d[0].toLowerCase().indexOf("e"),g=d[0].indexOf("}"),f=d[0].substring(f+1,g!=-1?g:d[0].length).trim()
}
a=new c({name:e,type:f,save:!0,inMWEditBox:!0,orig:a});
if(c!=this.RawReference){
c=this.splitNameVals(b);
b=c.names;
c=c.values;
for(e=0;e<b.length;e++)
d=b[e].trim().replace(/(?:\s*\|)*(.*)/,"$1"), f=c[e].trim(), f!=""&&(a.params[d]=f)
}
return a
},
AbstractReference:function(a){
if(!this.setType) this.setType=function(a){
this.type=a
};
this.update=function(){
var a=this.toString(),b=this.getCitationStrings();
if(b.length>0)
for(var d=0;d<b.length;d++)
b[d]==this.orig&&(proveit.log("Updating "+b[d]+" to "+a),b[d]=a);
else this.name!=null&&(proveit.log("Adding "+a+" to citationStrings"),b.push(a))
};
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={};
this.getSorter=function(){
var a=this;
return function(b,d){
var e=a.getSortIndex(b),f=a.getSortIndex(d);
return e!=-1&&f!=-1?e-f:b<d?-1:b==d?0:1
}
};
this.isValid=function(){
return!0
};
this.getLabel=function(){
var a="";
if(this.params.author) a=this.params.author+"; ";
else if(this.params.last) a=this.params.last,this.params.first&&(a+=", "+this.params.first),a+="; ";
this.params.title&&(a+=this.params.title);
if(a==""){
for(var b in this.params)
break;
b&&(a=b)
}
return a
};
this.getInsertionText=function(a){
proveit.log("getInsertionText");
if(a) return this.toString();
else if(this.name) return'<ref name="'+this.name+'" />';
else throw Error("getInsertionText: ref.name is null");
};
this.updateInText=function(){
var a=proveit.getMWEditBox();
if(a&&a!=null){
a.focus();
var b=proveit.getMWEditValue(),b=b.replace(this.orig,this.toString());
a.value=b;
this.orig=this.toString();
this.save=!0;
proveit.highlightTargetString(this.toString())
}
};
this.toStringInternal=function(a,b){
var d=this.name?'<ref name="'+this.name+'">':"<ref>";d+="{{"+a+(b?" "+this.type:"");
for(var e in this.params) d+=" | "+e+"="+this.params[e];
d+="}}</ref>";
return d
};
this.citationStrings=[];
this.setCitationStrings=function(a){
this.citationStrings=a
};
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(a){
var b=c[a];
this.type=b!=null?b:a
};
proveit.AbstractReference.call(this,a);
this.getSortIndex=function(a){
return jQuery.inArray(a,[ "url",
"title",
"encyclopedia",
"publisher",
"work",
"date",
"accessdate",
"author",
"last",
"first",
"subject",
"subjectlink",
"inventor",
"editor",
"author2",
"last2",
"first2",
"subject2",
"subjectlink2",
"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",
"newsgroup",
"journal",
"booktitle",
"program",
"episodelink",
"series",
"serieslink",
"credits",
"network",
"station",
"callsign",
"city",
"airdate",
"began",
"ended",
"season",
"seriesno",
"number",
"minutes",
"transcript",
"transcripturl",
"people",
"year",
"month",
"article",
"contribution",
"format",
"medium",
"newspaper",
"conference",
"volume",
"edition",
"issue",
"location",
"pages",
"page",
"language",
"isbn",
"issn",
"oclc",
"doi",
"pmid",
"id",
"archiveurl",
"archivedate",
"time",
"quote",
"ref"
])
};
this.toString=function(){
return this.toStringInternal("cite",!0)
};
var b={ web:{url:!0,title:!0},
book:{title:!0},
journal:{title:!0},
conference:{title:!0},
encyclopedia:{title:!0,encyclopedia:!0},
news:{title:!0,work:!0,date:!0},
newsgroup:{title:!0},
"press release":{title:!0},
interview:{last:!0},
episode:{title:!0},
video:{title:!0}
};
this.getRequiredParams=function(){
var a=b[this.type];
return a?a:{}
};
var d= { 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","work","date","accessdate","pages","location"],
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 a=d[this.type];
return a?a:[]
};
this.isValid=function(){
if(this.type=="") return!1;
var a=this.getRequiredParams(),b=!0,c;
for(c in a)
if(a[c]&&(b&=c in this.params,!b))break;
return b
};
var e={ 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:"telephone.png",
episode:"television.png",
video:"film.png"
},f=this.getIcon;
this.getIcon=function(){
var a=e[this.type];
if(a) return proveit.STATIC_BASE+a;
return f.call(this)
}
},
CitationReference: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(a){
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","version","pages","page","id","isbn","doi","oclc","accessdate"].indexOf(a)
};
this.toString=function(){
return this.toStringInternal("Citation",!1)
};
this.getRequiredParams=function(){
return c
};
this.getDefaultParams=function(){
return this.type?b[this.type]:["url","title","author","date","publisher"]
}
},
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"
}
},
getRefFromAddPane:function(a){
for(var c=a.id,c=new (this.togglestyle?this.CiteReference:this.CitationReference)({name:jQuery("#addrefname").val(),type:c}),b,a=jQuery(".paramlist",a)[0],d=jQuery("div",a),e=0;e<d.length;e++){
b=d[e];
this.log("getRefFromAddPane: i: "+e+", paramRow: "+b);
var f=jQuery(".paramvalue",b)[0],a=jQuery(b).hasClass("addedrow")?jQuery(".paramdesc",b)[0].value.trim():f.id.substring(this.NEW_PARAM_PREFIX.length);
this.log("getRefFromAddPane: paramRow.childNodes.length: "+b.childNodes.length);
this.log("getRefFromAddPane: valueTextbox.refName: "+f.refName);
this.log("getRefFromAddPane: valueTextbox.id: "+f.id);
b=f.value.trim();
this.log("getRefFromAddPane: paramName: "+a+"; paramVal: "+b);a!=""&&b!=""&&(c.params[a]=b)}c.update();
this.log("Exiting getRefFromAddPane");
return c
},
addReference:function(a){
this.addNewElement(a);
a.orig=a.toString();
this.insertRefIntoMWEditBox(a,!0);
a.save=!0;
a.inMWEditBox=!0
},
clearCitePanes:function(a){
a.hasChildNodes()&&a.removeChild(a.firstChild)
},
activateRemoveField:function(a){
jQuery(".delete-field",a).click(function(){
jQuery(a).hide("highlight",{},"slow",function(){
jQuery(a).remove()
})
})
},
changeAddPane:function(a){
jQuery("#add-fields").scrollTop(0);jQuery(a.parentNode).show();
var c=jQuery(".addpanes",a.parentNode.parentNode).get(0);
this.clearCitePanes(c);
var b=a.value,d=document.getElementById("dummyCitePane").cloneNode(!0);
d.id=b.replace(" ","_");
jQuery(".ref-name-row",d).children("input").attr("id","addrefname");
jQuery(".ref-name-row",d).children("label").attr("for","addrefname");
a=a.id=="citemenu"?new this.CiteReference({}):new this.CitationReference({});
a.type=b;
var b=this.getDescriptions(),e=a.getDefaultParams().slice(0);
e.sort(a.getSorter());
for(var f=0;f<e.length;f++) a.params[e[f]]="";
this.log("changeAddPane: newRef: "+a);
e=[];
for(j in a.params) e.push(j);
e.sort(a.getSorter());
for(var g=a.getRequiredParams(),i=jQuery(".paramlist",d)[0],f=0;f<e.length;f++){
var j=e[f],h;
if(b[j]){
h=document.getElementById("preloadedparamrow").cloneNode(!0);
var k=jQuery(".paramdesc",h);
if(g[j]){
k.addClass("required");
var l=jQuery(".delete-field",h)[0];
l.parentNode.removeChild(l)
}else
this.activateRemoveField(h);
k.text(b[j]);
k.attr("for",this.NEW_PARAM_PREFIX+j);
j=="accessdate"&&jQuery(".paramvalue",h).val(this.formatDate(new Date))
}else
h=
document.getElementById("addedparamrow").cloneNode(!0),jQuery(".paramdesc",h)[0].setAttribute("value",j);
h.id="";
this.activateRemoveField(h);
jQuery(".paramvalue",h)[0].id=this.NEW_PARAM_PREFIX+j;
this.log("changeAddPane: param: "+j+";
newRef.params[param]: "+a.params[j]);
jQuery(h).show();
i.appendChild(h)
}
jQuery(d).show();
c.insertBefore(d,c.firstChild);
this.log("Exiting changeAddPane")
},
createGUI:function(){
importStylesheetURI(this.JQUERYUI_STYLES_URL);
importStylesheetURI(this.STATIC_BASE+"styles.css");
var a=jQuery("<div/>",{id:"proveit"}),c=jQuery("<div/>",{id:"tabs"}),b=jQuery("<h1/>"),d=jQuery("<a/>",{title:"Created by the ELC Lab at Georgia Tech",href:"http://proveit.cc.gatech.edu",target:"_blank"}),e=jQuery("<img/>",{src:this.STATIC_BASE+"logo.png",alt:"ProveIt",height:30,width:118});
d.append(e);
b.append(d);
var f=jQuery("<button/>",{text:"show/hide"});
b.append(f);
c.append(b);
e=jQuery("<ul/>");
d=jQuery("<li/>");
b=jQuery("<a/>",{id:"view-link","class":"tab-link",href:"#view-tab"});
b.append("References (");
var g=jQuery("<span/>",{id:"numRefs"}).append("0");
b.append(g).append(")");
d.append(b);
e.append(d);
g=jQuery("<li/>");
d=jQuery("<a/>",{id:"add-link","class":"tab-link",href:"#add-tab"}).append("Add a Reference");
g.append(d);
e.append(g);
c.append(e);
var i=jQuery("<div/>",{id:"view-tab",css:{display:"none"}}),e=jQuery("<div/>",{id:"view-pane"}),g=jQuery("<div/>",{"class":"scroll",style:"height: 210px;"}),j=jQuery("<table/>",{id:"refs"}),h=jQuery("<tr/>",{id:"dummyRef",style:"display: none;"});
h.append(jQuery("<td/>",
{"class":"number"})).append(jQuery("<td/>",{"class":"type"})).append(jQuery("<td/>",{"class":"title"}));
var k=jQuery("<td/>",{"class":"edit"}).append(jQuery("<button/>",{text:"edit"}));
h.append(k);
j.append(h);
g.append(j);
e.append(g);
i.append(e);
k=jQuery("<div/>",{id:"edit-pane",style:"display: none"});
e=jQuery("<div/>",{id:"edit-fields","class":"inputs scroll",style:"height: 170px",tabindex:0});
h=jQuery("<div/>",{"class":"ref-name-row",tabindex:-1});
g=jQuery("<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("<ref> name");
h.append(g);
h.append(jQuery("<input/>",{id:"editrefname","class":"paramvalue"}));
g=jQuery("<div/>",{"class":"paramlist"});
e.append(h);
e.append(g);
k.append(e);
var l=jQuery("<div/>",{id:"edit-buttons"}),e=jQuery("<button/>",{style:"margin-right: 50px;"}).append("add field");
l.append(e);
e=jQuery("<span/>",{"class":"required",text:"bold"});
l.append(e).append(" = required field");
g=jQuery("<button/>",{"class":"right-side accept",text:"update edit form"});
l.append(g);
j=jQuery("<button/>",{"class":"right-side cancel",text:"cancel"});
l.append(j);
k.append(l);
i.append(k);
c.append(i);
k=jQuery("<div/>",{id:"dummyCitePane","class":"typepane",style:"display: none"});
h=h.clone();
k.append(h);
k.append(jQuery("<div/>",{"class":"paramlist"}));
c.append(k);
h=jQuery("<div/>",{id:"preloadedparamrow","class":"preloadedrow input-row",style:"display: none"}).append(jQuery("<label/>",{"class":"paramdesc"}));
k=jQuery("<input/>",{"class":"paramvalue",tabindex:-1});
h.append(k);
l=jQuery("<button/>",{"class":"delete-field"}).append("delete field");
h.append(l);
c.append(h);
h=jQuery("<div/>",{id:"addedparamrow","class":"addedrow input-row",style:"display: none"}).append(jQuery("<input/>",{"class":"paramdesc",tabindex:-1})).append(k.clone()).append(l.clone());
c.append(h);
var p=jQuery("<div/>",{id:"add-tab",css:{display:"none"}}),h=jQuery("<div/>",{id:"add-fields","class":"inputs scroll",style:"height: 170px"}),n=jQuery("<div/>",{style:"display: none",id:"cite","class":"input-row"}),
m=jQuery("<label/>",{"for":"citemenu","class":"paramdesc required",text:"Reference type"});
n.append(m);
for(var q=jQuery("<select/>",{id:"citemenu",change:function(){proveit.changeAddPane(q.get(0))}}),o=this.CiteReference.getTypes(),k=this.getDescriptions(),l=0;l<o.length;l++)
q.append(jQuery("<option/>",{value:o[l],text:k[o[l]]}));
n.append(q);
h.append(n);
h.append(jQuery("<div/>",{"class":"addpanes",id:"citepanes",tabindex:0}));
n=jQuery("<div/>",{style:"display: none",id:"citation","class":"input-row"});
m=m.clone().attr("for","citationmenu");
n.append(m);
for(var r=jQuery("<select/>",{id:"citemenu",change:function(){proveit.changeAddPane(r.get(0))}}),m=["web","book","journal","encyclopedia","news","patent"],o=0;o<m.length;o++)
r.append(jQuery("<option/>",value:m[l],text:k[m[l]]}));
n.append(r);
h.append(n).append(jQuery("<div/>",{"class":"addpanes",id:"citationpanes",style:"display: none;"}));
p.append(h);
h=jQuery("<div/>",{id:"add-buttons"});h.append(jQuery("<button/>",{style:"margin-right: 50px;",text:"add field"})).append(e.clone()).append(" = required").append(g.clone().text("insert into edit form")).append(j.clone());
p.append(h);
c.append(p);
a.append(c);
jQuery(document.body).prepend(a);
var s=function(){
jQuery("#edit-pane").hide();
jQuery("#view-pane").show()
};
jQuery("#tabs").tabs({selected:0,show:function(a,b){
switch(b.index){
case 1:
s(),proveit.changeAddPane(document.getElementById(proveit.togglestyle?"citemenu":"citationmenu"))
}
}});
jQuery(b).click(function(){
jQuery(i).is(":hidden")?f.click():s()
});
jQuery(d).click(function(){
jQuery(p).is(":hidden")&&f.click()
});
jQuery("#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.addReference(proveit.getRefFromAddPane(jQuery("#add-tab .typepane").get(0)));
jQuery("#tabs").tabs({selected:"#view-tab"});jQuery("div.scroll, #view-pane").scrollTop(1E5)}).next().button({icons:{primary:"ui-icon-circle-close"}}).click(function(){jQuery("#tabs").tabs({selected:"#view-tab"})});
jQuery("button.cancel").click(s);jQuery("#edit-buttons button:first").button({icons:{primary:"ui-icon-circle-plus"}}).click(function(){proveit.addPaneRow(jQuery("#edit-pane"))}).next().next().button({icons:{primary:"ui-icon-circle-check"}}).next().button({icons:{primary:"ui-icon-circle-close"}});
jQuery(".delete-field").button({icons:{primary:"ui-icon-close"},text:!1});f.button({icons:{primary:"ui-icon-triangle-1-n"},text:!1});
var t=jQuery("#view-tab, #add-tab");
f.toggle(function(){t.show();
f.button("option","icons",{primary:"ui-icon-triangle-1-s"})},function(){t.hide();f.button("option","icons",{primary:"ui-icon-triangle-1-n"})});
this.scanForRefs();
this.loadMaximized&&f.click();
jQuery("#refs tr").eq(0).click().click();
jQuery("#refs tr:even").addClass("light");
jQuery("#refs tr:odd").addClass("dark")
},
makeRefBoxRow:function(a,c){
var b=jQuery('<tr><td class="number"></td><td class="type"></td><td class="title"></td><td class="edit"></td></tr>').get(0);
a.isValid()||jQuery(b).addClass("invalid");
jQuery(".edit button",b).get(0);
var d=this,e="",f="";
if(a.params.title!=null) e=a.params.title,f=this.truncateTitle(e);
jQuery("td.title",b).text(f);
jQuery("td.title",b).attr("title",e);
e="";
a.params.year?e=a.params.year:a.params.date&&(f=a.params.date.match(/^([12]\d{3})/))&&(e=f[1]);
var g="";
a.params.author?
g=a.params.author:a.params.last&&(g=a.params.last);
if(a.params.coauthors||a.params.last2) g+=" <i>et al.</i>";
var i=a.getIcon(),j="",f=a.type;
switch(f){
case "web":
j=a.params.url;
break;
case "book":
a.params.isbn!=null&&(j=wgServer+"/w/index.php?title=Special%3ABookSources&isbn="+a.params.isbn);
break;
case "journal":
case "conference":
a.params.doi!=null&&(j="http://dx.doi.org/"+a.params.doi);
break;
case "news":
j=a.params.url;
break;
case "episode":
j="http://www.imdb.com/find?s=ep&q="+escape(a.params.title)
}
jQuery("td.type",
b).css("background-image","url("+i+")");
jQuery("td.type",b).attr("title",a.type);
var h=i="",k="";g!=""&&(i='By: <span class="author">'+g+"</span>");
e!=""&&(h='Date: <span class="date">'+e+"</span>");
f!=null&&(j!=""&&(f='<a href="'+j+'" target="_blank">'+f+"</a>"),k='Type: <span class="type">'+f+"</span>");
g="";
f=="raw"?g=k+" | "+a.toString():i!=""?g=h!=""?k!=""?i+" | "+h+" | "+k:i+" | "+h:k!=""?i+" | "+k:i:h!=""?g=k!=""?h+" | "+k:h:k!=""&&(g=k);g="<p>"+g+"</p>";
e=jQuery("<div />",{"class":"expanded"});
jQuery(e).append(g);
jQuery("td.title",b).append(e);
if(!c) f=jQuery("#refs tr").length,jQuery("td.number",b).text(f),jQuery("#numRefs").text(f);
jQuery(b).click(function(){
d.highlightTargetString(a.orig);
jQuery("#refs tr").removeClass("selected");
jQuery(b).addClass("selected")});
for(var f=function(){
d.updateEditPane(a);
jQuery("#view-pane").hide();
jQuery("#edit-pane").show()
},l=a.getCitationStrings(),g=jQuery('<span class="all-citations" />'),j=0;j<l.length;j++){
i=j+1;
for(h="";i>0;) k=--i%26,h=String.fromCharCode(97+
k)+h,i=Math.floor(i/26);
i=jQuery('<a href="#">'+h+"</a>");
h=function(a){
return function(){
for(var b=0,c=0,d=proveit.getMWEditValue(),c=0;c<a;c++){
b=d.indexOf(l[c],b);
if(b==-1) return proveit.log("citationStrings["+c+"]: "+l[c]+" not found. Returning."),!1;
b+=l[c].length}b=d.indexOf(l[a],b);
b==-1?proveit.log("citationStrings["+a+"]: "+l[a]+" not found."):proveit.highlightLengthAtIndex(b,l[a].length);
return!1
}
}
(j);
i.click(h);
g.append(i)
}
l.length>1&&(j=jQuery("<p />"),j.append('This reference is cited in the article <span class="num-citations">'+
l.length+" times</span>: ").append(g),e.append(j));
a.type!="raw"?(g=jQuery("<button />",{text:"edit"}),jQuery(g).button({icons:{primary:"ui-icon-pencil"},text:!1}),g.click(f),jQuery(".edit",b).append(g),g=jQuery("<button />",{"class":"edit",text:"edit this reference"}),jQuery(g).button({icons:{primary:"ui-icon-pencil"},text:!0}),g.click(f),e.append(g),jQuery(b).dblclick(f)):jQuery(".edit",b).append(" ");l.length>0&&(f=jQuery("<button />",{"class":"insert",text:"insert this reference at cursor"}),
jQuery(f).button({icons:{primary:"ui-icon-arrowthick-1-e"},text:!0}),f.click(function(){d.insertRefIntoMWEditBox(a,!1);return!1}),e.append(f));
return b
},
truncateTitle:function(a){
var c=a;a.length>86&&(c=c.substring(0,86),a=c.lastIndexOf(" "),a!=-1&&(c=c.substr(0,a),c+=" ..."));
return c
},formatDate:function(a){
var c=a.getFullYear(),b=this.getDescriptions().months[a.getMonth()],a=(a.getDate()<10?"0":"")+a.getDate();
return b+" "+a+", "+c
},addNewElement:function(a){
var c=this.getRefBox();
jQuery(c).append(this.makeRefBoxRow(a,!1))
}
},
window.proveit
);
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,"")
};
proveit.split._compliantExecNpcg=/()??/.exec("")[1]===void 0;
proveit.split._nativeSplit=String.prototype.split;
proveit.load();