User:Earth KING/monobook.js

From Wikipedia, the free encyclopedia

If a message on your talk page led you here, please be wary of who left it. The code below could contain malicious content capable of compromising your account; if your account appears to be compromised, it will be blocked. If you are unsure whether the code is safe, you can ask at the appropriate village pump.
Note: After saving, you have to bypass your browser's cache to see the changes. In Internet Explorer and Firefox, hold down the Ctrl key and click the Refresh or Reload button. Opera users have to clear their caches through Tools→Preferences, see the instructions for Opera. Konqueror and Safari users can just click the Reload button.
//<!-- Icon for 'Popups': [[Image:Nuvola mimetypes source java.png]] -->
/* <pre> */
 
/* Please Note: Almost everything on this page is from [[User:Omegatron/monobook.js]]. Do not copy stuff from here. */
 
/* winc script to put other scripts in this one..from [[User:Quarl/monobook.js]]. */
 
function winc(s) {
    s = s.replace(/^\[\[/, '').replace(/\]\]$/, '');
    document.write('<scr' + 'ipt type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=' + s
             + '&action=raw&ctype=text/javascript&dontcountme=s"></scr' 
             + 'ipt>');
}
 
 
/* Included functions */
 
winc('[[User:Omegatron/monobook.js/addlink.js]]');         /* Adds links to lists on the page, such as the personal tools section */
winc('[[User:Omegatron/monobook.js/fixdiffwidth.js]]');    /* Cleans up the diff so that long lines don't explode the width of the page. */
winc('[[User:Omegatron/monobook.js/edittop.js]]');         /* Adds a link to edit the top (intro) section of an article */
winc('[[User:Omegatron/monobook.js/namedredirect.js]]');   /* Learning XMLHttpRequest while workarounding [[Bugzilla: 218]] */
/*winc('[[User:Omegatron/monobook.js/autolinker.js]]');      Make [[links]] and {{templates}} clickable */
 
 
/* Add some extra tabs with different functionalities. */
 
winc('[[User:Omegatron/monobook.js/replacetab.js]]');               // Regex replacements in the text (from [[User:Trilobite/Tools]])
winc('[[User:Omegatron/monobook.js/unverified.js]]');               // Tag unverified images (from [[User:Trilobite/Tools]])
// winc('[[User:Omegatron/monobook.js/addsincetab.js]]');           // Shows difference between my last edit and current version ([[Wikipedia:WikiProject User scripts/Scripts/Changes since I last edited]])
winc('[[User:Omegatron/monobook.js/dashfixer.js]]');                // Converts -- into — and so on (User:Omegatron)
winc('[[User:Omegatron/monobook.js/unitformatter.js]]');            // Formats units according to SI (User:Omegatron)
winc('[[User:Omegatron/monobook.js/mathcharacterfixer.js]]');       // Fixes up some math characters (not TeX) (User:Omegatron)
winc('[[User:Omegatron/monobook.js/headingformattingfixer.js]]');   // Adds and removes whitespace to make formatting consistent and readable (User:Omegatron)
 
 
/* This function is used to include individual scripts from Quarl's pages in this. */
 
function qinc(s) {
    document.write('<scr' + 'ipt type="text/javascript" src="' 
             + 'http://wikipedia.quarl.org/scripts/' + s
             + '.js"></scr' 
             + 'ipt>');
}
 
 
 
/* All kinds of scripts from [[User:Quarl]] */
 
qinc('module');
qinc('datetime');
qinc('msg');
qinc('util');
qinc('wikiwidget');
qinc('wikins');
qinc('wikipage');
qinc('wikiedit');
qinc('diff');
qinc('shortcuts');
qinc('diffsince');
qinc('wikiwatch');
qinc('watchlist');
qinc('watchbutton');
qinc('autofocus');
qinc('autosummary');
qinc('smartsubmit');
qinc('newmessages');
qinc('tabsince');
 
addOnloadHook(function () {
 
$watchbutton.widgetLoad(); 
$tabsince.widgetLoad();
$watchlist.widgetLoad()
 
/* [[User:Omegatron/monobook.js/quarl.js]] */
 
/* uncomment this to hide alert() errors */
/* $msg.alert_disabled=true */
 
});
 
/* Live Preview */
 
wpUserName   = 'Earth KING';   // User name to display in signatures
wpShowImages = true;      // Enable downloading and displaying of images
 
winc('[[User:Pilaf/livepreview.js]]');
 
// Now set everything up
/* Convert to addonloadhook?  Can't because function doesn't exist yet. */
window.onload = Main;
function Main()
{
 LivePreviewInstall();
 // You may include here other "extensions"
}
 
 
/* The great [[Wikipedia:Tools/Navigation_popups|navigation popups]] from [[User:Lupin]] */
 
winc('[[User:Lupin/popups.js]]');
popupDelay=1;
popupAdminLinks=true;
imagePopupsForImages=true; 
 
/* Move things around so that sidebar can be fixed in position and content can scroll independently */
/* See [[meta:Help:User style/floating quickbar]] */
 
addOnloadHook(function () {
    var content = document.getElementById("column-content");    // Find the main content column
 
    var footer = document.getElementById("footer");  // Find the footer
    footer.parentNode.removeChild(footer);    // Remove the footer from the global wrapper
    content.appendChild(footer);    // Place footer at the end of the content column;
 
    var tabs = document.getElementById("p-cactions");   // Find the top tab list
    tabs.parentNode.removeChild(tabs);    // Remove the tab list from the side column
    content.insertBefore(tabs,content.firstChild);    // Place tab list at the beginning of the content column
});
 
/* Do some things when the page loads */
 
addOnloadHook(function () {
 
    /* Adds some links to my ''personal tools'' section ("My monobook.js", "My monobook.css", "My sandbox") */
 
    addLink('p-personal', '/wiki/User:Earth KING/monobook.js', 'My monobook.js', 'pt-monobookjs', 'monobook.js is used for storing user javascripts', '', 'pt-logout');
    addLink('p-personal', '/wiki/User:Earth KING/monobook.css', 'My monobook.css', 'pt-monobookcss', 'monobook.css is used for storing user CSS styles', '', 'pt-logout');
    addLink('p-personal', '/wiki/User:Earth KING/Sandbox', 'My sandbox', 'pt-sandbox', 'My sandbox is used for testing things', '', 'pt-logout');
    addLink('p-personal', '/w/index.php?title=Special:Prefixindex&namespace=2&from=Earth_KING/', 'My subpages', 'pt-subpages', 'Subpages of Earth KING', '', 'pt-logout');
 
    /* Shorten "edit this page" to just "edit" */
    if(document.getElementById('ca-edit')) {
        document.getElementById('ca-edit').firstChild.innerHTML = 'edit';
    }
 
});
 
 
 
 
 
/* Syntax highlighting on pre areas */
/* See [[Wikipedia:WikiProject User scripts/Scripts/Syntax highlighter]] */
 
addOnloadHook(function () {
    /* CSS syntax highlighting */
    if(document.title.indexOf(".js") == -1) {         //   Ignore pages that end in .js 
        var multicommentRE = new RegExp('(/\\*[\\s\\S]*?\\*/)', 'g');
        var ruleRE = new RegExp('([^\\{]+)\\{([^\\}]+)\\}', 'g');
        var idselectorRE = new RegExp('(#[a-zA-Z0-9\-\_]+)\\b', 'g');
        var classselectorRE = new RegExp('(\\.[a-zA-Z0-9\-\_]+)\\b', 'g');
        var pairRE = new RegExp('([a-zA-Z-]+):([^;]+);', 'g');
        var css = document.getElementsByTagName('pre');
        for (i = 0; i < css.length; i++) {
            var c = css[i];
            var content = c.innerHTML;
            content = content.replace(multicommentRE, '<span class="comment">$1</span>');
            content = content.replace(ruleRE, function(text, selector, body) {
                selector = selector.replace(idselectorRE, '<span class="idselector">$1</span>');
                selector = selector.replace(classselectorRE, '<span class="classselector">$1</span>');
                body = body.replace(pairRE, '<span class="property">$1</span>:<span class="value">$2</span>;');
                return selector + '{' + body + '}';
            });
            c.innerHTML = content;
        }
    } 
});
 
 
document.write(
    '<st' + 'yle type="text/css">            ' +
    ' div.audiolinkbox {                     ' +
    '     border:2px solid rgb(170,170,170); ' +
    '     background-color:rgb(250,250,250); ' +
    '     position:absolute;                 ' +
    '     margin:-1.2em;                     ' +
    '     display:none;                      ' +
    ' }                                      ' +
    '<' + '/style>'
    );
 
addOnloadHook(function () {
 
    function lightup () {
        this.parentNode.nextSibling.nextSibling.style.display="inline";
    }
 
    function lightout () {
        this.parentNode.nextSibling.nextSibling.style.display="none";
    }
 
    /* Get all the span tags */
    spans = document.getElementsByTagName('span');
 
    /* go through them all */
    for (i=0;i<spans.length;i++) {
    /* If the span is class audiolinkinfo */
        if (spans[i].className.indexOf("audiolinkinfo") != -1) {
            /* Put it in a box */
            box = document.createElement('div');
            box.className="audiolinkbox";
            spans[i].parentNode.insertBefore(box,spans[i]);
            box.appendChild(spans[i]);
            /* Remove the parentheses */
            insidebox = spans[i].firstChild
            for (j=0;j<insidebox.childNodes.length;j++) {
                if (insidebox.childNodes[j].textContent == "(" || insidebox.childNodes[j].textContent == ")") {
                    insidebox.removeChild(insidebox.childNodes[j])
                }
            }
            /* Add the hover thing to the regular link */
            spans[i-1].firstChild.onmouseout=lightout;
            spans[i-1].firstChild.onmouseover=lightup;
        }
    }
 
});
 
function addlilink(tabs, url, name, id, title, key){
    var na = document.createElement('a');
    na.href = url;
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    if(id) li.id = id;
    li.appendChild(na);
    tabs.appendChild(li);
    if(id)
    {
        if(key && title)
        {
            ta[id] = [key, title];
        }
        else if(key)
        {
            ta[id] = [key, ''];
        }
        else if(title)
        {
            ta[id] = ['', title];
        }
    }
    // re-render the title and accesskeys from existing code in wikibits.js
    akeytt();
    return li;
}
 
// 
 
/* </pre> */