Χρήστης:Geraki/monobook.js

Από τη Βικιπαίδεια, την ελεύθερη εγκυκλοπαίδεια

Σημείωση: Μετά την αποθήκευση πρέπει να καθαρίσετε την προσωρινή μνήμη του browser σας για να δείτε τις αλλαγές: Mozilla: πατήστε ReloadCtrl-R), IE / Opera: Ctrl-F5, Safari: Cmd-R, Konqueror Ctrl-R.

//<source lang="javascript">
 
// From [[Wikipedia:WikiProject User_scripts/Scripts/addLink]], revision 73544644
 
//A helper function to add a button to one of the toolbars in the interface.
//An improved(I hope) version of [[Wikipedia:WikiProject User scripts/Scripts/Add LI link|addlilink]].
//[[User:JesseW/sig|JesseW, the juggling janitor]] 05:33, 8 November *2005 (UTC)
 
function addLink(where, url, name, id, title, key, after){
    //* where is the id of the toolbar where the button should be added;
    //   i.e. one of "p-cactions", "p-personal", "p-navigation", or "p-tb".
    //
    //* url is the URL which will be called when the button is clicked.
    //   javascript: urls can be used to do more complex things.
    //
    //* name is what will appear as the name of the button.
    //
    //* id is the id of the button; it's best to define one.  
    //   Use a prefix to make sure its unique. Optional.
    //
    //* title is the tooltip title that gives a longer description 
    //   of the button; if you define a accesskey, mention it here. Optional.
    //
    //* key is the char you want for the accesskey. Optional.
    //
    //* after is the id of the button you want to follow this one. Optional.
    //
    var na = document.createElement('a');
    na.href = url;
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    if(id) li.id = id;
    li.appendChild(na);
    var tabs = document.getElementById(where).getElementsByTagName('ul')[0];
    if(after) {
	tabs.insertBefore(li,document.getElementById(after));
    } else {
	tabs.appendChild(li);
    }
    if(id) {
	if(key && title) { ta[id] = [key, title]; }
	else if(key) { ta[id] = [key, '']; }
	else if(title) { ta[id] = ['', title];} 
    }
    // re-render the title and accesskeys from existing code in wikibits.js
    akeytt();
    return li;
}
 
 
// From [[Wikipedia:WikiProject User_scripts/Scripts/Add_purge_to_tabs]], revision 76509603
 
 
// addPurge
addOnloadHook( function (){
    var x = document.getElementById('ca-history');
    if(!x) return;
    if(x.children) x = x.children[0].href;
    else x = x.childNodes[0].href;
    addLink("p-cactions", x.replace(/=history/, "=purge"), 'ανανέωση', 'ca-purge', 'Ανανέωση της εσωτερικής cache για αυτή την σελίδα', 0);
});
 
 
 
 
// From [[Wikipedia:WikiProject User_scripts/Scripts/Add_LI_link]], revision 73544143
 
 
function addlilink(tabs, url, name, id, title, key){
    var na = document.createElement('a');
    na.href = url;
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    if(id) li.id = id;
    li.appendChild(na);
    tabs.appendChild(li);
    if(id)
    {
        if(key && title)
        {
            ta[id] = [key, title];
        }
        else if(key)
        {
            ta[id] = [key, ''];
        }
        else if(title)
        {
            ta[id] = ['', title];
        }
    }
    // re-render the title and accesskeys from existing code in wikibits.js
    akeytt();
    return li;
}
 
function addToolboxLink(url, name, id){
    var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0];
    addlilink(tb, url, name, id);
}
 
// From [[Wikipedia:WikiProject User_scripts/Scripts/Add_tab]], revision 73544604
 
function addTab(url, name, id, title, key){
    var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
    return addlilink(tabs, url, name, id, title, key)
};
 
 
// From [[Wikipedia:WikiProject User_scripts/Scripts/User_tabs]], revision 73795341
 
 
 //Please leave the following line
 //[[user:Where/usertabs]]
 
 addOnloadHook(function() {
   if (document.title.search("/") != -1 || document.title.search("- History -") != -1) { //no subpages or history
      return;
   }
   if (document.title.indexOf("Χρήστης:") == 0 || document.title.indexOf("Συζήτηση χρήστη:") == 0) {
      username_a = document.URL.match(/:.*:(.*)/);
      username=username_a[1];
      addToolboxLink("http://el.wikipedia.org/wiki/Special:Contributions/" + username, "contrib", "ca-contrib", "contribs", "");
      addToolboxLink("http://el.wikipedia.org/w/index.php?title=Special%3ALog&type=move&user=" + username, "page moves", "ca-pagemoves", "page moves", "");
      addToolboxLink("http://el.wikipedia.org/w/index.php?title=Special%3ALog&type=block&user=" + username, "block log", "ca-blog", "blog", "");
      addToolboxLink("http://tools.wikimedia.de/~interiot/cgi-bin/count_edits?dbname=elwiki_p&user=" + username, "Αριθμός edits του "+username, "ca-kate", "kate", "");
       addToolboxLink('http://tools.wikimedia.de/~tangotango/userreg.php?user='+username+'&subdom=el&domain=.wikipedia.org&estimate=on', "Ημερομηνία εγγραφής του "+username, 'toolbox_tangotango'); addToolboxLink('http://tools.wikimedia.de/~daniel/WikiSense/Gallery.php?wikifam=.wikipedia.org&wikilang=el&order=-img_timestamp&img_user_text='+username+'&max=25&ofs=0&max=250', "Gallery του "+username, 'toolbox_gallery'); addToolboxLink('http://tools.wikimedia.de/~daniel/WikiSense/OrphanImages.php?wikifam=.wikipedia.org&wikilang=el&order=img_timestamp&img_user_text='+username+'&max=100&filter=notalk&ofs=0&max=250', "Ορφανές του "+username, 'toolbox_orphans');  addToolboxLink('http://tools.wikimedia.de/~daniel/WikiSense/UntaggedImages.php?wikifam=.wikipedia.org&wikilang=el&order=img_timestamp&img_user_text='+username+'&max=100&ofs=0&max=250', "Χωρίς ετικέτα του "+username, 'toolbox_untegged'); 
 
 
   }
 });
 
 
 
// From [[Wikipedia:WikiProject User_scripts/Scripts/Add_edit_section_0]] 
 
 
//If you are not editing a page, a tab will appear allowing you to edit the 0th section of a page (the top area usually used as an introduction.
 
addOnloadHook(function () {
    var x;
    if (!(x = document.getElementById('ca-edit') )) return;
    var url;
    if (!(url = x.getElementsByTagName('a')[0] )) return;
    if (!(url = url.href )) return;
    var y = addPortletLink('p-cactions', url+"&section=0", '0', 'ca-edit-0',
                           'Edit the lead section of this page', '0', x.nextSibling);
 
    y.className = x.className;  // steal classes from the the edit tab...
    x.className = 'istalk';     // ...and make the edit tab have no right margin
 
    // exception: don't steal the "selected" class unless actually editing section 0:
    if (/(^| )selected( |$)/.test(y.className)) {
        if (!document.editform || !document.editform.wpSection
            || document.editform.wpSection.value != "0") {
            y.className = y.className.replace(/(^| )selected( |$)/g, "$1");
            x.className += ' selected';
        }
    }
});
 
 
// Import [[User:Lupin/popups.js]]
 
document.write('<script type="text/javascript" src="http://en.wikipedia.org/w' + 
               '/index.php?title=User:Lupin/popups.js&action=raw&ctype=text/javascript"></script>'); 
 
popupAdminLinks=true;
popupFixDabs=true;
 
// jncsp-end
 
 
if (mwCustomEditButtons) {
  mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/f/fd/Button_underline.png",
    "speedTip": "Υπογράμμιση",
    "tagOpen": "<u>",
    "tagClose": "</u>",
    "sampleText": "Κείμενο"};
};
 
 
if (mwCustomEditButtons) {
  mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/b/b4/Button_category03.png",
    "speedTip": "Κατηγορία",
    "tagOpen": "[[Κατηγορία:",
    "tagClose": "|{{PAGENAME}}]]",
    "sampleText": "Κείμενο"};
};
 
if (mwCustomEditButtons) {
  mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/9/9e/Btn_toolbar_gallery.png",
    "speedTip": "Έκθεση",
    "tagOpen": "<gallery>",
    "tagClose": "</gallery",
    "sampleText": "Κείμενο"};
 
mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/7/79/Button_reflink.png",
    "speedTip": "Παραπομπή",
    "tagOpen": "<ref>",
    "tagClose": "</ref>",
    "sampleText": "Παραπομπή"};
 
mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/a/a0/Button_references_alt.png",
    "speedTip": "Ενότητα παραπομπών",
    "tagOpen": "<references />",
    "tagClose": "",
    "sampleText": ""};
 
mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/d/dd/Pulsante_tl.png",
    "speedTip": "Σύνδεσμος προς πρότυπο",
    "tagOpen": "{{tl|",
    "tagClose": "}}",
    "sampleText": "πρότυπο"};
 
mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/2/23/Button_code.png",
    "speedTip": "Κώδικας",
    "tagOpen": "<code>",
    "tagClose": "</code>",
    "sampleText": "κώδικας"};
 
mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/9/91/Button_pd.png",
    "speedTip": "Κοινό κτήμα",
    "tagOpen": "{{ΚΚ}}",
    "tagClose": "",
    "sampleText": ""};
 
mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/6/67/Button_BY.png",
    "speedTip": "Χωρίς πηγή",
    "tagOpen": "{{χωρίς πηγή}}",
    "tagClose": "",
    "sampleText": ""}; 
 
mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/7/78/Button_titre.png",
    "speedTip": "Χωρίς άδεια",
    "tagOpen": "{{χωρίς άδεια}}",
    "tagClose": "",
    "sampleText": ""}; 
 
mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/0/07/Deletewarn3.png",
    "speedTip": "Προειδοποίηση πηγή εικόνας",
    "tagOpen": "{"+"{subst:Προειδοποίηση πηγή εικόνας|", 
    "tagClose": "}"+"} ~"+"~"+"~",
    "sampleText": "όνομα εικόνας"};
 
mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/f/f4/Deletewarn4.png",
    "speedTip": "Προειδοποίηση άδεια εικόνας ",
    "tagOpen": "{"+"{subst:Προειδοποίηση άδεια εικόνας|", 
    "tagClose": "}"+"} ~"+"~"+"~",
    "sampleText": "όνομα εικόνας"};
 
mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/a/a9/Button_tournesol.png",
    "speedTip": "Καλωσόρισμα",
    "tagOpen": "{"+"{subst:Καλωσόρισμα}"+"} ", 
    "tagClose": "~"+"~"+"~",
    "sampleText": ""}
};
 
ec = {
 
	getParamValue: function(paramName) {
		var cmdRe=RegExp('[&?]'+paramName+'=([^&]*)');
		var h=document.location;
		var m;
		if (m=cmdRe.exec(h)) {
			try {
				while(m[1].indexOf('+')!=-1)
				{
					m[1]=m[1].substr(0,m[1].indexOf('+'))+" "+m[1].substr(m[1].indexOf('+')+1);
				}
				return decodeURIComponent(m[1]);
			} catch (someError) {}
		}
		return null;
	},
 
	doEditCount: function(user) {
		if (!user) { return; }
		ec.user=user;
		ec.makeEditCountDivs();
		ec.getContribs(user);
		setTimeout(ec.checkContribs, 1000);
	},
	makeEditCountDivs: function() {
		var d=document.createElement('div');
		d.id='editcount_output';
		ec.appendDivs(d, [ 'editcount_title', 'editcount_intervalselector', 
				   'editcount_stats' ]);
		var h=document.getElementById('siteSub');
		h.parentNode.insertBefore(d, h.nextSibling);
	},
	appendDivs: function(parent, list) {
		for (var i=0; i<list.length; ++i) {
			var d=document.createElement('div');
			d.id=list[i];
			parent.appendChild(d);
		}
	},
 
	checkContribs: function() {
		if (ec.complete) {
			ec.doOutput();
		} else {
			ec.doStatus();
			setTimeout(ec.checkContribs, 1000);
		}
	},
 
	doOutput: function(start, end) {
		var d=document.getElementById('editcount_stats');
		if (!ec.count) {
			d.innerHTML='No edits found for ' + ec.user;
			return;
		}
		if (!this.intsel) {
			this.intsel = new IntervalSelector({
				min: ts2unix(this.editlist.first.next.key),
				max: ts2unix(this.editlist.last.prev.key)});
			var this2=this;
			this.intsel.doneDrag=function() {
				//document.title=[this.lo, this.hi];
				this2.doOutput.apply(this2, map(unix2ts, [this.lo, this.hi]));
			};
			this.intsel.dragging=function() {
				var start=unix2ts(this2.intsel.lo);
				var end=unix2ts(this2.intsel.hi);
				document.getElementById('editcount_range').innerHTML=
				formatTs(start) + ' - ' + formatTs(end);
			};
//this.intsel.dragging=this.intsel.doneDrag; // too slow - pretty cool tho
			var intdiv=document.getElementById('editcount_intervalselector');
			intdiv.appendChild(this.intsel.box);
			this.appendDivs(intdiv, ['editcount_range']);
			this.intsel.dragging();
			this.intseldebug=document.createElement('div');
			this.intsel.box.parentNode.insertBefore(this.intseldebug, this.intsel.box);
		}
		document.getElementById('editcount_title').innerHTML=ec.outputHeading();
		document.getElementById('editcount_stats').innerHTML='<p>Total: ' + 
		ec.countFigure() + '<br>First edit: ' + ec.firstEdit.replace(/[TZ]/g, ' ') + 
		'(UTC)' + ec.statsTable(start, end);
	},
 
	outputHeading: function() {
		return '<h2>Edit count for ' + ec.user + '</h2>';
	},
 
	doStatus: function() {
		var d=document.getElementById('editcount_stats');
		d.innerHTML=ec.outputHeading() + '<p>Downloaded ' + ec.countFigure() + ' so far' + ec.statsTable();
	},
 
	countFigure: function() {
		return ec.count + ' edits over ' + objSum(ec.namespaces, 'articleCount') +  ' pages';
	},
 
	findEdit: function(timestamp, up) { // this is very broken - FIXME!
		if (up) {
			var e=this.editlist.first;
			while(e.key<timestamp && (e=e.next)){};
			//console.log('findEdit, up: got '+timestamp+', found '+(e.prev && e.prev.key || null) );
			return e.prev;
		} else {
			var e=this.editlist.last;
			while(e.key>timestamp && (e=e.prev)){}
			//console.log('findEdit, down: got '+timestamp+', found '+(e.next && e.next.key || null) );
			return e.next;
		}
	},
 
	statsTable: function(start, end) {
		//console.log('start: '+start + ', end: '+end);
		var barTotal=400;
		var endEdit=this.findEdit(end) || this.editlist.last;
		var startEdit=this.findEdit(start,true);
		if (!startEdit || !startEdit.key) { startEdit=this.editlist.first.next; }
		//console.log('endEdit:' + endEdit.key);
		//console.log('startEdit:'+ startEdit.key);
		var sumValue=function(val) {
			return objSum(startEdit.stats, val) - objSum(endEdit.stats, val);
		}
		var total=sumValue('count');
		if (!total) { return ''; }
		var statValue=function(k, val) {
			if (!startEdit.stats[k]) { return 0; }
			var r=startEdit.stats[k][val];
			//console.log(k + ' ' + val + ': ' + r);
			if (!endEdit.stats[k] || !endEdit.stats[k][val]) { return r; }
			return r - endEdit.stats[k][val];
		};
		// FIXME: abstract this away so it's trivial to add new columns
		r='<p>Statistics between '+formatTs(startEdit.key) + ' and '+formatTs(endEdit.key);
		r+='<table><tr><th>' + ['Namespace',
					   'New',
					   'Minor',
					   'Top',
					   'Summaries',
					   '(manual)',
					   'Pages',
					   'Count', '%'].join('</th><th>') + '</th></tr>';
		for (var k in ec.namespace_names) {
			if (!ec.namespaces[k]) { continue; }
			r += '<tr><td>'+[ec.namespace_names[k],
					 statValue(k, 'newCount'),
					 statValue(k, 'minorCount'),
					 statValue(k, 'topCount'),
					 statValue(k, 'commentCount'),
					 statValue(k, 'manualCommentCount'),
					 statValue(k, 'articleCount'),
					 statValue(k, 'count'),
					 percent(statValue(k, 'count'), total)].join('</td><td>') + '</td>';
			r+=ec.ecBar(barTotal, total, statValue(k, 'count'), statValue(k, 'minorCount') || 0);
			r+='</tr>';
		}
		var totalMinor = sumValue('minorCount');
		r+='<tr><td>'+['<b>Total</b>',
			       sumValue('newCount'),
			       totalMinor,
			       sumValue('topCount'),
			       sumValue('commentCount'),
			       sumValue('manualCommentCount'),
			       sumValue('articleCount'),
			       sumValue('count'),
			       '100'].join('</td><td>') + '</td>';
		r+=ec.ecBar(barTotal, total, sumValue('count'), totalMinor);
		r+='</table>';
		return r;
	},
 
	histogramBar: function(value, scale, colour, hint) {
		var height='2ex';
		var style='height: '+ height;
		style += '; background: ' + colour;
		style += '; width: ' + value * scale + 'px';
		style += '; float: left;';
		return '<span style="' + style + '" title="' + hint + '"></span>';
	},
 
	histogramCell: function(scale, values) {
		var r='<td><div style="width: ' + scale + 'px;">';
		for (var i=0; i<values.length; i+=3) { r+=ec.histogramBar(values[i], scale, values[i+1], values[i+2]); }
		r+='</div></td>';
		return r;
	},
 
	ecBar: function(scale, total, count, minor) {
		var nonMinorColour='blue';
		var minorColour='#0A3';
		return ec.histogramCell( scale, [(count-minor)/total, nonMinorColour, "non-minor edits",
						 minor/total, minorColour, "minor edits"]);
	},
 
	ajax: {
	download:function(bundle) {
			// mandatory: bundle.url
			// optional:  bundle.onSuccess (xmlhttprequest, bundle)
			// optional:  bundle.onFailure (xmlhttprequest, bundle)
			// optional:  bundle.otherStuff OK too, passed to onSuccess and onFailure
 
			var x = window.XMLHttpRequest ? new XMLHttpRequest()
			: window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP")
			: false;
 
			if (x) {
				x.onreadystatechange=function() {
					x.readyState==4 && ec.ajax.downloadComplete(x,bundle);
				};
				x.open("GET",bundle.url,true);
				x.send(null);
			}
			return x;
		},
 
	downloadComplete:function(x,bundle) {
			x.status==200 && ( bundle.onSuccess && bundle.onSuccess(x,bundle) || true )
			|| ( bundle.onFailure && bundle.onFailure(x,bundle) || alert(x.statusText));
		}
	},
 
 
	getContribs: function(user, startAt) {
		var limit=500; // currently maximum allowed per page by query.php
		var url='http://el.wikipedia.org/w/query.php?what=usercontribs' +
		'&uccomments' +  // enable for edit comment analysis
		'&format=json&uclimit=500&titles=User:'+escape(user);
		if (startAt) { url += '&ucend=' + startAt.replace(/[^0-9]/g, ''); }
		ec.ajax.download({ url: url, user: user,
				   startAt: startAt, onSuccess: ec.readContribs,
				   limit: limit});
	},
 
	readContribs: function(dl, bundle) {
		window.dl=dl;
		window.bundle=bundle;
		try {
			eval('var jsobj=' + dl.responseText);
			var pages=jsobj.pages;
			var child=ec.anyChild(pages);
			var contribs=child.contributions;
		} catch (summat) {
			throw new Error('Badness happened in readContribs: ' + summat.message);
			return;
		}
		var i=0, j=0;
		var minrev=null;
		for (var c in contribs) {
			++i;
			var cc=contribs[c];
			if (!minrev || cc.revid < minrev) { minrev = cc.revid; }
			if (ec.edits[cc.revid]) { continue; }
			++j;
			ec.doStats(cc);
			ec.edits[cc.revid] = cc;
		}
		ec.count += j;
		if (i == bundle.limit && ec.edits[minrev]) {
			ec.getContribs(bundle.user, ec.edits[minrev].timestamp);
		} else {
			ec.complete=true;
			minrev && (ec.firstEdit=ec.edits[minrev].timestamp);
		}
	},
 
	doStats: function (c) {
		var k=c.ns || 0;
		//if (!ec.namespaces[k]) { console.log('New namespace: '+k + ', title=' +c['*'] +
		// ', alleged NS=' + ec.namespace_names[k]); }
		if (!ec.namespaces[k]) { ec.namespaces[k] = {articles: {}}; }
		var n = ec.namespaces[k];
		incr(n, 'count');
		if (!n.articles[c['*']]) { incr(n, 'articleCount'); }
		incr(n.articles, c['*']);
		if (typeof c.minor != 'undefined') { incr(n, 'minorCount'); }
		if (typeof c.top != 'undefined') { incr(n, 'topCount'); }
		if (typeof c['new'] != 'undefined') { incr(n, 'newCount'); }
		if (c.comment) {
			incr(n, 'commentCount');
			if (!RegExp("^/[*].*?[*]/ *$").test(c.comment)) {
				incr(n, 'manualCommentCount');
			}
		}
		this.editlist.add({key: parseInt(c.timestamp.replace(/[^0-9]/g, ''), 10),
				   edit: c,
				   stats: this.saveStats()});
		// more stuff here, perhaps
	},
 
	saveStats: function() {
		var r={};
		var list=['count', 'articleCount', 'minorCount', 'topCount',
			  'newCount', 'commentCount', 'manualCommentCount'];
		for (var k in ec.namespaces) {
			r[k]=getStuff(ec.namespaces[k],list);
		}
		return r;
	},
 
	anyChild: function(obj) {
		for (var p in obj) {
			return obj[p];
		}
		return null;
	},
 
	edits: {},
	count: 0,
	complete: false,
	namespaces: {},
	namespace_names: {0: 'Article', 1: 'Talk',
			  2: 'User', 3: 'User talk',
			  4: 'Wikipedia', 5: 'Wikipedia talk',
			  6: 'Image', 7: 'Image talk',
			  8: 'MediaWiki', 9:'MediaWiki talk',
			  10: 'Template', 11: 'Template talk',
			  12: 'Help', 13: 'Help talk',
			  14: 'Category', 15: 'Category talk',
			  100: 'Portal', 101: 'Portal talk' // no comma
	},
	firstEdit: 0,
	editlist: new linkedList(
			{key: 99990101011200, stats: {}},
			{key: 0, stats: {}}),
 
	dummy: null // no comma
};
 
 
window.incr=function(obj, key) {
	if (!obj[key]) { obj[key]=1; }
	else { obj[key]++; }
}
 
window.objSum=function(obj, x, y) {
	var r=0;
	if (x && y) { for (var k in obj) { r+= (obj[k][x][y] ? obj[k][x][y] : 0); } }
	else if (x) { for (var k in obj) { r+= (obj[k][x] ? obj[k][x] : 0); } }
	else        { for (var k in obj) { r+= (obj[k] ? obj[k] : 0); } }
	return r;
}
 
window.percent=function(n, N) {
	return Math.floor(n/N * 1000 + .5)/10;
};
 
if((user=ec.getParamValue('ectarget'))!==null) { addOnloadHook(function(){ec.doEditCount(user);}); }
 
function linkedList(x0,y0) {
	this.first=null;
	this.last=null;
	this.hash={};
	this.add=function(x) {
		this.hash[x.key]=x;
		if (!this.first) {
			this.first=x;
			this.last=x;
			x.prev=x.next=null;
			return;
		}
		var k=x.key;
		if (true || k - this.first.key < this.last.key - k) {
			this.pushTop(x);
		} else {
			this.pushTail(x);
		}
	};
	this.pushTop=function(x) {
		if (x.key < this.first.key) {
			this.first.prev=x;
			x.next=this.first;
			this.first=x;
			x.prev=null;
			return;
		}
		if (x.key > this.last.key) {
			this.last.next=x;
			x.prev=this.last;
			this.last=x;
			x.next=null;
		}
		for (var y=this.first; y.next; y=y.next) {
			if (y.key < x.key && x.key <= y.next.key) {
				this.insertAfter(y, x);
				return;
			}
		}
	};
	this.pushTail=function(x) {
		for (var y=this.last; y.prev; y=y.prev) {
			if (y.prev.key < x.key && x.key <= y.key) {
				this.insertAfter(y.prev, x);
				return;
			}
		}
		this.first.prev=x;
		x.next=this.first;
		this.first=x;
		x.prev=null;
	};
	this.insertAfter=function(y,x) {
		x.next=y.next;
		x.prev=y;
		y.next.prev=x;
		y.next=x;
	};
	if (x0) { this.add(x0); }
	if (y0) { this.add(y0); }
}
 
window.getStuff=function(obj, list) {
	var r={};
	for (var i=0; i<list.length; ++i) {
		if (typeof obj[list[i]] != 'undefined') { r[list[i]]=obj[list[i]]; }
	}
	return r;
}
 
window.IntervalSelector=function(data) {
	if (!data) { data={}; }
	this.min=data.min || 10;
	this.max=data.max || 100;
	this.span=this.max-this.min;
	this.lo=data.lo || this.min;
	this.hi=data.hi || this.max;
	this.width=data.width || 400;
	this.height=data.height || 20;
	this.scale=this.width/this.span;
	this.minBarWidth=data.minBarWidth || 10;
	this.oldmousemove = null;
	this.createDiv();
}
 
 
IntervalSelector.prototype.createDiv=function() {
	var d=document.createElement('div');
	d.className='intervalselectorbox';
	//d.style.position='absolute';
	d.style.border='1px solid black'; // FIXME
	var s=document.createElement('div');
	s.className='intervalselector';
	s.style.position='relative';
	s.style.background='orange'; // FIXME
	//s.style.border='2px solid red'; // FIXME
	d.appendChild(s);
	this.box=d;
	this.bar=s;
	var this2=this;
	this.bar.onmousedown=function(e){ this2.mouseDown.apply(this2, [e]); }
	this.box.onmousedown=function(e){ this2.mouseDown.apply(this2, [e]); }
	this.updatePosition();
};
 
IntervalSelector.prototype.updatePosition=function() {
	var d=this.box;
	d.style.width=this.width+'px';
	d.style.height=this.height+'px';
	var s=this.bar;
	s.style.left=(this.lo-this.min)*this.scale+ 'px';
	s.style.width=(this.hi-this.lo)*this.scale + 'px';
	s.style.height=this.height + 'px';
};
 
IntervalSelector.prototype.mouseDown=function(e) {
	var endWidth=8;
	var pos=this.getMousePos(e);
	var this2=this;
 
	var dragFunction=null;
	var leftPos=findPosX(this.bar);
	if (pos.x - leftPos < endWidth) { dragFunction=this2.dragLo; }
	else if ( leftPos + parseInt(this.bar.style.width, 10) - pos.x < endWidth) { dragFunction=this2.dragHi; }
	else { dragFunction = this2.dragBar; }
	var x=pos.x, lo=this.lo;
	if (document.onmousemove && document.onmousemove.origin != 'IntervalSelector') {
		this.oldmousemove = document.onmousemove;
	}
	document.onmousemove=function(e) {
		dragFunction.apply(this2, [e, x, lo]);
		this2.dragging.apply(this2);
	};
	document.onmousemove.origin='IntervalSelector';
	document.onmouseup=function() {
		//console.log(this2.oldmousemove.toString());
		document.onmousemove= this2.oldmousemove;
		this2.doneDrag.apply(this2);
	};
	document.onmouseup.origin='IntervalSelector';
	//document.title=pos.x;
};
 
IntervalSelector.prototype.doneDrag=function(){};
IntervalSelector.prototype.dragging=function(){};
 
IntervalSelector.prototype.dragLo=function(e) {
	var pos=this.getMousePos(e);
	var newLo=this.min + (pos.x - findPosX(this.box))/this.scale;
	if (newLo < this.min) { newLo=this.min; }
	else if (newLo > this.hi - this.minBarWidth/this.scale) { newLo=this.hi - this.minBarWidth/this.scale; }
	this.lo=newLo;
	this.updatePosition();
};
 
IntervalSelector.prototype.dragHi=function(e) {
	var pos=this.getMousePos(e);
	var newHi=this.min + (pos.x - findPosX(this.box))/this.scale;
	if (newHi > this.max) { newHi=this.max; }
	else if (newHi < this.lo + this.minBarWidth/this.scale) { newHi=this.lo + this.minBarWidth/this.scale; }
	this.hi=newHi;
	this.updatePosition();
};
 
IntervalSelector.prototype.dragBar=function(e, x0, l0) {
	var pos=this.getMousePos(e);
	var delta=pos.x-x0;
	var newLo=l0 + delta/this.scale;
	var newHi=newLo + this.hi-this.lo;
	if (newLo < this.min) { newLo=this.min; newHi=newLo+this.hi-this.lo; }
	else if (newHi > this.max) { newHi=this.max; newLo=newHi-(this.hi-this.lo); }
	this.hi=newHi; this.lo=newLo;
	this.updatePosition();
};
 
IntervalSelector.prototype.getMousePos=function(e) {
	e = e || window.event;
	var x, y;
	if (e) {
		if (e.pageX) { x=e.pageX; y=e.pageY; }
		else if (typeof e.clientX!='undefined') {
			var left, top, docElt = window.document.documentElement;
 
			if (docElt) { left=docElt.scrollLeft; }
			left = left || window.document.body.scrollLeft || window.document.scrollLeft || 0;
 
			if (docElt) { top=docElt.scrollTop; }
			top = top || window.document.body.scrollTop || window.document.scrollTop || 0;
 
			x=e.clientX + left;
			y=e.clientY + top;
		} else { throw new Error ('bad mouse wiggle event in getMousePos'); return; }
	}
	return {x:x, y:y};
};
 
window.findPosX=function(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}
 
window.ts2unix=function(ts) {
	var t=ts.toString();
	return +(Date.UTC( t.substring(0,4), parseInt(t.substring(4,6),10)-1, t.substring(6,8),
			   t.substring(8,10), t.substring(10,12), t.substring(12,14)));
}
window.unix2ts=function(u) {
	var d=new Date(u);
	return map(zeroFill, [d.getUTCFullYear(), d.getUTCMonth()+1,
			      d.getUTCDate(), d.getUTCHours(),
			      d.getUTCMinutes(), d.getUTCSeconds()]).join('');
}
 
window.zeroFill=function(s, min) {
	min = min || 2;
	var t=s.toString();
	return repeatString('0', min - t.length) + t;
}
 
window.map=function(f, o) {
	if (isArray(o)) { return map_array(f,o); }
	return map_object(f,o);
}
window.isArray =function(x) { return x instanceof Array; }
 
window.map_array=function(f,o) {
	var ret=[];
	for (var i=0; i<o.length; ++i) {
		ret.push(f(o[i]));
	}
	return ret;
}
 
window.map_object=function(f,o) {
	var ret={};
	for (var i in o) { ret[o]=f(o[i]); }
	return ret;
}
 
window.repeatString=function(s,mult) {
	var ret='';
	for (var i=0; i<mult; ++i) { ret += s; }
	return ret;
};
 
window.formatTs=function(ts) {
	ts=ts.toString();
	if (ts.substring(0,4)=='9999') { return 'now'; }
	return [ts.substring(0,4), ts.substring(4,6), ts.substring(6,8)].join('-') +
	' ' + [ts.substring(8,10),ts.substring(10,12),ts.substring(12,14)].join(':');
};
 
function isMethodOf(klass, fn) {
	for (var f in klass.prototype) {
		if (fn===klass.prototype[f]) { return true; }
	}
	return false;
}
 
popupEditCounterTool='custom';
popupEditCounterUrl='http://el.wikipedia.org/wiki/%CE%A7%CF%81%CE%AE%CF%83%CF%84%CE%B7%CF%82:$1?ectarget=$1';
 
 
var tab_project = 'el.wikipedia.org';
 
// namespace names
var tab_ns_image = 'Εικόνα:';
//var tab_ns_imagetalk = 'Συζήτηση_εικόνας:';
var tab_ns_user = 'Χρήστης:';
//var tab_ns_usertalk = 'Συζήτηση_χρήστη:';
//var tab_ns_category = 'Κατηγορία:';
var tab_ns_special = 'Ειδικό:';
 
// Interface strings
var tab_check_usage = 'έλεγχος χρήσης';
var tab_categorize = 'αναζ. κατηγ.';
var tab_log = 'log';
var tab_gallery = 'gallery';
var tab_orphans = 'ορφανές';
var tab_untagged = 'χωρις άδεια';
var tab_tree = 'Δέντρο';
var tab_catscan = 'CatScan';
var tab_blocklog = 'Blocklog';
var tab_wikipedia = "en";  //this tabname is not likely to change depending on namespace
 
// Appends a new tab.
 
function global_append_tab(url, name, id)
{
  var na = document.createElement('a');
  na.setAttribute('href', url);  
 
  var txt = document.createTextNode(name);
  na.appendChild(txt);
 
  var li = document.createElement('li');
  if(id) li.id = id;
  li.appendChild(na);
 
  // Grab the element we want to append the tab and append the tab to it.
  var c1 = document.getElementById('column-one');
  var tabs = c1.getElementsByTagName('div')[0].getElementsByTagName('ul')[0];
  tabs.appendChild(li);
}
 
function global_add_image_tabs(imagetitle)
{
  imagetitle = imagetitle.substring(imagetitle.indexOf(':') + 1); // strip off "Image:" namespace
 
  global_append_tab('http://tools.wikimedia.de/~daniel/WikiSense/CheckUsage.php?i=' + imagetitle + '&w=_100000', tab_check_usage, 'ca-checkusage');
 
  global_append_tab('http://tools.wikimedia.de/~daniel/WikiSense/CommonSense.php?i=' + imagetitle + '&go-clean=yes' , tab_categorize, 'ca-commonsense');
 
  global_append_tab('/w/index.php?title=' + tab_ns_special + 'Log&page=' + tab_ns_image + imagetitle, tab_log, 'ca-log');
 
  // Add an "unthumb" link.  For Image:123px-Foo, links to Image:Foo.
  if (imagetitle.match(/^\d+px-/))
  {
    // imagetitle = imagetitle.substring(imagetitle.indexOf("px-") + 3);
    imagetitle = imagetitle.replace(/^\d+px-/, '');
    global_append_tab('/wiki/Image:' + imagetitle, 'unthumb', 'ca-unthumb');
  }
 
  // Add a tab going to enwiki
  global_append_tab('http://'+tab_wikipedia+'.wikipedia.org/wiki/Image:' + imagetitle, tab_wikipedia, 'ca-' + tab_wikipedia + 'wiki');
 
}
 
function global_add_user_tabs(username)
{
  // strip off namespaces like "User:"
  // username.split(":")[1] will fail if a colon is not present
  username = username.substring(username.indexOf(':') + 1);
 
  // removing subpages from the link
  // username.split("/")[0] works equally well
  // username = username.replace(/\/.*$/, '');
  username = username.split("/")[0];
 
  global_append_tab('http://tools.wikimedia.de/~daniel/WikiSense/Gallery.php?wikifam=' + tab_project + '&img_user_text=' + username , tab_gallery, 'ca-gallery');
  global_append_tab('http://tools.wikimedia.de/~daniel/WikiSense/OrphanImages.php?wiki=' + tab_project + '&img_user_text=' + username , tab_orphans, 'ca-orphans');
  global_append_tab('http://tools.wikimedia.de/~daniel/WikiSense/UntaggedImages.php?wiki=' + tab_project + '&img_user_text=' + username , tab_untagged, 'ca-untagged');
}
 
function global_add_category_tabs(category)
{
  category = category.substring(category.indexOf(':') + 1); // strip off "Category:" namespace
  // global_append_tab('/wiki/Special:CategoryTree?target=' + category + '&mode=categories&dotree=Laden', tab_tree);
  // global_append_tab('http://tools.wikimedia.de/~daniel/WikiSense/CategoryTree.php?wiki=' + tab_project + '&cat=' + category , tab_tree);
  global_append_tab('http://tools.wikimedia.de/~daniel/WikiSense/CategoryIntersect.php?wiki=' + tab_project + '&basecat=' + category , tab_catscan, 'ca-catscan');
}
 
// On Special:Contributions, we add the user tabs just like for a user page.
// On Special:Blockip, we add a blocklog tab.
function global_add_special_tabs(title)
{
  // Replace with wgPageName
  //  if (title.indexOf(tab_ns_special + 'Blockip') == 0)
  if (wgPageName == "Special:Blockip")
  {
    // so we don't break after blocking
    var username = document.getElementsByName('wpBlockAddress')[0] ? document.getElementsByName('wpBlockAddress')[0].defaultValue : '';
 
    if (username != '')
    {
      global_append_tab('/w/index.php?title=' + tab_ns_special + 'Log&type=block&page=' + tab_ns_user + username, tab_blocklog, 'ca-blocklog');
    }
  }
  // Replace with wgPageName
  // else if (title.indexOf(tab_ns_special + 'Contributions') == 0)
  else if (wgPageName == "Special:Contributions")
  {
    var username = document.getElementById('contentSub').getElementsByTagName('a')[0].firstChild.nodeValue;
    global_add_user_tabs(tab_ns_user + username);
  }
}
 
function global_do_onload()
{
    // extract the namespace
    // var title = global_get_tidy_title();
    var title = wgPageName;
 
    // Namespace numbers are (see [[m:Help:Variables]]):
    // -1: Special
    // 2:  User
    // 3:  User_talk
    // 6:  Image
    // 7:  Image_talk
    // 14: Category
    switch(wgNamespaceNumber)
    {
        case -1:
            global_add_special_tabs(title);
            break;
        case 2:
        case 3:
            global_add_user_tabs(title);
            break;
        case 6:
        case 7:
            global_add_image_tabs(title);
            break;
        case 14:
            global_add_category_tabs(title);
            break;
        default:
            // nothing
    }
}
 
addOnloadHook( global_do_onload );
 
addOnloadHook(function (){
		if(queryString("submitdelete")=="true") document.forms[0].wpConfirmB.click();
	});
	function queryString(p) {
		var re = RegExp('[&?]' + p + '=([^&]*)');
		var matches;
		if (matches = re.exec(document.location)) {
			try { 
				return decodeURI(matches[1]);
			} catch (e) {
			}
		}
		return null;
	};
 
 
/// WikiEd
 
document.write('<script type="text/javascript" src="'
+ 'http://en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.js'
+ '&action=raw&ctype=text/javascript"></script>');
 
/// WikiMiniAtlas
 
document.write('<script type="text/javascript" src="'
+ 'http://meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.js'
+ '&action=raw&ctype=text/javascript"></script>');
 
 
 
//// RBL check
 
addOnloadHook(function () {
    var addr;
    if (wgCanonicalNamespace == "Special" && wgCanonicalSpecialPageName == "Contributions")
        addr = document.forms[0].target.value;
    else if (wgCanonicalNamespace == "Χρήστης" || wgCanonicalNamespace == "Συζήτηση_χρήστη")
        addr = wgTitle;
 
    if (!/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/.test(addr)) return;  // not an IP
 
    addPortletLink('p-tb', 'http://www.robtex.com/rbls/'+addr+'.html',
                   'RBL check', 't-rblcheck', 'Multi-RBL check');
});
 
 
/// Αιτίες διαγραφής 
 
 
if (document.title.indexOf("Επιβεβαίωση διαγραφής") != -1 || document.title.indexOf("Επιβεβαίωση διαγραφής") != -1) {
     var csdDeleteForm = {
				FillSelect:function(sel, arr){
					if(arr && arr.length>0){
						if(arr.length>1){
							var FirstOpt = new Option("Αιτίες ΓΔ", "");
							// catches stupid IE error
							if(FirstOpt.innerHTML != "Αιτίες ΓΔ"){
								FirstOpt.innerHTML = "Αιτίες ΓΔ";
							}
							sel.appendChild(FirstOpt);
							sel.options[0].style.color = "gray"
						}
						sel.disabled = false;
						for(var i=0;i<arr.length;i++){
							var opt = new Option(arr[i].display, arr[i].value);
							// catches stupid IE error
							if(opt.innerHTML != arr[i].display){
								opt.innerHTML = arr[i].display;
							}
							sel.appendChild(opt);
						}
					}else{
						sel.options[0] = new Option("No Options Available", "");
						// catches stupid IE error
						if(sel.options[0].innerHTML != "No Options Available"){
							sel.options[0].innerHTML = "No Options Available";
						}
						sel.disabled = true;
						return false;
					}
					return true;
				},
                                ValueArray:[
                                        {"value":"[[Βικιπαίδεια:Γρήγορη διαγραφή σελίδων#Γενικά|Γ1]]: κείμενο που είναι ακατανόητο/αλαμπουρνέζικα","display":"Γ1 - αλαμπουρνέζικα"},
                                        {"value":"[[Βικιπαίδεια:Γρήγορη διαγραφή σελίδων#Γενικά|Γ2]]: δοκιμαστική σελίδα","display":"Γ2 - δοκιμή"},
                                        {"value":"[[Βικιπαίδεια:Γρήγορη διαγραφή σελίδων#Γενικά|Γ3]]: καθαρός [[Βικιπαίδεια:βανδαλισμός|]]","display":"Γ3 - βανδαλισμός"},
                                        {"value":"[[Βικιπαίδεια:Γρήγορη διαγραφή σελίδων#Γενικά|Γ4]]: επαναδημιουργία διαγραμμένης σελίδας","display":"Γ4 - διαγραμμένη "},
                                        {"value":"[[Βικιπαίδεια:Γρήγορη διαγραφή σελίδων#Γενικά|Γ5]]: συνεισφορά από αποκλεισμένο χρήστη","display":"Γ5 - αποκλεισμένος χρήστης"},
                                        {"value":"[[Βικιπαίδεια:Γρήγορη διαγραφή σελίδων#Γενικά|Γ6]]: προσωρινή διαγραφή για συγχώνευση ιστορικών","display":"Γ6 - συγχώνευση"},
                                        {"value":"[[Βικιπαίδεια:Γρήγορη διαγραφή σελίδων#Γενικά|Γ7]]: ζητήθηκε από τον μοναδικό συνεισφέροντα","display":"Γ7 - αίτηση χρήστη"},
                                        {"value":"[[Βικιπαίδεια:Γρήγορη διαγραφή σελίδων#Γενικά|Γ8]]: σελίδα συζήτησης διαγραμμένης σελίδας","display":"Γ8 - σελίδα συζήτησης"},
                                        {"value":"[[Βικιπαίδεια:Γρήγορη διαγραφή σελίδων#Άρθρα|Α1]]: άρθρο που έχει λίγο ή κανένα περιεχόμενο σχετικά με το αξιόλογο του θέματος","display":"Α1 - πολύ σύντομο"},
                                        {"value":"[[Βικιπαίδεια:Γρήγορη διαγραφή σελίδων#Άρθρα|Α2]]: άρθρο που έχει μόνο εξωτερικούς συνδέσμους","display":"Α2 - εξωτερικοί σύνδεσμοι"},
                                        {"value":"[[Βικιπαίδεια:Γρήγορη διαγραφή σελίδων#Άρθρα|Α5]]: άρθρο για πραγματικό πρόσωπο ή ομάδα προσώπων από το οποίο δεν προκύπτει η δημοσιότητα ή σπουδαιότητα του προσώπου","display":"Α5 - μη σημαντικό"},
                                        {"value":"[[Βικιπαίδεια:Γρήγορη διαγραφή σελίδων#Άρθρα|Α6]]: άρθρο που είναι σαφείς παραβίαση πνευματικών δικαιωμάτων","display":"Α6 - παραβίαση π.δ."},
 
                                        ],
				//**************************** attaching function *****************************************
				// got thIS super handi function from http://www.scottandrew.com he is pretty dang smart **
			        //*****************************************************************************************
				addEvent:function(obj, evType, fn, useCapture){
					//alert(obj);
					if (obj.addEventListener){
						obj.addEventListener(evType, fn, useCapture);
						return true;
					} else if (obj.attachEvent){
						var r = obj.attachEvent("on"+evType, fn);
						return r;
					} else {
						alert("Handler could not be attached");
					}
				}
			}
			function addSelectAfter(){
    				var obj = document.getElementById('wpReason');
    			        // create select using included array
				var sel = document.createElement("SELECT");
				csdDeleteForm .FillSelect(sel, csdDeleteForm .ValueArray);
				// name it
				sel.name = "csdOptions";
				sel.id = "csdOptions";
                                sel.style.marginLeft = "10px";
                                csdDeleteForm .addEvent(sel, "change", csdChangeBox, false);
				// check for next sibling and insert before it or at the end
				if(obj.nextSibling){
					obj.parentNode.insertBefore(sel,obj.nextSibling);
				}else{
					obj.parentNode.appendChild(sel);
				}
			}
			try{
				// add one on load
				csdDeleteForm.addEvent(window, "load", addSelectAfter, false);
			}catch(err){}
}
 
function csdChangeBox() {
                                                         var obj = document.getElementById('wpReason');
                                                         obj.value = document.getElementById('csdOptions').value;
                                                         }
//</source>