User:Mike Dillon/Scripts/tabs.js: Difference between revisions

Content deleted Content added
No edit summary
m Maintenance: Fixing deprecated call to addPortletLink (mw:ResourceLoader/Migration_guide_(users)#addPortletLink)
 
(12 intermediate revisions by one other user not shown)
Line 1:
// Requires: addlilink()[[User:Mike Dillon/Scripts/i18n.js]]
 
/* <pre><nowiki> */
 
/* Messages */
// Duplicate link tab from the top to the bottom of the content area
wfAddMsg("en", "purgeTabLabel", "Purge");
function morelinks() {
wfAddMsg("es", "purgeTabLabel", "Purgar");
var tabs = document.getElementById('p-cactions').cloneNode(true);
wfAddMsg("en", "purgeTabTitle", "Purge this page from the server cache");
tabs.id = 'mytabs';
wfAddMsg("es", "purgeTabTitle", "Purgar esta página del cache de servidor");
var listitems = tabs.getElementsByTagName('LI');
 
for (i=0;i<listitems.length;i++) {
wfAddMsg("en", "lastDiffTabLabel", "Last");
if(listitems[i].id) listitems[i].id = 'mytabs-' + listitems[i].id;
wfAddMsg("es", "lastDiffTabLabel", "Previa");
}
wfAddMsg("en", "lastDiffTabTitle", "Show differences between this revision and the previous");
document.getElementById('column-content').appendChild(tabs);
wfAddMsg("es", "lastDiffTabTitle", "Mostrar las diferencias entre esta revisión y la previa");
}
addOnloadHook(morelinks);
 
// Add a new list item to the page tabs
function addTab(url, name, id, title, key) {
// Add tab to the top tabs
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
addlilinkmw.util.addPortletLink(tabs'p-cactions', url, name, id, title, key);
 
// Add tab to the bottom if the tabs have been cloned
addlilinkmw.util.addPortletLink(bottomTabs'mytabs', url, name, 'mytabs-' + id, title, key);
var bottomTabsContainer = document.getElementById('mytabs');
if (bottomTabsContainer != null) {
var bottomTabs = bottomTabsContainer.getElementsByTagName('ul')[0];
addlilink(bottomTabs, url, name, 'mytabs-' + id, title, key);
}
}
 
// Add a 'purge' linkand 'last' links to the tabs
addOnloadHook(function addPurge() {
var x = document.getElementById('ca-history');
if(!x) return;
Line 36 ⟶ 31:
else x = x.childNodes[0].href;
 
addTab(x.replace(/action=history/, "action=purge"), 'purge', 'ca-purge',
wfMsg("purgeTabLabel"), 'ca-purge', wfMsg("purgeTabTitle"));
'Purge the internal cache for this page', 'g');
addTab(x.replace(/action=history/, "diff=" + wgCurRevisionId + "&oldid=prev"),
}
wfMsg("lastDiffTabLabel"), 'ca-last', wfMsg("lastDiffTabTitle"));
addOnloadHook(addPurge);
});
 
// Add a 'last' link to the tabs to show last diff
function doLastDiff() {
var nurl = wgServer + wgScriptPath + "/index.php?title=" + escape(wgPageName) + "&diff=cur&oldid=prev";
document.___location = nurl
}
function addLastDiff() {
var x = document.getElementById('ca-history');
if(!x) return;
 
addTab('javascript:doLastDiff()', 'last', 'ca-last', 'Show most recent diff');
}
addOnloadHook(addLastDiff);
 
/* </nowiki></pre> */