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)
 
(18 intermediate revisions by one other user not shown)
Line 1:
// Requires: [[User:Mike Dillon/Scripts/i18n.js]]
// Duplicate link tab from the top to the bottom of the content area
 
function morelinks() {
/* <pre><nowiki> */
var tabs = document.getElementById('p-cactions').cloneNode(true);
 
tabs.id = 'mytabs';
/* Messages */
var listitems = tabs.getElementsByTagName('LI');
wfAddMsg("en", "purgeTabLabel", "Purge");
for (i=0;i<listitems.length;i++) {
wfAddMsg("es", "purgeTabLabel", "Purgar");
if(listitems[i].id) listitems[i].id = 'mytabs-' + listitems[i].id;
wfAddMsg("en", "purgeTabTitle", "Purge this page from the server cache");
}
wfAddMsg("es", "purgeTabTitle", "Purgar esta página del cache de servidor");
document.getElementById('column-content').appendChild(tabs);
 
}
wfAddMsg("en", "lastDiffTabLabel", "Last");
runOnLoad(morelinks);
wfAddMsg("es", "lastDiffTabLabel", "Previa");
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
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, id, title, key);
}
}
 
// Add a 'purge' linkand 'last' links to the tabs
addOnloadHook(function addPurge() {
ta['ca-purge'] = ['g', 'Purge the internal cache for this page'];
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');
akeytt();
}
runOnLoad(addPurge);
 
addTab(x.replace(/action=history/, "action=purge"), 'purge', 'ca-purge');
// Add a 'last' link to the tabs to show last diff
wfMsg("purgeTabLabel"), 'ca-purge', wfMsg("purgeTabTitle"));
function doLastDiff() {
var nurl addTab(x.replace(/action=history/, "http://en.wikipedia.org/w/index.php?titlediff=" + getPname()wgCurRevisionId + "&diff=cur&oldid=prev";),
wfMsg("lastDiffTabLabel"), 'ca-last', wfMsg("lastDiffTabTitle"));
document.___location = nurl
});
 
function addLastDiff() {
/* </nowiki></pre> */
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
var l=addlilink(tabs, "javascript:doLastDiff()", 'last', '');
l.lastChild.title="Show most recent diff";
}
runOnLoad(addLastDiff);