User:Wrcmills/monobook.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. |
The accompanying .css page for this skin can be added at User:Wrcmills/monobook.css. |
var flameviper = new Object();
flameviper.util = {
getobj:function(id) {
return document.getElementById ?
document.getElementById(id) :
document.all[id];
},
add:function(parent, tag, attr) {
var el = document.createElement(tag);
if (attr) {
for (key in attr) {
el[key] = attr[key];
}
}
return parent.appendChild(el);
},
mousebtnmap:{
ns:[null,1,3,2],
ie:[null,1,2,null,3]
},
xmlhttpreq:function() {
if (window.XMLHttpRequest) {
xmlhttpobj = new XMLHttpRequest()
} else {
try {
xmlhttpobj = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttpobj = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
xmlhttpobj = null;
}
}
}
return xmlhttpobj;
}
};
flameviper.comm = {
doreq:function(url,postdata,headers) {
var req = flameviper.util.xmlhttpreq();
req.open(postdata?"POST":"GET", url, false);
for(header in headers) {
req.setRequestHeader(header,headers[header]);
}
req.send(postdata||null);
return req;
}
};
flameviper.wputil = {
username:function() {
return wgUserName;
//return flameviper.util.getobj("pt-userpage").childNodes[0].childNodes[0].nodeValue;
},
iseditpage:function() {
return document.title.indexOf("Editing ")==0;
},
pagename:function() {
var iseditpage = flameviper.wputil.iseditpage();
return document.title.substr(iseditpage?8:0,document.title.indexOf(" - ")-(iseditpage?8:0));
},
addsidepanel:function(id,label) {
var div = flameviper.util.add(flameviper.util.getobj("column-one"), "div", {className:"portlet",id:id});
flameviper.util.add(div, "H5").innerHTML = label;
flameviper.util.add(flameviper.util.add(div, "div", {className:"pBody"}), "ul");
},
addsidepanelbutton:function(id,label,targhref) {
var li = flameviper.util.add((flameviper.util.getobj(id).getElementsByTagName("ul"))[0],"li");
with(flameviper.util.add(li,"a")) {
innerHTML = label;
href = targhref;
}
return li;
},
setpagecontent:function(pagename,content,summary,watch) {
var prelimresp = flameviper.comm.doreq("/w/index.php?title="+pagename+"&action=submit");
var edittime = prelimresp.responseText.match(/\<input type='hidden' value="(\d+)" name="wpEdittime" \/\>/)[1];
var edittoken = prelimresp.responseText.match(/\<input type='hidden' value="([0-9a-f]+)" name="wpEditToken" \/\>/)[1];
flameviper.comm.doreq("/w/index.php?title="+pagename+"&action=submit",
"wpEdittime="+edittime+
"&wpEditToken="+edittoken+
"&wpTextbox1="+escape(content)+
"&wpSummary="+escape(summary)+
(watch?"&wpWatchthis=on":"")+
"&wpSection=&wpSave=Save+page",
{"Content-Type":"application/x-www-form-urlencoded"});
},
getpagecontent:function (pagename) {
var req = flameviper.comm.doreq("/w/index.php?title="+pagename+"&action=edit");
var content = req.responseText.match(/\<textarea[\w\W]*?\>([\w\W]*?)\<\/textarea\>/)[1];
content = content.replace(/\<\;/gi, "<");
content = content.replace(/\>\;/gi, ">");
content = content.replace(/\"\;/gi, "\"");
content = content.replace(/\&\;/gi, "&");
return content;
}
};
flameviper.statuschanger = new Object();
/* configuration */
// change these to whatever you'd like to show up on your status page.
flameviper.statuschanger.statuscode = {
online:'{{{2|<font color= "green">online</font> }}}',
busy:'{{{3|<font color= "blue">on wikivacation</font>}}}',
offline:'{{{4|<font color= "red">offline</font>}}}'
};
// true to use the personal bar, false to create a panel in the left column
flameviper.statuschanger.usepersonalbar = true;
// true if you'd like your status page on your watchlist
flameviper.statuschanger.watchstatus = true;
/* end configuration */
flameviper.statuschanger.oldonload = window.onload;
window.onload = function() {
if (typeof flameviper.statuschanger.oldonload == "function"){setTimeout('flameviper.statuschanger.oldonload()',50);}
if (flameviper.statuschanger.usepersonalbar) {
var a = flameviper.wputil.addsidepanelbutton("p-personal", "Online",
'javascript:flameviper.statuschanger.setstatus("online")'
);
var b = flameviper.wputil.addsidepanelbutton("p-personal", "Offline",
'javascript:flameviper.statuschanger.setstatus("offline")'
);
var c = flameviper.wputil.addsidepanelbutton("p-personal", "Vacation",
'javascript:flameviper.statuschanger.setstatus("busy")'
);
a.style.borderRight=b.style.borderRight="1px solid #aaaaaa";
b.style.marginLeft=c.style.marginLeft="0px";
a.style.paddingRight=b.style.paddingLeft=b.style.paddingRight=c.style.paddingLeft="2px";
} else {
flameviper.wputil.addsidepanel("tz-statuschanger", "status changer");
flameviper.wputil.addsidepanelbutton("tz-statuschanger", "Online",
'javascript:flameviper.statuschanger.setstatus("online")'
);
flameviper.wputil.addsidepanelbutton("tz-statuschanger", "Busy",
'javascript:flameviper.statuschanger.setstatus("busy")'
);
flameviper.wputil.addsidepanelbutton("tz-statuschanger", "Offline",
'javascript:flameviper.statuschanger.setstatus("offline")'
);
}
};
flameviper.statuschanger.setstatus = function(statusname) {
flameviper.wputil.setpagecontent(
"User:"+flameviper.wputil.username()+"/Status",
flameviper.statuschanger.statuscode[statusname],
statusname,
flameviper.statuschanger.watchstatus);
};