Użytkownik:Adiblol/monobook.js: Różnice pomiędzy wersjami

Z Nonsensopedii, polskiej encyklopedii humoru
M
M
 
(Nie pokazano 34 wersji utworzonych przez jednego użytkownika)
Linia 1: Linia 1:
// <nowiki>
// <nowiki>


/*

Wikinarzędzia
Copyright (C) 2008-2010 by adiblol <adiblol(at)chommik(dot)eu>
Licencja: GNU GPL 3+ - http://www.gnu.org/licenses/gpl.html
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.


*/


///////////////////////////////////////////////////
///////////////////////////////////////////////////
Linia 18: Linia 39:
descs['worek'] = '[[N:W|worek]]';
descs['worek'] = '[[N:W|worek]]';
descs['kat.'] = 'kategoria';
descs['kat.'] = 'kategoria';
descs['półpauzy'] = 'półpauzy';
texts['ek'] = '{{ek}}';
texts['ek'] = '{{ek}}';
texts['ek-prywata'] = '{{ek|[[Nonsensopedia:Prywata|Prywata]]}}';
texts['ek-prywata'] = '{{ek|[[Nonsensopedia:Prywata|Prywata]]}}';
Linia 52: Linia 74:


}
}
function addToSummary(v) {

document.getElementById('wpSummary').value += v;
}
function addToText(v) {
document.getElementById('wpTextbox1').value=v+"\n\n\n"+document.getElementById('wpTextbox1').value;
}
function addToTextAndSummary(t,s) {
addToText(t);
addToSummary(s);
}
function addGameCategory() {
function addGameCategory() {
document.getElementById('wpTextbox1').value += "\n\n[[kategoria:Gra|"+wgTitle.substring(wgTitle.indexOf(' ')+1, wgTitle.length)+']]';
document.getElementById('wpTextbox1').value += "\n\n[[kategoria:Gra|"+wgTitle.substring(wgTitle.indexOf(' ')+1, wgTitle.length)+']]';
Linia 64: Linia 95:
function RegisterRevert() {
function RegisterRevert() {
d = document.getElementById('mw-diff-otitle1').firstChild.firstChild;
d = document.getElementById('mw-diff-otitle1').firstChild.firstChild;
nu = document.getElementById('mw-diff-ntitle2').firstChild;
document.getElementById('mw-diff-otitle1').innerHTML += '(<a href="#" onclick="revertArticle(&apos;'+d.innerText+'&apos;,&apos;'+d.href+'&apos;);">przywróć</a>)';
document.getElementById('mw-diff-otitle1').innerHTML += '(<a href="#" onclick="revertArticle(&apos;'+d.innerHTML+'&apos;,&apos;'+escape(nu.innerHTML)+'&apos;,&apos;'+d.href+'&apos;);">przywróć</a>)';
}
}
var conn = new XMLHttpRequest;
var conn = new XMLHttpRequest;
Linia 73: Linia 104:
var revertVersion='';
var revertVersion='';
var revertAddress='';
var revertAddress='';
var revertStartTime='';
var revertEditTime='';
var revertContents='';
var revertNewerUser='';


function revertDone() {
function revertShowMsg(text) {
document.getElementById('revertMessage').innerHTML = text;
if (conn.readyState==4 && conn.status==200) {
alert('Revert zakończony!');
location.href='/index.php?title='+escape(wgPageName);
}
}
}


function revertGetContents() {
function revertGetContents() {
if (conn.readyState==4 && conn.status==200) {
if (conn.readyState==4 && conn.status==200) {
var cont = conn.responseText;
revertContents = conn.responseText;
document.getElementById('revertConfirm').disabled = '';
conn = new XMLHttpRequest;
revertShowMsg('Gotowy.');
conn.open('POST', '/index.php?title='+escape(wgPageName)+'&action=submit', true);
}
conn.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
}
conn.setRequestHeader("Content-length", text.length);

conn.setRequestHeader("Connection", "close");
function revertDo() {
conn.onreadystatechange = revertDone;
revertShowMsg('Trwa wysyłanie danych...');
conn.send('wpLogin=&wpSection=&wpScrolltop=&wpTextbox1='+escape(cont)+'&wpSave=Zapisz&wpSummary='+escape('Revert: '+revertVersion)+'wpAutoSummary='+escape(revertAutoSummary)+'&wpEditToken='+escape(revertEditToken)+'&antispam=');
var f = document.createElement('form');
alert('revertGetContents();');
function HiddenInput(name, value) {
var e = document.createElement('input');
e.type='hidden';
e.name = name;
e.value = value;
return e;
}
}
f.action = '/index.php?title='+encodeURI(wgPageName)+'&action=submit';
f.method = 'post';
f.enctype = 'multipart/form-data';
f.appendChild(HiddenInput('wpLogin', ''));
f.appendChild(HiddenInput('wpSection', ''));
f.appendChild(HiddenInput('wpStarttime', revertStartTime));
f.appendChild(HiddenInput('wpEdittime', revertEditTime));
f.appendChild(HiddenInput('wpScrolltop', ''));
f.appendChild(HiddenInput('wpMinoredit', '1'));
f.appendChild(HiddenInput('wpTextbox1', revertContents));
var subm = document.createElement('button');
subm.type='submit';
subm.name='s_u_b_m_i_t';
subm.value='s-u-b-m-i-t';
subm.innerHtml='wyslij';
f.appendChild(subm);
var rdesc = '';
var opt = document.getElementById('revertReason').selectedIndex;
if (opt==0) rdesc=''; else
if (opt==1) rdesc = document.getElementById('revertDesc').value; else
rdesc = document.getElementById('revertReason').options[opt].innerHTML;
f.appendChild(HiddenInput('wpSummary', 'Revert: '+revertVersion+((rdesc!='')?' ('+rdesc+')':'')+'. Anulowano wersję użytk. '+revertNewerUser));
f.appendChild(HiddenInput('wpSave', 'Zapisz'));
f.appendChild(HiddenInput('wpEditToken', revertEditToken));
f.appendChild(HiddenInput('wpAutoSummary', revertAutoSummary));
f.appendChild(HiddenInput('antispam', ''));
document.getElementById('globalWrapper').appendChild(f);
f.submit();
revertShowMsg('Wysłano!<br /><a href="javascript:history.back();">Wstecz</a>');
}
}


Linia 99: Linia 166:
revertEditToken = conn.responseText.substr(conn.responseText.indexOf('name="wpEditToken"')-36, 34);
revertEditToken = conn.responseText.substr(conn.responseText.indexOf('name="wpEditToken"')-36, 34);
revertAutoSummary = conn.responseText.substr(conn.responseText.indexOf('name="wpAutoSummary"')+42, 32);
revertAutoSummary = conn.responseText.substr(conn.responseText.indexOf('name="wpAutoSummary"')+42, 32);
revertStartTime = conn.responseText.substr(conn.responseText.indexOf('name="wpStarttime"')-16, 14);
revertEditTime = conn.responseText.substr(conn.responseText.indexOf('name="wpEdittime"')-16, 14);
conn = new XMLHttpRequest;
conn = new XMLHttpRequest;
conn.open('GET', revertAddress, true);
conn.open('GET', revertAddress, true);
conn.onreadystatechange = revertGetContents;
conn.onreadystatechange = revertGetContents;
conn.send(null);
conn.send(null);
revertShowMsg('Pobieranie treści...');
alert('EditToken: '+revertEditToken+"\n\nAutoSummary: "+revertAutoSummary);
}
}
}
}


function revertArticle(ver,addr) {
function revertReasonChange() {
document.getElementById('revertDesc').style.visibility = ((document.getElementById('revertReason').selectedIndex==1)?'visible':'hidden');
}

function revertArticle(ver,nusr,addr) {
document.getElementById('mw-diff-otitle1').parentNode.innerHTML = '<span id="revertMessage" style="color:#006600;font-size:14pt"></span>';
s = '<h3>Przyczyna revertu:</h3><select id="revertReason" style="width:80%" onchange="revertReasonChange();"><option value="noreason">(brak)</option><option value="custom">(własny)</option>';
reasons=Array('wandalizm', 'blank', 'bezsens', 'bo tak', 'głupoty', 'celebrities');
for (var i=0;i<reasons.length;i++) {
s += '<option value="n">'+reasons[i]+'</option>';
}
s += '</select><button id="revertConfirm" onclick="revertDo();" disabled="disabled" style="width:16%">OK</button><input type="text" id="revertDesc" value="" style="width:98%;visibility:hidden" />';
document.getElementById('mw-diff-ntitle1').parentNode.innerHTML=s;
//d = document.getElementById('jump-to-nav');
//d = document.getElementById('jump-to-nav');
conn.open('GET', '/index.php?title='+escape(wgPageName)+'&action=edit', true);
conn.open('GET', '/index.php?title='+encodeURI(wgPageName)+'&action=edit', true);
conn.onreadystatechange = revertGetEditToken;
conn.onreadystatechange = revertGetEditToken;
revertVersion = ver;
revertVersion = ver;
revertAddress = addr+'&action=raw';
revertAddress = addr+'&action=raw';
revertNewerUser = unescape(nusr);
conn.send(null);
conn.send(null);
revertShowMsg('Pobieranie danych...');
}

function RegisterContribs() {
/*alert(document.getElementById('p-cactions'));
alert(document.getElementById('p-cactions').lastChild);
alert(document.getElementById('p-cactions').lastChild.firstChild);*/
document.getElementById('ca-history').parentNode.innerHTML +=
'<li id="ca-contribs"><a href="/index.php?title='+encodeURI('Special:Contributions/'+wgTitle)+'" title="Pokaż wkład tego użytkownika">Wkład</a></li>';
}
}


Linia 122: Linia 213:
}
}


if ((wgAction=='edit') || (wgAction=='submit')) {
addOnloadHook(RegisterDescs);
}


//if (wgUserName=='Adiblol') { // Zmień to na swoją nazwę użytkownika.
addOnloadHook(CheckHistory);
// Poniżej znajdują się linie służące do włączania funkcjonalności.
// Jeśli nie chcesz z jakiejś korzystać, wykomentuj ją, stawiając na początku linii dwa slash'e.
if ((wgAction=='edit') || (wgAction=='submit')) {
addOnloadHook(RegisterDescs); // Pomocnicze narzędzia dla opisów zmian, daje gotową listę, podobną jak na Wikipedii, ponadto daje przyciski automatycznie dodające szablony takie jak ek, worek itp. do artykułów.
}
/*if (wgCanonicalNamespace=='User') {
addOnloadHook(RegisterContribs); // Dodaje w "cactions" strony użytkownika (dyskusja, edytuj, historia itp.) przycisk "wkład", nie jest on potrzebny ponieważ podobny link istnieje w "narzędziach" w sidebarze.
}*/
addOnloadHook(CheckHistory); // Automatyczny rewert dowolnej wersji.
/*} else {
alert("Wygląda na to, że skopiowałeś sobie bezprawnie moje narzędzia! Aby ich używać, wykaż choć trochę inteligencji, pogrzeb w plikach monobooka i zmień co trzeba ;)\n\n[Ma to na celu zapewnienie ochrony Nonsensopedii przed noobami wykorzystującymi cudze skrypty (script-kiddies) do niecnych celów. Nie mam nic przeciwko wykorzystywaniu moich skryptów przez innych, o ile robią to sensownie.]");
}*/





function addToSummary(v) {
document.getElementById('wpSummary').value += v;
}
function addToText(v) {
document.getElementById('wpTextbox1').value=v+"\n\n\n"+document.getElementById('wpTextbox1').value;
}
function addToTextAndSummary(t,s) {
addToText(t);
addToSummary(s);
}


// </nowiki>
// </nowiki>

Aktualna wersja na dzień 20:48, 25 cze 2010

// <nowiki>

/*

  Wikinarzędzia
  Copyright (C) 2008-2010 by adiblol <adiblol(at)chommik(dot)eu>
  Licencja: GNU GPL 3+ - http://www.gnu.org/licenses/gpl.html
  
   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.
   
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   
   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.


*/

///////////////////////////////////////////////////
///// OPISY  ZMIAN  I  AUTOWKLEJANIE  DO  ARTÓW
///////////////////////////////////////////////////

function RegisterDescs() {
 descs=Array();
 texts=Array();
 descs['ek'] = '{{[[Szablon:Ek|ek]]}}';
 descs['ek-prywata'] = 'ek ([[N:P|prywata]])';
 descs['ek-total'] = 'ek (totalne zło)';
 descs['red'] = 'red.';
 descs['lit'] = 'literówka';
 descs['popr.format'] = 'popr. format. wiki';
 descs['sdu'] = 'SdU';
 descs['worek'] = '[[N:W|worek]]';
 descs['kat.'] = 'kategoria';
 descs['półpauzy'] = 'półpauzy';
 texts['ek'] = '{{ek}}';
 texts['ek-prywata'] = '{{ek|[[Nonsensopedia:Prywata|Prywata]]}}';
 texts['ek-total'] = '{{ek|TOTALNE ZŁO I BEZSENS!!!}}';
 texts['sdu'] = '{{Kasacja}}';
 texts['worek'] = '{{worek}}';
 

 var s='';
 for (dn in descs) {
  s+='<a href="#" onclick="addToSummary(&apos;'+descs[dn]+'&apos;);return false;">'+dn+'</a>, ';
 }
 document.getElementById('editOptions').innerHTML =  
  '<small style="border:1px solid #444;background:#eee;padding:2px">&nbsp;<b>Gotowce</b>: '+s+
  '</small>'+document.getElementById('editOptions').innerHTML;
 
 s='';
 var c='';
 for (dn in texts) {
  if (descs[dn]) {
   c+='<button style="height:23px" onclick="addToTextAndSummary(&apos;'+texts[dn]+'&apos;,&apos;'+descs[dn]+
    '&apos;);return false;">'+dn+'</button>&nbsp;';
  }
  s+='<a href="#" onclick="addToText(&apos;'+texts[dn]+'&apos;);return false;">'+dn+'</a>, ';
 }
 if (wgCanonicalNamespace=='Gra') {
  var gl = '<a href="#" onclick="addGameCategory();return false;"><b>Kategoria Gra</b></a>;&nbsp; &nbsp;';
 } else var gl='';
 document.getElementById('editform').innerHTML =
  '<small style="border:1px solid #444;background:#eee;padding:2px">&nbsp;<b>Dodatkowe</b>: '+gl+s+
  '</small>'+document.getElementById('editform').innerHTML;
  
 document.getElementById('editOptions').innerHTML += '<br /><b>GOTOWCE (tekst &amp; opis)</b>: '+c+'<br /><br />';

}
function addToSummary(v) {
  document.getElementById('wpSummary').value += v;
}
function addToText(v) {
 document.getElementById('wpTextbox1').value=v+"\n\n\n"+document.getElementById('wpTextbox1').value;
}
function addToTextAndSummary(t,s) {
 addToText(t);
 addToSummary(s);
}
function addGameCategory() {
 document.getElementById('wpTextbox1').value += "\n\n[[kategoria:Gra|"+wgTitle.substring(wgTitle.indexOf(' ')+1, wgTitle.length)+']]';
}


///////////////////////////////////////////////////
///// AUTOMATYCZNY  REVERT
///////////////////////////////////////////////////

function RegisterRevert() {
 d = document.getElementById('mw-diff-otitle1').firstChild.firstChild;
 nu = document.getElementById('mw-diff-ntitle2').firstChild;
 document.getElementById('mw-diff-otitle1').innerHTML += '(<a href="#" onclick="revertArticle(&apos;'+d.innerHTML+'&apos;,&apos;'+escape(nu.innerHTML)+'&apos;,&apos;'+d.href+'&apos;);">przywróć</a>)';
}
var conn = new XMLHttpRequest;

var revertEditToken='';
var revertAutoSummary='';
var revertVersion='';
var revertAddress='';
var revertStartTime='';
var revertEditTime='';
var revertContents='';
var revertNewerUser='';

function revertShowMsg(text) {
 document.getElementById('revertMessage').innerHTML = text;
}

function revertGetContents() {
 if (conn.readyState==4 && conn.status==200) {
  revertContents = conn.responseText;
  document.getElementById('revertConfirm').disabled = '';
  revertShowMsg('Gotowy.');
 }
}

function revertDo() {
 revertShowMsg('Trwa wysyłanie danych...');
 var f = document.createElement('form');
 function HiddenInput(name, value) {
  var e = document.createElement('input');
  e.type='hidden';
  e.name = name;
  e.value = value;
  return e;
 }
 f.action = '/index.php?title='+encodeURI(wgPageName)+'&action=submit';
 f.method = 'post';
 f.enctype = 'multipart/form-data';
 f.appendChild(HiddenInput('wpLogin', ''));
 f.appendChild(HiddenInput('wpSection', ''));
 f.appendChild(HiddenInput('wpStarttime', revertStartTime));
 f.appendChild(HiddenInput('wpEdittime', revertEditTime));
 f.appendChild(HiddenInput('wpScrolltop', ''));
 f.appendChild(HiddenInput('wpMinoredit', '1'));
 f.appendChild(HiddenInput('wpTextbox1', revertContents));
 var subm = document.createElement('button');
 subm.type='submit';
 subm.name='s_u_b_m_i_t';
 subm.value='s-u-b-m-i-t';
 subm.innerHtml='wyslij';
 f.appendChild(subm);
 var rdesc = '';
 var opt = document.getElementById('revertReason').selectedIndex;
 if (opt==0) rdesc=''; else
  if (opt==1) rdesc = document.getElementById('revertDesc').value; else
   rdesc = document.getElementById('revertReason').options[opt].innerHTML;
 f.appendChild(HiddenInput('wpSummary', 'Revert: '+revertVersion+((rdesc!='')?' ('+rdesc+')':'')+'. Anulowano wersję użytk. '+revertNewerUser));
 f.appendChild(HiddenInput('wpSave', 'Zapisz'));
 f.appendChild(HiddenInput('wpEditToken', revertEditToken));
 f.appendChild(HiddenInput('wpAutoSummary', revertAutoSummary));
 f.appendChild(HiddenInput('antispam', ''));
 document.getElementById('globalWrapper').appendChild(f);
 f.submit();
 revertShowMsg('Wysłano!<br /><a href="javascript:history.back();">Wstecz</a>');
}

function revertGetEditToken() { 
 if (conn.readyState==4 && conn.status==200) {
  revertEditToken = conn.responseText.substr(conn.responseText.indexOf('name="wpEditToken"')-36, 34);
  revertAutoSummary = conn.responseText.substr(conn.responseText.indexOf('name="wpAutoSummary"')+42, 32);
  revertStartTime = conn.responseText.substr(conn.responseText.indexOf('name="wpStarttime"')-16, 14);
  revertEditTime = conn.responseText.substr(conn.responseText.indexOf('name="wpEdittime"')-16, 14);
  conn = new XMLHttpRequest;
  conn.open('GET', revertAddress, true);
  conn.onreadystatechange = revertGetContents;
  conn.send(null);
  revertShowMsg('Pobieranie treści...');
 }
}

function revertReasonChange() {
 document.getElementById('revertDesc').style.visibility = ((document.getElementById('revertReason').selectedIndex==1)?'visible':'hidden');
}

function revertArticle(ver,nusr,addr) {
 document.getElementById('mw-diff-otitle1').parentNode.innerHTML = '<span id="revertMessage" style="color:#006600;font-size:14pt"></span>';
 s = '<h3>Przyczyna revertu:</h3><select id="revertReason" style="width:80%" onchange="revertReasonChange();"><option value="noreason">(brak)</option><option value="custom">(własny)</option>';
 reasons=Array('wandalizm', 'blank', 'bezsens', 'bo tak', 'głupoty', 'celebrities');
 for (var i=0;i<reasons.length;i++) {
  s += '<option value="n">'+reasons[i]+'</option>';
 }
 s += '</select><button id="revertConfirm" onclick="revertDo();" disabled="disabled" style="width:16%">OK</button><input type="text" id="revertDesc" value="" style="width:98%;visibility:hidden" />';
 document.getElementById('mw-diff-ntitle1').parentNode.innerHTML=s;
 //d = document.getElementById('jump-to-nav');
 conn.open('GET', '/index.php?title='+encodeURI(wgPageName)+'&action=edit', true);
 conn.onreadystatechange = revertGetEditToken;
 revertVersion = ver;
 revertAddress = addr+'&action=raw';
 revertNewerUser = unescape(nusr);
 conn.send(null);
 revertShowMsg('Pobieranie danych...');
}

function RegisterContribs() {
 /*alert(document.getElementById('p-cactions'));
 alert(document.getElementById('p-cactions').lastChild);
 alert(document.getElementById('p-cactions').lastChild.firstChild);*/
 document.getElementById('ca-history').parentNode.innerHTML +=
  '<li id="ca-contribs"><a href="/index.php?title='+encodeURI('Special:Contributions/'+wgTitle)+'" title="Pokaż wkład tego użytkownika">Wkład</a></li>';
}

function CheckHistory() {
 if (document.getElementById('mw-diff-otitle1')) {
  RegisterRevert();
 }
}


//if (wgUserName=='Adiblol') { // Zmień to na swoją nazwę użytkownika.
 // Poniżej znajdują się linie służące do włączania funkcjonalności.
 // Jeśli nie chcesz z jakiejś korzystać, wykomentuj ją, stawiając na początku linii dwa slash'e.
 if ((wgAction=='edit') || (wgAction=='submit')) {
  addOnloadHook(RegisterDescs); // Pomocnicze narzędzia dla opisów zmian, daje gotową listę, podobną jak na Wikipedii, ponadto daje przyciski automatycznie dodające szablony takie jak ek, worek itp. do artykułów.
 }
 /*if (wgCanonicalNamespace=='User') {
  addOnloadHook(RegisterContribs); // Dodaje w "cactions" strony użytkownika (dyskusja, edytuj, historia itp.) przycisk "wkład", nie jest on potrzebny ponieważ podobny link istnieje w "narzędziach" w sidebarze.
 }*/
 addOnloadHook(CheckHistory); // Automatyczny rewert dowolnej wersji.
/*} else {
 alert("Wygląda na to, że skopiowałeś sobie bezprawnie moje narzędzia! Aby ich używać, wykaż choć trochę inteligencji, pogrzeb w plikach monobooka i zmień co trzeba ;)\n\n[Ma to na celu zapewnienie ochrony Nonsensopedii przed noobami wykorzystującymi cudze skrypty (script-kiddies) do niecnych celów. Nie mam nic przeciwko wykorzystywaniu moich skryptów przez innych, o ile robią to sensownie.]");
}*/


// </nowiki>