Wikipedysta:Christo76/common.js: Różnice pomiędzy wersjami

Usunięta treść Dodana treść
Nie podano opisu zmian
UWAGA! Zastąpienie treści hasła bardzo krótkim tekstem: „importScript('Wikipedysta:Kaligula/js/watchCat.js');”
Linia 1:
jQuery( document ).ready( function() {
var elBefore = document.getElementById( 'pt-mytalk' );
 
var elNew = document.createElement( 'li' );
elNew.innerHTML = '<a href="//pl.wikipedia.org/wiki/Wikipedysta:Christo76/watchlists">Listy artykułów</a>';
elBefore.parentNode.insertBefore( elNew, elBefore );
} );
 
/* Skrypt do edytowania tabelek zabytków */
importScript('Wikipedysta:Yarl/skrypty/WikiLubiZabytki.js');
 
importScript('Wikipedysta:Kaligula/js/watchCat.js');
 
importScript( 'Wikipedysta:Christo76/customWatchlists.js' ); // Backlink: [[User:MusikAnimal/customWatchlists.js]]
/*
|
| author: Kaligula
| license: CC-BY-SA-3.0
| version: 2.3.5
| credits: Matma Rex
| Nux
| _____________________________________________________________________________________
|
| opis działania: [[Wikipedysta:Kaligula/js/watchCat]]
\*_____________________________________________________________________________________*/
 
//if ( (wgNamespaceNumber==14 && wgAction=='view') || wgPageName=='Specjalna:GadgetPrefs' ) {
 
addOnloadHook(function () {
 
mw.loader.using('ext.gadget.gConfig', function(){
 
// settings
gConfig.register(
'watchCat',
{
name: 'watchCat',
descriptionPage: 'Wikipedysta:Kaligula/js/watchCat'
},
[
{
name: 'invert',
desc: 'Odwróć kolorowanie (zaznacza w kategorii artykuły nieobserwowane).',
type: 'boolean',
deflt: false,
legacy: [window, 'watchCat_invert']
},
{
name: 'pending',
desc: 'Sprawdzaj od razu czy wersja oczekuje na przejrzenie (gdy odznaczone, dodany będzie link z funkcją sprawdzającą).',
type: 'boolean',
deflt: true,
legacy: [window, 'watchCat_pending']
},
{
name: 'changed',
desc: 'Zaznacz artykuły zmienione od ostatniej wizyty.',
type: 'boolean',
deflt: true,
legacy: [window, 'watchCat_changed']
},
{
name: 'noCSS',
desc: 'Wyłącz domyślny styl kolorowania (użytkownik musi określić własne style w CSS, np. w [[Specjalna:Moja strona/common.css|common.css]]).',
descMode: 'wikitext',
type: 'boolean',
deflt: false,
legacy: [window, 'watchCat_noCSS']
}
]
);
 
var watchCat_invert = gConfig.get('watchCat','invert');
var watchCat_pending = gConfig.get('watchCat','pending');
var watchCat_changed = gConfig.get('watchCat','changed');
var watchCat_noCSS = gConfig.get('watchCat','noCSS');
 
if(!watchCat_noCSS) importStylesheet('Wikipedysta:Kaligula/js/watchCat.css');
 
$.ajax({
url:location.protocol+'//pl.wikipedia.org/wiki/Specjalna:Edytuj_obserwowane/raw'
}).done(function(html){
var wList = $(html).find('#mw-input-wpTitles').text();
 
$('#mw-pages a').each(function(i){
if ( (wList.match(new RegExp('^'+this.innerHTML.replace(/([\(\)\[\]\{\}\|\?\.\*\^\$\+])/g,'\\$1')+'$','m'))!=null) == (watchCat_invert == false)) {
//there's a match and we don't invert selection OR there's no match and we invert selection
$(this).toggleClass('watchCat-main');
 
}
});
 
if (watchCat_pending || watchCat_changed) {
 
function watchCatPendChanArr() {
var arr=[],j=0,i;
$('#mw-pages a.watchCat-main').each(function(i){
if (i%50==0) { j=i/50; arr[j] = []; }
arr[j].push(this.innerHTML)
})
arr.forEach(function(el, i){ arr[i]=el.join('|'); })
return arr;
}
 
if (watchCat_changed) {
// function watchCatChan() {
var arr = watchCatPendChanArr();
window.watchCatStamps = {};
window.watchCatChanCounter = 0;
arr.forEach(function(el, i){
$.ajax({
url:location.protocol+'//pl.wikipedia.org/w/api.php?action=query&prop=info&format=json&inprop=watched%7Cnotificationtimestamp&indexpageids=&titles=' + encodeURI(arr[i])
}).done(function(data){
watchCatChanCounter++;
data.query.pageids.forEach(function(elm, j){
if (data.query.pages[elm].watched == "") {
watchCatStamps[data.query.pages[elm].title] = (data.query.pages[elm].notificationtimestamp != "");
};
});
if (watchCatChanCounter==arr.length){
$('#mw-pages a.watchCat-main').each(function(){
(watchCatStamps[this.innerHTML]) ? ($(this).toggleClass('watchCat-watched-changed')) : {};
});
}
});
});
// }
}
function watchCatPend() {
var arr = watchCatPendChanArr();
window.watchCatFlags = {};
window.watchCatPendCounter = 0;
arr.forEach(function(el, i){
$.ajax({
url:location.protocol+'//pl.wikipedia.org/w/api.php?action=query&indexpageids&prop=flagged&format=json&titles=' + encodeURI(arr[i])
}).done(function(data){
watchCatPendCounter++;
data.query.pageids.forEach(function(elm, j){
watchCatFlags[data.query.pages[elm].title] = ( (!data.query.pages[elm].flagged) ? "watchCat-flagged-unreviewed" : ((data.query.pages[elm].flagged.pending_since) ? "watchCat-flagged-pending" : "watchCat-flagged-reviewed") );
});
if (watchCatPendCounter==arr.length){
$('#mw-pages a.watchCat-main').each(function(index){
$(this).toggleClass(watchCatFlags[this.innerHTML]);
});
}
});
});
}
 
if (watchCat_pending) {
watchCatPend();
}
else {
$('#mw-pages > p')[0].outerHTML += '\n→ <a href=# onclick="watchCatPend()">Sprawdź wersje oznaczone obserwowanych artykułów</a><br>\n→ Narzędzia zewnętrzne: <a href="http://toolserver.org/~magnus/deep_insight.php?language=pl&category=' + wgTitle + '&depth=10&mode=web&doit=Do+it" class="external text">wersje nieprzejrzane</a>/<a href="http://toolserver.org/~magnus/deep_out_of_sight.php?language=pl&category=' + wgTitle + '&depth=10&mode=web&doit=Do+it" class="external text">wersje oczekujące na ponowne przejrzenie</a>'
}
}
});
});
});
//}