User:Outriggr/metadata.js
From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Firefox/Mozilla/Safari: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Internet Explorer: press Ctrl-F5, Opera/Konqueror: press F5.
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 = wgServer + wgScriptPath + "/index.php?title=Talk:" + wgTitle + "&action=raw"; loadXMLDoc(url); } } } addOnloadHook(begin);