User:Vito Genovese/Template helper/Reflist.js

// *************************************************************************************** // TEMPLATE HELPER // *************************************************************************************** // No information page yet - Reference section module // *************************************************************************************** // *************************************************************************************** // INFORMATION // *************************************************************************************** // Author                           : w:User:ais523 // Enhancements                     : w:User:Alai ve w:User:jj137 // Fixes                            : w:User:Zro ve w:User:Amalthea // Source                           : en:User:Zro/stubtagtab3.js // Info                             : No documentation yet // Localization                     : User:Vito Genovese // *************************************************************************************** // CODE // ***************************************************************************************

function threflist { if(wgNamespaceNumber==0) { thAddPortletLink( "javascript:reflisttab", "Reflist", "ca-reflisttab", "Add references section to the articles", ""); } if(location.href.indexOf("&autoaddreflist=")!=-1&&document.getElementById('wpTextbox1')!=null) {   var x=decodeURIComponent(location.href.split("&autoaddreflist=")[1]); y="subst:"; document.editform.wpTextbox1.value = document.editform.wpTextbox1.value + "\n{"+"{"+y+x+"}}" document.getElementById('wpSummary').value= "Adding \"References\" using Template Helper"; document.getElementById('wpPreview').click; } } window.temphelpInit= (window.temphelpInit|| []).concat(threflist); //schedule initializer

function reflisttab { var h;  // Subpages var a=['Reflist']; var i=0; h=" &bull; "; while(i"+a[i]+" &bull; "; i++; } h+="  "; document.getElementById("contentSub").innerHTML=h; } function reflistmenurender(a) {

if(a.readyState != 4){ document.getElementById('reflistmenudiv').innerHTML= "Loading, please wait..."; return; }

if(a.responseText.indexOf('') ==-1 ){ document.getElementById('reflistmenudiv').innerHTML= "Something is wrong. Problem with the category perhaps?"; return; }

var s=a.responseText.split('')[1].split(" ")[0]; s=s.split("&lt;").join("<").split("&gt;").join(">"); s=s.split("&quot;").join('"').split("&amp;").join('&'); s=s.split('<a href="/wiki/Template:'); var i=s.length; while(--i) s[i]=s[i].split('" title').join('\');" title'); s=s.join('<a temphref="javascript:reflistwith(\);  s=s.split('<a href=').join('<a style="color:#000000;" notanhref=');  s=s.split('<a temphref=').join('<a href=');  document.getElementById('reflistmenudiv').innerHTML=s; } function reflistmenu(x) {  //Fetch the relevant subpage  var a = sajax_init_object;  a.open('GET',mw.config.get('wgServer')+mw.config.get('wgScriptPath')+'/api.php?action=parse&prop=text&text='+    encodeURIComponent()+'&format=xml');  a.onreadystatechange = function{reflistmenurender(a)};  a.send(''); } function reflistwith(x) {  if(x==null||x=="") return;  location.href=mw.config.get('wgServer')+mw.config.get('wgScript')+"?title="+encodeURIComponent(mw.config.get('wgPageName'))+                                                  "&action=edit&autoaddreflist="+encodeURIComponent(x); } //