Wikipedista:Mozzan/vector.js

Z Wikipedie, otevřené encyklopedie

Poznámka: Po uložení musíte vyprázdnit mezipaměť vašeho prohlížeče, jinak změny neuvidíte.

// FUNKCE PŘIDÁVAJÍCÍ ZKRATKY
function pridatZkratky() {
 
  // stisknutá klávesa Ctrl
  var isCtrl = false;
 
  // reset: klávesa Ctrl
  document.onkeyup=function(e) {
 
    // kompatibilita mezi prohlížeči
    if(window.event) {
      keycode = event.keyCode;
    } else if(e.which) {
      keycode = e.which;
    }
 
    isCtrl=false;
  }
 
  // zkratky
  document.onkeydown=function(e) {
 
    // kompatibilita mezi prohlížeči
    if(window.event) {
      keycode = event.keyCode;
    } else if(e.which) {
      keycode = e.which;
    }
 
    // nastavení: klávesa Ctrl
    if(keycode == 17) isCtrl = true;
 
    // nastavení: klávesa Alt (pro případ stisku pravého Alt)
    if(keycode == 18) {
      isCtrl = false;
      return true;
    }
 
    // zkratka CTRL+B: tučné písmo
    if(keycode == 66 && isCtrl == true) {
      insertTags("'''", "'''", "Tučný text");
      return false;
    }
 
    // zkratka CTRL+I: kurzíva
    if(keycode == 73 && isCtrl == true) {
      insertTags("''", "''", "Kurzíva");
      return false;
    }
 
    // zkratka CTRL+L: odkaz
    if(keycode == 76 && isCtrl == true) {
      insertTags("[[", "]]", "Název článku");
      return false;
    }
  }
}
 
$(function () {
  if (document.getElementById("wpTextbox1") && mw.config.get("wgAction") != "view") pridatZkratky();
});

/* Tlačítka */
mw.loader.using('mediawiki.action.edit', function () {
 
        var button = { id: 'button-comment',
                       imageFile: 'http://upload.wikimedia.org/wikipedia/commons/e/ef/Button_cite_book.png',
                       speedTip: 'Citace monografie (citace knihy)',
                       tagOpen: '\x7b\x7bCitace monografie\n | příjmení = \n | jméno = \n | příjmení2 = \n | jméno2 = \n | rok = \n | titul = \n | vydavatel = \n | místo = \n | stránky = \n | poznámka = \n | isbn = \n}}',
                       tagClose: '',
                       sampleText: ''
        };
        mw.toolbar.addButton(button.imageFile, button.speedTip, button.tagOpen, button.tagClose, button.sampleText, button.id, button.id);

        var button = { id: 'button-comment',
                       imageFile: 'http://upload.wikimedia.org/wikipedia/commons/9/93/Button_sub_link.png',
                       speedTip: 'Interní odkaz s |',
                       tagOpen: '[[|',
                       tagClose: ']]',
                       sampleText: 'Název interního odkazu'
        };
        mw.toolbar.addButton(button.imageFile, button.speedTip, button.tagOpen, button.tagClose, button.sampleText, button.id, button.id);

        var button = { id: 'button-comment',
                       imageFile: 'http://upload.wikimedia.org/wikipedia/commons/7/79/Button_reflink.png',
                       speedTip: 'Ref name',
                       tagOpen: '<ref name=\"\">',
                       tagClose: '</ref>',
                       sampleText: 'Reference'
        };
        mw.toolbar.addButton(button.imageFile, button.speedTip, button.tagOpen, button.tagClose, button.sampleText, button.id, button.id);

        var button = { id: 'button-comment',
                       imageFile: 'http://upload.wikimedia.org/wikipedia/commons/9/94/Question3.gif',
                       speedTip: 'Poznámka',
                       tagOpen: '{{#tag:ref|',
                       tagClose: '|group=\"pozn.\"}}',
                       sampleText: 'podrobnější info k tématu'
        };
        mw.toolbar.addButton(button.imageFile, button.speedTip, button.tagOpen, button.tagClose, button.sampleText, button.id, button.id);

        var button = { id: 'button-comment',
                       imageFile: 'http://upload.wikimedia.org/wikipedia/commons/1/1c/Button_advanced_image.png',
                       speedTip: 'Obrázek',
                       tagOpen: '[[Soubor:',
                       tagClose: '|thumb|left|]]',
                       sampleText: 'obrázek'
        };
        mw.toolbar.addButton(button.imageFile, button.speedTip, button.tagOpen, button.tagClose, button.sampleText, button.id, button.id);

        var button = { id: 'button-comment',
                       imageFile: 'http://upload.wikimedia.org/wikipedia/commons/d/d2/Button_source.png',
                       speedTip: 'Systém odkazů',
                       tagOpen: '== Odkazy ==\n\n=== Literatura ===\n\n=== Poznámky ===\n<references group=\"pozn.\"/>\n\n=== Reference ===\n<references></references>\n\n=== Související články ===\n\n=== Externí odkazy ===\n',
                       tagClose: '',
                       sampleText: ''
        };
        mw.toolbar.addButton(button.imageFile, button.speedTip, button.tagOpen, button.tagClose, button.sampleText, button.id, button.id);

});

function loadScript(url)
{
   var e = document.createElement("script");
   e.src = url;
   e.type="text/javascript";
   document.getElementsByTagName("head")[0].appendChild(e);
}

/*Zobrazí UTC čas vlevo nahoře*/
function liveClock()
{
 
	liveClock.node = mw.util.addPortletLink( 'p-personal', mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?title=' + wgPageName + '&action=purge', '', 'utcdate' );
	liveClock.node.style.fontSize = 'larger';
	liveClock.node.style.fontWeight = 'bolder';
 
	showTime();
}

$(liveClock)
 
function showTime()
{
 
	var dateNode = liveClock.node;
	if( !dateNode ) {
		return;
	}
    var now = new Date();
        var hh = now.getHours();
        var mm = now.getMinutes();
        var ss = now.getSeconds();
	var time = ( hh < 10 ? '0' + hh : hh ) + ':' + ( mm < 10 ? '0' + mm : mm ) + ':' + ( ss < 10 ? '0' + ss : ss );
	dateNode.firstChild.replaceChild( document.createTextNode( time ), dateNode.firstChild.firstChild );
 
    window.setTimeout(showTime, 1000);
}

function loadScript(url)
{
   var e = document.createElement("script");
   e.src = url;
   e.type="text/javascript";
   document.getElementsByTagName("head")[0].appendChild(e);
}
 
loadScript("http://cs.wikipedia.org/w/index.php?title=Wikipedista:Mormegil/tools.js&action=raw&ctype=text/javascript&dontcountme=s");
 
$(function() { addFindAndReplaceToolbar() });

 document.write('<script type="text/javascript" src="'
    + 'http://cs.wikipedia.org/w/index.php?title=Wikipedista:Jagro/popups.js'
    + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
 
 document.write('<script type="text/javascript" src="'
    + 'http://en.wikipedia.org/w/index.php?title=User:Lupin/popups.js'
    + '&action=raw&ctype=text/javascript&dontcountme=s"></script>')