Redaktor:Palica/monobook.js

z Wikipédie, slobodnej encyklopédie

Poznámka: Aby sa zmeny prejavili, po uložení musíte vymazať vyrovnávaciu pamäť vášho prehliadača. Mozilla / Firefox / Safari: držte stlačený Shift a kliknite na Reload alebo stlačte buď Ctrl-F5 alebo Ctrl-R (Command-R na Macintosh); Konqueror:: kliknite na tlačidlo Reload alebo stlačte F5; Opera vymazať vyrovnávaciu pamäť prehliadača v ponuke Tools→Preferences; Internet Explorer: držte Ctrl a kliknite na Refresh alebo stlačte Ctrl-F5;

/* <nowiki> */
//--------------------------------------------------------------------------------
// [[User:Lupin/popups.js]] - please include this line 
mw.loader.load('https://en.wikipedia.org/w/index.php?action=raw&ctype=text/javascript&title=User:Lupin/popups.js');

popupAdminLinks=false;
popupActionsMenu=true;
popupStructure='menus';
popupPreviewRawTemplates=true;
//--------------------------------------------------------------------------------

//--------------------------------------------------------------------------------
// wikEd - A full-featured edit page-integrated text editor for Firefox / Mozilla
mw.loader.load('https://en.wikipedia.org/w/index.php?action=raw&ctype=text/javascript&title=User:Cacycle/wikEd.js');
//--------------------------------------------------------------------------------

//--------------------------------------------------------------------------------
// Two columns
mw.loader.load('https://en.wikipedia.org/w/index.php?action=raw&ctype=text/javascript&title=Wikipedia:WikiProject_User_scripts/Scripts/TwoColumns.js');
//--------------------------------------------------------------------------------

//--------------------------------------------------------------------------------
/* Inspired by [[en:User:ABCD/monobook.js]] */
function vitajte(){
    var reg = prompt("Reg?");
    if(!reg) return;
    document.editform.wpSummary.value = 'Vitajte/Welcome ';
    var txt = document.editform.wpTextbox1;
    if(txt.value.length > 0) txt.value += '\n';
    txt.value += '{{Vitajte|redaktor=Palica|reg=reg' + reg + '}}';
    txt.focus();
}

function addlilink(tabs, url, name, id, title, key){
    var na = document.createElement('a');
    na.href = url;
    na.appendChild(document.createTextNode(name));
    na.accesskey = key;
    var pref = 'alt-';
    var clientPC = navigator.userAgent.toLowerCase();
    if(((clientPC.indexOf('AppleWebKit')!=-1) && (clientPC.indexOf('spoofer')==-1)) || navigator.userAgent.toLowerCase().indexOf( 'mac' ) != -1 ) pref = 'control-';
    if(clientPC.indexOf('opera')!=-1) pref = 'shift-esc-';
    if(key && title) na.title = title + ' [' + pref + key + ']';
    else if(title) na.title = title;
    else if(key) na.title = '[' + pref + key + ']';
    var li = document.createElement('li');
    if(id) li.id = id;
    li.appendChild(na);
    tabs.appendChild(li);
    return li;
}

function addTab(url, name, id, title, key){
    var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
    addlilink(tabs, url, name, id, title, key);
}

function addLinks(){
    ta['ca-diff'] = new Array('d', 'Show last diff');
    ta['ca-purge'] = new Array('g', 'Purge the internal cache for this page');
    ta['ca-0section'] = new Array('0', 'Edit the 0th section of this page');
    if(!document.getElementById) return;
    var x = document.getElementById('ca-history');
    var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
    if(!x) return;
    if(x.children) x = x.children[0];
    else x = x.childNodes[0];
    addlilink(tabs, x.href.replace(/=history/, "=purge"), 'purge', 'ca-purge');
    addlilink(tabs, x.href.replace(/=history/, "=edit&section=0"), '0', 'ca-0section');
    addlilink(tabs, x.href.replace(/action=history/, "diff=cur&oldid=prev"), 'diff', 'ca-diff');
}

function changeLinks(){
    if(!document.getElementById) return;
    document.getElementById('pt-mytalk').firstChild.innerHTML = 'moja diskusia';
    document.getElementById('pt-preferences').firstChild.innerHTML = 'nastavenia';
    document.getElementById('pt-watchlist').firstChild.innerHTML = 'sledované články';
    document.getElementById('pt-mycontris').firstChild.innerHTML = 'moje príspevky';
    document.getElementById('pt-logout').firstChild.innerHTML = 'odhlásenie';
    if(document.getElementById('ca-talk'))
       document.getElementById('ca-talk').firstChild.innerHTML = 'diskusia';
    if(document.getElementById('ca-edit'))
        document.getElementById('ca-edit').firstChild.innerHTML = 'upravuj';
    if(document.getElementById('ca-history'))
        document.getElementById('ca-history').firstChild.innerHTML = 'história';
    if(document.getElementById('ca-move'))
        document.getElementById('ca-move').firstChild.innerHTML = 'presuň';
    if(document.getElementById('ca-watch'))
        document.getElementById('ca-watch').firstChild.innerHTML = 'sleduj';
    if(document.getElementById('ca-nstab-wp'))
        document.getElementById('ca-nstab-wp').firstChild.innerHTML = 'About';
}

function addForceSummary(){
    if(!/&action=edit/.test(window.location.href)) return;
    if(/&section=new/.test(window.location.href)) return;
    if(!document.forms.editform) return;
    document.forms.editform.wpSave.onclick = forceSummary;
}

function forceSummary(){
    if(!document.forms.editform.wpSummary.value.replace(/^(\/\*.*\*\/)? *(.*) *$/,'$2')){
      var r = prompt('Are you sure you want to submit without adding a summary?\nTo add a summary, type it in the box below:',document.forms.editform.wpSummary.value);
      if(r == null) return false;
      document.forms.editform.wpSummary.value = r;
    }
    return true;
}

function morelinks(){
        addTab('javascript:vitajte()', 'vitajte', '');
}

function addToolBoxLinks(){
    var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0];
    addlilink(tb, '/wiki/Special:Newpages', 'Nové stránky', 't-newpages');
    addlilink(tb, '/wiki/Special:Shortpages', 'Krátke stránky', 't-shortpages');
    addlilink(tb, '/wiki/Special:Allpages', 'Všetky stránky', 't-allpages');
    addlilink(tb, '/wiki/Special:Allmessages', 'All messages', 't-allmessages');
    addlilink(tb, '/wiki/Special:Log', 'Logs', 't-logs');
}

function strip_namespace(target){
    var colon = target.indexOf(':');
    if(colon != -1){
        var spaces = ['User', 'Wikipedia', 'Image', 'MediaWiki', 'Template', 'Help', 'Category', 'Portal'];
        var ns = target.substring(0, colon);
        if(ns == '' || ns == 'Talk') return target.substring(colon + 1);
        else
            for(var i = 0; i < spaces.length; ++i)
                if(ns == spaces[i] || ns == spaces[i] + '_talk') return target.substring(colon + 1);
    }
    return target;
}

function getParam(name){
    if(location.search){
        for(var x in location.search.substring(1).split('&')){
            var eq = x.indexOf('=');
            if(x.substring(0, eq) == name) return x.substring(eq + 1);
        }
    }
    return '';
}

function myLoadFuncs(){
    addLinks();
    addForceSummary();
    morelinks();
    addToolBoxLinks();
}

//if (window.addEventListener) window.addEventListener("load",myLoadFuncs,false);
//else if (window.attachEvent) window.attachEvent("onload",myLoadFuncs);
$(myLoadFuncs);
//--------------------------------------------------------------------------------
/* </nowiki> */