Jump to content

User:Grm wnr/monobook.js

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Grm wnr (talk | contribs) at 23:43, 23 September 2005. 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.
/* Commenting out for testing

//START NavPopups

// [[User:Lupin/popups.js]] - please include this line 

document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Lupin/popups.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');

popupAdminLinks=true;
popupDelay=2;

//END NavPopups

function addPurgeLink() { // Adds a "Purge page" link to the toolbox

  // remove "action" variable from the URL and insert new one

  myURL = window.location;
  var myGetVars = myURL.search.substring(1,myURL.search.length).split("&");
  var myCleanGetVars = Array(); 
  for (i=0;i<myGetVars.length;++i) {
    if (myGetVars[i] && myGetVars[i].substr(0,6) != "action") {
      myCleanGetVars.push(myGetVars[i]);
    }
  }
  myCleanGetVars.push("action=purge");
  var myNewGetVars = "?" + myCleanGetVars.join("&");
  myURLString = myURL.protocol + "//" + myURL.hostname + myURL.pathname + myNewGetVars + myURL.hash;

  addToToolbox('Purge page', myURLString, 'Purge this page', 't-purge');
}

function addEditCountLink() { // Add "Count User edits" link to toolbox
  if (window.location.pathname.indexOf('index.php') > 0) { // GET mode
    myTrigger = window.location.search;
  } else { // Path mode
    myTrigger = window.location.pathname;
  }
  if (myTrigger.indexOf('User:') > 0) { // We're in User space
    myUName = extractUName('User:', myTrigger);
  } else if (myTrigger.indexOf('User_talk:') > 0) { // We're in User_talk space 
    myUName = extractUName('User_talk:', myTrigger);
  } else if (myTrigger.indexOf('Special:Contributions') > 0) { // We're viewing contributions
    myUName = extractUName('Special:Contributions/', myTrigger); 
  } else { // Bail out
    return false;
  }
  myEscapedUName = myUName.replace(/_/, "+");
  myClearUName = myUName.replace(/_/, " ");
  myURLString = 'http://kohl.wikimedia.org/~kate/cgi-bin/count_edits.cgi?user='+ myEscapedUName +'&dbname=enwiki';
  addToToolbox('Count user edits', myURLString, 'Count edits by ' + myClearUName, 't-ucount');
  myBlockString = 'http://en.wikipedia.org/w/index.php?title=Special:Blockip&ip='+myClearUName;
  addToToolbox('Block user', myBlockString, 'Block ' + myClearUName, 't-ublock');

  if (myTrigger.search(/\d+\.\d+\.\d+\./) > 0) { // 3 dots = assume IP adress
    myIPString = 'http://www.dnsstuff.com/tools/whois.ch?ip='+myClearUName+'&cache=off';
    addToToolbox('IP lookup', myIPString, 'Look up ' + myClearUName, 't-ulook');

  }
}

function addCrossWPSearchLink() { // Search article in other WPs link to toolbox
  if (window.location.pathname.indexOf('index.php') > 0) { // GET mode
    myTrigger = window.location.search;
  } else { // Path mode
    myTrigger = window.location.pathname;
  }
  if (
myTrigger.indexOf('User:') < 0 && 
myTrigger.indexOf('User_talk:') < 0 && 
myTrigger.indexOf('Wikipedia:') < 0 && 
myTrigger.indexOf('Wikipedia_talk:') < 0 && 
myTrigger.indexOf('Category:') < 0 && 
myTrigger.indexOf('Category_talk:') < 0 && 
myTrigger.indexOf('Template:') < 0 && 
myTrigger.indexOf('Template_talk:') < 0 && 
myTrigger.indexOf('Image:') < 0 && 
myTrigger.indexOf('Image_talk:') < 0 && 
myTrigger.indexOf('Help:') < 0 && 
myTrigger.indexOf('Help_talk:') < 0 && 
myTrigger.indexOf('MediaWiki:') < 0 &&
myTrigger.indexOf('Special:') < 0 &&
myTrigger.indexOf('MediaWiki_talk:') < 0 ) { // We're in Article space
    myArticleName = extractUName('/wiki/', myTrigger);
  } else if (myTrigger.indexOf('Talk:') > 0) { // We're in Talk space 
    myArticleName = extractUName('Talk:', myTrigger);
  } else { // Bail out
    return false;
  }

  myURLString = 'http://vs.aka-online.de/cgi-bin/globalwpsearch.pl?timeout=30&minor=1&search='+ myArticleName;

  addToToolbox('Other Wikipedias', myURLString, 'Look up ' + myArticleName + 'in other language Wikipedias', 't-uotherwp');
}

function StubConvert() {

document.getElementsByName("wpSummary")[0].value = "{{LebRedlink-stub}} => {{LebanonRedlink-stub}} as per [[WP:SFD]]";
document.getElementsByName("wpMinoredit")[0].checked = "checked";
oldArticleText = document.getElementsByName("wpTextbox1")[0].value;
newArticleText = oldArticleText.replace(/\{\{[L|l]ebRedlink-stub\}\}/, "{{LebanonRedlink-stub}}");
document.getElementsByName("wpTextbox1")[0].value = newArticleText;

document.editform.submit();

}

function addStubConvLink() {
  addToToolbox('Lebanon convert', 'javascript:StubConvert();', 'Lebanon convert', 't-AEConv');
}

function extractUName(namespace, myString) {
  myCleanedString = myString.substring(myString.indexOf(namespace) + namespace.length,myString.length);
  if (myCleanedString.indexOf('/') > 0) {
    mySliceEnd = myCleanedString.indexOf('/');
  } else {
    mySliceEnd = myCleanedString.length;
  }
  myCleanerString = myCleanedString.substring(0,mySliceEnd);
  return myCleanerString;
}

function addToToolbox(label, link, title, id) { // Create new child node of the toolbox object

  var myLinktext = document.createTextNode(label);
  var myLink = document.createElement("a");
  myLink.href = link;
  myLink.title = title;
  myLink.appendChild(myLinktext);
  var myListItem = document.createElement("li");
  myListItem.id = id;
  myListItem.appendChild(myLink);
  document.getElementById('p-tb').getElementsByTagName("ul")[0].appendChild(myListItem);

}

function reformatMyPage() { // execute all formatting functions...
  addPurgeLink();
  addEditCountLink();
  addCrossWPSearchLink();
//  addStubConvLink();
}

// when the page is loaded

if (window.addEventListener) window.addEventListener("load",reformatMyPage,false);
else if (window.attachEvent) window.attachEvent("onload",reformatMyPage);
*/

 // ============================================================
 // BEGIN Dynamic Navigation Bars (Custom fork for testing)
 
 // set up the words in your language
 var NavigationBarHideFork = '<small>[ Hide ]</small>';
 var NavigationBarShowFork = '<small>[ Show ]</small>';
 
 // set up max count of Navigation Bars on page,
 // if there are more, all will be hidden
 // NavigationBarShowDefault = 0; // all bars will be hidden
 // NavigationBarShowDefault = 1; // on pages with more than 1 bar all bars will be hidden
 var NavigationBarShowDefaultFork = 1;
 
 
 // shows and hides content and picture (if available) of navigation bars
 // Parameters:
 //     indexNavigationBar: the index of navigation bar to be toggled
 function toggleNavigationBarFork(indexNavigationBarFork)
 {
    var NavToggleFork = document.getElementById("NavToggleFork" + indexNavigationBarFork);
    var NavFrameFork = document.getElementById("NavFrameFork" + indexNavigationBarFork);
 
    if (!NavFrameFork || !NavToggleFork) {
        return false;
    }
 
    // if shown now
    if (NavToggleFork.firstChild.data == NavigationBarHideFork) {
        for (
                var NavChildFork = NavFrameFork.firstChild;
                NavChildFork != null;
                NavChildFork = NavChildFork.nextSibling
            ) {
            if (NavChildFork.className == 'NavPicFork') {
                NavChildFork.style.display = 'none';
            }
            if (NavChildFork.className == 'NavContentFork') {
                NavChildFork.style.display = 'none';
            }
            if (NavChildFork.className == 'NavToggleFork') {
                NavChildFork.firstChild.data = NavigationBarShowFork;
            }
        }
 
    // if hidden now
    } else if (NavToggleFork.firstChild.data == NavigationBarShowFork) {
        for (
                var NavChildFork = NavFrameFork.firstChild;
                NavChildFork != null;
                NavChildFork = NavChildFork.nextSibling
            ) {
            if (NavChildFork.className == 'NavPicFork') {
                NavChildFork.style.display = 'block';
            }
            if (NavChildFork.className == 'NavContentFork') {
                NavChildFork.style.display = 'block';
            }
            if (NavChildFork.className == 'NavToggleFork') {
                NavChildFork.firstChild.data = NavigationBarHideFork;
            }
        }
    }
 }
 
 // adds show/hide-button to navigation bars
 function createNavigationBarToggleButtonFork()
 {
    var indexNavigationBarFork = 0;
    // iterate over all < div >-elements
    for(
            var i=0; 
            NavFrameFork = document.getElementsByTagName("div")[i]; 
            i++
        ) {
        // if found a navigation bar
        if (NavFrameFork.className == "NavFrameFork") {
 
            indexNavigationBarFork++;
            var NavToggleFork = document.createElement("a");
            NavToggleFork.className = 'NavToggleFork';
            NavToggleFork.setAttribute('id', 'NavToggleFork' + indexNavigationBarFork);
            NavToggleFork.setAttribute('href', 'javascript:toggleNavigationBarFork(' + indexNavigationBarFork + ');');
 
            var NavToggleTextFork = document.createTextNode(NavigationBarHideFork);
            NavToggleFork.appendChild(NavToggleTextFork);
 
            // add NavToggle-Button as first div-element 
            // in < div class="NavFrame" >
            NavFrameFork.firstChild.lastChild.appendChild(
                NavToggleFork,
            );
            NavFrameFork.setAttribute('id', 'NavFrameFork' + indexNavigationBarFork);
        }
    }
    // if more Navigation Bars found than Default: hide all
    if (NavigationBarShowDefaultFork < indexNavigationBarFork) {
        for(
                var i=1; 
                i<=indexNavigationBarFork; 
                i++
        ) {
            toggleNavigationBarFork(i);
        }
    }
 
 }
 
 aOnloadFunctions[aOnloadFunctions.length] = createNavigationBarToggleButtonFork;
 
 // END Dynamic Navigation Bars
 // ============================================================