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

Content deleted Content added
link to required js
use addPortletLink; combine onload hook for adding purge and last tabs
Line 21:
// 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];
addlilinkaddPortletLink(tabs'p-cactions', url, name, id, title, key);
 
// Add tab to the bottom if the tabs have been cloned
addlilinkaddPortletLink(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 () {
var x = document.getElementById('ca-history');
if(!x) return;
 
if(x.children) x = x.children[0].href;
else x = x.childNodes[0].href;
 
addTab(x.replace(/=history/, "=purge"), 'purge', 'ca-purge',
'Purge the internal cache for this page', 'g');
});
 
// Add a 'last' link to the tabs to show last diff
addOnloadHook(function () {
var x = document.getElementById('ca-history');
Line 52 ⟶ 36:
else x = x.childNodes[0].href;
 
addTab(x.replace(/action=history/, "action=purge"), 'purge', 'ca-purge',
'purge', 'ca-purge', 'Purge the internal cache for this page', 'g');
addTab(x.replace(/action=history/, "diff=cur&oldid=prev"),
'last', 'ca-last', 'Show most recent diff');