User:Adrian~enwiki/combined.js

/****************************************************************************

* Built from the following scripts:

* module.js

* datetime.js

* msg.js

* util.js

* download.js

* wikiwidget.js

* wikins.js

* wikipage.js

* wikipageXfd.js

* wikiedit.js

* wikistate.js

* autoreplace.js

* wikiparse.js

* diff.js

* kookie.js

* md5.js

* token.js

* shortcuts.js

* diffsince.js

* wikiwatch.js

* autoedit.js

* nav_custom.js

* iframedl.js

* wikiimg.js

* drag.js

* overlib/overlib.js

* instaview.js

* instaviewtiny.js

* notes.js

* linkedit.js

* sig.js

* rollback.js

* autotag.js

* copyvio.js

* edittop.js

* watchlist.js

* watchbutton.js

* autofocus.js

* directredirect.js

* locz.js

* datez.js

* coorz.js

* imdbz.js

* alexafy.js

* userscript.js

* autosummary.js

* smartsubmit.js

* newmessages.js

* tabdiff.js

* tabsince.js

* purge.js

* editcount.js

* nav_logs.js

* nav_afd.js

* hideown.js

* google.js

* debugnote.js

* querysave.js

* extedit.js

* autoafd.js

* afd_vote.js

* xfdclose.js

* obsolete/autowarn.js

* redirector.js

* popups.js

* picturepopups.js

* instapreview.js

****************************************************************************/

/****************************************************************************

* BEGIN module.js

****************************************************************************/

// $Id: module.js 1179 2006-02-23 22:10:31Z quarl $

// module.js - dependency tracking

// quarl 2006-02-07 initial version

var $module = new Object();

// can be a URL prefix or a User:Wikipedia prefix

$module.options = {

// auto_load: "http://wikipedia.quarl.org/scripts/"

auto_load: null

};

var Module = $module.Module = function(name) {

if (!(this instanceof $module.Module)) {

return new $module.Module(name, params);

}

if (typeof(name) != 'string') {

alert("$module.Module: need name (error 7e05c98d-b55c-4e1f-a48a-170d7bcb63a8)");

return void(0);

}

this.module = { name: name };

$module.provide(this.module.name, this);

return this;

}

$module.Module.prototype.depend = function() {

var l;

for (var i = 0; i < arguments.length; ++i) {

if (!(l=$module.depend1(arguments[i], this))) return null;

}

return l;

}

$module.Module.prototype.inherit = function(parent) {

// allow string name of parent, because the module might not yet be loaded

// at this point

var parent0 = parent;

if (typeof(parent) == 'string') {

parent = window[parent];

}

if (!parent) {

alert($module.msgpfx(child) + "Can't inherit from " + parent0);

return;

}

for (var v in parent) {

if (v == 'module') continue;

if (typeof(this[v]) == 'undefined') child[v] = parent[v];

}

}

$module.Module.prototype.alert = function(msg) {

window.alert(this.module.name + ': ' + msg);

}

// requires msg.js

$module.Module.prototype.error = function(msg) {

return $msg.error('(' + this.module.name + ') ' + msg);

}

// requires msg.js

$module.Module.prototype.warning = function(msg) {

return msg.warning('(' + this.module.name + ') ' + msg);

}

// requires msg.js

$module.Module.prototype.debug = function(msg) {

return $msg.debug('(' + this.module.name + ') ' + msg);

}

$module.modules = {};

$module.provide = function(s, t) {

$module.modules[s] = (t || 1);

}

$module.msgpfx = function(t) {

return (t && t.module && t.module.name) ? ("$module (" + t.module.name + "): ") : "$module: ";

}

$module.depend = function() {

var l;

for (var i = 0; i < arguments.length; ++i) {

if (!(l=$module.depend1(arguments[i], null))) return null;

}

return l;

}

$module.depend1 = function(s, t) {

var m = $module.modules[s];

if (!m) {

if ($module.options.auto_load) {

$module.loadScript($module._makeScriptUrl(s));

m = $module.modules[s];

if (!m) {

alert($module.msgpfx(t) + "Error loading module '"+s+"'");

return false;

}

} else {

if (!$module.options.auto_load && s.match(/[.]css$/)) {

// XXX TODO: check document.styleSheets

return;

}

alert($module.msgpfx(t) + "Error, depends on '"+s+"', but not yet loaded (error 05ceb474-86ec-49ac-833f-89a5d77130bc)");

}

}

return m;

}

$module.loadScript = function(s) {

if (s.match(/[.]js$/)) {

document.write('' + s + '";');

// TODO: use document.styleSheets; test with .href

$module.modules[s] = 1;

} else {

alert("$module.loadScript: unknown type (error 32326eb9-095b-4f21-ba23-1bda4d6091fe)");

}

}

$module._makeScriptUrl = function(t, ns) {

ns = ns || $module.options.auto_load;

if (ns.match(/^(http|ftp):/)) {

return ns + '/' + t;

} else if (ns.match(/^\[\[(.*)\]\]$/)) {

var page = RegExp.$1 + '/' + t;

if (ns.match(/[.]js$/)) {

return ('/w/index.php?title=' + page +

'&action=raw&ctype=text/javascript&dontcountme=s');

} else if (ns.match(/[.]css$/)) {

return ('/w/index.php?title=' + page +

'&action=raw&ctype=text/css&dontcountme=s');

} else {

return ('/w/index.php?title=' + page);

}

} else {

alert("Unknown value for ns (error 01b7cf1a-f746-4c93-8992-b0542a2f54c3)");

return null;

}

}

/****************************************************************************

* END module.js

****************************************************************************/

/****************************************************************************

* BEGIN datetime.js

****************************************************************************/

// $Id: datetime.js 1236 2006-02-24 11:35:23Z quarl $

// datetime.js - date/time utility functions

var $datetime = new Module('datetime.js');

// return N days ago (default today)

$datetime.previousDay = function(days) {

days = days || 0;

var d = new Date();

d.setDate(d.getDate() - days); // automatically wraps as necessary

return d;

}

$datetime.L2 = function(x) {

if (x < 0) return ""+x;

if (x < 10) return "0"+x;

return ""+x;

}

$datetime.L3 = function(x) {

if (x < 0) return ""+x;

if (x < 10) return "00"+x;

if (x < 100) return "0"+x;

return ""+x;

}

$datetime.datestampUTCISO = function(d) {

d = d || new Date();

return ("" +

d.getUTCFullYear() + '-' +

$datetime.L2(d.getUTCMonth()+1) + '-' +

$datetime.L2(d.getUTCDate()));

}

$datetime.timestampUTCISO = function(d) {

d = d || new Date();

return ($datetime.L2(d.getUTCHours()) + ':' +

$datetime.L2(d.getUTCMinutes()));

}

$datetime.logtimestamp = function(d) {

d = d || new Date();

return ($datetime.L2(d.getHours()) + ':' +

$datetime.L2(d.getMinutes()) + ':' +

$datetime.L2(d.getSeconds()) + '.' +

$datetime.L3(d.getTime() % 100));

}

$datetime.monthnames = [

"January", "February", "March", "April", "May", "June",

"July", "August", "September", "October", "November", "December" ];

$datetime.datestampYYYYMonthD = function(d) {

d = d || new Date();

return ("" +

d.getUTCFullYear() + ' ' +

$datetime.monthnames[d.getUTCMonth()] + ' ' +

d.getUTCDate());

}

$datetime.datestampMonthYYYY = function(d) {

d = d || new Date();

return ("" +

$datetime.monthnames[d.getUTCMonth()] + ' ' +

d.getUTCFullYear());

}

// from Lupin's popups

$datetime.formatAge = function(age) {

var addunit = function(num,str) {

return + num + ' ' + str + ((num!=1) ? 's' : ) ;

}

// coerce into a number

age = 0 + age;

var a = age;

var seclen = 1000;

var minlen = 60*seclen;

var hourlen = 60*minlen;

var daylen = 24*hourlen;

var weeklen = 7*daylen;

var numweeks = (a-a%weeklen)/weeklen; a = a-numweeks*weeklen; var sweeks = addunit(numweeks, 'week');

var numdays = (a-a%daylen)/daylen; a = a-numdays*daylen; var sdays = addunit(numdays, 'day');

var numhours = (a-a%hourlen)/hourlen; a = a-numhours*hourlen; var shours = addunit(numhours, 'hour');

var nummins = (a-a%minlen)/minlen; a = a-nummins*minlen; var smins = addunit(nummins, 'minute');

var numsecs = (a-a%seclen)/seclen; a = a-numsecs*seclen; var ssecs = addunit(numsecs, 'second');

if (age > 4*weeklen) { return sweeks; }

if (age > weeklen) { return sweeks + ' ' + sdays; }

if (age > daylen) { return sdays + ' ' + shours; }

if (age > 6*hourlen) { return shours; }

if (age > hourlen) { return shours + ' ' + smins; }

if (age > 10*minlen) { return smins; }

if (age > minlen) { return smins + ' ' + ssecs; }

return ssecs;

}

/****************************************************************************

* END datetime.js

****************************************************************************/

/****************************************************************************

* BEGIN msg.js

****************************************************************************/

// $Id: msg.js 1188 2006-02-23 22:23:09Z quarl $

// error, warning, debug functions

// quarl 2006-02-20 initial version

var $msg = new Module('msg.js');

$msg.depend('msg.css');

$msg.depend('datetime.js');

$msg.options = {

debuglogsize: 500

};

$msg.error = function(msg) {

alert(msg);

// dummy try/catch to automatically interrupt if running under debugger

// (kind of like a built-in breakpoint)

try { throw 0; } catch(e) {};

return void(0);

}

$msg.warning = function(msg) {

alert(msg);

return void(0);

}

$msg.debuglog = [];

$msg.debug = function(msg) {

msg = '[' + $datetime.logtimestamp() + '] ' + msg;

$msg.debuglog.push(msg);

// if it's way over budget, delete until we're at budget

if ($msg.debuglog.length > $msg.options.debuglogsize * 1.5) {

$msg.debuglog.splice(0, $msg.debuglog.length-$msg.options.debuglogsize);

}

}

$msg.debug("-- Initializing Wikipedia Power Toolkit --");

/****************************************************************************

* END msg.js

****************************************************************************/

/****************************************************************************

* BEGIN util.js

****************************************************************************/

// $Id: util.js 1224 2006-02-24 10:40:00Z quarl $

// util.js - miscellaneous utility functions for Wikipedia user scripts

// quarl 2006-01-09 initial version

// NON-NAMESPACED FUNCTION NAMES ARE DEPRECATED

var $util = new Module('util.js');

$util.depend('msg.js');

/////////////////////////////////////////////////////////////

// MISCELLANEOUS FUNCTIONS

// $util.defineClass = function(constructor, functions) {

// var c = constructor;

// c.prototype = functions;

// return c;

// }

$util.merge = function(o, params) {

if (!params) return o;

for (var p in params) {

o[p] = params[p];

}

return o;

}

$util.copyArray = function(a, i) {

var r = [];

i = i || 0;

for (; i < a.length; i++) {

r.push(a[i]);

}

return r;

}

$util.assocArray = function(x) {

for (var i in x) {

x[ x[i] ] = 1;

}

return x;

}

// flatten an array

$util.flatten = function(list, start) {

var ret=[];

if (typeof start == 'undefined') start=0;

for (var i=start; i

if (typeof list[i] == typeof []) {

return ret.concat($util.flatten(list[i])).concat($util.flatten(list, i+1));

}

else ret.push(list[i]);

}

return ret;

};

$util.bindThis = function(this_, method) {

return function() { return method.apply(this_, arguments); };

}

$util.callHooks = function(callbacks) {

var args = $util.copyArray(arguments, 1);

for (var i in callbacks) {

var callback = callbacks[i];

callback.apply(callback, args);

}

}

$util.hookEventObj = function(obj, hookName, hookFunct) {

if (!obj) return;

if (obj.addEventListener)

obj.addEventListener(hookName, hookFunct, false);

else if (obj.attachEvent)

obj.attachEvent("on" + hookName, hookFunct);

}

// wikibits.js:addOnloadHook does almost exactly what we want. Its primary

// feature is it runs at the end of loading rather than after loading, so the

// user does not see the page before running the hooks.

//

// The disadvantage is its buggy behavior if any of the hooks thrown an

// exception: the entire list of hooks is re-run, producing poor results like

// multiple tabs.

$util._onloadFunctions = [];

$util._runOnloadHooks = function() {

if ($util._onloadFunctions == null) return;

// Using a while loop in this manner ensures that if we queue up more

// hooks during _runOnloadHooks, they get queued at the end, and also if

// we raise an exception for some reason, we don't re-run the entire list.

while ($util._onloadFunctions.length) {

try {

$util._onloadFunctions[0] ();

} catch(e) {

var s = $util._onloadFunctions[0].toString();

$util.error("_runOnloadHooks: Error in onload hook '"+$util.strAbbrev(s,297)+"': " + e);

}

$util._onloadFunctions.shift();

}

$util._onloadFunctions = null;

}

// This is more robust than wikibits.js's addOnloadHook. That version uses an

// array of fuctions; if there is an error, the hook functions sometimes get

// re-run.

$util.addOnloadHook = function(f) {

if (!f) {

alert("$util.addOnloadHook: no function given! (error 0a0fb885-97fb-4089-b7c5-90f0be7d5abc)");

return;

}

if ($util._onloadFunctions == null) {

// we've already finished _runOnloadHooks, so just run f now.

// TODO: any advantage to doing setTimeout(f, 0) here?

f();

} else {

$util._onloadFunctions.push(f);

// $util.hookEventObj(window, "load", f);

}

// setTimeout is NOT a good alternative to addEventListener. The reason

// is that timeout functions are called too soon: since the