User:Seren-dipper/short-title.js

/* ======================================= */ /* Start of: short-title.js */ /* Copied 2010-10-06 from: */ /* http://en.wikipedia.org/wiki/User:PleaseStand/short-title.js */ /* I have just changed (shortened): «"WP:"» into: «"W:"» */ /* and changed the separating characters between */ /* and from " - " to " @ ". */ /* The rest is as the original (last modified on 2010-10-06 at 00:25:44). */ /* --- */ // Released into the public domain  /*global $, document, wgAction, wgArticleId, wgContentLanguage, wgCurRevisionId, wgFormattedNamespaces, wgNamespaceNumber, wgScriptPath, wgTitle, window*/ (function{	if(wgAction == "view" && wgNamespaceNumber >= 0) {		var nsPrefix, shortcut;		switch(wgNamespaceNumber) {			case 0: nsPrefix = ""; break; // (Main)			case 4: nsPrefix = "W:"; break; // Wikipedia			case 5: nsPrefix = "WT:"; break; // Wikipedia talk			default: nsPrefix = wgFormattedNamespaces[wgNamespaceNumber] + ":";		}		shortcut = nsPrefix + wgTitle;	       $.getJSON(wgScriptPath + "/api.php", {format: "json", maxage: 86400, action: "query", revids: wgCurRevisionId, prop: "revisions"}, function(data) { try { var isoDate = data.query.pages[wgArticleId].revisions[0].timestamp; document.title = shortcut + " @ " + isoDate.replace(/T.*$/, "") + " Wikipedia," + wgContentLanguage.toUpperCase; } catch(e) {} });	} else {		document.title = window.document.title.replace(/ \- [^\-]*$/, " - " + "Wikipedia," + wgContentLanguage.toUpperCase);	} }); /* End of: short-title.js */ /* ======================================= */