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

Content deleted Content added
link to required js
m Maintenance: Fixing deprecated call to addPortletLink (mw:ResourceLoader/Migration_guide_(users)#addPortletLink)
 
(10 intermediate revisions by one other user not shown)
Line 1:
// Requires: [[User:Mike Dillon/Scripts/addlilinki18n.js]]
 
/* <pre><nowiki> */
 
/* Messages */
// Duplicate link tab from the top to the bottom of the content area
wfAddMsg("en", "purgeTabLabel", "Purge");
addOnloadHook(function () {
wfAddMsg("es", "purgeTabLabel", "Purgar");
// Clone the original tabs and change the id to "mytabs"
wfAddMsg("en", "purgeTabTitle", "Purge this page from the server cache");
var tabs = document.getElementById('p-cactions').cloneNode(true);
wfAddMsg("es", "purgeTabTitle", "Purgar esta página del cache de servidor");
tabs.id = 'mytabs';
 
wfAddMsg("en", "lastDiffTabLabel", "Last");
// Find individual tabs with ids and prefix the ids with "mytabs-"
wfAddMsg("es", "lastDiffTabLabel", "Previa");
var listitems = tabs.getElementsByTagName('LI');
wfAddMsg("en", "lastDiffTabTitle", "Show differences between this revision and the previous");
for (var i=0; i < listitems.length; i++) {
wfAddMsg("es", "lastDiffTabTitle", "Mostrar las diferencias entre esta revisión y la previa");
if(listitems[i].id) listitems[i].id = 'mytabs-' + listitems[i].id;
}
 
// Add the cloned tabs at the end of the "column-content" div
document.getElementById('column-content').appendChild(tabs);
});
 
// 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 () {
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 ⟶ 31:
else x = x.childNodes[0].href;
 
addTab(x.replace(/action=history/, "diffaction=cur&oldid=prevpurge"),
'last'wfMsg("purgeTabLabel"), 'ca-lastpurge', 'Show most recent diff'wfMsg("purgeTabTitle"));
addTab(x.replace(/action=history/, "diff=purge"), 'purge',+ 'ca-purge'wgCurRevisionId + "&oldid=prev"),
wfMsg("lastDiffTabLabel"), 'ca-last', wfMsg("lastDiffTabTitle"));
});