User:Aboutmovies/metadatatest.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:Aboutmovies/metadatatest. |
var linkColor = "#002BB8";
var linkLead = '<a style="color:' + linkColor + ';" href="/wiki/Category:Wikipedia 1.0 assessments">';
function loadXMLDoc(url)
{
// branch for native XMLHttpRequest object
if (window.XMLHttpRequest) {
var tpreq = new XMLHttpRequest();
}
// branch for IE/Windows ActiveX version
else if (window.ActiveXObject) {
var tpreq = new ActiveXObject("Microsoft.XMLHTTP");
}
if (tpreq) {
tpreq.onreadystatechange = function () {
if (tpreq.readyState==4) {
// if "OK"
if (tpreq.status==200) {
getAssessment(tpreq);
}
// else { alert("Problem retrieving data:" + tpreq.statusText); }
}
// else { alert("Problem retrieving data:" + tpreq.statusText); }
};
tpreq.open("GET", url, true);
tpreq.send("");
}
}
function getAssessment(myreq)
{
var talk = myreq.responseText; //.toLowerCase();
var otherInfo = "";
if ( talk.match( /\{\{ganominee/i ) ) { otherInfo='. <i>Currently a <a href="' + wgServer + '/w/index.php?title=Wikipedia:Good_article_candidates" style="color:' + linkColor + ';">Good Article candidate</a></i>.';}
else if ( talk.match(/\{\{fac}/i ) ) { otherInfo='. <i>Currently a <a href="' + wgServer + '/w/index.php?title=Wikipedia:Featured_article_candidates/' + wgPageName + '&redirect=no" style="color:' + linkColor + ';">Featured Article candidate</a></i>.';}
else if ( talk.match(/\{\{FormerFA2?/i) || talk.match(/currentstatus *= *FFA/i) ) {otherInfo='. <i>A <a href="' + wgServer + '/w/index.php?title=Category:Wikipedia former featured articles" style="color:' + linkColor + ';">former</a> Featured Article</i>.';}
if ( talk.match(/class *= *a/i) ) { update("#007BFF", "An " + linkLead + "A-class</a> article", otherInfo);}
else if ( talk.match(/\{\{ga[|}]/i ) || talk.match(/currentstatus *= *(ffa\/)?ga/i) ) { update("#007700", 'A <a style="color:' + linkColor + ';" href="/wiki/Wikipedia:Good Articles">Good Article</a>', otherInfo);}
else if ( talk.match(/class *= *b/i) ) { update("#999933", "A " + linkLead + "B-class</a> article", otherInfo);}
else if ( talk.match(/class *= *start/i) ) { update("#BB6600", "A " + linkLead + "Start-class</a> article", otherInfo);}
else if ( talk.match(/class *= *stub/i) ) { update("#990011", "A " + linkLead + "Stub-class</a> article", otherInfo);}
else { update("#000000", "An " + linkLead + "unassessed</a> article", otherInfo);}
}
function update(color, slogan, info) {
document.getElementsByTagName("h1")[0].style.cssText = "color: " + color + ";";
t = document.getElementById("siteSub").innerHTML;
document.getElementById("siteSub").innerHTML = "<i>" + slogan + "</i> " + t.charAt(0).toLowerCase() + t.substring(1) + info;
}
function begin() {
if ( wgNamespaceNumber==0 && !location.pathname.match('/w/index.php') ) {
if ( document.getElementById("ca-talk").className == "new" ) {
update("#000000", "An " + linkLead + "unassessed</a> article", "");
}
else if ( document.getElementById("featured-star") ) {update("#0066CC", 'A <a style="color:' + linkColor + ';" href="/wiki/Wikipedia:Featured Articles">Featured Article</a>', "");}
else {
var url = mw.config.get('wgServer') + mw.config.get('wgScriptPath') + "/index.php?title=Talk:" + wgTitle + "&action=raw";
loadXMLDoc(url);
}
}
}
$(begin);