MediaWiki:Common.js: различия между версиями

>Grep
funny bug
>Sikon
Нет описания правки
Строка 1: Строка 1:
/* <pre><nowiki> */
/* <pre><nowiki> */
function addLoadEvent(func)
{
if (window.addEventListener)
  window.addEventListener("load", func, false);
else if (window.attachEvent)
  window.attachEvent("onload", func);
}
/* Обеспечиваем нигилистические фокусы (см., например, статью [[Google]]) */
function do_nihilism()
{
  nhl = document.getElementById('nihilism');
  if(nhl)
  {
    msg = nhl.innerHTML;
    document.getElementById('globalWrapper').innerHTML = "<div id='nihilism_message'>" + msg + "</div>";   
  }
}
addLoadEvent(do_nihilism);
/* Делаем ссылку «править» для нулевой секции — (C) Edward. */
function do_edit_null()
{
  if(document.getElementById('bodyContent').innerHTML.match('class=\"editsection\"'))
    document.getElementById('bodyContent').innerHTML = "<div class=\"editsection\" id=\"ca-edit-0\">[<a href=\"http://absurdopedia.wikia.com/index.php?title=" + document.title.substr(0, document.title.lastIndexOf(" — ")) + "&action=edit&section=0\">править</a>]</div>" + document.getElementById('bodyContent').innerHTML;
}
addLoadEvent(do_edit_null);




Строка 82: Строка 54:
ta['ca-nstab-help'] = new Array('c','Страница справки');
ta['ca-nstab-help'] = new Array('c','Страница справки');
ta['ca-nstab-category'] = new Array('c','Страница категории');
ta['ca-nstab-category'] = new Array('c','Страница категории');
function addLoadEvent(func)
{
if (window.addEventListener)
  window.addEventListener("load", func, false);
else if (window.attachEvent)
  window.attachEvent("onload", func);
}
/* Обеспечиваем нигилистические фокусы (см., например, статью [[Google]]) */
function do_nihilism()
{
  nhl = document.getElementById('nihilism');
  if(nhl)
  {
    msg = nhl.innerHTML;
    document.getElementById('globalWrapper').innerHTML = "<div id='nihilism_message'>" + msg + "</div>";   
  }
}
addLoadEvent(do_nihilism);
/* Делаем ссылку «править» для нулевой секции — (C) Edward. */
function do_edit_null()
{
  if(document.getElementById('bodyContent').innerHTML.match('class=\"editsection\"'))
    document.getElementById('bodyContent').innerHTML = "<div class=\"editsection\" id=\"ca-edit-0\">[<a href=\"http://absurdopedia.wikia.com/index.php?title=" + document.title.substr(0, document.title.lastIndexOf(" — ")) + "&action=edit&section=0\">править</a>]</div>" + document.getElementById('bodyContent').innerHTML;
}
addLoadEvent(do_edit_null);
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://absurdopedia.wikia.com/index.php?title=Template:Stdreasons&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;
}
addLoadEvent(fillDeleteReasons);


/* </nowiki></pre> */
/* </nowiki></pre> */