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)
 
(22 intermediate revisions by one other user not shown)
Line 1:
// Requires: [[User:Mike Dillon/Scripts/i18n.js]]
// Add a 'purge' link to the tabs
 
function addPurge(){
/* <pre><nowiki> */
ta['ca-purge'] = ['g', 'Purge the internal cache for this page'];
 
/* Messages */
wfAddMsg("en", "purgeTabLabel", "Purge");
wfAddMsg("es", "purgeTabLabel", "Purgar");
wfAddMsg("en", "purgeTabTitle", "Purge this page from the server cache");
wfAddMsg("es", "purgeTabTitle", "Purgar esta página del cache de servidor");
 
wfAddMsg("en", "lastDiffTabLabel", "Last");
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
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);
 
// 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');
akeytt();
 
addTab(x.replace(/action=history/, "action=purge"), 'purge', 'ca-purge');
if (window.addEventListener) window.addEventListener("load", addPurge, false);
wfMsg("purgeTabLabel"), 'ca-purge', wfMsg("purgeTabTitle"));
else if (window.attachEvent) window.attachEvent("onload", addPurge);
addTab(x.replace(/action=history/, "diff=" + wgCurRevisionId + "&oldid=prev"),
 
wfMsg("lastDiffTabLabel"), 'ca-last', wfMsg("lastDiffTabTitle"));
// Add a 'last' link to the tabs to show last diff
});
function doLastDiff() {
var nurl = "http://en.wikipedia.org/w/index.php?title=" + getPname() + "&diff=cur&oldid=prev";
document.___location = nurl
}
function addLastDiff() {
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
var l=addlilink(tabs, "javascript:doLastDiff()", 'last', '');
l.lastChild.title="Show most recent diff";
}
 
/* </nowiki></pre> */
if (window.addEventListener) window.addEventListener("load", addLastDiff, false);
else if (window.attachEvent) window.attachEvent("onload", addLastDiff);