User:Jvs/global.js

From Meta, a Wikimedia project coordination wiki

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
// <nowiki>
/** Tlačítka */
var initFnList = [];

mw.loader.using('mediawiki.action.edit', function () {

  var button;

  button = { id: 'button-comment',
    imageFile: '//upload.wikimedia.org/wikipedia/commons/c/c8/Button_redirect.png',
    speedTip: 'Redirect',
    tagOpen: '#REDIRECT [[',
    tagClose: ']]',
    sampleText: ''
  };
  mw.toolbar.addButton(button.imageFile, button.speedTip, button.tagOpen, button.tagClose, button.sampleText, button.id, button.id);

  /*button = { id: 'button-comment',
    imageFile: '//upload.wikimedia.org/wikipedia/commons/d/d1/Button_mysignature.png',
    speedTip: 'Alternativní podpis |',
    tagOpen: '--[[Wikipedista:Jvs|Jvs]]&nbsp;<sub>[[Wikipedista diskuse:Jvs|slova]]</sub><sup>[[Speciální:Contributions/Jvs|činy]]</sup> \x7E\x7E\x7E\x7E\x7E',
    tagClose: '',
    sampleText: ''
  };
  mw.toolbar.addButton(button.imageFile, button.speedTip, button.tagOpen, button.tagClose, button.sampleText, button.id, button.id);*/

  button = { id: 'button-comment',
    imageFile: '//upload.wikimedia.org/wikipedia/commons/a/a0/Button_keep.png',
    speedTip: 'Vyřešeno',
    tagOpen: '\x7b\x7bWikipedie:Nástěnka správců/Vyřešeno}}&nbsp;',
    tagClose: '',
    sampleText: ''
  };
  mw.toolbar.addButton(button.imageFile, button.speedTip, button.tagOpen, button.tagClose, button.sampleText, button.id, button.id);

  button = { id: 'button-comment',
    imageFile: '//upload.wikimedia.org/wikipedia/commons/1/13/Button_delete.png',
    speedTip: 'Nevyřešeno',
    tagOpen: '\x7b\x7bWikipedie:Nástěnka správců/Nevyřešeno}}&nbsp;',
    tagClose: '',
    sampleText: ''
  };
  mw.toolbar.addButton(button.imageFile, button.speedTip, button.tagOpen, button.tagClose, button.sampleText, button.id, button.id);

  /*button = { id: 'button-comment',
    imageFile: '//upload.wikimedia.org/wikipedia/commons/3/38/Button_comment_vote.png',
    speedTip: 'Komentář',
    tagOpen: '\x7b\x7bKomentář}}&nbsp;',
    tagClose: '',
    sampleText: ''
  };
  mw.toolbar.addButton(button.imageFile, button.speedTip, button.tagOpen, button.tagClose, button.sampleText, button.id, button.id);*/

  button = { id: 'button-comment',
    imageFile: '//upload.wikimedia.org/wikipedia/commons/c/cd/Exp0.png',
    speedTip: 'Experimenty0',
    tagOpen: '\x7b\x7bsubst:experimenty0}} --\x7E\x7E\x7E\x7E',
    tagClose: '',
    sampleText: ''
  };
  mw.toolbar.addButton(button.imageFile, button.speedTip, button.tagOpen, button.tagClose, button.sampleText, button.id, button.id);

  button = { id: 'button-comment',
    imageFile: '//upload.wikimedia.org/wikipedia/commons/a/a5/Buttonexperimenty.png',
    speedTip: 'Experimenty',
    tagOpen: '\x7b\x7bsubst:experimenty}} --\x7E\x7E\x7E\x7E',
    tagClose: '',
    sampleText: ''
  };
  mw.toolbar.addButton(button.imageFile, button.speedTip, button.tagOpen, button.tagClose, button.sampleText, button.id, button.id);

  button = { id: 'button-comment',
    imageFile: '//upload.wikimedia.org/wikipedia/commons/1/16/Buttonexperimenty2.png',
    speedTip: 'Experimenty2',
    tagOpen: '\x7b\x7bsubst:experimenty2}} --\x7E\x7E\x7E\x7E',
    tagClose: '',
    sampleText: ''
  };
  mw.toolbar.addButton(button.imageFile, button.speedTip, button.tagOpen, button.tagClose, button.sampleText, button.id, button.id);

  /*button = { id: 'button-comment',
    imageFile: '//upload.wikimedia.org/wikipedia/commons/5/5b/Button_STFW.png',
    speedTip: 'ExperimentySTFW',
    tagOpen: '\x7b\x7bExperimentySTFW}} --\x7E\x7E\x7E\x7E',
    tagClose: '',
    sampleText: ''
  };
  mw.toolbar.addButton(button.imageFile, button.speedTip, button.tagOpen, button.tagClose, button.sampleText, button.id, button.id);*/

  /*button = { id: 'button-comment',
    imageFile: '//upload.wikimedia.org/wikipedia/commons/2/2e/Button_broom.png',
    speedTip: 'Smazaný článek',
    tagOpen: '\x7b\x7bsubst:nevýznamné',
    tagClose: '}} ',
    sampleText: ''
  };
  mw.toolbar.addButton(button.imageFile, button.speedTip, button.tagOpen, button.tagClose, button.sampleText, button.id, button.id);*/

  button = { id: 'button-comment',
    imageFile: '//upload.wikimedia.org/wikipedia/commons/1/13/Stub_class_button.png',
    speedTip: 'Subpahýl',
    tagOpen: '\x7b\x7bsubst:Subpahýl}}',
    tagClose: '',
    sampleText: ''
  };
  mw.toolbar.addButton(button.imageFile, button.speedTip, button.tagOpen, button.tagClose, button.sampleText, button.id, button.id);

  button = { id: 'button-comment',
    imageFile: '//upload.wikimedia.org/wikipedia/commons/1/13/Stub_class_button.png',
    speedTip: 'Přeložit',
    tagOpen: '\x7b\x7bsubst:Přeložit}}',
    tagClose: '',
    sampleText: ''
  };
  mw.toolbar.addButton(button.imageFile, button.speedTip, button.tagOpen, button.tagClose, button.sampleText, button.id, button.id);

  button = { id: 'button-comment',
    imageFile: '//upload.wikimedia.org/wikipedia/commons/1/13/Stub_class_button.png',
    speedTip: 'Strojový překlad',
    tagOpen: '\x7b\x7bsubst:Strojový překlad}}',
    tagClose: '',
    sampleText: ''
  };
  mw.toolbar.addButton(button.imageFile, button.speedTip, button.tagOpen, button.tagClose, button.sampleText, button.id, button.id);

  button = { id: 'button-comment',
    imageFile: '//upload.wikimedia.org/wikipedia/commons/2/22/Button_radio_activite.png',
    speedTip: 'Urgentně upravit',
    tagOpen: '\x7b\x7bsubst:Urgentně upravit}}',
    tagClose: '',
    sampleText: ''
  };
  mw.toolbar.addButton(button.imageFile, button.speedTip, button.tagOpen, button.tagClose, button.sampleText, button.id, button.id);

  button = { id: 'button-comment',
    imageFile: '//upload.wikimedia.org/wikipedia/commons/2/22/Button_radio_activite.png',
    speedTip: 'Urgentně ověřit',
    tagOpen: '\x7b\x7bsubst:Urgentně ověřit}}',
    tagClose: '',
    sampleText: ''
  };
  mw.toolbar.addButton(button.imageFile, button.speedTip, button.tagOpen, button.tagClose, button.sampleText, button.id, button.id);

  button = { id: 'button-comment',
    imageFile: '//upload.wikimedia.org/wikipedia/commons/2/22/Button_radio_activite.png',
    speedTip: 'Významnost',
    tagOpen: '\x7b\x7bsubst:Významnost}}',
    tagClose: '',
    sampleText: ''
  };
  mw.toolbar.addButton(button.imageFile, button.speedTip, button.tagOpen, button.tagClose, button.sampleText, button.id, button.id);

  button = { id: 'button-comment',
    imageFile: '//upload.wikimedia.org/wikipedia/commons/e/e5/Button_copyvio.png',
    speedTip: 'Copyvio',
    tagOpen: '\x7b\x7bCopyvio|zdroj=',
    tagClose: '}}',
    sampleText: ''
  };
  mw.toolbar.addButton(button.imageFile, button.speedTip, button.tagOpen, button.tagClose, button.sampleText, button.id, button.id);

  button = { id: 'button-comment',
    imageFile: '//upload.wikimedia.org/wikipedia/commons/3/33/Button_unreferenced.png',
    speedTip: 'Chybí zdroj',
    tagOpen: '\x7b\x7bsubst:Fakt',
    tagClose: '}}',
    sampleText: ''
  };
  mw.toolbar.addButton(button.imageFile, button.speedTip, button.tagOpen, button.tagClose, button.sampleText, button.id, button.id);

  button = { id: 'button-comment',
    imageFile: '//upload.wikimedia.org/wikipedia/commons/4/4a/Button_welcome.png',
    speedTip: 'Vítejte',
    tagOpen: '\x7b\x7bsubst:vítejte}} --\x7E\x7E\x7E\x7E',
    tagClose: '',
    sampleText: ''
  };
  mw.toolbar.addButton(button.imageFile, button.speedTip, button.tagOpen, button.tagClose, button.sampleText, button.id, button.id);

  button = { id: 'button-comment',
    imageFile: '//upload.wikimedia.org/wikipedia/commons/e/e9/Button_preview.png',
    speedTip: 'Náhled',
    tagOpen: '== Prosím používejte tlačítko „Ukázat náhled“ ==\n\x7b\x7bsubst:Náhled}} --\x7E\x7E\x7E\x7E',
    tagClose: '',
    sampleText: ''
  };
  mw.toolbar.addButton(button.imageFile, button.speedTip, button.tagOpen, button.tagClose, button.sampleText, button.id, button.id);

  button = { id: 'button-comment',
    imageFile: '//upload.wikimedia.org/wikipedia/commons/6/6c/Button_commons.png',
    speedTip: 'Commonscat',
    tagOpen: '\x7b\x7bCommonscat|',
    tagClose: '}}',
    sampleText: ''
  };
  mw.toolbar.addButton(button.imageFile, button.speedTip, button.tagOpen, button.tagClose, button.sampleText, button.id, button.id);

  button = { id: 'button-comment',
    imageFile: '//upload.wikimedia.org/wikipedia/commons/9/91/Button_cite_web.png',
    speedTip: 'Citace elektronické monografie (webu)',
    tagOpen: '<ref>\x7b\x7bCitace elektronické monografie\n | příjmení = \n | jméno = \n | odkaz na autora = \n | vydavatel = \n | titul = \n | url = \n | datum vydání = \n | datum přístupu = ' + (y = new Date().getFullYear ()) + '-' + (m = new Date ().getMonth () + 1) + '-' + (d = new Date ().getDate ()) + '\n | jazyk = \n}}</ref>',
    tagClose: '',
    sampleText: ''
  };
  mw.toolbar.addButton(button.imageFile, button.speedTip, button.tagOpen, button.tagClose, button.sampleText, button.id, button.id);

  button = { id: 'button-comment',
    imageFile: '//upload.wikimedia.org/wikipedia/commons/e/ef/Button_cite_book.png',
    speedTip: 'Citace monografie',
    tagOpen: '<ref>\x7b\x7bCitace monografie\n | příjmení = \n | jméno = \n | odkaz na autora = \n | titul = \n | vydavatel = \n | místo = \n | rok = \n | isbn = \n | strany = \n | počet stran = \n | url = \n | jazyk = \n}}</ref>',
    tagClose: '',
    sampleText: ''
  };
  mw.toolbar.addButton(button.imageFile, button.speedTip, button.tagOpen, button.tagClose, button.sampleText, button.id, button.id);

  button = { id: 'button-comment',
    imageFile: '//upload.wikimedia.org/wikipedia/commons/4/49/Button_cite_journal.png',
    speedTip: 'Citace periodika',
    tagOpen: '<ref>\x7b\x7bCitace periodika\n | příjmení = \n | jméno = \n | autor = \n | titul = \n | periodikum = \n | rok = \n | měsíc = \n | ročník = volume \n | číslo = issue \n | doi = \n | issn = \n | url = \n | strany = \n | jazyk = \n}}</ref>',
    tagClose: '',
    sampleText: ''
  };
  mw.toolbar.addButton(button.imageFile, button.speedTip, button.tagOpen, button.tagClose, button.sampleText, button.id, button.id);

  button = { id: 'button-comment',
    imageFile: '//upload.wikimedia.org/wikipedia/commons/1/17/Button_small_2.png',
    speedTip: 'Small',
    tagOpen: '\x7b\x7bmalé|',
    tagClose: '}}',
    sampleText: ''
  };
  mw.toolbar.addButton(button.imageFile, button.speedTip, button.tagOpen, button.tagClose, button.sampleText, button.id, button.id);

  button = { id: 'button-comment',
    imageFile: '//upload.wikimedia.org/wikipedia/commons/0/05/Button_Anf%C3%BChrung.png',
    speedTip: 'Uvozovky',
    tagOpen: '\„',
    tagClose: '\“',
    sampleText: ''
  };
  mw.toolbar.addButton(button.imageFile, button.speedTip, button.tagOpen, button.tagClose, button.sampleText, button.id, button.id);

  button = { id: 'button-comment',
    imageFile: '//upload.wikimedia.org/wikipedia/commons/6/64/Button_nbsp_bold.png',
    speedTip: 'Pevná mezera',
    tagOpen: '&nbsp;',
    tagClose: '',
    sampleText: ''
  };
  mw.toolbar.addButton(button.imageFile, button.speedTip, button.tagOpen, button.tagClose, button.sampleText, button.id, button.id);

  button = { id: 'button-comment',
    imageFile: '//upload.wikimedia.org/wikipedia/commons/d/d2/Button_flagicon.png',
    speedTip: 'Flagicon',
    tagOpen: '\x7b\x7bflagicon|',
    tagClose: '}}',
    sampleText: ''
  };
  mw.toolbar.addButton(button.imageFile, button.speedTip, button.tagOpen, button.tagClose, button.sampleText, button.id, button.id);

  button = { id: 'button-comment',
    imageFile: '//upload.wikimedia.org/wikipedia/commons/3/3a/Button_av-img.png',
    speedTip: 'Požadavek na obrázek',
    tagOpen: '\x7b\x7bPožadavek na obrázek}}',
    tagClose: '',
    sampleText: ''
  };
  mw.toolbar.addButton(button.imageFile, button.speedTip, button.tagOpen, button.tagClose, button.sampleText, button.id, button.id);

  button = { id: 'button-comment',
    imageFile: '//upload.wikimedia.org/wikipedia/commons/a/a5/Button_STUB.png',
    speedTip: 'Pahýl',
    tagOpen: '\x7b\x7bpahýl}}',
    tagClose: '',
    sampleText: ''
  };
  mw.toolbar.addButton(button.imageFile, button.speedTip, button.tagOpen, button.tagClose, button.sampleText, button.id, button.id);

  button = { id: 'button-comment',
    imageFile: '//upload.wikimedia.org/wikipedia/commons/4/41/Button_hr_halfwidth.png',
    speedTip: 'Pomlčka',
    tagOpen: '–',
    tagClose: '',
    sampleText: ''
  };
  mw.toolbar.addButton(button.imageFile, button.speedTip, button.tagOpen, button.tagClose, button.sampleText, button.id, button.id);

  button = { id: 'button-comment',
    imageFile: '//upload.wikimedia.org/wikipedia/commons/4/4f/Button_sig_(zh).png',
    speedTip: 'Překlad',
    tagOpen: '\x7b\x7bPřeklad|en|',
    tagClose: '|}}',
    sampleText: ''
  };
  mw.toolbar.addButton(button.imageFile, button.speedTip, button.tagOpen, button.tagClose, button.sampleText, button.id, button.id);

});

// --------- přemapování klávesov. kombinací Ctrl+L, Ctrl+B a Ctrl+I, testováno ve Firefoxu 3.0.8). ---------
var myAccessKeys = {
  addEvent : function(obj, type, fn) {
    if (obj.addEventListener) {
      obj.addEventListener(type, fn, false);
    }
    else if (obj.attachEvent) { // IE
      obj.attachEvent('on' + type, function() {return fn.apply(obj, new Array(window.event));});
    }
  },

  filterKey : function(evt) {
    if (!evt) evt = event;
    var keyCode = evt.keyCode ? evt.keyCode : evt.which ? evt.which : evt.charCode;

    /*
    if (evt.altKey && evt.shiftKey)
    if (evt.ctrlKey)
    if (evt.shiftKey)
    if (evt.altKey)
    */

    if (evt.ctrlKey)
    {
      if (false);
      else if (keyCode == 66 || keyCode == 98) {
        // alert("Ctrl+B/b pressed");
        insertTags("\'\'\'","\'\'\'","Tučný text");
        evt.preventDefault();
        return false;
      }
      else if (keyCode == 73 || keyCode == 105) {
        // alert("Ctrl+I/i pressed");
        insertTags("\'\'","\'\'","Kurzíva");
        evt.preventDefault();
        return false;
      }
      else if (keyCode == 76 || keyCode == 108) {
        // alert("Ctrl+L/l pressed");
        insertTags("[[","]]","Název odkazu");
        evt.preventDefault();
        return false;
      }
    }

    return true;
  },

  init : function() {
    if (document.getElementById('wpTextbox1')) {
      myAccessKeys.addEvent(document.getElementById('wpTextbox1'), 'keypress', myAccessKeys.filterKey);
    }
  }
};

initFnList.push(function() { myAccessKeys.init(); });

// --- Vypnout automatické uložení stránky pomocí klávesy Enter ---
if (1) {
  var disableEnter = function(e) {
    var key = (window.event ? window.event.keyCode /*IE*/ : e.which /*FF*/);
    return (key != 13);
  };

  initFnList.push(function() {
    if (document.getElementById('wpMinoredit')) {
      document.getElementById('wpMinoredit').onkeypress = disableEnter;
    }

    if (document.getElementById('wpSummary')) {
      document.getElementById('wpSummary').onkeypress = disableEnter;

      // ve shrnuti editace vysunout razeni v kategoriich az za hranate zavorky
      document.getElementById('wpSummary').onchange = function() {
        var f = this;
        f.value = f.value.replace(/\[\[(Kategorie:.*?)\|(.*?)]]/g, "[[$1]] ($2)");
      };
    }
  });
}

// --- Wire ---
mw.loader.load("//cs.wikipedia.org/w/index.php?title=Wikipedista:Jvs/wire.js&action=raw&ctype=text/javascript&dontcountme=s");

// [[d:User:Yair rand/WikidataInfo.js]]
mw.loader.load("//www.wikidata.org/w/index.php?title=User:Yair rand/WikidataInfo.js&action=raw&ctype=text/javascript");
	
jQuery( function () {
	for (var i in initFnList) {
		initFnList[i]();
	}
});
// </nowiki>