Ugrás a tartalomhoz

Szerkesztő:Boro/common.js

A Wikipédiából, a szabad enciklopédiából

Megjegyzés: közzététel után frissítened kell a böngésződ gyorsítótárát, hogy lásd a változásokat.

  • Firefox / Safari: tartsd lenyomva a Shift gombot és kattints a Frissítés gombra a címsorban, vagy használd a Ctrl–F5 vagy Ctrl–R (Macen ⌘–R) billentyűkombinációt
  • Google Chrome: használd a Ctrl–Shift–R (Macen ⌘–Shift–R) billentyűkombinációt
  • Internet Explorer / Edge: tartsd nyomva a Ctrl-t, és kattints a Frissítés gombra, vagy nyomj Ctrl–F5-öt
  • Opera: Nyomj Ctrl–F5-öt
// Szerkesztő-eszköztár gombok

mwCustomEditButtons[mwCustomEditButtons.length] = {


"imageFile": "http://upload.wikimedia.org/wikipedia/commons/a/a7/Button_smiley3.png",
"speedTip": "Mosoly",
"tagOpen": "",
"tagClose": "",
"sampleText": "'':-)''" } 

mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "http://upload.wikimedia.org/wikipedia/commons/2/29/Button_user.png",
"speedTip": "Üdvözlet-új",
"tagOpen": "{{",
"tagClose": "",
"sampleText": "subst:Üdvözlet-új|user=|kép=csillagos}}" }


mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "http://upload.wikimedia.org/wikipedia/commons/a/ae/Button_trait%C3%A9conserver.png",
"speedTip": "Támogatom",
"tagOpen": "",
"tagClose": "",
"sampleText": "{{támogatom}}" }

mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "http://upload.wikimedia.org/wikipedia/commons/9/96/Button_trait%C3%A9supprimer.png",
"speedTip": "Ellenzem",
"tagOpen": "",
"tagClose": "",
"sampleText": "{{ellenzem}}" }

mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "http://upload.wikimedia.org/wikipedia/commons/7/7f/Button_tgk-j_min.png",
"speedTip": "mikro",
"tagOpen": "",
"tagClose": "",
"sampleText": "μ" }



// Szerkesztő-eszköztár gombok vége

// Purge
$( function (){
var hist = document.getElementById('ca-history');
var url = hist.getElementsByTagName('a')[0];
if(!hist || !url) return;
if (!(url = url.href)) return;
mw.util.addPortletLink('p-cactions', url.replace(/([?&]action=)history([&#]|$)/, '$1purge$2'),
'purge', 'ca-purge', 'Szerveroldali gyorsítótár kiürítése', 'g');
});

// Purge vége

// Tgr-féle summary

/* automatically set default value for summary fields
* (elements with wpSummary or wpReason id)
* (except for new section summary)
* install a button to set/change default value
* TODO: touched flag for summary field/minor edit checkbox 
*    to avoid overwriting manually specified values when hitting back button
*/

function readSummaryCookie() {
    var cookieText;
    var cookiePos = document.cookie.indexOf('autosummary=');
    if(cookiePos!=-1) {
       var results = document.cookie.match('autosummary=(.*?)(;|$)');
       if(results) cookieText = unescape(results[1]);
    } else cookieText = '';
    return cookieText;
}
function writeSummaryCookie(text) {
    if(text) {
       document.cookie = 'autosummary='+escape(text);
    } else {
       document.cookie = 'autosummary=; expires=Thu, 01-Jan-1970 00:00:01 GMT;'; // delete cookie
    }
}

function autoSummaryInstall() {
    if(!document.getElementById || !document.createElement) return; // DOM check
    var summary = document.getElementById('wpSummary'); // edit summary
    if(!summary) summary = document.getElementById('wpReason'); // admin del/block/etc. summary
    if(!summary) return; // edit mode check
    if(/&section=new/.test(window.location.href)) return;

    var summaryText = readSummaryCookie();
    // set summary text
    if(summaryText) {
       if(summaryText.match(/^\(m\)/)) { // mark edit as minor
          if(document.getElementById("wpMinoredit"))
             document.getElementById("wpMinoredit").checked = true;
          summaryText = summaryText.replace(/^\(m\) */, '');
       }
       if(summary.value.match(/^(\/\*.*\*\/)? *$/)) summary.value += summaryText; // avoid overwriting summary when using back button
    }

    // create button
    var autoSummaryButton = document.createElement('a');
    autoSummaryButton.id = 'autosummary';
    if(summaryText) autoSummaryButton.className = 'internal';
    else autoSummaryButton.className = 'new';
    autoSummaryButton.href = 'javascript:autoSummary()';
    autoSummaryButton.appendChild(document.createTextNode('[auto]'));
    var br = summary.nextSibling;
    br.parentNode.insertBefore(autoSummaryButton, br);
}

function autoSummary() {
    var summaryText = readSummaryCookie();
    var r = prompt('Összefoglaló szövege:', summaryText);
    if(r!=null) { // user pressed Ok
       if(r) {
          if(r.match(/^\(m\)/)) { // mark edit as minor
             if(document.getElementById("wpMinoredit"))
                document.getElementById("wpMinoredit").checked = true;
             r = r.replace(/^\(m\) */, '');
          }
          var summary = document.getElementById('wpSummary');
          if(!summary) summary = document.getElementById('wpReason');
          if(summary.value.match(/^(\/\*.*\*\/)? *$/)) summary.value += r;
       }
       writeSummaryCookie(r);
    }
}

addLoadEvent(autoSummaryInstall);


// Tgr-féle summary vége