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;

// [[User:ais523/bracketmatch.js]] - Colour matching brackets in a copy of the edit box.
// By [[User:ais523]], on a suggestion by [[User:Absidy]].
 
$(function(){
  var p=document.getElementById('wikiPreview');
  if(p==null) p=document.getElementById('viewsourcetext');
  if(p)
    p.innerHTML+="<div id='bm_parseres'><a href='javascript:bm_parsebrackets();'>Parse</a></div>";
});
 
function bm_parsebrackets()
{
  var t=document.getElementById('wpTextbox1').value;
  var a=sajax_init_object();
  var p='action=expandtemplates&generatexml=1&format=json&callback=bm_callback&text='+encodeURIComponent(t);
  a.open('POST', mw.config.get('wgServer')+mw.config.get('wgScriptPath')+'/api.php');
  a.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  a.setRequestHeader("Content-length", p.length);
  a.setRequestHeader("Connection", "close");
  a.onreadystatechange=function(){bm_apirespond(a)};
  a.send(p);
}
 
function bm_apirespond(a)
{
  try
  {
    if(a.readyState==4)
      eval(a.responseText);
  }
  catch(e)
  {
    document.getElementById('bm_parseres').innerHTML=
      "Could not parse due to a server error. <a href='javascript:bm_parsebrackets();'>Parse</a>";
  }
}
 
var colang;
 
function bm_hexdigit(n)
{
  var i=Math.floor(n);
  if(i<10) return i+'';
  if(i==10) return 'A';
  if(i==11) return 'B';
  if(i==12) return 'C';
  if(i==13) return 'D';
  if(i==14) return 'E';
  if(i==15) return 'F';
}
 
function bm_tohex(n)
{
  var i=Math.floor(n);
  return bm_hexdigit(i/16)+bm_hexdigit(i%16);
}
 
function bm_gencol(ang)
{
  var r=Math.sin(ang)+1;
  var g=Math.sin(ang+3.14159*2/3)+1;
  var b=Math.sin(ang-3.14159*2/3)+1;
  return bm_tohex(r*127.5)+bm_tohex(g*127.5)+bm_tohex(b*127.5);
}
 
function bm_callback(o)
{
  var subs={"tplarg":"{{{",
            "/tplarg":"}}}",
            "template":"{{",
            "/template":"}}",
            "part":"|",
            "ext":"&"+"lt;",
            "/attr":"&"+"gt;",
            "attr/":"&"+"gt;"};
  var h=o.parsetree["*"].split("<");
  var i=h.length;
  var r;
  var n;
  var sp=0;
  var st=new Array();
  var col;
  colang=0;
  while(--i)
  {
    col="";
    n=1;
    h[i]=h[i].split(">");
    h[i][0]=h[i][0].split(" ");
    r=subs[h[i][0][0]];
    if(r==undefined) r="";
    if(r=='}}}'||r=='}}')
    {
      st[sp]=bm_gencol(colang);
      col=st[sp];
      sp++;
      colang+=2.4; //golden angle in radians, approx
    }
    else if(r=='{{{'||r=='{{')
    {
      sp--;
      col=st[sp];
      n=2;
    }
    if(col!="")
      r="<font color='#"+col+"' id='bm_f"+col+n+"' onclick='bm_highlight(\""+col+"\",\"black\")'>"+r+"</font>";
    h[i][0]=r;
    h[i]=h[i].join("");
  }
  document.getElementById('bm_parseres').innerHTML=
    "<div style='border:1px solid blue'><tt>"+h.join("").split("\n").join("<br />")+
    "</tt></div><div><a href='javascript:bm_parsebrackets();'>Parse</a></div>";
}
 
function bm_highlight(x,c)
{
  document.getElementById('bm_f'+x+'1').style.backgroundColor=c;
  document.getElementById('bm_f'+x+'2').style.backgroundColor=c;
  if(c=="black")
    window.setTimeout("bm_highlight('"+x+"','transparent')",3000);
}
 
//test: {{{a|b}}} {{a|b}} {{c|{{e|a=b|3=c}}|f}}<imagemap type=c>abc</imagemap>
//test: <i>f</i><nowiki>g</nowiki><includeonly>h</includeonly>
//test: <noinclude>i</noinclude> {{{{{{{{j}}}}}}}}
/* test:
{{startofline}}
*/

if (mwCustomEditButtons) {
//Strike-Out Button
mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageFile": "http://upload.wikimedia.org/wikipedia/en/c/c9/Button_strike.png",
    "speedTip": "Strike",
    "tagOpen": "<s>",
    "tagClose": "</s>",
    "sampleText": "Strike-through text"};
mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/b/ba/Button_conserver.png",
    "speedTip": "Hlasuj Za",
    "tagOpen": "",
    "tagClose": "",
    "sampleText": "#{{za}} \~\~\~\~"};
mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/f/fc/Button_supp.png",
    "speedTip": "Hlasuj Proti",
    "tagOpen": "",
    "tagClose": "",
    "sampleText": "#{{proti}} \~\~\~\~"};
mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/4/4e/Button_neutre.png",
    "speedTip": "Hlasuj Neutral",
    "tagOpen": "",
    "tagClose": "",
    "sampleText": "#{{neutral}} \~\~\~\~"};
};

function addPurge(){
    ta['ca-purge'] = ['g', 'Purge the internal cache for 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');
}

function addEditSection0(){
    ta['ca-edit-0'] = ['', 'Edit the zeroth section of this page'];
    if(!document.getElementById) return;
    var x = document.getElementById('ca-edit');
    if(!x) return;
    var y = document.createElement('LI');
    y.id = 'ca-edit-0';
    if(x.className == 'selected'){
      if(/&action=edit&section=0$/.test(window.location.href)){
        x.className = 'istalk';
        y.className = 'selected';
      } else {
        x.className = 'selected istalk';
      }
    } else if(x.className == 'selected istalk'){
      if(/&action=edit&section=0$/.test(window.location.href)){
        x.className = 'istalk';
        y.className = 'selected istalk';
      } else {
        y.className = 'istalk';
      }
    } else {
      y.className = x.className;
      x.className = 'istalk';
    }
    var z = document.createElement('A');
    if(x.children){
        z.href = x.children[0].href + '&section=0';
        z.appendChild(document.createTextNode('0'));
        y.appendChild(z);
        document.getElementById('p-cactions').children[1].insertBefore(y,x.nextSibling);
    }else{
        z.href = x.childNodes[0].href + '&section=0';
        z.appendChild(document.createTextNode('0'));
        y.appendChild(z);
        document.getElementById('p-cactions').childNodes[3].insertBefore(y,x.nextSibling);
    }
}

function experimenty(){
    var dva = confirm("Druhýkrát?");
    var txt = document.editform.wpTextbox1;
    if(txt.value.length > 0) txt.value += '\n';
    if (dva) {
      txt.value += '{{experimenty2}} --~~'+'~~';
      document.editform.wpSummary.value = '{{experimenty2}}';
    } else {
      txt.value += '{{experimenty}} ~~'+'~~';
      document.editform.wpSummary.value = '{{experimenty}}';
    }
    txt.focus();
}

function vandalizmus(){
    var dva = confirm("Druhýkrát?");
    var txt = document.editform.wpTextbox1;
    if(txt.value.length > 0) txt.value += '\n';
    if (dva) {
      txt.value += '{{vandalizmus2}} --~~'+'~~';
      document.editform.wpSummary.value = '{{vandalizmus2}}';
    } else {
      txt.value += '{{vandalizmus}} --~~'+'~~';
      document.editform.wpSummary.value = '{{vandalizmus}}';
    }
    txt.focus();
}

function zaregistrujsa(){
    document.editform.wpSummary.value = '{{zaregistruj sa}}';
    var txt = document.editform.wpTextbox1;
    if(txt.value.length > 0) txt.value += '\n';
    txt.value += '{{zaregistruj sa}} --~~'+'~~';
    txt.focus();
}

function reklama(){
    var dva = confirm("Druhýkrát?");
    var txt = document.editform.wpTextbox1;
    if(txt.value.length > 0) txt.value += '\n';
    if (dva) {
      txt.value += '{{reklama2}} --~~'+'~~';
      document.editform.wpSummary.value = '{{reklama2}}';
    } else {
      txt.value += '{{reklama}} --~~'+'~~';
      document.editform.wpSummary.value = '{{reklama}}';
    }
    txt.focus();
}

function urgent(){
    document.editform.wpSummary.value = 'urgent';
    var datum = new Date();
    var den = datum.getDate();
    if (den.toString().length == 1) {den = '0' + den.toString();}
    var mesiac = datum.getMonth();
    mesiac++;
    if (mesiac.toString().length == 1) {mesiac = '0' + mesiac.toString();}
    var rok = datum.getFullYear();
    var txt = document.editform.wpTextbox1;
    txt.value = '\x7b\x7burgentne upraviť|' + rok.toString() + mesiac.toString() + den.toString() + '}}\n' + txt.value;
    txt.focus();
}

function ZmazatLebo(){
    document.editform.wpSummary.value = 'rýchle zmazanie';
    var dovod = prompt("Zadaj dôvod","nezmysel");
    var txt = document.editform.wpTextbox1;
    txt.value = '\x7b\x7bZL|' + dovod + '}}\n' + txt.value;
    txt.focus();
}

function addlilink(tabs, url, name, id){
    var na = document.createElement('a');
    na.href = url;
    na.id = id;
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    li.appendChild(na);
    tabs.appendChild(li);
    return li;
}

function morelinks(){
    var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
    if(document.title.indexOf("Úprava stránky") == 0)
    {
      addlilink(tabs, 'javascript:urgent()', 'urgentne upraviť', '');
      addlilink(tabs, 'javascript:ZmazatLebo()', 'zmazať lebo', '');
    }
    if(document.title.indexOf("Úprava stránky Diskusia s redaktorom") == 0)
    {
      /*addlilink(tabs, 'javascript:zaregistrujsa()', 'registrácia', '');*/
      addlilink(tabs, 'javascript:reklama()', 'reklama', '');
      addlilink(tabs, 'javascript:experimenty()', 'experimenty', '');
      addlilink(tabs, 'javascript:vandalizmus()', 'vandalizmus', '');
    }
}

function LinkFA() 
{
   // iterate over all <span>-elements
   for(var i=0; a = document.getElementsByTagName("span")[i]; i++) {
      // if found a FA span
      if(a.className == "FA") {
         // iterate over all <li>-elements
         for(var j=0; b = document.getElementsByTagName("li")[j]; j++) {
            // if found a FA link
            if(b.className == "interwiki-" + a.id) {
               b.style.padding = "0 0 0 16px";
               b.style.backgroundImage = "url('http://upload.wikimedia.org/wikipedia/en/6/60/LinkFA-star.png')";
               b.style.backgroundRepeat = "no-repeat";
               b.title = "This article has gained featured status";
            }
         }
      }
   }
}

function myLoadFuncs(){
  if (!window.ta)
    window.ta = {};
  addPurge();
//    addEditSection0();
//    InsertButtonsToToolBar();
  morelinks();
  LinkFA();
}

if (window.addEventListener)
window.addEventListener("load",myLoadFuncs,false);
else if (window.attachEvent)
window.attachEvent("onload",myLoadFuncs);
else {
    window._old_ABCD_onload = window.onload;
    window.onload = function(){
        window._old_ABCD_onload();
        myLoadFuncs();
    }
}