User:Aconcagua/monobook.js

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
// [[User:Lupin/popups.js]]
 
mw.loader.load(
             'https://en.wikipedia.org/w/index.php?title=User:Lupin/popups.js'
             + '&action=raw&ctype=text/javascript&dontcountme=s');


// ***************************************************************************************
 // Insert a personalized Texttemplate into the Special:Upload edit box (from User:Dschwen)
 // ***************************************************************************************
function delayedUpdateSpecialUpload()
{
 var editbox = document.getElementById('wpUploadDescription');

   editbox.value = "== {"+"{int:filedesc}"+"} ==\n"
                 + "{"+"{Information\n"
                 + "|Description=\n"
                 + "* {"+"{de|["+"[:de:|]"+"]}"+"}\n"
                 + "* {"+"{en|["+"[:en:|]"+"]}"+"}\n"
                 + "|Source={"+"{Own}"+"}\n"
                 + "|Date=YYYY-MM-DD\n"
                 + "|Author=~"+"~"+"~\n"
                 + "|Permission=GFDL, Cc-by-sa-3.0\n"
                 + "|other_versions=\n"
                 + "}"+"}\n"
                 + "{"+"{location dec||heading:xxx}"+"}\n"
                 + "{"+"{User:Aconcagua/Template:Credits}"+"}\n\n"
                 + "== {"+"{int:license}"+"} ==\n"
                 + "{"+"{Self|GFDL|Cc-by-sa-3.0}"+"}\n\n"
                 + "["+"[Category:]"+"]"
}
function setSpecialUploadTemplate()
{
 var uploadURL = 'http://commons.wikimedia.org/w/index.php?title=Special:Upload&uselang=deownwork';
 
 // I upload mostly my own work
 document.getElementById('n-uploadbtn').firstChild.href = uploadURL;
 
 // preload input form
 if(window.location.href == uploadURL) setTimeout( "delayedUpdateSpecialUpload()", 500 );
}
$(setSpecialUploadTemplate);


//**************************************************************************************************
 // Interwiki-Beobachtungslisten in Sidebar (http://www.mediawiki.org/wiki/Manual:Interface/Sidebar)
 //*************************************************************************************************

function ModifySidebar(action, section, name, link) {
    try {
        switch (section) {
          case "languages":
            var target = "p-lang";
            break;
          case "toolbox":
            var target = "p-tb";
            break;
          case "navigation":
            var target = "p-navigation";
            break;
          default:
            var target = "p-" + section;
            break;
        }
 
        if (action == "add") {
            var node = document.getElementById(target)
                               .getElementsByTagName('div')[0]
                               .getElementsByTagName('ul')[0];
 
            var aNode = document.createElement('a');
            var liNode = document.createElement('li');
 
            aNode.appendChild(document.createTextNode(name));
            aNode.setAttribute('href', link);
            liNode.appendChild(aNode);
            liNode.className='plainlinks';
            node.appendChild(liNode);
        }
 
        if (action == "remove") {
            var list = document.getElementById(target)
                               .getElementsByTagName('div')[0]
                               .getElementsByTagName('ul')[0];
 
            var listelements = list.getElementsByTagName('li');
 
            for (var i = 0; i < listelements.length; i++) {
                if (listelements[i].getElementsByTagName('a')[0].innerHTML == name ||
                    listelements[i].getElementsByTagName('a')[0].href == link) {
 
                    list.removeChild(listelements[i]);
                }
            }
        }
 
    } catch(e) {
      // lets just ignore what's happened
      return;
    }
}
 
function CustomizeModificationsOfSidebar() {
    ModifySidebar("add", "toolbox", "BL en.Wikipedia", "http://en.wikipedia.org/wiki/Special:Watchlist");
    ModifySidebar("add", "toolbox", "BL de.Wikipedia", "http://de.wikipedia.org/w/index.php?title=Spezial:Beobachtungsliste");
    ModifySidebar("add", "toolbox", "BL Commons 3h", "http://commons.wikimedia.org/w/index.php?title=Special:Watchlist&days=0.125");
    ModifySidebar("add", "toolbox", "BL Commons 4h", "http://commons.wikimedia.org/w/index.php?title=Special:Watchlist&days=0.166667");
    ModifySidebar("add", "toolbox", "Upload deownwork", "http://commons.wikimedia.org/w/index.php?title=Special:Upload&uselang=deownwork");
}
 
$(CustomizeModificationsOfSidebar);


//***********************
 // Seitenaufrufstatistik
 //**********************

$(function () {
 if ( wgNamespaceNumber == 6 )
 {
   mw.util.addPortletLink ('p-cactions', 'http://stats.grok.se/commons.m/201005/File' + ":" + wgTitle, 'AufrufStats');//catscan-pop
}
});

$(function () {
 if ( wgNamespaceNumber == 0 )
 {
   mw.util.addPortletLink ('p-cactions', 'http://stats.grok.se/de/201005/' + wgTitle, 'AufrufStats');//catscan-pop
}
});