Jump to content

User:Salix alba/mathcite.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
var tags = document.getElementsByTagName("span");
for(var i=0;i<tags.length;++i) {
 var tag=tags[i];
 if(tag.getAttribute('class') == "Z3988") {
  var title = tag.getAttribute('title').replace(/\+/g," ");
  var parts = title.split("&");
  var res=""; //<br/>" + title + "<br/>";
  var o = new Object();
  for(var j=0;j<parts.length;++j) {
   var keyval = parts[j].split("=");
   var decoded = decodeURIComponent(keyval[1]);
   var replaced = decoded.replace(/[\[]http(\S+) ([^\]]*)[\]]/g,"<a href=\"http$1\">$2</a>");
   //res += keyval[0] + "=[" + keyval[1] + "]<br/>\n" + decoded + "<br/>\n" + replaced + "<br/>\n";
   //res += "["+parts[j]+"]";
   res += keyval[0] + "=" + replaced + "<br/>\n";
   if(keyval[0].substring(0,4) == "rft.")
	o[keyval[0].substring(4)]=replaced;
  }
  tag.innerHTML = "<br/>" + res;
 }
}