:User:Mr.Z-man.sock/monobook.js
var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
var userTemplates = [];
function citeTemplate(templatename, short, basicfields, expandedfields) {
// Properties
this.templatename = templatename; // The template name - "cite web", "cite book", etc.
this.shortform = short; // A short form, used for the dropdown box
this.basic = basicfields; // Basic fields - author, title, publisher...
this.extra = expandedfields; // Less common - quote, archiveurl - should be everything the template supports minus the basic ones
// Methods
this.getForm = function() {
form = '
'+
' | '+
' | ';
'+
' | '+
' |
return form;
}
}
function fixStr(s) {
s = s.slice(0,1).toUpperCase() + s.slice(1);
s = s.replace('_',' ');
return s;
}
if ((wgAction == 'edit' || wgAction == 'submit') && !((wgNamespaceNumber == 2 || wgNamespaceNumber == 4) && (wgPageName.indexOf('.js') != -1 || wgPageName.indexOf('.css') != -1 ))) {
var wikiEditorTests = {
// Add emoticons section
'add_sections_toolbar': {
'call': 'addToToolbar',
'data': {
'sections': {
'emoticons': {
'type': 'toolbar',
'label': 'Emoticons'
}
}
},
},
// Add faces group to emoticons section
'add_groups': {
'call': 'addToToolbar',
'data': {
'section': 'emoticons',
'groups': {
'faces': {
'label': 'Faces'
}
}
},
},
// Add smile tool to faces group of emoticons section
'add_tools': {
'call': 'addToToolbar',
'data': {
'section': 'emoticons',
'group': 'faces',
'tools': {
'smile': {
label: 'Smile!',
type: 'button',
icon: 'http://upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Gnome-face-smile.svg/22px-Gnome-face-smile.svg.png',
action: {
type: 'encapsulate',
options: {
pre: ":)",
}
}
}
}
},
},
// Add info section
'add_sections_booklet': {
'call': 'addToToolbar',
'data': {
'sections': {
'info': {
'type': 'booklet',
'label': 'Info'
}
}
},
},
// Add info section
'add_pages_table': {
'call': 'addToToolbar',
'data': {
'section': 'info',
'pages': {
'colors': {
'layout': 'table',
'label': 'Colors',
'headings': [
{ content: 'Name' },
{ content: 'Temperature' },
{ content: 'Swatch' }
]
}
}
},
},
// Add colors rows
'add_rows': {
'call': 'addToToolbar',
'data': {
'section': 'info',
'page': 'colors',
'rows': [
{
'name': { content: 'Red' },
'temp': { content: 'Warm' },
'swatch': { content: '
},
{
'name': { content: 'Blue' },
'temp': { content: 'Cold' },
'swatch': { content: '
},
{
'name': { content: 'Silver' },
'temp': { content: 'Neutral' },
'swatch': { content: '
}
]
},
},
// Add
'add_pages_characters': {
'call': 'addToToolbar',
'data': {
'section': 'info',
'pages': {
'emoticons': {
'layout': 'characters',
'label': 'Emoticons'
},
'removeme': {
'layout': 'characters',
'label': 'Remove Me!'
}
}
},
},
// Add
'add_characters': {
'call': 'addToToolbar',
'data': {
'section': 'info',
'page': 'emoticons',
'characters': [ ':)', ':))', ':(', '<3', ';)' ]
},
},
};
js2AddOnloadHook( function() {
var $target = $( '#wpTextbox1' );
for ( test in wikiEditorTests ) {
alert( wikiEditorTests[test] );
$target.wikiEditor(
wikiEditorTests[test].call,
wikiEditorTests[test].data
);
}
alert( $target.wikiEditor );
});
function refInit() {
$('#edittoolbar-section-advanced').hide();
$('#edittoolbar-section-help').hide();
citetemplates = getCiteTemplates();
var initialform = '
'+'
';$('#edittoolbar > .sections').append(initialform);
$('#edittoolbar-section-references').show();
return false;
}
function getCiteTemplates() {
// Cite template definitions go here
var web = new citeTemplate('cite web', 'Web',
['last', 'first', 'title', 'url', 'work', 'publisher', 'accessdate'],
['author', 'authorlink', 'coauthors', 'archiveurl', 'archivedate', 'publisher', 'location', 'page', 'pages', 'language', 'format', 'doi', 'date', 'month', 'year', 'quote']
);
var news = new citeTemplate('cite news', 'News',
['last', 'first', 'title', 'url', 'work', 'publisher', 'date', 'page', 'accessdate'],
['author', 'authorlink', 'coauthors', 'archiveurl', 'archivedate', 'publisher', 'agency', 'location', 'trans_title', 'pages', 'language', 'format', 'id', 'date', 'month', 'year', 'quote']
);
var citeTemplates = new Array(web, news);
return citeTemplates.concat(userTemplates);
}
function insertForm(form) {
$('#edittoolbar-section-refform').slideUp('fast', function() {
$('#edittoolbar-section-refform').html(form);
if (form != '') {
$('#edittoolbar-section-refform').slideDown('normal');
}
});
}
function fillAccessdate() {
var date = new Date();
var day = date.getUTCDate().toString();
var month = months[date.getUTCMonth()];
var year = date.getUTCFullYear().toString();
var datestr = day+' '+month+' '+year;
$('#accessdate').val(datestr);
}
}
/*
var numforms = 0;
var wikEdAutoUpdateUrl;
function refbuttons() {
if (mwCustomEditButtons && document.getElementById('toolbar') ) {
button = document.createElement('a');
button.href = "javascript:easyCiteMain()";
button.title = "Insert Citation";
buttonimage = document.createElement('img');
buttonimage.src = "http://upload.wikimedia.org/wikipedia/commons/e/ea/Button_easy_cite.png";
buttonimage.alt = "Insert Citation";
button.appendChild(buttonimage);
var toolbar = document.getElementById('toolbar');
if (navigator.userAgent.indexOf('MSIE') == -1) {
if (toolbar.style != null) {
toolbar.style.height = 'auto';
}
else {
toolbar.setAttribute('style', 'margin-bottom: 6px; height: auto;');
}
toolbar.appendChild(button);
citemain = document.createElement('div');
citemain.style.display = 'none';
citemain.style.margin = '0.2em 0 -0.2em 0';
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("dispErrors()", "Error check") );
citemain.appendChild( addOption("hideInitial()", "Cancel") );
toolbar.appendChild(citemain);
}
else {
toolbar.appendChild(button);
selection = '
';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';
oldFormHide();
}
function oldFormHide() {
if (numforms != 0) {
document.getElementById('citediv'+numforms).style.display = 'none';
}
if (document.getElementById('errorform') != null) {
document.getElementById('citeselect').removeChild(document.getElementById('errorform'));
}
}
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) {
oldFormHide();
template = templatename;
var legend;
if (template == "cite web") {
legend = "Cite web source";
} else {
legend = "Cite news source";
}
newtime = getTime();
numforms++;
form = '
'
document.getElementById('citeselect').innerHTML += form;
}
function citeBook() {
oldFormHide();
template = "cite book";
numforms++;
form = '
'
document.getElementById('citeselect').innerHTML += form;
}
function citeJournal() {
oldFormHide();
template = "cite journal";
numforms++;
form = '
'
document.getElementById('citeselect').innerHTML += form;
}
function addcites(template) {
cites = document.getElementById('citediv'+numforms).getElementsByTagName('input');
insertTags(cite, , );
document.getElementById('citediv'+numforms).style.display = 'none';
}
function getNamedRefs(calls) {
if (typeof(wikEdUseWikEd) != 'undefined') {
if (wikEdUseWikEd == true) {
WikEdUpdateTextarea();
}
}
text = document.getElementById('wpTextbox1').value;
var regex;
if (calls) {
regex = /< *?ref +?name *?= *?(('([^']*?)')|("([^"]*?)")|([^'"\s]*?[^\/]\b)) *?\/ *?>/gi //'
} else {
regex = /< *?ref +?name *?= *?(('([^']*?)')|("([^"]*?)")|([^'"\s]*?[^\/]\b)) *?>/gi //'
}
var namedrefs = new Array();
var i=0;
var nr=true;
do {
ref = regex.exec(text);
if(ref != null){
if (ref[5]) {
namedrefs[i] = ref[5];
} else if (ref[3]) {
namedrefs[i] = ref[3];
} else {
namedrefs[i] = ref[6];
}
i++;
} else {
nr=false;
}
} while (nr==true);
return namedrefs;
}
function citeNamedRef() {
namedrefs = getNamedRefs(false);
if (namedrefs == '') {
oldFormHide();
numforms++;
out = '
';document.getElementById('citeselect').innerHTML += out;
}
else {
oldFormHide();
numforms++;
form = '
'
document.getElementById('citeselect').innerHTML += form;
}
}
function addnamedcite() {
name = document.getElementById('citediv'+numforms).getElementsByTagName('select')[0].value;
insertTags(ref, , );
document.getElementById('citediv'+numforms).style.display = 'none';
}
function getAllRefs() {
if (typeof(wikEdUseWikEd) != 'undefined') {
if (wikEdUseWikEd == true) {
WikEdUpdateTextarea();
}
}
text = document.getElementById('wpTextbox1').value;
regex = /< *?ref( +?name *?= *?(('([^']*?)')|("([^"]*?)")|([^'"\s]*?[^\/]\b)))? *?>((.|\n)*?)< *?\/? *?ref *?>/gim //"
var allrefs = new Array();
var i=0;
var nr=true;
do {
ref = regex.exec(text);
if(ref != null){
if (ref[0].search(/[^\s]{150}/) != -1) {
ref[0] = ref[0].replace(/\|([^\s])/g, "| $1");
}
ref[0] = ref[0].replace(/
ref[0] = ref[0].replace(/>/g, ">");
allrefs[i] = ref[0];
i++;
} else {
nr=false;
}
} while (nr==true);
return allrefs;
}
function NRcallError(namedrefs, refname) {
for (var i=0; i if (namedrefs[i] == refname) { return true; } } return false; } function errorCheck() { var allrefs = getAllRefs(); var allrefscontent = new Array(); var samecontentexclude = new Array(); var sx=0; var templateexclude = new Array(); var tx=0; var skipcheck = false; var namedrefcalls = getNamedRefs(true); for (var i=0; i allrefscontent[i] = allrefs[i].replace(/< *?ref( +?name *?= *?(('([^']*?)')|("([^"]*?)")|([^'"\s]*?[^\/]\b)))? *?>((.|\n)*?)< *?\/? *?ref *?>/gim, "$8"); //" } var namedrefs = getNamedRefs(false); var errorlist = new Array(); var q=0; unclosed = document.getElementById('unclosed').checked; samecontent = document.getElementById('samecontent').checked; templates = document.getElementById('templates').checked; repeated = document.getElementById('repeated').checked; undef = document.getElementById('undef').checked; for (var i=0; i if (allrefs[i].search(/< *?\/ *?ref *?>/) == -1 && unclosed) { errorlist[q] = ' errorlist[q] += ' q++; } if (samecontent) { for (var d=0; d if (allrefscontent[i] == samecontentexclude[d]) { skipcheck = true; } } var p=0; while (p if (allrefscontent[i] == allrefscontent[p] && i != p) { errorlist[q] = ' errorlist[q] += ' q++; samecontentexclude[sx] = allrefscontent[i] sx++; break; } p++; } skipcheck=false; } if (templates) { if (allrefscontent[i].search(/\{\{cite/i) == -1 && allrefscontent[i].search(/\{\{citation/i) == -1 && allrefscontent[i].search(/\{\{Comic (book|strip) reference/i) == -1 && allrefscontent[i].search(/\{\{Editorial cartoon reference/i) == -1 && allrefscontent[i].search(/\{\{harv/i) == -1) { for (var x=0; x if (allrefscontent[i] == templateexclude[x]) { skipcheck = true; } } if (!skipcheck) { errorlist[q] = ' errorlist[q] += ' q++; templateexclude[tx] = allrefscontent[i]; tx++; } skipcheck = false; } } } if (repeated) { var repeatnameexclude = new Array(); var rx=0; for (var k=0; k for (var d=0; d if (namedrefs[k] == repeatnameexclude[d]) { skipcheck = true; } } var z=0; while (z if (namedrefs[k] == namedrefs[z] && k != z) { errorlist[q] = ' errorlist[q] += ' q++; repeatnameexclude[rx] = namedrefs[z]; rx++; break; } z++; } skipcheck = false; } } if (undef) { var undefexclude = new Array(); var ux=0; for (var p=0; p for (var d=0; d if (allrefscontent[i] == undefexclude[d]) { skipcheck = true; } } if (!skipcheck) { if (!NRcallError(namedrefs, namedrefcalls[p])) { errorlist[q] = ' errorlist[q] += ' q++; undefexclude[ux] = namedrefs[p]; ux++; } } skipcheck = false; } } if (q > 0) { return errorlist; } else { return 0; } } function dispErrors() { oldFormHide(); form = ' document.getElementById('citeselect').innerHTML += form; } function doErrorCheck() { var errors = errorCheck(); document.getElementById('citeselect').removeChild(document.getElementById('errorform')); if (errors == 0) { if (numforms != 0) { document.getElementById('citediv'+numforms).style.display = 'none'; } numforms++; out = ' document.getElementById('citeselect').innerHTML += out; } else { if (numforms != 0) { document.getElementById('citediv'+numforms).style.display = 'none'; } numforms++; form = ' ' document.getElementById('citeselect').innerHTML += form; } } hookEvent("load", refbuttons); ';'+allrefs[i]+' ';
Unclosed <ref> tag ';'+allrefscontent[i]+' ';
Multiple refs contain this content, a named reference should be used instead ';'+allrefs[i]+' ';
Does not use a citation template ';'+namedrefs[k]+' ';
Multiple references are given the same name ';'+namedrefcalls[p]+' ';
A named reference is used but not defined