User:Vito Genovese/Template helper/Reflist.js
Appearance
Note: After saving, changes may not occur immediately. Click here to learn how to bypass your browser's cache.
- Mozilla / Firefox / Safari: hold down Shift while clicking Reload, or press Ctrl-Shift-R (Cmd-Shift-R on Apple Mac);
- Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5;
- Konqueror: simply click the Reload button, or press F5;
- Opera users may need to completely clear their cache in Tools→Preferences.
Warning: Malicious code can compromise your account. Page preview will cause your web browser to execute this page's content as code under some skins, including Monobook. If you have any questions about any code you plan to add, you can ask at the appropriate reading room. |
This script seems to have a documentation page at User:Vito Genovese/Template helper/Reflist. |
// ***************************************************************************************
// 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="<div style='color:#000000; background-color:#fff8f8;'>• ";
while(i<a.length)
{
h+="<a href='javascript:reflistmenu(\""+a[i]+"\");'>"+a[i]+"</a> • ";
i++;
}
h+="</div><div id='reflistmenudiv' style='color:#000000; background-color:#fffff8;'></div>";
document.getElementById("contentSub").innerHTML=h;
}
function reflistmenurender(a)
{
if(a.readyState != 4){
document.getElementById('reflistmenudiv').innerHTML= "<i>Loading, please wait...</i>";
return;
}
if(a.responseText.indexOf('<text xml:space="preserve">') ==-1 ){
document.getElementById('reflistmenudiv').innerHTML= "<i>Something is wrong. Problem with the category perhaps?</i>";
return;
}
var s=a.responseText.split('<text xml:space="preserve">')[1].split("</text>")[0];
s=s.split("<").join("<").split(">").join(">");
s=s.split(""").join('"').split("&").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('__NOTOC____NOEDITSECTION__{{User:Vito_Genovese/Template_helper/'+
x+'}}')+'&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);
}
// </source>