User:Mike Dillon/Scripts/tabs.js

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Mike Dillon (talk | contribs) at 07:11, 12 February 2006. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// Duplicate link tab from the top to the bottom of the content area
function morelinks() {
  var tabs = document.getElementById('p-cactions').cloneNode(true); = 'mytabs';
  var listitems = tabs.getElementsByTagName('LI');
  for (i=0;i<listitems.length;i++) {
    if(listitems[i].id) listitems[i].id = 'mytabs-' + listitems[i].id;

// Add a new list item to the page tabs
function addTab(url, name, id, title, key){
    var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
    addlilink(tabs, url, name, id, title, key);

    // Add tab to the bottom if the tabs have been cloned
    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' link to the tabs
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');

// Add a 'last' link to the tabs to show last diff
function doLastDiff() {
  var nurl = "" + getPname() + "&diff=cur&oldid=prev";
  document.location = nurl
function addLastDiff() {
  var x = document.getElementById('ca-history');
  if(!x) return;
  ta['ca-last'] = ['', 'Show most recent diff'];
  addTab('javascript:doLastDiff()', 'last', 'ca-last');