பயனர்:Shrikarsan/refToolbar.js
Appearance
குறிப்பு - சேமித்த பின்னர், நீங்கள் செய்த மாற்றங்களைக் காண்பதற்கு உங்கள் உலவியின் இடைமாற்று அகற்றப்பட வேண்டும்.
- மொஸில்லா பயர்பாக்ஸ் / சபாரி: Shift+Reload, அல்லது Ctrl-F5 அல்லது Ctrl-R (⌘-R Mac ல்)
- கூகிள் குரோம் Ctrl-Shift-R அழுத்தவும். (⌘-Shift-R Mac ல்) ;
- இண்டர்நெட் எக்ஸ்ப்ளோரர்: Ctrl-Refresh அல்லது Ctrl-F5 ஐ அழுத்தவும்.
- ஒபேரா: Tools → Preferences இல் இடைமாற்றை அகற்றவும்;
// _________________________________________________________________________________________
// | |
// | === WARNING: GLOBAL GADGET FILE === |
// | Changes to this page affect many users. |
// | Please discuss changes on the talk page or on [[Wikipedia_talk:Gadget]] before editing. |
// |_________________________________________________________________________________________|
//
// Imported from version 208865990 as of 22:46, April 28, 2008 from [[User:Mr.Z-man/refToolbar.js]]
// For a description, see [[User:Mr.Z-man/refToolbar]]
var numforms = 0;
var wikEdAutoUpdateUrl;
function refbuttons() {
if (mwCustomEditButtons && document.getElementById('toolbar') && wikEdAutoUpdateUrl == null) {
button = document.createElement('a');
button.href = "javascript:easyCiteMain()";
button.title = "Insert Citation";
buttonimage = document.createElement('img');
buttonimage.src = "//upload.wikimedia.org/wikipedia/commons/e/ea/Button_easy_cite.png";
buttonimage.alt = "Insert Citation";
button.appendChild(buttonimage);
document.getElementById('toolbar').appendChild(button);
if (navigator.userAgent.indexOf('MSIE') == -1) {
citemain = document.createElement('div');
citemain.style.display = 'none';
citemain.setAttribute('Id', 'citeselect');
citemain.appendChild( addOption("citeWeb()", "Web") );
citemain.appendChild( addOption("citeNews()", "News") );
citemain.appendChild( addOption("citeBook()", "Book") );
citemain.appendChild( addOption("citeJournal()", "Journal") );
citemain.appendChild( addOption("citeNamedRef()", "Named references") );
citemain.appendChild( addOption("hideInitial()", "Cancel") );
document.getElementById('wpTextbox1').parentNode.insertBefore(citemain, document.getElementById('wpTextbox1'));
}
else {
selection = '<div id="citeselect" style="display:none"><input type="button" value="Web" onclick="citeWeb()" />'+
'<input type="button" value="News" onclick="citeNews()" />'+
'<input type="button" value="Book" onclick="citeBook()" />'+
'<input type="button" value="Journal" onclick="citeJournal()" />'+
'<input type="button" value="Named references" onclick="citeNamedRef()" />'+
'<input type="button" value="Cancel" onclick="hideInitial()" /></div>';
document.getElementById('editform').innerHTML = selection + document.getElementById('editform').innerHTML;
}
}
}
function addOption(script, text) {
option = document.createElement('input');
option.setAttribute('type', 'button');
option.setAttribute('onclick', script);
option.setAttribute("value", text);
return option;
}
function hideInitial() {
document.getElementById('citeselect').style.display = 'none';
if (document.getElementById('citediv1') ) {
document.getElementById('citediv'+numforms).style.display = 'none';
}
}
function easyCiteMain() {
document.getElementById('citeselect').style.display = '';
}
function getTime() {
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);
}
function citeWeb() {
citeNewsWeb("cite web");
}
function citeNews() {
citeNewsWeb("cite news");
}
function citeNewsWeb(templatename) {
if (numforms != 0) {
document.getElementById('citediv'+numforms).style.display = 'none';
}
template = templatename;
var legend;
if (template="cite web") {
legend = "Cite web source";
} else {
legend = "Cite news source";
}
newtime = getTime();
numforms++;
form = '<div id="citediv'+numforms+'">'+
'<fieldset><legend>'+legend+'</legend>'+
'<table cellspacing="5">'+
'<input type="hidden" value="'+template+'" id="template">'+
'<tr><td width="120"><label for="url"> URL: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="url"></td>'+
'<td width="120"><label for="title"> Title: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="title"></td></tr>'+
'<tr><td width="120"><label for="last"> Last name: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="last"></td>'+
'<td width="120"><label for="first"> First name: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="first"></td></tr>'+
'<tr><td width="120"><label for="coauthors"> Coauthors: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="coauthors"></td>'+
'<td width="120"><label for="date"> Publication date: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="date"></td></tr>'+
'<tr><td width="120"><label for="work"> Work: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="work"></td>'+
'<td width="120"><label for="publisher"> Publisher: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="publisher"></td></tr>'+
'<tr><td width="120"><label for="pages"> Pages: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="pages"></td>'+
'<td width="120"><label for="language"> Language: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="language"></td></tr>'+
'<tr><td width="120"><label for="accessdate"> Access date: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="accessdate" value="'+ newtime +'"></td>'+
'<td width="120"><label for="refname"> Reference name: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="refname"></td></tr>'+
'</table>'+
'<input type="button" value="Add citation" onClick="addcites()">'+
'</fieldset></div>';
document.getElementById('citeselect').innerHTML += form;
}
function citeBook() {
if (numforms != 0) {
document.getElementById('citediv'+numforms).style.display = 'none';
}
template = "cite book";
numforms++;
form = '<div id="citediv'+numforms+'">'+
'<fieldset><legend>Cite book source</legend>'+
'<table cellspacing="5">'+
'<input type="hidden" value="'+template+'" id="template">'+
'<tr><td width="120"><label for="last"> Last name: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="last"></td>'+
'<td width="120"><label for="first"> First name: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="first"></td></tr>'+
'<tr><td width="120"><label for="coauthors"> Coauthors: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="coauthors"></td>'+
'<td width="120"><label for="others"> Others: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="others"></td></tr>'+
'<tr><td width="120"><label for="title"> Title: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="title"></td>'+
'<td width="120"><label for="editor"> Editor: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="editor"></td></tr>'+
'<tr><td width="120"><label for="publisher"> Publisher: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="publisher"></td>'+
'<td width="120"><label for="location"> Location: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="location"></td></tr>'+
'<tr><td width="120"><label for="date"> Publication date: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="date"></td>'+
'<td width="120"><label for="edition"> Edition: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="edition"></td></tr>'+
'<tr><td width="120"><label for="series"> Series: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="series"></td>'+
'<td width="120"><label for="volume"> Volume: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="volume"></td></tr>'+
'<tr><td width="120"><label for="pages"> Pages: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="pages"></td>'+
'<td width="120"><label for="chapter"> Chapter: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="chapter"></td></tr>'+
'<tr><td width="120"><label for="isbn"> ISBN: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="isbn"></td>'+
'<td width="120"><label for="oclc"> OCLC: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="oclc"></td></tr>'+
'<tr><td width="120"><label for="url"> URL: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="url"></td>'+
'<td width="120"><label for="accessdate"> Access date: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="accessdate"></td></tr>'+
'<tr><td width="120"><label for="language"> Language: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="language"></td>'+
'<td width="120"><label for="refname"> Reference name: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="refname"></td></tr>'+
'</table>'+
'<input type="button" value="Add citation" onClick="addcites()">'+
'</fieldset></div>';
document.getElementById('citeselect').innerHTML += form;
}
function citeJournal() {
if (numforms != 0) {
document.getElementById('citediv'+numforms).style.display = 'none';
}
template = "cite journal";
numforms++;
form = '<div id="citediv'+numforms+'">'+
'<fieldset><legend>Cite book source</legend>'+
'<table cellspacing="5">'+
'<input type="hidden" value="'+template+'" id="template">'+
'<tr><td width="120"><label for="last"> Last name: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="last"></td>'+
'<td width="120"><label for="first"> First name: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="first"></td></tr>'+
'<tr><td width="120"><label for="coauthors"> Coauthors: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="coauthors"></td>'+
'<td width="120"><label for="date"> Publication date: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="date"></td></tr>'+
'<tr><td width="120"><label for="title"> Title: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="title"></td>'+
'<td width="120"><label for="journal"> Journal: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="journal"></td></tr>'+
'<tr><td width="120"><label for="publisher"> Publisher: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="publisher"></td>'+
'<td width="120"><label for="location"> Location: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="location"></td></tr>'+
'<tr><td width="120"><label for="volume"> Volume: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="volume"></td>'+
'<td width="120"><label for="issue"> Issue: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="issue"></td></tr>'+
'<tr><td width="120"><label for="pages"> Pages: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="pages"></td>'+
'<td width="120"><label for="issn"> ISSN: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="issn"></td></tr>'+
'<tr><td width="120"><label for="oclc"> OCLC: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="oclc"></td>'+
'<td width="120"><label for="language"> Language: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="language"></td></tr>'+
'<tr><td width="120"><label for="url"> URL: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="url"></td>'+
'<td width="120"><label for="accessdate"> Access date: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="accessdate"></td></tr>'+
'<tr><td width="120"><label for="refname"> Reference name: </label></td>'+
'<td width="400"><input type="text" style="width:100%" id="refname"></td></tr>'+
'</table>'+
'<input type="button" value="Add citation" onClick="addcites()">'+
'</fieldset></div>';
document.getElementById('citeselect').innerHTML += form;
}
function addcites(template) {
cites = document.getElementById('citediv'+numforms).getElementsByTagName('input');
var citebegin = '<ref';
var citename = '';
var citeinner = '';
for (var i=0; i<cites.length-1; i++) {
if (cites[i].value != '' && cites[i].id != "refname" && cites[i].id != "template") {
citeinner += "|" + cites[i].id + "=" + cites[i].value;
}
else if (cites[i].value != '' && cites[i].id == "refname" && cites[i].id != "template") {
citebegin += ' name="' + cites[i].value + '"';
}
else if (cites[i].value != '' && cites[i].id != "refname" && cites[i].id == "template") {
citename = '>{{' + cites[i].value;
}
}
cite = citebegin + citename + citeinner + "}}</ref>";
insertTags(cite, '', '');
document.getElementById('citediv'+numforms).style.display = 'none';
}
function getNamedRefs() {
text = document.getElementById('wpTextbox1').value;
regex = /<\s*?ref\s+?name\s*?=\s*?(('([^']*?)')|("([^"]*?)"))\s*?>/gi //'
var namedrefs = new Array();
var i=0;
var nr=true;
do {
ref = regex.exec(text);
if(ref != null){
namedrefs[i] = ref[5];
i++;
} else {
nr=false;
}
} while (nr==true);
return namedrefs;
}
function citeNamedRef() {
namedrefs = getNamedRefs();
if (namedrefs == '') {
if (numforms != 0) {
document.getElementById('citediv'+numforms).style.display = 'none';
}
numforms++;
out = '<div id="citediv'+numforms+'"><fieldset>'+
'<legend>References in text</legend>There are no named refs (<tt><ref name="Name"></tt>) in the text</fieldset></div>';
document.getElementById('citeselect').innerHTML += out;
}
else {
if (numforms != 0) {
document.getElementById('citediv'+numforms).style.display = 'none';
}
numforms++;
form = '<div id="citediv'+numforms+'">'+
'<fieldset><legend>References in article</legend>'+
'<table cellspacing="5">'+
'<tr><td><label for="namedrefs"> Named references in text</label></td>'+
'<td><select name="namedrefs" id="namedrefs">';
for (var i=0;i<namedrefs.length;i++) {
form+= '<option value="'+namedrefs[i]+'">'+namedrefs[i]+'</option>';
}
form+= '</select>'+
'</td></tr></table>'+
'<input type="button" value="Add citation" onClick="addnamedcite()">'+
'</fieldset></div>';
document.getElementById('citeselect').innerHTML += form;
}
}
function addnamedcite() {
name = document.getElementById('citediv'+numforms).getElementsByTagName('select')[0].value;
ref = '<ref name="'+name+'" />';
insertTags(ref, '', '');
document.getElementById('citediv'+numforms).style.display = 'none';
}
hookEvent("load", refbuttons);