Wikisłownikarz:Yarl/vector.js
Uwaga: aby zobaczyć zmiany po opublikowaniu, 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 / Edge: Przytrzymaj Ctrl, jednocześnie klikając Odśwież, lub naciśnij klawisze Ctrl+F5
- Opera: Naciśnij klawisze Ctrl+F5.
// ------------------------------------------------------
// Przyciski górne
$(function()
{
//
// Menu górne
//
var el = document.getElementById('pt-userpage');
el.style.cssText = 'font-weight:bold';
var elBefore = document.getElementById('pt-mytalk');
elBefore.style.cssText = 'font-weight:bold';
elBefore.firstChild.innerHTML = 'dyskusja';
var elNew = document.createElement('li');
elNew.innerHTML = '<a href="http://pl.wiktionary.org/wiki/Wikipedysta:YarluBot">bot</a> / <a href="/w/index.php?title=Special:Contributions/YarluBot">wkład</a>';
elBefore.parentNode.insertBefore(elNew, elBefore);
myLogout = document.getElementById('pt-logout');
});
// ------------------------------------------------------
// Automatyczne opisy zmian
// Autor (Author): [[:pl:User:Adziura|Adam Dziura]]
// Poprawki (Fixes): [[:pl:User:Nux|Maciej Jaros]]
if (document.URL.indexOf("action=edit") > 0 || document.URL.indexOf("action=submit") > 0)
{
if (wgCanonicalNamespace != "Special")
{
function przyciskiOpis()
{
// stop before starting
if (window.przyciskiOpisDone)
return;
//
// sprawdzenie, czy to jest pole edycji z opisem zmian (nie jest takie jako nagłówek)
var el = document.getElementById('wpSummaryLabel');
if (el)
{
if (el.innerHTML.indexOf('pis zmian')==-1)
return // stop
;
}
else
{
return; // stop
}
//
// dodanie elementu okalającego przyciski bezpośrednio za opisem zmian
var el = document.getElementById('wpSummary').nextSibling;
var opisBtns = document.createElement('span');
opisBtns.id = 'userSummaryButtons'
el.parentNode.insertBefore(document.createElement('br'), el)
el.parentNode.insertBefore(opisBtns, el)
//
// adding buttons
//var kl = 'userButtonsStyle';
var kl = ''; // klas not needed (all of <a> in #userSummaryButtons set with CSS)
if (opisBtns)
{
// 1
przyciskiDodaj(opisBtns, '+en', 'dodajOpis("dodane: en")', kl,
'dodano: en');
przyciskiDodaj(opisBtns, '+pl', 'dodajOpis("dodane: pl")', kl,
'dodano: pl');
przyciskiDodaj(opisBtns, 'nowe', 'dodajOpis("dodane")', kl,
'nowe');
opisBtns.appendChild(document.createTextNode(' | ')); // odstęp
przyciskiDodaj(opisBtns, 'drobne', 'dodajOpis("drobne")', kl,
'drobne');
przyciskiDodaj(opisBtns, 'uzup.', 'dodajOpis("uzup.")', kl,
'uzup.');
opisBtns.appendChild(document.createTextNode(' | ')); // odstęp
przyciskiDodaj(opisBtns, 'grafika', 'dodajOpis("grafika")', kl,
'grafika');
przyciskiDodaj(opisBtns, 'etym.', 'dodajOpis("etymologia")', kl,
'etymologia');
przyciskiDodaj(opisBtns, 'tłum.', 'dodajOpis("tłumaczenia")', kl,
'tłumaczenia');
przyciskiDodaj(opisBtns, 'wymowa', 'dodajOpis("wymowa")', kl,
'wymowa');
przyciskiDodaj(opisBtns, 'ref', 'dodajOpis("źródła")', kl,
'źródła');
// document.editform.wpMinoredit.onclick = onMinorEditClick;
}
}
/*
Parametry:
* elUserBtns - element okalający, do którego dodać przycisk
* pTekst - tekst w środku przycisku
* pAkcja - akcja (w formie tekstowej) jaką wykonać przy naciśnięciu; może być ciągiem poleceń
* pKlasa - klasa jeśli konieczna
* pOpis - opis widoczny w dymku przy przycisku
*/
function przyciskiDodaj(elUserBtns, pTekst, pAkcja, pKlasa, pOpis)
{
var nowyBtn = document.createElement('a');
// atrybuty
nowyBtn.appendChild(document.createTextNode(pTekst));
nowyBtn.title = pOpis;
if (pKlasa != '')
nowyBtn.className = pKlasa
;
nowyBtn.onclick = new Function(pAkcja);
// dodanie przycisku
elUserBtns.appendChild(nowyBtn);
}
var clickedMinor = false;
function onMinorEditClick()
{
if (this.checked && !clickedMinor)
{
dodajOpis("drobne");
clickedMinor = true;
}
}
function dodajOpis(opis)
{
var wpS = document.editform.wpSummary;
if (wpS.value != '' && wpS.value.charAt(wpS.value.length-2) != '/')
{
wpS.value += ', ' + opis
}
else
{
wpS.value += opis
}
}
$(przyciskiOpis);
}
};
// ------------------------------------------------------
// EditHysteria script by [[:pl:User:ChP94]]
// Standard fix by [[:pl:User:Saper]]
// Released under the [http://www.gnu.org/licenses/gpl.txt GNU Public License (GPL)]
// <pre><nowiki>
var eh_ajax; var cont;
function eh_init() {
var conts = document.getElementsByTagName("h1");
for(i=0;i<conts.length;i++) {
var c = conts[i];
if(c.getAttribute("class")=="firstHeading") {
cont = c; break;
}
}
if(!cont) {
cont = document.getElementById("section-0");
}
eh_initAjax();
eh_getHistory();
}
//Function from QuickEdit 2 by ASM
function eh_initAjax()
{
try
{
if (window.XMLHttpRequest)
{
eh_ajax = new XMLHttpRequest();
eh_ajax.overrideMimeType('text/xml');
}
else if (window.ActiveXObject)
eh_ajax = new ActiveXObject('Microsoft.XMLHTTP');
else throw 'Nie ma AJAX-ów!';
}
catch (e)
{
return false;
}
if (!eh_ajax)
{
qeShowError('Błąd tworzenia obiektu ajax');
return false;
}
return true;
}
function eh_getHistory()
{
var title = encodeURIComponent(mw.config.get('wgPageName'));
eh_ajax.onreadystatechange = eh_getHistotyResponse;
eh_ajax.open('GET', 'http://pl.wiktionary.org/w/index.php?title='+title+'&action=history', true);
eh_ajax.send(null);
}
function eh_getHistotyResponse()
{
if (eh_ajax.readyState != 4 || eh_ajax.status != 200)
return;
var xml = eh_ajax.responseXML;
var title = encodeURIComponent(mw.config.get('wgPageName'));
var spans = xml.getElementsByTagName("span");
var user = ""; var diff = 0; var l_user = ""; var l_diff = -1; var count = 1;
for(i=0;i<spans.length;i++) {
var s = spans[i];
if(s.getAttribute("class") == "history-user") {
var u = s.firstChild.innerHTML;
if(l_diff == -1) {
try {
l_diff = s.previousSibling.previousSibling.previousSibling.previousSibling.getAttribute("value");
}
catch (e) {
}
}
if(l_user == "") l_user = u;
else if(u != l_user) {
user = u;
diff=s.previousSibling.previousSibling.previousSibling.previousSibling.getAttribute("value");
break;
}
else {
count++;
}
}
}
if(l_diff!=-1){
prevuSpan = document.createElement("div");
prevuSpan.style.fontSize = "8pt";
prevuSpan.id = "contentSub";
prevuSpan.style.position = "absolute";
prevuSpan.innerHTML = "Ostatnia <a href=\"/w/index.php?title=" + wgPageName + "&diff=" + l_diff + "&oldid=" + diff + "\"/>zmiana</a>:" +
" <b><a href=\"/wiki/Wikipedysta:" + l_user + "\">" + l_user + "</a></b>" +
" (<a href=\"/wiki/Dyskusja_Wikipedysty:"+l_user+"\">dyskusja</a>) [" + count + " razy].";
if(user != "") {
prevuSpan.innerHTML += " Wcześniej: " + "<a href=\"/wiki/Wikipedysta:" + user + "\">" + user + "</a>" +
" (<a href=\"/wiki/Dyskusja_Wikipedysty:"+user+"\">dyskusja</a>)";
}
cont.appendChild(prevuSpan);
}
else if(l_user!=""){
prevuSpan = document.createElement("div");
prevuSpan.style.fontSize = "8pt";
prevuSpan.id = "contentSub";
prevuSpan.style.position = "absolute";
prevuSpan.innerHTML = "To jest jedyna wersja. " +
"Twórca: <a href=\"/wiki/Wikipedysta:" + l_user + "\">" + l_user + "</a>" +
" (<a href=\"/wiki/Dyskusja_Wikipedysty:"+l_user+"\">dyskusja</a>).";
cont.appendChild(prevuSpan);
}
}
$(eh_init);
// </nowiki></pre>
/*
==== Dodanie linka [edytuj] dla sekcji nagłówkowej ====
; Pomysł: [[:en:User:Pile0nades]]
; Wykonanie: Maciej Jaros [[:pl:User:Nux]]
; Licencja: [http://opensource.org/licenses/gpl-license.php GNU General Public License v2]
*/
// Liczba nagłówków drugiego, trzeciego i czwartego stopnia
// jakie muszą się pojawić w artykule, żeby pojawił się link
var addEditTopLinkNumHeaders = 0; // dla 2 => dla dwóch i więcej się pojawi
function addEditTopLink() {
//
// somehow it gets run twice on some pages - stop that
if (window.addEditTopLinkDone)
return
;
window.addEditTopLinkDone = true;
//
// if this is preview page or there is no edit tab, stop
if (!wgIsArticle)
return
;
//
// if there are no edit-section links then stop
var spans = document.getElementById("bodyContent").getElementsByTagName("span");
var i;
for (i = 0; i < spans.length; i++) {
if (spans[i].className == 'editsection')
break
;
}
if (i>=spans.length)
return
;
//
// additional checkup to stop
var test = document.getElementById("bodyContent").getElementsByTagName("h2").length +
document.getElementById("bodyContent").getElementsByTagName("h3").length +
document.getElementById("bodyContent").getElementsByTagName("h4").length;
// note that there is always siteSub (h3)
if (test<=addEditTopLinkNumHeaders)
return
;
//
// get first header element
var fst_h1 = document.getElementById("content").getElementsByTagName("h1")[0];
//
// Creating elements
//
// create div
var div = document.createElement("DIV");
div.className = 'editsection';
// create link
var link = document.createElement("A");
link.href = document.getElementById("ca-edit").getElementsByTagName("a")[0].href + '§ion=0';
link.setAttribute('title', 'edytuj sekcję nagłówkową artykułu');
link.appendChild(document.createTextNode('edytuj'));
// append link and stuff to div
div.appendChild(document.createTextNode('['));
div.appendChild(link);
div.appendChild(document.createTextNode(']'));
//
// Styling
//
div.style.cssText = 'padding:.7em 0 0 1.0em; float:right; font-size:x-small;';
//
// Insert edit div into h1 and content of h1 to div (it has to be like that so that FF doesn't select the edit link on double click)
//
var div_h1 = document.createElement("div");
// move children
while(fst_h1.childNodes.length)
{
div_h1.appendChild(fst_h1.firstChild)
}
fst_h1.appendChild(div); // edit link
fst_h1.appendChild(div_h1); // previous h1 content
}
if (skin=='vector' || skin=='monobook')
{
addOnloadHook(addEditTopLink);
}