Użytkownik:Ekspert/monobook.js
Z Nonsensopedii, polskiej encyklopedii humoru
Uwaga: aby zobaczyć zmiany po zapisaniu, może zajść potrzeba wyczyszczenia pamięci podręcznej przeglądarki.
- Firefox / Safari: Przytrzymaj Shift podczas klikania Odśwież bieżącą stronę, lub naciśnij klawisze Ctrl+F5 lub Ctrl+R (⌘-R na komputerze Mac)
- Google Chrome: Naciśnij Ctrl-Shift-R (⌘-Shift-R na komputerze Mac)
- Internet Explorer: Przytrzymaj Ctrl jednocześnie klikając Odśwież lub naciśnij klawisze Ctrl+F5
- Konqueror: Kliknij polecenie Odśwież lub naciśnij klawisz F5
- Opera: Wyczyść pamięć podręczną w Narzędzia → Preferencje
// <nowiki>
///////////////////////////////////////////////////
///// OPISY ZMIAN I AUTOWKLEJANIE DO ARTÓW
///////////////////////////////////////////////////
function RegisterDescs() {
descs=Array();
texts=Array();
descs['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';
texts['ek'] = '{{ek}}';
texts['ek-prywata'] = '{{ek|[[Nonsensopedia:Prywata|Prywata]]}}';
texts['ek-dno'] = '{{ek|Dno totalne}}';
texts['sdu'] = '{{Kasacja}}';
texts['worek'] = '{{worek}}';
var s='';
for (dn in descs) {
s+='<a href="#" onclick="addToSummary(''+descs[dn]+'');return false;">'+dn+'</a>, ';
}
document.getElementById('editOptions').innerHTML =
'<small style="border:1px solid #444;background:#eee;padding:2px"> <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(''+texts[dn]+'',''+descs[dn]+
'');return false;">'+dn+'</button> ';
}
s+='<a href="#" onclick="addToText(''+texts[dn]+'');return false;">'+dn+'</a>, ';
}
if (wgCanonicalNamespace=='Gra') {
var gl = '<a href="#" onclick="addGameCategory();return false;"><b>Kategoria Gra</b></a>; ';
} else var gl='';
document.getElementById('editform').innerHTML =
'<small style="border:1px solid #444;background:#eee;padding:2px"> <b>Dodatkowe</b>: '+gl+s+
'</small>'+document.getElementById('editform').innerHTML;
document.getElementById('editOptions').innerHTML += '<br /><b>GOTOWCE (tekst & 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;
document.getElementById('mw-diff-otitle1').innerHTML += '(<a href="#" onclick="revertArticle(''+d.innerText+'',''+d.href+'');">przywróć</a>)';
}
var conn = new XMLHttpRequest;
var revertEditToken='';
var revertAutoSummary='';
var revertVersion='';
var revertAddress='';
var revertStartTime='';
var revertEditTime='';
var revertContents='';
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('wpTextbox1', revertContents));
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+')':'')));
f.appendChild(HiddenInput('wpSave', 'Zapisz'));
f.appendChild(HiddenInput('wpEditToken', revertEditToken));
f.appendChild(HiddenInput('wpAutoSummary', revertAutoSummary));
f.appendChild(HiddenInput('antispam', ''));
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,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';
conn.send(null);
revertShowMsg('Pobieranie danych...');
}
function CheckHistory() {
if (document.getElementById('mw-diff-otitle1')) {
RegisterRevert();
}
}
if ((wgAction=='edit') || (wgAction=='submit')) {
addOnloadHook(RegisterDescs);
}
addOnloadHook(CheckHistory);
// </nowiki>