User:StonedChipmunk/avm.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
Documentation for this user script can be added at User:StonedChipmunk/avm. |
//<nowiki>
topaz.statuschanger_avm = new Object();
/* 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.statuschanger_avm.statuscode = {
overload:'<center>The AVM displays my current frequency of fighting vandalism.<br>Low Med High<br>[[Image:Red pog.svg|20px|Low]] [[Image:Orange pog.svg|20px|Medium]] [[Image:Green pog.svg|20px|High]]<br>[[Image:Blue pog.svg|60px|OVERLOAD!]]<br>Status: OVERLOAD!</center>',
high:'<center>The AVM displays my current frequency of fighting vandalism.<br>Low Med High<br>[[Image:Red pog.svg|20px|Low]] [[Image:Orange pog.svg|20px|Medium]] [[Image:Green pog.svg|20px|High]]<br>[[Image:Green pog.svg|60px|High]]<br>Status: High</center>',
medium:'<center>The AVM displays my current frequency of fighting vandalism.<br>Low Med High<br>[[Image:Red pog.svg|20px|Low]] [[Image:Orange pog.svg|20px|Medium]] [[Image:Green pog.svg|20px|High]]<br>[[Image:Orange pog.svg|60px|Medium]]<br>Status: Medium</center>',
low:'<center>The AVM displays my current frequency of fighting vandalism.<br>Low Med High<br>[[Image:Red pog.svg|20px|Low]] [[Image:Orange pog.svg|20px|Medium]] [[Image:Green pog.svg|20px|High]]<br>[[Image:Red pog.svg|60px|Low]]<br>Status: Low</center>'
};
// this will make wikimarkup work in your stauscodes but will disable auto-updating
topaz.statuschanger_avm.enablewikimarkup = true;
// true to use the personal bar, false to create a panel in the left column
topaz.statuschanger_avm.usepersonalbar = false;
// true if you'd like your status page on your watchlist
topaz.statuschanger_avm.watchstatus = false;
/* end configuration */
topaz.statuschanger_avm.buttonlist = {};
topaz.statuschanger_avm.oldonload = window.onload;
window.onload = function() {
if (typeof topaz.statuschanger_avm.oldonload == "function") {
setTimeout('topaz.statuschanger_avm.oldonload()',50);
}
if (!topaz.statuschanger_avm.usepersonalbar) {
topaz.wputil.addsidepanel("tz-statuschanger", "status changer");
}
var buttonlist = [];
for (status in topaz.statuschanger_avm.statuscode) {
buttonlist.push(status);
topaz.statuschanger_avm.buttonlist[status] =
topaz.wputil.addsidepanelbutton(
topaz.statuschanger_avm.usepersonalbar ? "p-personal" : "tz-statuschanger",
status,
'javascript:topaz.statuschanger_avm.setstatus("' + status + '")'
);
}
if (topaz.statuschanger_avm.usepersonalbar) {
for(var i=0; i<buttonlist.length; i++) {
with (topaz.statuschanger_avm.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.statuschanger_avm.curstatus."+escape(topaz.wputil.username())) {
topaz.util.cookie.set("topaz.statuschanger_avm.curstatus", spanlist[i].innerHTML);
}
}
topaz.statuschanger_avm.update();
};
topaz.statuschanger_avm.setstatus = function(statusname) {
topaz.wputil.setpagecontent(
"User:"+topaz.wputil.username()+"/AVM",
(!topaz.statuschanger_avm.enablewikimarkup ?
'<includeonly><span class="topaz.statuschanger_avm.inlinestatus.'
+ escape(topaz.wputil.username())
+ '"></includeonly>'
: '') +
topaz.statuschanger_avm.statuscode[statusname] +
(!topaz.statuschanger_avm.enablewikimarkup ?
'<includeonly></span></includeonly>'
: '') +
'<span class="topaz.statuschanger_avm.curstatus.'+escape(topaz.wputil.username()) +
'" style="display:none">'+statusname+'</span>',
statusname,
topaz.statuschanger_avm.watchstatus);
topaz.util.cookie.set("topaz.statuschanger_avm.curstatus", statusname);
topaz.statuschanger_avm.update();
};
topaz.statuschanger_avm.laststatus = null;
topaz.statuschanger_avm.update = function() {
var curstatus = topaz.util.cookie.get("topaz.statuschanger_avm.curstatus");
if (curstatus && curstatus != topaz.statuschanger_avm.laststatus) {
for (status in topaz.statuschanger_avm.buttonlist) {
with (topaz.statuschanger_avm.buttonlist[status].style) {
if (status == curstatus) {
fontWeight = "bold";
} else {
fontWeight = "normal";
}
}
}
if (!topaz.statuschanger_avm.enablewikimarkup) {
var spanlist = document.getElementsByTagName("span");
for (var i=0; i<spanlist.length; i++) {
if (spanlist[i].className == "topaz.statuschanger_avm.inlinestatus."+escape(topaz.wputil.username())) {
spanlist[i].innerHTML = topaz.statuschanger_avm.statuscode[curstatus];
}
}
}
}
topaz.statuschanger_avm.laststatus = curstatus;
};
setInterval("topaz.statuschanger_avm.update()", 5000);
//</nowiki>