User:Kevinalewis/metadatatemp.js

var linkColor = "#002BB8"; var linkLead = '';

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='. Currently a Good Article candidate.';}

else if ( talk.match(/\{\{fac}/i ) ) { otherInfo='. Currently a Featured Article candidate.';}

else if ( talk.match(/\{\{FormerFA2?/i) || talk.match(/currentstatus *= *FFA/i) ) {otherInfo='. A former Featured Article.';}

if ( talk.match(/class *= *a/i) ) { update("#007BFF", "An " + linkLead + "A-class article", otherInfo);}

else if ( talk.match(/\{\{ga[|}]/i ) || talk.match(/currentstatus *= *(ffa\/)?ga/i) ) { update("#007700", 'A Good Article', otherInfo);}

else if ( talk.match(/class *= *b/i) ) { update("#999933", "A " + linkLead + "B-class article", otherInfo);}

else if ( talk.match(/class *= *start/i) ) { update("#BB6600", "A " + linkLead + "Start-class article", otherInfo);}

else if ( talk.match(/class *= *stub/i) ) { update("#990011", "A " + linkLead + "Stub-class article", otherInfo);}

else { update("#000000", "An " + linkLead + "unassessed article", otherInfo);} }

function update(color, slogan, info) { document.getElementsByTagName("h1")[0].style.cssText = "color: " + color + ";"; t = document.getElementById("siteSub").innerHTML; document.getElementById("siteSub").innerHTML = "" + slogan + " " +            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 article", ""); }   else if ( document.getElementById("featured-star") ) {update("#0066CC", 'A Featured Article</a>', "");} else { var url = mw.config.get('wgServer') + mw.config.get('wgScriptPath') + "/index.php?title=Talk:" + wgTitle + "&action=raw"; loadXMLDoc(url); } } }

$(begin);