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

Z Nonsensopedii, polskiej encyklopedii humoru
M
M (lepszy bajerek (na Nowych Stronach bida, to się można pobawić))
 
Linia 1: Linia 1:
// pierwotna wersja pochodzi z strony Wikipedysta:Beau/skrypty (tam też jest opisany sposób użycia skryptu na swoim koncie)
// Wersja (Version)
// Rozbudowane przez Bulwersatora
var tmp_VERSION = '0.2';
// umożliwia wykonywanie typowych operacji na ZB za pomocą jednego kliknięcia
// przyciski tylko podczas edycji strony dyskusji - testy
// dodatkowe opisy zmian
// szczegółowy opis: Wikipedia:Narzędzia/magicOfGreenRectangles
var magicOfGreenRectangles = {};
/**
Autor (Author): Wikipedysta:Skalee (User:Skalee)
Licencje (Licensing):
- CC-BY-SA 3.0: http://creativecommons.org/licenses/by-sa/3.0/deed.pl (jako główna licencja Wikipedii)
- MIT:
Copyright (c) 2011 Wikipedysta:Skalee
magicOfGreenRectangles.list = new Array();
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//dotyczy artykułów (przestrzeni głównej)
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
magicOfGreenRectangles.main_space_list = new Array(
{
caption: "interpunkcja",
template: "brak",
summary: " int.",
title: "",
content: "",
content_type: ""
},
{
caption: "ortografia",
template: "brak",
summary: " ort.",
title: "",
content: "",
content_type: ""
},
{
caption: "typografia",
template: "brak",
summary: " typog.",
title: "",
content: "",
content_type: ""
},
{
caption: "kategoryzacja",
template: "brak",
summary: " kat.",
title: "",
content: "",
content_type: ""
},
{
caption: "sortowanie",
template: "brak",
summary: " sort.",
title: "",
content: "",
content_type: ""
},
{
caption: "poprawa linków",
template: "brak",
summary: " linkfix",
title: "",
content: "",
content_type: ""
},
{
caption: "dodanie grafiki",
template: "brak",
summary: " +grafika",
title: "",
content: "",
content_type: ""
}
);
magicOfGreenRectangles.test = function(number) {
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
var item = this.list[number];
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
if(item.content_type=="comment") document.editform.wpTextbox1.value = document.editform.wpTextbox1.value + item.content + " ~~" + "~~";
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
else if(item.content_type=="top") document.editform.wpTextbox1.value = item.content + document.editform.wpTextbox1.value;
IN THE SOFTWARE.
document.editform.wpSummary.value = document.editform.wpSummary.value + item.summary;
*/
if (dodatkowePrzyciskiOpisuEdycji !== undefined)
{
alert('Błąd krytyczny - konflikt nazw!\n\nJeden ze skryptów używa już nazwy dodatkowePrzyciskiOpisuEdycji jako zmienną globalną.');
}
}
magicOfGreenRectangles.init = function() {
var dodatkowePrzyciskiOpisuEdycji = {ver: tmp_VERSION, version: tmp_VERSION};
if (wgNamespaceNumber == 3) this.list=this.talk_list;
else if (wgNamespaceNumber == 1) this.list = this.article_discussion_list;
else if (wgNamespaceNumber == 0) this.list=this.main_space_list;
else if (wgNamespaceNumber == 4) this.list = this.wikipedia_list;
else if (wgNamespaceNumber == 14) this.list = this.category_list;
else if (wgNamespaceNumber%2 == 1) this.list = this.discussion_list;
else return;
dodatkowePrzyciskiOpisuEdycji.init = function() {
var miejsceNaPrzyciski = $("#userSummaryButtons");
if (miejsceNaPrzyciski.length > 0) {
dodatkowePrzyciskiOpisuEdycji.uporzadkujDanePrzyciskowWgWierszy();
dodatkowePrzyciskiOpisuEdycji.wstawDodatkowePrzyciski(miejsceNaPrzyciski);
}
};
if (wgAction != 'edit' && wgAction != 'submit')
dodatkowePrzyciskiOpisuEdycji.uporzadkujDanePrzyciskowWgWierszy = function() {
return;
var ustawienia = (dodatkowePrzyciskiOpisuEdycjiUstawienia === undefined ? [] : dodatkowePrzyciskiOpisuEdycjiUstawienia);
dodatkowePrzyciskiOpisuEdycji.wiersze = [];
for (var i in ustawienia) {
var danePrzycisku = ustawienia[i];
var nrWiersza = danePrzycisku.nrWiersza || 1;
if (dodatkowePrzyciskiOpisuEdycji.wiersze[nrWiersza] === undefined) dodatkowePrzyciskiOpisuEdycji.wiersze[nrWiersza] = [];
dodatkowePrzyciskiOpisuEdycji.wiersze[nrWiersza].push(danePrzycisku);
}
};
var userSummaryButtons = document.getElementById('userSummaryButtons');
dodatkowePrzyciskiOpisuEdycji.wstawDodatkowePrzyciski = function(miejsceNaPrzyciski) {
for (var i in dodatkowePrzyciskiOpisuEdycji.wiersze) {
var wiersz = dodatkowePrzyciskiOpisuEdycji.wiersze[i];
if (wiersz === undefined) continue;
miejsceNaPrzyciski.append($("<br/>"));
for (var j in wiersz) {
miejsceNaPrzyciski.append(dodatkowePrzyciskiOpisuEdycji.stworzNowyPrzycisk(wiersz[j]));
}
}
};
if (! userSummaryButtons)
dodatkowePrzyciskiOpisuEdycji.ustalFunkcjeDlaPrzycisku = function(danePrzycisku) {
{
if ('function' == typeof danePrzycisku.funkcja) {
var userSummaryButtons = document.createElement('div');
return danePrzycisku.funkcja;
userSummaryButtons.id = 'userSummaryButtons'
} else if (danePrzycisku.funkcja) {
var minoredit = document.getElementById('wpMinoredit');
return new Function(danePrzycisku.funkcja);
if (! minoredit)
} else {
return;
return function() { dodajOpis(danePrzycisku.opis); };
}
};
minoredit.parentNode.insertBefore(userSummaryButtons, minoredit);
dodatkowePrzyciskiOpisuEdycji.ustalStylDlaPrzycisku = function(danePrzycisku) {
}
var styl = '';
else
if (danePrzycisku.kolorTla) {
{
styl += 'background-color:' + danePrzycisku.kolorTla + ';';
userSummaryButtons.appendChild(document.createElement('br'));
}
}
if (danePrzycisku.kolorTekstu) {
var el = userSummaryButtons;
styl += 'color:' + danePrzycisku.kolorTekstu + ';';
}
for (var i = 0; i < this.list.length; i++) {
if (danePrzycisku.styl) {
var item = this.list[i];
styl += danePrzycisku.styl;
if (!item.type) {
}
przyciskiDodaj(el, item.caption, 'magicOfGreenRectangles.test(' + i + ')', '', item.title);
return (styl.length > 0 ? styl : null);
};
}
else if (item.type == 'text') {
el.appendChild(document.createTextNode(item.content));
}
else if (item.type == 'element') {
el.appendChild(document.createElement(item.content));
}
}
}
addOnloadHook(function() { magicOfGreenRectangles.init() });
dodatkowePrzyciskiOpisuEdycji.stworzNowyPrzycisk = function(danePrzycisku) {
var nowyPrzycisk = $("<a></a>");
nowyPrzycisk.click(dodatkowePrzyciskiOpisuEdycji.ustalFunkcjeDlaPrzycisku(danePrzycisku));
nowyPrzycisk.text(danePrzycisku.skrot);
nowyPrzycisk.attr('title', danePrzycisku.podpowiedz || danePrzycisku.opis);
var styl = dodatkowePrzyciskiOpisuEdycji.ustalStylDlaPrzycisku(danePrzycisku);
if (styl) {
nowyPrzycisk.attr('style', styl);
}
return nowyPrzycisk;
};
// </nowiki> -------------------------------------------
// Koniecznie chcemy podpiąć się pod $.ready PO TYM jak podepnie się mediawiki.common-edit.
mw.loader.using('mediawiki.common-edit', function() { $(dodatkowePrzyciskiOpisuEdycji.init); });

dodatkowePrzyciskiOpisuEdycjiUstawienia = [
{opis: 'int.', skrot: 'interpunkcja', nrWiersza: 1, kolorTla: 'whitesmoke'},
{opis: 'ort.', skrot: 'ortografia', nrWiersza: 1, kolorTla: 'whitesmoke'},
{opis: 'styl.', skrot: 'stylistyka', nrWiersza: 1, kolorTla: 'whitesmoke'},
{opis: 'estet.', skrot: 'estetyka', nrWiersza: 1, kolorTla: 'whitesmoke'},
{opis: 'typog.', skrot: 'typografia', nrWiersza: 1, kolorTla: 'whitesmoke'},
{opis: 'rekat.', skrot: 'poprawa kategorii', nrWiersza: 2, kolorTla: 'blanchedalmond'},
{opis: 'linfix', skrot: 'poprawa linków', nrWiersza: 2, kolorTla: 'blanchedalmond'},
{opis: '+grafika', skrot: 'dodanie grafiki', nrWiersza: 2, kolorTla: 'blanchedalmond', kolorTekstu: 'red'},
{opis: '+video', skrot: 'dodanie video', nrWiersza: 2, kolorTla: 'deepskyblue', styl:'color:azure;'}
];

Aktualna wersja na dzień 17:19, 8 paź 2011

// pierwotna wersja pochodzi z strony Wikipedysta:Beau/skrypty (tam też jest opisany sposób użycia skryptu na swoim koncie)
// Rozbudowane przez Bulwersatora
// umożliwia wykonywanie typowych operacji na ZB za pomocą jednego kliknięcia
// przyciski tylko podczas edycji strony dyskusji - testy
// dodatkowe opisy zmian
// szczegółowy opis: Wikipedia:Narzędzia/magicOfGreenRectangles
 
var magicOfGreenRectangles = {}; 
 
magicOfGreenRectangles.list = new Array();
 
//dotyczy artykułów (przestrzeni głównej)
magicOfGreenRectangles.main_space_list = new Array(
	{
		caption: "interpunkcja",
		template: "brak",
		summary: " int.",
		title: "",
		content: "",
		content_type: ""
	},
	{
		caption: "ortografia",
		template: "brak",
		summary: " ort.",
		title: "",
		content: "",
		content_type: ""
	},
	{
		caption: "typografia",
		template: "brak",
		summary: " typog.",
		title: "",
		content: "",
		content_type: ""
	},
	{
		caption: "kategoryzacja",
		template: "brak",
		summary: " kat.",
		title: "",
		content: "",
		content_type: ""
	},
	{
		caption: "sortowanie",
		template: "brak",
		summary: " sort.",
		title: "",
		content: "",
		content_type: ""
	},
	{
		caption: "poprawa linków",
		template: "brak",
		summary: " linkfix",
		title: "",
		content: "",
		content_type: ""
	},
	{
		caption: "dodanie grafiki",
		template: "brak",
		summary: " +grafika",
		title: "",
		content: "",
		content_type: ""
	}
);
 
magicOfGreenRectangles.test = function(number)  {
	var item = this.list[number];
	if(item.content_type=="comment") document.editform.wpTextbox1.value = document.editform.wpTextbox1.value + item.content + " ~~" + "~~";
	else if(item.content_type=="top") document.editform.wpTextbox1.value = item.content + document.editform.wpTextbox1.value;
	document.editform.wpSummary.value = document.editform.wpSummary.value + item.summary;
}
 
magicOfGreenRectangles.init = function() {
	if (wgNamespaceNumber == 3) this.list=this.talk_list;
	else if (wgNamespaceNumber == 1) this.list = this.article_discussion_list; 
	else if (wgNamespaceNumber == 0) this.list=this.main_space_list;
	else if	(wgNamespaceNumber == 4) this.list = this.wikipedia_list;
	else if	(wgNamespaceNumber == 14) this.list = this.category_list;
	else if	(wgNamespaceNumber%2 == 1) this.list = this.discussion_list;
	else return;
 
 
	if (wgAction != 'edit' && wgAction != 'submit')
		return;
 
	var userSummaryButtons = document.getElementById('userSummaryButtons');
 
	if (! userSummaryButtons)
	{
		var userSummaryButtons = document.createElement('div');
		userSummaryButtons.id = 'userSummaryButtons'
		var minoredit = document.getElementById('wpMinoredit');
		if (! minoredit)
			return;
 
		minoredit.parentNode.insertBefore(userSummaryButtons, minoredit);
	}
	else
	{
		userSummaryButtons.appendChild(document.createElement('br'));
	}
	var el = userSummaryButtons;
 
	for (var i = 0; i < this.list.length; i++) {
		var item = this.list[i];
		if (!item.type) {
			przyciskiDodaj(el, item.caption, 'magicOfGreenRectangles.test(' + i + ')', '', item.title);
 
		}
		else if (item.type == 'text') {
			el.appendChild(document.createTextNode(item.content));
		}
		else if (item.type == 'element') {
			el.appendChild(document.createElement(item.content));
		}
	}
}
 
addOnloadHook(function() { magicOfGreenRectangles.init() });
 
// </nowiki> -------------------------------------------