MediaWiki:Gadget-SimplifyRefNotesTag.js

注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google ChromeFirefoxMicrosoft EdgeSafari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。

window.simplifyRefNotesTag=function(){

 var i,j;

 function num2alp(n){    //本功能將數字按順序轉為英文字母;
  var chk=parseInt(n);
  if(isNaN(chk)) return null;

  var digit=new Array();
  var result="";
  
  while(chk>0){
   digit.unshift(chk%26);
   chk=Math.floor(chk/26);
  }
  
  for(var j=digit.length; j-->0; ){
   if(digit[j]<=0){
    if(j>0){
     digit[j]+=26;
     digit[j-1]-=1;
    }else{
     break;
    }
   }
    
   result=String.fromCharCode("a".charCodeAt(0)+(digit[j]-1))+result;
  }
  
  return result;
 }   //功能結束;
 
 //將各上標簡化開始;
 var sups=document.getElementsByTagName("sup");
 var sup_textnode;

 var temp, num, alp;

 for(i=sups.length; i-->0; ){
  if(sups[i].className=="reference" && (""+sups[i].id).indexOf("cite_ref")==0)
  if(sups[i].childNodes.length==1)
  if( (""+sups[i].childNodes[0].tagName).toLowerCase()=="a")
  if(sups[i].childNodes[0].childNodes.length==1)
  if( (""+sups[i].childNodes[0].childNodes[0].nodeName)=="#text")
  if(sups[i].childNodes[0].childNodes[0].nodeValue.indexOf("[")==0 || !isNaN(sups[i].childNodes[0].childNodes[0].nodeValue.charAt(0)) )
  if((sups[i].childNodes[0].childNodes[0].nodeValue+sups[i].group_name).match(/[參参註注]/g) ){
   sup_textnode=sups[i].childNodes[0].childNodes[0];
   
   if(sups[i].parentNode.id=="refTag-cite_ref-sup"){
    temp=sup_textnode.nodeValue.split(/[參参] /g);
    sup_textnode.nodeValue=temp.join("");
   }else if(sups[i].parentNode.id=="noteTag-cite_ref-sup"){
    temp=sup_textnode.nodeValue.split(/[註注] /g);

    for(j=temp[temp.length-1].length; j-->0; ){
     if( !isNaN(temp[temp.length-1].charAt(j)) ) break;
    }

    num=parseInt(temp[temp.length-1].substring(0,j+1));

    temp[temp.length-1]=num2alp(num)+temp[temp.length-1].substring(j+1);
    sup_textnode.nodeValue=temp.join("");
   }
  }
 }
 //將各上標簡化結束;

 //將備註列表項目用英文字母排序;
 if(document.getElementById("references-NoteFoot")){
  var ol=document.getElementById("references-NoteFoot").getElementsByTagName("ol");  
  for(i=ol.length; i-->0; ){
   if(ol[i].className=="references") ol[i].type="a";
  }
 }

 window.simplifyRefNotesTag=function(){};
}

window.load_Merge_Simplify=function(){
 if( (""+(typeof window.mergeRefBracket)).toLowerCase()=="function") window.mergeRefBracket();
 if( (""+(typeof window.simplifyRefNotesTag)).toLowerCase()=="function") window.simplifyRefNotesTag();

 window.load_Merge_Simplify=function(){};
}

$( function(){
 window.load_Merge_Simplify();
});