Jump to content

User:Gerbrant/edit/blame.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
new function()
{
	var settings, self = this, myWin = null, div;
	try{  settings = Gerbrant.edit.blame;  }catch(nosettings){}
	if(!settings) settings = {};
	//Test settings here, like this: if(!settings.onAllPages && !isJsPage) return;

	function refreshWindow()
	{
		var i, t = [
'<form action="http://wikipedia.ramselehof.de/wikiblame.php" method="post">\
<input type="hidden" name="lang" value="en">\
<input type="hidden" name="project" value="wikipedia">\
<table style="background:none">\
<tr><td align="right">Article</td><td><input type="text" name="article" value="',
wgPageName,
'" size="21"></td></tr>\
<tr><td align="right">Search for</td><td><input type="text" name="needle" value="" size="21"></td></tr>\
<tr><td align="right">Always skip</td><td><input type="text" name="skipversions" value="0" size="11"> versions</td></tr>\
<tr><td align="right">Ignore first</td><td><input type="text" name="ignorefirst" value="0" size="11"> versions</td></tr>\
<tr><td align="right">Check</td><td><input type="text" name="limit" value="500" size="11"> versions</td></tr>\
<tr><td align="right">Starting date</td><td><select name="offtag" size="auto">'];
		var f = function(a, b, s)
		{
			for(i = a; i < s; i++) t.push('<option value="', i, '">', i, '</option>');
			t.push('<option value="', s, '" selected>', s, '</option>');
			for(i = s + 1; i <= b; i++) t.push('<option value="', i, '">', i, '</option>');
		}, d = new Date(), y = d.getFullYear();
		f(1, 31, d.getDate());
		t.push(
'</select>&nbsp;<select name="offmon" size="auto">');
		f(1, 12, d.getMonth() + 1);
		t.push(
'</select>&nbsp;<select name="offjahr" size="auto">');
		f(2002, y, y);
		t.push(
'</select></td>\
<tr><td align="right">Start with</td><td>\
<input id="Gerbrant-edit-blame-desc" type="radio" name="order" value="desc" checked><label for="Gerbrant-edit-blame-desc">latest</label>\
<input id="Gerbrant-edit-blame-asc" type="radio" name="order" value="asc"><label for="Gerbrant-edit-blame-asc">oldest</label></td></tr>\
<tr><td align="right">Search method</td><td>\
<input id="Gerbrant-edit-blame-lin" type="radio" name="searchmethod" value="lin"><label for="Gerbrant-edit-blame-lin">linear</label>\
<input id="Gerbrant-edit-blame-int" type="radio" name="searchmethod" value="int" checked><label for="Gerbrant-edit-blame-int">interpolated</label></td></tr>\
<tr><td colspan="2" align="center"><input type="submit" value="Start"></td></table></form>');
		div.innerHTML = t.join("");
	}
 
	this.show = function()
	{
		if(myWin == null)
		{
			myWin = new Gerbrant.gui.window("Blame");
			div = myWin.getContent();
		}
		refreshWindow();
	}
	this.caption = "Blame";
 
	loadModules(["Gerbrant.gui.window", "Gerbrant.gui.toolbox"], function()
	{
		module("Gerbrant.edit.blame", self);
		if(!settings.notInToolbox) Gerbrant.gui.toolbox.addObject(self);
	});
}