User:AndyZ/monobook.js/footnotehelper.js

From Wikipedia, the free encyclopedia

Note: After saving, you have to bypass your browser's cache to see the changes. Mozilla/Safari: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Internet Explorer: press Ctrl-F5, Opera/Konqueror: press F5.

//<pre>
//create array refA, whose contents are the parameter names for {{cite web}}
var refA = new Array()
refA[0]='last'
refA[1]='first'
refA[2]='authorlink'
refA[3]='date'
refA[4]='url'
refA[5]='title'
refA[6]='format'
refA[7]='work'
refA[8]='pages'
refA[9]='publisher'
refA[10]='language'
refA[11]='accessdate' 

//function generates the footnote
function createFootnote(){
for(i=0;i<12;i++){
//for loop that runs through each text box and sees if there is content
if(document.getElementById("t"+i).value!=""){
document.refForm.refOutput.value+="|"+refA[i]+"="+document.getElementById("t"+i).value
}
}
//ending braces
document.refForm.refOutput.value+="\}\}</ref>"
}

//create array refB, whose contents are the parameter names for {{cite book}}
var refB = new Array()
refB[0]='last'
refB[1]='first'
refB[2]='authorlink'
refB[3]='year'
refB[4]='url'
refB[5]='title'
refB[6]='id'
refB[7]='location'
refB[8]='pages'
refB[9]='publisher'
refB[10]='language'
refB[11]='accessdate' 
refB[12]= 'chapter'

//function generates the footnote
function createFootnote2(){
if(document.refFormB.refOutput.value!="<ref>{{cite book"){
alert("You may wish to reset before submitting")
}
for(i=0;i<13;i++){
//for loop that runs through each text box and sees if there is content
if(document.getElementById("b"+i).value!=""){
document.refFormB.refOutput.value+="|"+refB[i]+"="+document.getElementById("b"+i).value
}
}
//ending braces
document.refFormB.refOutput.value+="\}\}</ref>"
}

//hides refWindow layer, shows button for maxing
function hide1(){
document.getElementById('refWindow').style.visibility="hidden"
document.getElementById('tab1').style.visibility="hidden"
document.getElementById('tab2').style.visibility="hidden"
document.getElementById('maxbutton').style.visibility="visible"
}

//shows refWindow layer, hides button for maxing
function show1(){
document.getElementById('refWindow').style.visibility="visible"
document.getElementById('tab1').style.visibility="visible"
document.getElementById('tab2').style.visibility="visible"
document.getElementById('maxbutton').style.visibility="hidden"
//mode1="web"

//tab appearances change:
document.getElementById('tab1').style.background="#ff5555"
document.getElementById('tab2').style.background="#55ff55"
document.getElementById('tab1').style.borderBottom="0px solid #000000"
document.getElementById('tab1').style.zIndex="21"
document.getElementById('tab2').style.zIndex="19"
document.getElementById('tab2').style.borderBottom="1px solid #000000"
}

//hides refWindow2 layer, shows button for maxing
function hide2(){
document.getElementById('refWindow2').style.visibility="hidden"
document.getElementById('tab1').style.visibility="hidden"
document.getElementById('tab2').style.visibility="hidden"
document.getElementById('maxbutton2').style.visibility="visible"
}

//shows refWindow2 layer, hides button for maxing
function show2(){
document.getElementById('refWindow2').style.visibility="visible"
document.getElementById('refWindow').style.visibility="hidden"
document.getElementById('tab1').style.visibility="visible"
document.getElementById('tab2').style.visibility="visible"
document.getElementById('maxbutton').style.visibility="hidden"
//mode1="book"

//tab appearances change:
document.getElementById('tab1').style.background="#55ff55"
document.getElementById('tab2').style.background="#ff5555"
document.getElementById('tab2').style.borderBottom="0px solid #000000"
document.getElementById('tab2').style.zIndex="21"
document.getElementById('tab1').style.zIndex="19"
document.getElementById('tab1').style.borderBottom="1px solid #000000"
}

//to show the correct window
function show3(theType){
if(theType.substring(0,3)=="web"){
document.getElementById('refWindow').style.visibility="visible"
document.getElementById('tab1').style.visibility="visible"
document.getElementById('tab2').style.visibility="visible"
document.getElementById('maxbutton').style.visibility="hidden"
}
if(theType.substring(0,4)=="book"){
document.getElementById('refWindow').style.visibility="visible"
document.getElementById('tab1').style.visibility="visible"
document.getElementById('tab2').style.visibility="visible"
document.getElementById('maxbutton2').style.visibility="hidden"
}
}

//to hide only window, not tabs
function hide3(theP){
if(theP=="web"){document.getElementById('refWindow').style.visibility="hidden"}
if(theP=="book"){document.getElementById('refWindow2').style.visibility="hidden"}
}

//creates pop-up windows
function popWindow(theThing){
if(theThing!="help"){theContent="<html><head><title>"+theThing+"</title></head><body onload='resizeTo(300,300)'>"}
else{theContent="<html><head><title>"+theThing+"</title></head><body onload='resizeTo(800,800)'>"}

if(theThing=="last") {theContent+="Last name of author"}
if(theThing=="first") {theContent+="First name of author"}
if(theThing=="authorlink") {theContent+="Wikilink to appropriate Wikipedia article (no brackets)"}
if(theThing=="date") {theContent+="Date of access (please wikilink). Can be in ISO 8601 YYYY-MM-DD format or other formats."}
if(theThing=="url") {theContent+="URL of web reference"}
if(theThing=="title") {theContent+="Title of web page"}
if(theThing=="format") {theContent+="Format (pdf, doc, etc.). If it is not included, it is assumed that it is HTML."}
if(theThing=="work") {theContent+="If the site is part of a larger work, provide name of larger work"}
if(theThing=="pages") {theContent+="The page numbers used"}
if(theThing=="publisher") {theContent+="Publisher, if there is one"}
if(theThing=="language") {theContent+="Language the page is in"}
if(theThing=="accessdate") {theContent+="The date of access in ISO 8601 YYYY-MM-DD format (do not wikilink)"}
if(theThing=="help"){
theContent+="<h2>Help</h2><br><br>"
theContent+="<br><br><b>What are references and footnotes?</b><br><br>References are the sources used in the creation of articles. Per <a href='http://en.wikipedia.org/wiki/WP:NOT'>WP:NOT</a>, no articles should contain <a href='http://en.wikipedia.org/wiki/WP:NOR'>no original research</a>. All articles should be sourced to guarantee that the articles are accurate. References are located in a single section at the end of an article; footnotes are dispersed throughout the articles, and upon clicking them it drags the reader to the source used."
theContent+="<br><br><b>Do I need footnotes?</b><br><br>Preferably, yes. <a href='http://en.wikipedia.org/wiki/WP:WIAFA'>WP:WIAFA</a> requires them for all featured articles; to establish the accuracy of articles, however, all articles should have them."
theContent+="<br><br><b>How I created a footnote?</b><br><br>That is what this is for. All it actually does is simplify the process of flicking between pages to find the parameters of Template:Cite web and other relevant templates; if you know all of the parameters by heart, there really is not much point to this.<br><br>At the bottom of the page, under a ==Notes== section (below the ==See also==, but above the ==External links== per WP:GTL), add: <<font style='background:yellow'>references/</font>> (use div tags with the class set equal to 'references-small' around this preferably).<br><br>In the text, add the footnotes created by the JS script where the inline citations are required. Just copy them from the text area and paste them in the relevant part of the article."
theContent+="<br><br><b>Can I make more than one footnote point to the same information?</b><br><br>Yes, use <<font>ref name=THENAME>footnote information<</font>/ref> for each footnote that you wish to point to the same information."
theContent+="<br><br><b>What relevant Wikipedia: namespace guidelines are there?</b><br><br><a href='http://en.wikipedia.org/wiki/WP:FOOTNOTE'>WP:FOOTNOTE</a>, <a href='http://en.wikipedia.org/wiki/WP:CITE'>WP:CITE</a>, and <a href='http://en.wikipedia.org/wiki/WP:V'>WP:V</a> are relevant guidelines."
theContent+="<br><br><b>Can you repeat that all again?</b><br><br>Uhh... no ;)."
}
theContent+="</body></html>"

winName = window.open("http://en.wikipedia.org/","Help")
winName.document.write(theContent)
winName.document.close()	
}

//creates pop-up windows
function popWindow2(theThing){
if(theThing!="help"){theContent="<html><head><title>"+theThing+"</title></head><body onload='resizeTo(300,300)'>"}
else{theContent="<html><head><title>"+theThing+"</title></head><body onload='resizeTo(800,800)'>"}

if(theThing=="last") {theContent+="Last name of author"}
if(theThing=="first") {theContent+="First name of author"}
if(theThing=="authorlink") {theContent+="Wikilink to appropriate Wikipedia article (no brackets)"}
if(theThing=="date") {theContent+="Date of publication (do not wikilink). Should be in ISO 8601 YYYY-MM-DD format."}
if(theThing=="url") {theContent+="URL of book, it is online"}
if(theThing=="title") {theContent+="Title of book"}
if(theThing=="id") {theContent+="Id, as in ISBN number."}
if(theThing=="location") {theContent+="Place of publication"}
if(theThing=="pages") {theContent+="The page numbers used"}
if(theThing=="publisher") {theContent+="Publisher, if there is one"}
if(theThing=="language") {theContent+="Language the book is in"}
if(theThing=="accessdate") {theContent+="The date of access in ISO 8601 YYYY-MM-DD format (do not wikilink)"}
if(theThing=="help"){
theContent+="<h2>Help</h2><br><br>"
theContent+="<b>What are references and footnotes?</b><br><br>References are the sources used in the creation of articles. Per <a href='http://en.wikipedia.org/wiki/WP:NOT'>WP:NOT</a>, no articles should contain <a href='http://en.wikipedia.org/wiki/WP:NOR'>no original research</a>. All articles should be sourced to guarantee that the articles are accurate. References are located in a single section at the end of an article; footnotes are dispersed throughout the articles, and upon clicking them it drags the reader to the source used."
theContent+="<br><br><b>Do I need footnotes?</b><br><br>Preferably, yes. <a href='http://en.wikipedia.org/wiki/WP:WIAFA'>WP:WIAFA</a> requires them for all featured articles; to establish the accuracy of articles, however, all articles should have them."
theContent+="<br><br><b>How I created a footnote?</b><br><br>That is what this is for. All it actually does is simplify the process of flicking between pages to find the parameters of Template:Cite web and other relevant templates; if you know all of the parameters by heart, there really is not much point to this.<br><br>At the bottom of the page, under a ==Notes== section (below the ==See also==, but above the ==External links== per WP:GTL), add: <<font style='background:yellow'>references/</font>> (use div tags with the class set equal to 'references-small' around this preferably).<br><br>In the text, add the footnotes created by the JS script where the inline citations are required. Just copy them from the text area and paste them in the relevant part of the article."
theContent+="<br><br><b>Can I make more than one footnote point to the same information?</b><br><br>Yes, use <<font>ref name=THENAME>footnote information<</font>/ref> for each footnote that you wish to point to the same information."
theContent+="<br><br><b>What relevant Wikipedia: namespace guidelines are there?</b><br><br><a href='http://en.wikipedia.org/wiki/WP:FOOTNOTE'>WP:FOOTNOTE</a>, <a href='http://en.wikipedia.org/wiki/WP:CITE'>WP:CITE</a>, and <a href='http://en.wikipedia.org/wiki/WP:V'>WP:V</a> are relevant guidelines."
theContent+="<br><br><b>Can you repeat that all again?</b><br><br>Uhh... no ;)."
}
theContent+="</body></html>"

winName = window.open("http://en.wikipedia.org/","Help")
winName.document.write(theContent)
winName.document.close()	
}

//mode1 variable indicates if web or book window is open; web or book
//mode1="web"

var web_var = "web"
var book_var = "book"

//function switch1() will switch tabs for a book citation instead of web and vice-versa
function switch1(theType){
if(theType=="book"){
hide3(web_var); show2(); 
//mode1="book"
}
if(theType=="web"){
hide3(book_var); show1(); 
//mode1="web"
}
}

//generates the layer with the text boxes
document.write('<div name="web" id="tab1" style="position:absolute; margin-top:32px; margin-left:50px; height:5px; z-index:21; visibility:hidden; background:#ff5555; border:1px solid #222222; border-bottom:0px solid #222222" onclick="switch1(this.name)">Web </div><div name="book" id="tab2" style="position:absolute; margin-top:32px; margin-left:87px; height:5px; z-index:19; visibility:hidden; background:#55ff55; border:1px solid #222222" onclick="switch1(this.name)">Book</div>'
+'<span id="refWindow" style="position:absolute; top=100; left=100; visibility:hidden; z-index:20; background:#f0f0ff; width:40%; height:30%; margin:50px; border:1px solid #000000">'
+'<span valign="right" style="color:red" onclick="hide1()">X</span><br>Click on the descriptions at the right of the text boxes for their definitions.'
+'<form name="refForm">'
	+'<input type="button" name="refMaker" value="Create footnote" onclick="createFootnote()">'
	+'<input type="reset" name="reset" value="Reset"><br>'
	+'<input id="t0" type="text" name="last" value=""> <span onclick="popWindow(refA[0])">Last name</span><br>'
	+'<input id="t1" type="text" name="first" value=""> <span onclick="popWindow(refA[1])">First name</span><br>'
	+'<input id="t2" type="text" name="authorlink" value=""> <span onclick="popWindow(refA[2])">Link to author</span><br>'
	+'<input id="t3" type="text" name="date" value=""> <span onclick="popWindow(refA[3])">Date</span><br>'
	+'<input id="t4" type="text" name="url" value=""> <span onclick="popWindow(refA[4])">URL*</span><br>'
	+'<input id="t5" type="text" name="title" value=""> <span onclick="popWindow(refA[5])">Title*</span><br>'
	+'<input id="t6" type="text" name="format" value=""> <span onclick="popWindow(refA[6])">Format</span><br>'
	+'<input id="t7" type="text" name="work" value=""> <span onclick="popWindow(refA[7])">Work</span><br>'
	+'<input id="t8" type="text" name="pages" value=""> <span onclick="popWindow(refA[8])">Pages</span><br>'
	+'<input id="t9" type="text" name="publisher" value=""> <span onclick="popWindow(refA[9])">Publisher</span><br>'
	+'<input id="t10" type="text" name="language" value=""> <span onclick="popWindow(refA[10])">Language</span><br>'
	+'<input id="t11" type="text" name="accessdate" value=""> <span onclick="popWindow(refA[11])">Date of access*</span><br>'
	+'<span style="font-size:75%"> * denotes that the parameter is required</span><br>'
	+'<input type="button" name="help" id="theHelpbutton" value="Help" onclick="popWindow(this.name)"><br>'
	+'<textarea name="refOutput" cols="50" rows="5"><ref>{{cite web</textarea>'
	+'</form></span>'
        +'<span id="maxbutton" style="position:absolute; left=0; top=0; visibility:hidden; z-index=19; background:yellow; height=20px; margin-top:120px; margin-left:5px"><span name="web_max_button" onclick="show3(this.name)">[restore]</span></span>')

document.write('<span id="refWindow2" style="position:absolute; top=100; left=100; visibility:hidden; z-index:20; background:#f0f0ff; width:40%; height:30%; margin:50px; border:1px solid #000000">'
+'<span valign="right" style="color:red" onclick="hide2()">X</span><br>Click on the descriptions at the right of the text boxes for their definitions.'
+'<form name="refFormB">'
	+'<input type="button" name="refMaker" value="Create footnote" onclick="createFootnote2()">'
	+'<input type="reset" name="reset" value="Reset"><br>'
	+'<input id="b0" type="text" name="last" value=""> <span onclick="popWindow2(refB[0])">Last name</span><br>'
	+'<input id="b1" type="text" name="first" value=""> <span onclick="popWindow2(refB[1])">First name</span><br>'
	+'<input id="b2" type="text" name="authorlink" value=""> <span onclick="popWindow2(refB[2])">Link to author</span><br>'
	+'<input id="b3" type="text" name="year" value=""> <span onclick="popWindow2(refB[3])">Year of publication</span><br>'
	+'<input id="b4" type="text" name="url" value=""> <span onclick="popWindow2(refB[4])">URL</span><br>'
	+'<input id="b5" type="text" name="title" value=""> <span onclick="popWindow2(refB[5])">Title*</span><br>'
	+'<input id="b6" type="text" name="id" value=""> <span onclick="popWindow2(refB[6])">ISBN #</span><br>'
	+'<input id="b7" type="text" name="location" value=""> <span onclick="popWindow2(refB[7])">Location of publication</span><br>'
	+'<input id="b8" type="text" name="pages" value=""> <span onclick="popWindow2(refB[8])">Last name</span><br>'
	+'<input id="b9" type="text" name="publisher" value=""> <span onclick="popWindow2(refB[9])">Publisher</span><br>'
	+'<input id="b10" type="text" name="language" value=""> <span onclick="popWindow2(refB[10])">Language</span><br>'
	+'<input id="b11" type="text" name="accessdate" value=""> <span onclick="popWindow2(refB[11])">Date of access</span><br>'
+'<input id="b12" type="text" name="accessdate" value=""> <span onclick="popWindow2(refB[12])">Chapter</span><br>'
	+'<span style="font-size:75%"> * denotes that the parameter is required</span><br>'
	+'<input type="button" name="help" id="theHelpbutton" value="Help" onclick="popWindow2(this.name)"><br>'
	+'<textarea name="refOutput" cols="50" rows="5"><ref>{{cite book</textarea>'
	+'</form></span>'
        +'<span id="maxbutton2" style="position:absolute; left=0; top=0; visibility:hidden; z-index=19; background:yellow; height=20px; margin-top:120px; margin-left:5px"><span name="book_max_button" onclick="show3(this.name)">[restore]</span></span>')

//function addOnloadHook to allow the creation of a new tab in editing mode. 
//It can also be called upon by javascript:show1()
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=' 
             + 'User:Omegatron/monobook.js/addlink.js'
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');

addOnloadHook(function () {
    if(document.forms.editform) {
        addLink('p-cactions', 'javascript:show1()', 'footnote creater', 'ca-datefixer', 'Quick help with footnotes', '', '');
    }
});


//</pre>