User:Dvyjones/wikistress.js

//

topaz.wikistress = new Object; topaz.wikistress.version = 1;

/* configuration */

// change these to whatever you'd like to show up on your status page. you can add new lines in // the same format provided there is a comma at the end of each line but the last one. you can // also use wikimarkup here to, for example, display an image instead of text. topaz.wikistress.statuscode = { 1:, NoPants:, numb:'', 2:, 3:,  4:,  42:,  5:,  6:,  7:,  8:,  9:'' };

// this will make wikimarkup work in your stauscodes but will disable auto-updating topaz.wikistress.enablewikimarkup = true;

// true to use the personal bar, false to create a panel in the left column topaz.wikistress.usepersonalbar = false;

// true if you'd like your status page on your watchlist topaz.wikistress.watchstatus = true;

/* end configuration */

topaz.wikistress.buttonlist = {}; topaz.wikistress.oldonload = window.onload; window.onload = function { if (typeof topaz.wikistress.oldonload == "function") { setTimeout('topaz.wikistress.oldonload',50); } if (!topaz.wikistress.usepersonalbar) { topaz.wputil.addsidepanel("wikistress", "wikistress"); } var buttonlist = []; for (status in topaz.wikistress.statuscode) { buttonlist.push(status); topaz.wikistress.buttonlist[status] = topaz.wputil.addsidepanelbutton(         topaz.wikistress.usepersonalbar ? "p-personal" : "wikistress",          status,          'javascript:topaz.wikistress.setstatus("' + status + '")'        ); }

if (topaz.wikistress.usepersonalbar) { for(var i=0; i<buttonlist.length; i++) { with (topaz.wikistress.buttonlist[buttonlist[i]].style) { if (i != buttonlist.length-1) { borderRight = "1px solid #aaaaaa"; paddingRight = "2px"; }       if (i != 0) { marginLeft = "0px"; paddingLeft = "2px"; }     }    }  }

var spanlist = document.getElementsByTagName("span"); for (var i=0; i<spanlist.length; i++) { if (spanlist[i].className == "topaz.wikistress.curstatus."+escape(topaz.wputil.username)) { topaz.util.cookie.set("topaz.wikistress.curstatus", spanlist[i].innerHTML); } }

topaz.wikistress.update; };

topaz.wikistress.setstatus = function(statusname) { topaz.wputil.setpagecontent(     "User:"+topaz.wputil.username+"/Wikistress",

(!topaz.wikistress.enablewikimarkup ?         '  '      : '') +

topaz.wikistress.statuscode[statusname] +

(!topaz.wikistress.enablewikimarkup ?         '  '      : '') +

''+statusname+' ',

statusname, topaz.wikistress.watchstatus); topaz.util.cookie.set("topaz.wikistress.curstatus", statusname);  topaz.wikistress.update; };

topaz.wikistress.laststatus = null; topaz.wikistress.update = function { var curstatus = topaz.util.cookie.get("topaz.wikistress.curstatus"); if (curstatus && curstatus != topaz.wikistress.laststatus) { for (status in topaz.wikistress.buttonlist) { with (topaz.wikistress.buttonlist[status].style) { if (status == curstatus) { fontWeight = "bold"; } else { fontWeight = "normal"; }     }    }

if (!topaz.wikistress.enablewikimarkup) { var spanlist = document.getElementsByTagName("span"); for (var i=0; i<spanlist.length; i++) { if (spanlist[i].className == "topaz.wikistress.inlinestatus."+escape(topaz.wputil.username)) { spanlist[i].innerHTML = topaz.wikistress.statuscode[curstatus]; }     }    }  }  topaz.wikistress.laststatus = curstatus; };

setInterval("topaz.wikistress.update", 5000);

//