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

Content deleted Content added
m remove alt-g from purge
m Maintenance: Fixing deprecated call to addPortletLink (mw:ResourceLoader/Migration_guide_(users)#addPortletLink)
 
(8 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';
 
// Find individual tabs with ids and prefix the ids with "mytabs-"
var listitems = tabs.getElementsByTagName('LI');
for (var i=0; i < listitems.length; i++) {
if(listitems[i].id) listitems[i].id = 'mytabs-' + listitems[i].id;
}
 
wfAddMsg("en", "lastDiffTabLabel", "Last");
// Add the cloned tabs at the end of the "column-content" div
wfAddMsg("es", "lastDiffTabLabel", "Previa");
document.getElementById('column-content').appendChild(tabs);
wfAddMsg("en", "lastDiffTabTitle", "Show differences between this revision and the previous");
});
wfAddMsg("es", "lastDiffTabTitle", "Mostrar las diferencias entre esta revisión y la previa");
 
// Add a new list item to the page tabs
function addTab(url, name, id, title, key) {
// Add tab to the top tabs
mw.util.addPortletLink('p-cactions', url, name, id, title, key);
 
// Add tab to the bottom if the tabs have been cloned
mw.util.addPortletLink('mytabs', url, name, 'mytabs-' + id, title, key);
}
 
Line 37 ⟶ 32:
 
addTab(x.replace(/action=history/, "action=purge"),
'purge'wfMsg("purgeTabLabel"), 'ca-purge', 'Purge the internal cache for this page'wfMsg("purgeTabTitle"));
addTab(x.replace(/action=history/, "diff=cur" + wgCurRevisionId + "&oldid=prev"),
'last'wfMsg("lastDiffTabLabel"), 'ca-last', 'Show most recent diff'wfMsg("lastDiffTabTitle"));
});