importScript("User:Smith609/toolbox2.js");
importScript('User:Smith609/taxonomy.js');
//importScript('User:Smith609/refToolbar.js');
//importScript('User:Smith609/refsByName.js');
//importScript('User:Smith609/enDashes.js');
//importScript('User:Smith609/references.js');
//importScript('User:Smith609/reftool.js');
<!--hide advert-->
if (document.getElementById("siteNoticeSmall")) document.getElementById("siteNoticeSmall").style.display = "none";
<!-- My main page rearrangements -->
content = document.getElementById("bodyContent");
nodes = document.getElementsByTagName("table");
var featuredPic = false;
for (var i=0; i<nodes.length; i++) {
if (nodes[i].getAttribute("style") == "margin: -8px; border-spacing: 8px;") featuredPic = nodes[i];
else if (nodes[i].getAttribute("style") == "margin: 0px -8px; border-spacing: 8px;") mainContent = nodes[i];
}
if (featuredPic) content.insertBefore(featuredPic, mainContent);
<!-- Replace -->
function wpTextboxReplace()
{
var s = prompt("Search regexp:");
if(s){
var r = prompt("Replace /"+s+"/ with:");
if(!r && r != '') return;
var txt = document.editform.wpTextbox1;
txt.value = txt.value.replace(new RegExp(s, "mg"), r);
}
}
$(function () {
if (document.forms.editform) {
mw.util.addPortletLink('p-cactions', 'javascript:wpTextboxReplace()', 'Replace', 'ca-replace',
'Regexp replace for the edit window', 'R', document.getElementById('ca-history'));
}
});
<!-- end replace-->
function format() {
var txt = document.editform.wpTextbox1;
txt.value = catFixer(txt.value);
txt.value = entities(txt.value);
txt.value = fixheadings(txt.value);
txt.value = fixsyntax(txt.value);
txt.value = linkfixer(txt.value, false);
//txt.value = imagefixer(txt.value);
txt.value = whitespace(txt.value);
txt.value = linksimplifyer(txt.value);
txt.value = trim(txt.value);
}
function whitespace(str){
str = str.replace(/\t/g, " ");
str = str.replace(/^ ? ? \n/gm, "\n");
str = str.replace(/(\n\n)\n+/g, "$1");
str = str.replace(/== ? ?\n\n==/g, "==\n==");
str = str.replace(/\n\n(\* ?\[?http)/g, "\n$1");
str = str.replace(/^ ? ? \n/gm, "\n");
str = str.replace(/\n\n\*/g, "\n*");
str = str.replace(/[ \t][ \t]+/g, " ");
str = str.replace(/([=\n]\n)\n+/g, "$1");
str = str.replace(/ \n/g, "\n");
//* bullet points
str = str.replace(/^([\*#]+) /gm, "$1");
str = str.replace(/^([\*#]+)/gm, "$1 ");
//==Headings==
str = str.replace(/^(={1,4}) ?(.*?) ?(={1,4})$/gm, "$1$2$3");
//dash — spacing
str = str.replace(/ ?(–|–|–|–|–) ?/g, "$1");
str = str.replace(/ ?(—|—|—|—|—) ?/g, "$1");
str = str.replace(/([^1–9])(—|—|—|—|—|–|–|–|–|–)([^1–9])/g, "$1 $2 $3");
return trim(str);
}
function entities(str){
//str = str.replace(//g, "");
str = str.replace(/–|–|–/g, "–");
str = str.replace(/—|—|—/g, "—");
// str = str.replace(/(cm| m|km|mi)<sup>2</sup>/g, "$1²");
str = str.replace(/²/g, "²");
str = str.replace(/°/g, "°");
return trim(str);
}
//Fix ==See also== and similar section common errors.
function fixheadings(str)
{
if( !str.match(/= ?See also ?=/) )
str = str.replace(/(== ?)(see also:?|related topics:?|related articles:?|internal links:?|also see:?)( ?==)/gi, "$1See also$3");
str = str.replace(/(== ?)(external links?:?|outside links?|web ?links?:?|exterior links?:?)( ?==)/gi, "$1External links$3");
str = str.replace(/(== ?)(references?:?)( ?==)/gi, "$1References$3");
str = str.replace(/(== ?)(sources?:?)( ?==)/gi, "$1Sources$3");
str = str.replace(/(== ?)(further readings?:?)( ?==)/gi, "$1Further reading$3");
return str;
}
function catFixer(str){
str = str.replace(/\[\[ ?[Cc]ategory ?: ?/g, "[[Category:");
return trim(str);
}
//fixes many common syntax problems
function fixsyntax(str)
{
//replace html with wiki syntax
if( !str.match(/'<\/?[ib]>|<\/?[ib]>'/gi) )
{
str = str.replace(/<i>(.*?)<\/i>/gi, "''$1''");
str = str.replace(/<b>(.*?)<\/b>/gi, "'''$1'''");
}
str = str.replace(/<br\/>/gi, "<br />");
str = str.replace(/<br>/gi, "<br />");
return trim(str);
}
//formats links in standard fashion
function linkfixer(str, checkImages)
{
str = str.replace(/\]\[/g, "] [");
var m = str.match(/\[?\[[^\]]*?\]\]?/g);
if (m)
{
for (var i = 0; i < m.length; i++)
{
var x = m[i].toString();
var y = x;
//internal links only
if ( !y.match(/^\[?\[http:\/\//i) && !y.match(/^\[?\[image:/i) )
{
if (y.indexOf(":") == -1 && y.substr(0,3) != "[[_" && y.indexOf("|_") == -1)
{
if (y.indexOf("|") == -1)
y = y.replace(/_/g, " ");
else
y = y.replace( y.substr(0, y.indexOf("|")), y.substr(0, y.indexOf("|")).replace(/_/g, " "));
}
y = y.replace(/ ?\| ?/, "|").replace("|]]", "| ]]");
}
str = str.replace(x, y);
}
}
//repair bad internal links
str = str.replace(/\[\[ ?([^\]]*?) ?\]\]/g, "[[$1]]");
str = str.replace(/\[\[([^\]]*?)( |_)#([^\]]*?)\]\]/g, "[[$1#$3]]");
//repair bad external links
str = str.replace(/\[?\[http:\/\/([^\]]*?)\]\]?/gi, "[http://$1]");
str = str.replace(/\[http:\/\/([^\]]*?)\|([^\]]*?)\]/gi, "[http://$1 $2]");
return trim(str);
}
//fixes images
function imagefixer(str)
{
//remove external images
str = str.replace(/\[?\[image:http:\/\/([^\]]*?)\]\]?/gi, "[http://$1]");
//fix links within internal images
var m = str.match(/\[?\[image:[^\[\]]*?(\[?\[[^\]]*?\]*?[^\[\]]*?)*?\]+/gi);
if (m)
{
for (var i = 0; i < m.length; i++)
{
var x = m[i].toString();
var y = x;
y = y.replace(/^\[\[i/i, "I").replace(/\]\]$/, "");
y = y.replace(/(\[[^\]]*?)$/, "$1]");
y = linkfixer(y, true);
y = "[[" + y + "]]";
str = str.replace(x, y);
}
}
return trim(str);
}
//simplifies some links e.g. [[Dog|dog]] to [[dog]] and [[Dog|dogs]] to [[dog]]s
function linksimplifyer(str){
var m = str.match(/\[\[([^[]*?)\|([^[]*?)\]\]/g);
if (m)
{
for (var i = 0; i < m.length; i++)
{
var n_arr = m[i].toString().match(/\[\[([^[]*?)\|([^[]*?)\]\]/);
var n = n_arr[0];
var a = n_arr[1];
var b = n_arr[2];
if (b.indexOf(a) == 0 || b.indexOf(TurnFirstToLower(a)) == 0)
{
var k = n.replace(/\[\[([^\]\|]*?)\|(\1)([\w]*?)\]\]/i, "[[$2]]$3");
str = str.replace(n, k);
}
}
}
str = str.replace(/\[\[([^\]\|]+)\|([^\]\|]+)\]\]([A-Za-z\'][A-Za-z]*)([\.\,\;\:\"\!\?\s\n])/g, "[[$1|$2$3]]$4");
return str;
}
//trim start and end, trim spaces from the end of lines
function trim(str) {
str = str.replace(/ $/gm, "");
return str.replace(/^\s*|\s*$/g, "");
}
//turns first character to lowercase
function TurnFirstToLower(input) {
if (input != "")
{
var input = trim(input);
var temp = input.substr(0, 1);
return temp.toLowerCase() + input.substr(1, input.length);
}
else
return "";
}
//entities that should never be unicoded
function noUnicodify(str) {
str = str.replace(" & ", " & ");
str = str.replace("&", "&").replace("<", "&lt;").replace(">", "&gt;").replace(""", "&quot;").replace("'", "&apos;");
str = str.replace("−", "−").replace("×", "×");
str = str.replace(" ", " ").replace(" ", " ").replace("", "­");
str = str.replace("′", "′");
str = str.replace(/&(#0?9[13];)/, "&$1");
str = str.replace(/&(#0?12[345];)/, "&$1");
return str;
}
$(function () {
if(document.forms.editform) {
mw.util.addPortletLink('p-cactions', 'javascript:format()', 'format', 'ca-format', 'Format article', '', document.getElementById('ca-edit'));
}
});
/*
<!--end format tidier-->
<!--inline edit section -->
var body; // shortcut for body node
var xmlhttp; // XMLHTTPRequest object
var startNode; // div that includes section header and edit link
var editSec; // edit link
var editForm; // spliced edit form
var preview; // spliced preview or diff content
var oldContent; // original content of section
var xmlhttpDone = false; // kludge to prevent multiple calls to callback
importScript("User:Supadawg/util.js");
function inc(path) {
var lt = String.fromCharCode(60);
var gt = String.fromCharCode(62);
document.writeln(lt+'script type="text/javascript" src="/w/index.php?title='+path+'&action=raw&ctype=text/javascript&dontcountme=s"'+gt+lt+'/script'+gt);
}
function initSecEdit()
{
body = document.getElementsByTagName("body")[0];
// apply to all divs of class "editsection"
var editSecs = document.getElementsByTagName("span");
var secCount = 1;
var pagetitleRe=/\/(wiki\/|w\/index\.php\?title=)([^&?]*)/; // from [Wikipedia:WikiProject User scripts/Techniques]
for ( var i = 0; i < editSecs.length; i++ ) {
if ( editSecs[i].getAttribute("class") == "editsection" ) {
for ( var k = 0; k < editSecs[i].childNodes.length; k++ ) {
if ( editSecs[i].childNodes[k].nodeName == "A" ) {
// grab editing uri, escape it, then put it back in
var editURI = "http://en.wikipedia.org/w/index.php?title="+encodeURIComponent2(pagetitleRe.exec(decodeURI(editSecs[i].childNodes[k].getAttribute("href")))[2]).replace(/\"/gi, "%22").replace(/\'/gi, "%27")+"&action=edit§ion="+secCount;
// give it a unique id
editSecs[i].childNodes[k].setAttribute( "id", "editSection"+secCount );
// swap the href with a function call, passing the original href as the second parameter
editSecs[i].childNodes[k].setAttribute( "href", "javascript:editSection( document.getElementById('editSection" + secCount + "'), '"+editURI+"' );" );
secCount++;
}
}
}
}
}
// called on click of section edit link
function editSection( elem, editURI )
{
cancelEdit(); // get rid of any other sections being edited
editSec = elem;
startNode = elem.parentNode.parentNode;
// initiate xmlhttprequest for section edit page
xmlhttpDone = false;
xmlhttp = null // kludge
xmlhttp = createXMLHTTP( "GET", editURI, stateChange );
}
// put raw input returned from XMLHTTPRequest into a div so we can grab specific elements
function makeDiv( rawHTML )
{
var div = createNode( body, "div", {style: "visibility: hidden; position: absolute;"} );
div.innerHTML = rawHTML.replace(/<script[^>]*><\/script>/gi, ""); // if script tags are placed into the DOM, they force reload of files, and nasty things happen
return div;
}
function isHTag( node )
{
return node.nodeName.charAt(0) == 'H' && !isNaN( parseInt( node.nodeName.charAt(1) ) );
}
// callback for onclick of an edit link
function stateChange()
{
if ( xmlhttp && xmlhttp.readyState == 4 ) {
if ( xmlhttp.status == 200 ) {
if ( xmlhttpDone )
return;
xmlhttpDone = true;
// store old content of section – loop until we hit header of same spot in hierarchy
if ( !oldContent ) {
oldContent = makeDiv("");
var curElem = startNode.nextSibling;
while ( curElem ) {
var hitSiblingSection = false;
if ( isHTag( curElem ) ) {
for ( var i = 0; i < curElem.childNodes.length; i++ ) {
if ( curElem.childNodes[i].nodeName == "SPAN"
&& curElem.childNodes[i].getAttribute("class") == "editsection"
&& parseInt( curElem.nodeName.charAt(1) ) <= parseInt( startNode.nodeName.charAt(1) ) )
hitSiblingSection = true;
}
}
else if ( curElem.nodeName == "DIV" && curElem.getAttribute("class") == "printfooter" )
break;
if ( hitSiblingSection )
break;
var nextElem = curElem.nextSibling;
oldContent.appendChild( curElem );
curElem = nextElem;
}
}
else
removeNode( oldContent );
var div = makeDiv( xmlhttp.responseText );
editForm = $("editform");
// change onclick of preview and diff buttons to our function
$("wpPreview").setAttribute( "type", "button" );
$("wpPreview").setAttribute( "onclick", "javascript:getEditData( previewChanged, $('wpPreview') );" );
$("wpDiff").setAttribute( "type", "button" );
$("wpDiff").setAttribute( "onclick", "javascript:getEditData( diffChanged, $('wpDiff') );" );
insertAfter( editForm, startNode );
removeNode( div );
editSec.setAttribute( "oldHref", editSec.getAttribute("href") );
editSec.setAttribute( "href", "javascript:cancelEdit();" );
editSec.innerHTML = "cancel";
}
else
alert("Problem retrieving data – status: "+xmlhttp.status);
}
}
// firefox hack, not sure if this is a problem in other browsers
function encodeURIComponent2( content )
{
// from [http://en.wikipedia.org/wiki/User:Topaz/wputil.js]
content = content.replace(/\<\;/gi, "<");
content = content.replace(/\>\;/gi, ">");
content = content.replace(/\"\;/gi, "\"");
content = content.replace(/\&\;/gi, "&");
return encodeURIComponent( content );
}
// encode differently based on type of form element
function field2Post( node, allowButton )
{
var reqBody = "";
switch ( node.nodeName ) {
case "TEXTAREA":
reqBody += "&"+node.getAttribute("name")+"="+encodeURIComponent2( node.value );
break;
case "INPUT":
var inputType = node.getAttribute("type");
if ( inputType == "checkbox" ) {
if ( node.checked )
reqBody += "&"+node.getAttribute("name")+"=on"
}
else if ( allowButton || (inputType != "submit" && inputType != "button") )
reqBody += "&"+node.getAttribute("name")+"="+encodeURIComponent2( node.value );
break;
case "DIV":
reqBody += form2Post( node, false );
break;
}
return reqBody;
}
// manually encodes a form element for XMLHTTPRequest
function form2Post( node )
{
var reqBody = "";
for ( var i = 0; i < node.childNodes.length; i++ )
reqBody += field2Post( node.childNodes[i], false );
return reqBody;
}
// get preview or diff data
function getEditData( callback, clickedBut )
{
xmlhttpDone = false;
xmlhttp = null; // kludge
var action = editForm.getAttribute("action");
xmlhttp = createXMLHTTP( "POST", "http://en.wikipedia.org"+action, callback, {
body: form2Post( editForm ) + field2Post( clickedBut, true ),
headers: {
"Content-Type": "application/x-www-form-urlencoded",
"Referer": "http://en.wikipedia.org" + action.substring( 0, action.indexOf('&') ) + "&action=edit§ion="+(parseInt(editSec.getAttribute("id").substring(11))+1)
}
} );
}
// callback for preview data
function previewChanged()
{
if ( xmlhttp && xmlhttp.readyState == 4 ) {
if ( xmlhttp.status == 200 ) {
if ( xmlhttpDone )
return;
xmlhttpDone = true;
var div = makeDiv( xmlhttp.responseText );
if ( preview )
removeNode( preview );
preview = $("wikiPreview");
insertAfter( preview, startNode );
removeNode( div );
}
else
alert("Problem retrieving data – status: "+xmlhttp.status);
}
}
// callback for diff data
function diffChanged()
{
if ( xmlhttp && xmlhttp.readyState == 4 ) {
if ( xmlhttp.status == 200 ) {
if ( xmlhttpDone )
return;
xmlhttpDone = true;
var div = makeDiv( xmlhttp.responseText );
if ( preview )
removeNode( preview );
preview = $("wikiDiff");
insertAfter( preview, startNode );
removeNode( div );
}
else
alert("Problem retrieving data – status: "+xmlhttp.status);
}
}
// remove form and preview or diff data
function cancelEdit()
{
if ( preview )
removeNode( preview );
preview = null;
if ( editForm )
removeNode( editForm );
editForm = null;
if ( oldContent ) {
oldContent.setAttribute( "style", "position: static; visibility: visible;" );
insertAfter( oldContent, startNode );
}
oldContent = null;
if ( editSec ) {
editSec.setAttribute( "href", editSec.getAttribute("oldHref") );
editSec.innerHTML = "edit";
}
}
addEventListener( "load", initSecEdit, false );
<!-- end inline edit section-->
<!--AJAX preview-->
importScript('User:Alex_Smotrov/qpreview.js');
<!--/AJAX preview-->
<!--Better change view-->
/* {{en:User:Cacycle/wikEd_template}} <pre clear="all"><nowiki> */
// version info
var wikEdDiffProgramVersion = '0.9.1g';
var wikEdDiffProgramDate = 'May 2, 2007';
/*
== wikEdDiff ==
A user script that provides an improved and easier to read diff view for comparing article versions
on Wikipedia and other MediaWiki sites.
Features:
* Additions and deletions are highlighted by color in a single article text
* Block moves are detected and indicated by color
* Unchanged regions of the text are omitted from the output
* Highly optimized for MediaWiki source texts
wikEdDiff uses the Cacycle diff.js routines [[en:User:Cacycle/diff]] and is also an integrated part of wikEd,
the full-featured JavaScript in-browser editor (http://en.wikipedia.org/wiki/User:Cacycle/wikEd)
Homepage: http://en.wikipedia.org/wiki/User:Cacycle/wikEdDiff
Author: Cacycle (http://en.wikipedia.org/wiki/User:Cacycle)
License: This code has been released into the public domain
== Installation ==
* Copy the following short block of code to [[User:YOURUSERNAME/monobook.js]]
* Press SHIFT-Reload to update to the newest version
* PLEASE DO NOT COPY THE WHOLE PROGRAM
* See http://en.wikipedia.org/wiki/User:Cacycle/wikEdDiff for detailed instructions
* Users of wikEd do not have to install wikEdDiff
// ---- START INSTALLATION CODE ----
// install [[User:Cacycle/wikEdDiff]] enhanced diff view using ajax
document.write('<script type="text/javascript" src="'
+ 'http://en.wikipedia.org/w/index.php?title=User:Cacycle/wikEdDiff.js'
+ '&action=raw&ctype=text/javascript"></script>');
// ---- END INSTALLATION CODE ----
*/
//
// user configurable variables
//
// diff.js routines URL, also defined in wikEd.js
var wikEdDiffScriptSrc = wikEdDiffScriptSrc || 'http://en.wikipedia.org/w/index.php?title=User:Cacycle/diff.js&action=raw&ctype=text/javascript';
// allow ajax requests from local copy for testing, also defined in wikEd.js
if (typeof(wikEdAllowLocalAjax) == 'undefined') { var wikEdAllowLocalAjax = false; }
// wikEdDiff css rules
var wikEdDiffCSS = wikEdDiffCSS || [];
WikEdDiffInitObject(wikEdDiffCSS, {
'.wikEdDiffWrapper': 'margin: 0 0 1em 0;',
'.wikEdDiffButtonWrapper': 'text-align: center;',
'.wikEdDiffButton': 'padding: 0; margin: 0.2em 0 0.33em 0;',
'.wikEdDiffDiv': 'background: #faf8f6; padding: 0.5em; border: 1px solid; border-color: #808080;'
});
// use local copies of images for testing (set to true in local copy of edit page), also defined in wikEd.js
if (typeof(wikEdUseLocalImages) == 'undefined') { var wikEdUseLocalImages = false; }
// path to local images for testing, also defined in wikEd.js
var wikEdImagePathLocal = wikEdImagePathLocal || 'file:///D:/wikEd/images/';
// path to images, also defined in wikEd.js
var wikEdImagePath = wikEdImagePath || 'http://upload.wikimedia.org/wikipedia/commons/';
// image filenames, also defined in wikEd.js
var wikEdImage = wikEdImage || [];
WikEdDiffInitImage(wikEdImage, {
'wikEdDiff': 'c/c6/WikEdDiff.png'
});
// user readable texts, copy changes to http://en.wikipedia.org/wiki/User:Cacycle/wikEd_international_en.js
var wikEdText = wikEdText || [];
WikEdDiffInitObject(wikEdText, {
'wikEdDiffButtonImg alt': 'wikEdDiff',
'wikEdDiffButton title': 'Show improved diff view',
'wikEdDiffLoading': '...'
});
// show complete unshortened article text for local diff, also defined in wikEd.js
if (typeof(wikEdFullDiff) == 'undefined') { var wikEdFullDiff = false; }
//
// end of user configurable variables
//
// global dom elements
var wikEdDiffWrapper;
var wikEdDiffButtonWrapper;
var wikEdDiffDiv;
var wikEdDiffButton;
// hash of loaded scripts, also defined in wikEd.js
var wikEdExternalScripts = wikEdExternalScripts || [];
if (typeof(wikEdDiffPreset) == 'undefined') { var wikEdDiffPreset = false; }
// diff table element
var wikEdDiffTable;
// call the setup routine
if (typeof(addOnloadHook) == 'function') {
if (typeof(doneOnloadHook) == 'boolean') {
if (doneOnloadHook == true) {
WikEdDiffSetup();
}
else {
addOnloadHook(WikEdDiffSetup);
}
}
else {
addOnloadHook(WikEdDiffSetup);
}
}
else {
window.onload = WikEdDiffSetup;
}
//
// WikEdDiffSetup: create wikEdDiff elements
//
function WikEdDiffSetup() {
// run only once
if (wikEdDiffWrapper != null) {
return;
}
// detect diff table
var table = document.getElementsByTagName('TABLE');
for (var i = 0; i < table.length; i ++) {
if (table[i].className == 'diff') {
wikEdDiffTable = table[i];
}
}
// check if this is a diff page
if (wikEdDiffTable == null) {
return;
}
// detect already loaded external scripts
if (wikEdExternalScripts == null) {
var pageScripts = document.getElementsByTagName('script');
for (var i = 0; i < pageScripts.length; i ++) {
var nameMatch = pageScripts[i].src.match(/\/([^\/]*?)($|\?)/);
if (nameMatch != null) {
var scriptName = nameMatch[1];
if (scriptName != '') {
wikEdExternalScripts[scriptName] = true;
}
}
}
}
// load the external diff script
var head = document.getElementsByTagName('head')[0];
if (wikEdExternalScripts['diff.js'] == null) {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = wikEdDiffScriptSrc;
head.appendChild(script);
wikEdExternalScripts['diff.js'] = true;
}
// add stylesheet definitions (slow method for IE compatibility)
var diffStyle = new WikEdDiffStyleSheet();
var rules = '';
for (var ruleName in wikEdDiffCSS) {
var ruleStyle = wikEdDiffCSS[ruleName];
diffStyle.addRule(ruleName, ruleStyle);
}
// create wikEdDiff wrapper
wikEdDiffWrapper = document.createElement('div');
wikEdDiffWrapper.id = 'wikEdDiffWrapper';
wikEdDiffWrapper.className = 'wikEdDiffWrapper';
// create wikEdDiff button wrapper
wikEdDiffButtonWrapper = document.createElement('div');
wikEdDiffButtonWrapper.id = 'wikEdDiffButtonWrapper';
wikEdDiffButtonWrapper.className = 'wikEdDiffButtonWrapper';
wikEdDiffWrapper.appendChild(wikEdDiffButtonWrapper);
// create wikEdDiff button
wikEdDiffButton = document.createElement('button');
wikEdDiffButton.id = 'wikEdDiffButton';
wikEdDiffButton.title = wikEdText['wikEdDiffButton title'];
wikEdDiffButton.className = 'wikEdDiffButton';
wikEdDiffButtonWrapper.appendChild(wikEdDiffButton);
// add button image
var diffImg = document.createElement('img');
diffImg.id = 'wikEdDiffButtonImg';
diffImg.src = wikEdImage['wikEdDiff'];
diffImg.title = wikEdText['wikEdDiffButton title'];
diffImg.alt = wikEdText['wikEdDiffButtonImg alt'];
wikEdDiffButton.appendChild(diffImg);
wikEdDiffDiv = document.createElement('div');
wikEdDiffDiv.id = 'wikEdDiffDiv';
wikEdDiffDiv.className = 'wikEdDiffDiv';
wikEdDiffDiv.style.display = 'none';
// add wrapper after diff table
wikEdDiffWrapper.appendChild(wikEdDiffDiv);
if (wikEdDiffTable.nextSibling != null) {
wikEdDiffTable.parentNode.insertBefore(wikEdDiffWrapper, wikEdDiffTable.nextSibling);
}
else {
wikEdDiffTable.parentNode.appendChild(wikEdDiffWrapper);
}
// add event listener to button
wikEdDiffButton.onclick = WikEdDiff;
// run WikEdDiff if enabled in wikEd
if (typeof(wikEdDiffPreset) == 'boolean') {
if ( (wikEdDiffPreset == true) && (WikEdDiffGetCookie('wikEdDiff') == '') ) {
WikEdDiff();
}
}
return;
}
//
// WikEdDiff: fetch the old versions using ajax to display a diff
//
function WikEdDiff() {
// check if set tup
if (wikEdDiffDiv == null) {
return;
}
// display diff
wikEdDiffDiv.style.display = 'block';
// fetch only once
if (wikEdDiffDiv.innerHTML.length > 0) {
return;
}
// check if this is a diff page
if (wikEdDiffTable == null) {
return;
}
// display div
if (wikEdDiffDiv.innerHTML.length == 0) {
wikEdDiffDiv.innerHTML = wikEdText['wikEdDiffLoading'];
}
// generate request url from MediaWiki variables or from location url
var url;
if (typeof(mw.config.get('wgScriptPath')) == 'string') {
url = mw.config.get('wgScriptPath') + '/index.php';
}
else {
url = window.location.protocol + '//' + window.location.hostname + '/' + window.location.pathname;
}
var article;
if (typeof(mw.config.get('wgPageName')) == 'string') {
article = mw.config.get('wgPageName');
}
else {
var articleMatch = window.location.search.match(/(\?|&)title=([^&#]+)/);
article = articleMatch[2];
}
url += '?title=' + encodeURIComponent(article) + '&action=raw&maxage=0';
// get diff table and version link cells
var tdArray = document.getElementsByTagName('TD');
var tdOld;
var tdNew;
for (var i = 0; i < tdArray.length; i ++) {
if (tdArray[i].className == 'diff-otitle') {
tdOld = tdArray[i];
}
else if (tdArray[i].className == 'diff-ntitle') {
tdNew = tdArray[i];
break;
}
}
if ( (tdOld == null) || (tdNew == null) ) {
return;
}
var oldVersion = null;
var newVersion = null;
var oldUrl;
var newUrl;
// preview pages use latest article version and textarea
if (/(\?|&)action=submit\b/.test(window.location.search) == true) {
var textarea = document.getElementsByName('wpTextbox1');
if (textarea.length == 0) {
return;
}
newVersion = textarea[0].value;
newVersion = newVersion.replace(/\s+$/g, '');
if (typeof(mw.config.get('wgCurRevisionId')) == 'string') {
oldUrl = url + '&oldid=' + mw.config.get('wgCurRevisionId');
}
else {
oldUrl = url;
}
}
// diff pages use two different old versions
else {
// get revision id numbers from links in table cells
var versionMatchOld = tdOld.innerHTML.match(/(\?|&)oldid=(\d+)/);
var versionMatchNew = tdNew.innerHTML.match(/(\?|&)oldid=(\d+)/);
if (versionMatchOld == null) {
return;
}
oldUrl = url + '&oldid=' + versionMatchOld[2];
if (versionMatchNew != null) {
newUrl = url + '&oldid=' + versionMatchNew[2];
}
else {
newUrl = url;
}
}
// allow ajax request from local copy for testing
if (wikEdAllowLocalAjax == true) {
if (typeof(netscape) == 'object') {
netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserRead');
}
}
// get the old version using ajax
var ajaxOld = WikEdDiffAjaxInitObject();
if (ajaxOld == null) {
return;
}
ajaxOld.open('GET', oldUrl, true);
ajaxOld.send(null);
// ajax response handler for old version
ajaxOld.onreadystatechange = function() {
if (ajaxOld.readyState != 4) {
return;
}
oldVersion = ajaxOld.responseText;
if (newVersion != null) {
WikEdDiffResponse(oldVersion, newVersion);
}
return;
}
// get the new version using ajax
if (newUrl != null) {
var ajaxNew = WikEdDiffAjaxInitObject();
if (ajaxNew == null) {
return;
}
ajaxNew.open('GET', newUrl, true);
ajaxNew.send(null);
// ajax response handler for new version
ajaxNew.onreadystatechange = function() {
if (ajaxNew.readyState != 4) {
return;
}
newVersion = ajaxNew.responseText;
if (oldVersion != null) {
WikEdDiffResponse(oldVersion, newVersion);
}
return;
}
}
}
//
// WikEdDiffResponse: calculate and display the diff between two versions
//
function WikEdDiffResponse(oldVersion, newVersion) {
// call external diff program
var diffText = WDiffString(oldVersion, newVersion);
if (wikEdFullDiff != true) {
diffText = WDiffShortenOutput(diffText);
}
wikEdDiffDiv.innerHTML = diffText;
wikEdDiffDiv.style.display = 'block';
return;
}
/*
// get section for section editing
var section = document.getElementsByName('wpSection');
if (section.length > 0) {
if (section[0].value != '') {
url += '§ion=' + section[0].value;
}
}
*/
//
// WikEdDiffInitObject: initialize object, keep pre-defined values
//
function WikEdDiffInitObject(array, preset) {
for (var key in preset) {
if (array[key] == null) {
array[key] = preset[key];
}
}
return;
}
//
// WikEdDiffInitImage: initialize images, keep pre-defined values
//
function WikEdDiffInitImage(array, preset) {
for (var key in preset) {
if (array[key] == null) {
// remove MediaWiki path prefixes and add local path
if (wikEdUseLocalImages == true) {
array[key] = wikEdImagePathLocal + preset[key].replace(/^[0–9a-f]+\/[0–9a-f]+\//, '');
}
// add path
else {
array[key] = wikEdImagePath + preset[key];
}
}
}
return;
}
//
// WikEdDiffStyleSheet: create a new style sheet object, also defined in wikEdDiff.js
//
function WikEdDiffStyleSheet(documentObject) {
this.styleElement = null;
if (documentObject == null) {
documentObject = document;
}
// IE
if (documentObject.createStyleSheet) {
this.styleElement = documentObject.createStyleSheet();
}
// standards compliant browsers
else {
this.styleElement = documentObject.createElement('style');
this.styleElement.from = 'text/css';
var insert = documentObject.getElementsByTagName('head')[0];
if (insert != null) {
insert.appendChild(this.styleElement);
}
}
// addRule: add one rule at the time using DOM method, very slow
// IE
this.addRule = function(selector, declaration) {
if (this.styleElement.addRule) {
this.styleElement.addRule(selector, declaration);
}
// standards compliant browsers
else {
if (this.styleElement.sheet != null) {
if (this.styleElement.sheet.insertRule != null) {
this.styleElement.sheet.insertRule(selector + ' { ' + declaration + ' } ', 0);
}
}
}
};
// addRules: add all rules at once, much faster
this.addRules = function(rules) {
this.styleElement.innerHTML = rules;
return;
}
}
//
// WikEdDiffGetCookie: get a cookie
//
function WikEdDiffGetCookie(name) {
var cookie = ' ' + document.cookie;
var search = ' ' + name + '=';
var setStr = '';
var offset = 0;
var end = 0;
offset = cookie.indexOf(search);
if (offset != -1) {
offset += search.length;
end = cookie.indexOf(';', offset)
if (end == -1) {
end = cookie.length;
}
setStr = cookie.substring(offset, end);
setStr = setStr.replace(/\\+/g, ' ');
setStr = decodeURIComponent(setStr);
}
return(setStr);
}
//
// WikEdDiffAjaxInitObject: cross browser wrapper for creating new XMLHttpRequest object
//
function WikEdDiffAjaxInitObject() {
var ajax;
// current browsers
try {
ajax = new XMLHttpRequest();
}
catch (e) {
// IE 6
try {
ajax = new ActiveXObject('Microsoft.XMLHTTP');
}
catch (e) {
// IE 5.5
try {
ajax = new ActiveXObject('Msxml2.XMLHTTP');
}
catch (e) { }
}
}
return(ajax);
}
//
// WikEdDiffGetOffsetTop: get element offset relative to window top
//
function WikEdDiffGetOffsetTop(element) {
var offset = 0;
do {
offset += element.offsetTop;
} while ( (element = element.offsetParent) != null );
return(offset);
}
/* </nowiki></pre> */
<!--/better changes view-->
<!--***Colour code page for top contributor***-->
importScript('User:Ais523/topcontrib.js'); // [[User:Ais523/topcontrib.js]]
<!--/colour code by contributions-->
<!--Changes since I last edited tab-->
//From http://en.wikipedia.org/w/index.php?title=User:JesseW/monobook.js&oldid=20755510
function addSinceTab() {
if (window.location.href.indexOf("&action=history&gotosince=true")!=-1) {
do_since_I_last_edited()
}
else if (mw.config.get('wgCanonicalNamespace') != "Special") {
mw.util.addPortletLink("p-cactions", "/w/index.php?title="+mw.config.get('wgPageName')+"&action=history&gotosince=true", 'since', '', "since");
}
}
function do_since_I_last_edited() {
var csub=document.getElementById("contentSub");
var msg=document.createElement("p");
msg.appendChild(document.createTextNode
("Parsing history... please wait..."));
msg.className="error";
csub.insertBefore(msg, csub.firstChild)
var username=document.getElementById("pt-userpage").textContent;
var hists=document.getElementById("pagehistory").getElementsByTagName('li');
for (n=0;n<hists.length;n++) {
if (hists[n].getElementsByTagName("span")[0].getElementsByTagName('a')[0].textContent==username) {
document.location=hists[n].childNodes[1].href;
return;
}
}
msg.replaceChild(document.createTextNode
("You have not edited this page! (recently)"),
msg.firstChild);
}
$(addSinceTab);
//
<!--/since I last spoke-->
<!-- green links to redirect pages-->
// [[User:Dschwen/highlightredirects.js]] – please include this line if (mw.config.get('wgAction') != 'edit' && mw.config.get('wgCanonicalNamespace') != 'Special')
var ss = document.styleSheets[0];
if (ss.insertRule) {
ss.insertRule('a.mw-redirect{color:#05a}', ss.cssRules.length);
} else if (ss.addRule) {
ss.addRule('a.mw-redirect', 'color:#05a');
}
<!--/Green links to redirect-->
<!-- Free use rationale adder-->
// importScript('User:AzaToth/morebits.js');
// importScript('User:AWeenieMan/furme.js'); // causing bugs in IE
<!--/Free use rationale adder-->