MediaWiki:Monobook.js: Difference between revisions

Reverting - some JS-controlled features are not working any more
No edit summary
(Reverting - some JS-controlled features are not working any more)
Line 1: Line 1:
/* <pre><nowiki> */
/* tooltips and access keys */
/* tooltips and access keys */
ta = new Object();
ta = new Object();
Line 51: Line 49:
ta['ca-nstab-help'] = new Array('c','View the help page');
ta['ca-nstab-help'] = new Array('c','View the help page');
ta['ca-nstab-category'] = new Array('c','View the category page');
ta['ca-nstab-category'] = new Array('c','View the category page');
var re = RegExp("(.*) - Halopedia, the Halo Wiki");
var matches = re.exec(document.title);
if (matches && matches[1].indexOf("Editing") == -1) {
    skinName = matches[1];
    document.write('<style type="text/css">/*<![CDATA[*/ @import "/index.php?title=' + skinName + '/monobook.css' + '&action=raw&ctype=text/css"; /*]]>*/</style>');
    document.write('<script type="text/javascript" src="/index.php?title=MediaWiki:Skin/' + skinName + '/monobook.js' + '&action=raw&ctype=text/javascript"></script>');
    }
if (window.location.href.indexOf("printable=yes") != -1) {
    document.write('<style type="text/css">/*<![CDATA[*/ @import "/index.php?title=MediaWiki:PrintableTweaks.css&action=raw&ctype=text/css"; /*]]>*/</style>');
}
// onload stuff
function loadFunc()
{
    document.getElementById('searchform').getElementsByTagName('a')[0].href = "http://halo.wikia.com/index.php?title=Special:Search&adv=1";
    if(document.getElementById('infoboxinternal') != null)
    {
        document.getElementById('infoboxend').innerHTML = '<a id="infoboxtoggle" href="javascript:infoboxToggle()">[Hide]</a>';
    }
    fillEditSummaries();
    fillDeleteReasons();
    if(typeof onPageLoad != "undefined")
    {
        onPageLoad();
    }
}
function infoboxToggle()
{
    if(document.getElementById('infoboxtoggle').innerHTML == '[Hide]')
    {
        document.getElementById('infoboxinternal').style.display = 'none';
        document.getElementById('infoboxtoggle').innerHTML = '[Show]';
    }
    else
    {
        document.getElementById('infoboxinternal').style.display = 'block';
        document.getElementById('infoboxtoggle').innerHTML = '[Hide]';
    }
}
function fillEditSummaries()
{
    var label = document.getElementById("wpSummaryLabel");
    if(label == null)
    {
        return;
    }
    var comboString = "Standard summaries: <select id='stdSummaries' onchange='onStdSummaryChange()'>";
    comboString += "</select><br />";
    label.innerHTML = comboString + label.innerHTML;
    var request;
    try
    {
        request = new XMLHttpRequest();
    }
    catch(e)
    {
        request = new ActiveXObject("Msxml2.XMLHTTP");
    }
    request.open("GET", "http://halo.wikia.com/index.php?title=Template:Stdsummaries&action=raw&ctype=text/plain");
    request.onreadystatechange = function()
    {
        if(request.readyState == 4)
        {
            var combo = document.getElementById("stdSummaries");
            var lines = request.responseText.split("\n");
            var i;
            for(i = 0; i < lines.length; i++)
            {
                var value = lines[i].indexOf("-- ") == 0 ? lines[i].substring(3) : "";
                combo.innerHTML += "<option value='" + value + "'>" + lines[i] + "</option>";
            }
        }
    }
    request.send(null);
}
function onStdSummaryChange()
{
    var combo = document.getElementById("stdSummaries");
    var value = combo.options[combo.selectedIndex].value;
    if(value != "")
        document.getElementById("wpSummary").value = value;
}
function fillDeleteReasons()
{
    var label = document.getElementById("wpReason");
    if(label == null)
    {
        return;
    }
    label = document.getElementById("contentSub");
    if(label == null)
    {
        return;
    }
    var comboString = "<br /><select id='stdReasons' onchange='onStdReasonChange()'>";
    comboString += "</select>";
    label.innerHTML += comboString;
    var request;
    try
    {
        request = new XMLHttpRequest();
    }
    catch(e)
    {
        request = new ActiveXObject("Msxml2.XMLHTTP");
    }
    request.open("GET", "http://halo.wikia.com/index.php?title=Template:Stdsummaries&action=raw&ctype=text/plain");
    request.onreadystatechange = function()
    {
        if(request.readyState == 4)
        {
            var combo = document.getElementById("stdReasons");
            var lines = request.responseText.split("\n");
            var i;
            for(i = 0; i < lines.length; i++)
            {
                var value = lines[i].indexOf("-- ") == 0 ? lines[i].substring(3) : "";
                combo.innerHTML += "<option value='" + value + "'>" + lines[i] + "</option>";
            }
        }
    }
    request.send(null);
}
function onStdReasonChange()
{
    var combo = document.getElementById("stdReasons");
    var value = combo.options[combo.selectedIndex].value;
    if(value != "")
        document.getElementById("wpReason").value = value;
}
window.onload = loadFunc;
}