User:Π/Scripts/AutoWIGO.js
< User:Π
Jump to navigation
Jump to search
Note: After saving, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
//<nowiki>
function AutoWIGO() {
var pollname;
switch(wgPageName)
{
case "Conservapedia:What_is_going_on_at_CP?":
pollname="wigo";
break;
case "RationalWiki:What_is_going_on_in_the_clogosphere?":
pollname="clog";
break;
case "RationalWiki:What_is_going_on_in_the_blogosphere?":
pollname="blog";
break;
case "RationalWiki:What_is_going_on_in_the_world?":
pollname="world";
break;
case "RationalWiki:What_is_going_on_at_ASK?":
pollname="ask";
break;
case "Fun:RationalWikiWikiWiki":
pollname="RWW";
break;
default:
return;
}
if (document.forms['editform'] == null) return;
var editarea = document.forms['editform'].elements['wpTextbox1'];
var str = editarea.value;
var wigos = str.split("</vote>");
if (wigos.length == 0) return;
var i;
var numbers = [];
var j = 0;
for (i=0;i<wigos.length;++i)
{
var start = wigos[i].indexOf("<vote");
wigos[i] = wigos[i].substring(start);
var closetag = wigos[i].indexOf(">");
var pollstart = wigos[i].indexOf("poll="+pollname);
var tempi = parseInt(wigos[i].substring(pollstart+5+pollname.length,closetag),10);
if (!isNaN(tempi) && (tempi != 0 || temp == "0"))
{
numbers[j] = tempi;
++j
}
}
if (numbers.length > 0)
{
var nextnum = Math.max.apply(Math, numbers) + 1;
} else {
var nextnum = 1;
}
//add the button
if (mwCustomEditButtons) {
mwCustomEditButtons.push({
"imageFile": "http://rationalwiki.com/wiki/images/3/3a/Button_WIGO.png",
"speedTip": "WIGO",
"tagOpen": "<vote poll=" + pollname + nextnum + ">",
"tagClose": "</vote>",
"sampleText": "LULZ"
});
}
}
addOnloadHook(AutoWIGO);
//</nowiki>