Медијавики:Gadget-PatrolLog.js — разлика између измена
Изглед
Promena koda |
Promena koda |
||
| Ред 1: | Ред 1: | ||
// Gadget: FRQuickLinks (FlaggedRevs + | // Gadget: FRQuickLinks (FlaggedRevs + Patrol helpers) | ||
// Toolbox linkovi za sysop/patroller | // Toolbox linkovi za sysop/patroller | ||
// | // Radi na: članci (0), Vojna Enciklopedija: (4), Šablon: (10), Pomoć: (12), Kategorija: (14) | ||
$(function () { | $(function () { | ||
var ns = mw.config.get('wgNamespaceNumber'); | |||
// | // Dozvoljeni imenski prostori | ||
if ( | var allowedNamespaces = [0, 4, 10, 12, 14]; | ||
if (allowedNamespaces.indexOf(ns) === -1) return; | |||
// | // Samo sysop ili patroller | ||
var groups = mw.config.get('wgUserGroups') || []; | var groups = mw.config.get('wgUserGroups') || []; | ||
if (!(groups.includes('sysop') || groups.includes('patroller'))) return; | if (!(groups.includes('sysop') || groups.includes('patroller'))) return; | ||
var pageName = mw.config.get('wgPageName'); | var pageName = mw.config.get('wgPageName'); // npr. AB_23 | ||
var titleTxt = mw.config.get('wgTitle'); | var titleTxt = mw.config.get('wgTitle'); // npr. AB 23 | ||
var | // FlaggedRevs state (iz RLCONF) | ||
var | var stableId = mw.config.get('wgStableRevisionId') || 0; | ||
var curId = mw.config.get('wgCurRevisionId') || 0; | |||
/ | // ---------- 1) GLOBAL: Nepregledane ---------- | ||
mw.util.addPortletLink( | mw.util.addPortletLink( | ||
'p-tb', | 'p-tb', | ||
| Ред 31: | Ред 30: | ||
); | ); | ||
/ | // ---------- 2) GLOBAL: Izmene na čekanju ---------- | ||
mw.util.addPortletLink( | mw.util.addPortletLink( | ||
'p-tb', | 'p-tb', | ||
| Ред 42: | Ред 39: | ||
); | ); | ||
/ | // ---------- 3) PER-PAGE: Stabilizacija (ova strana) ---------- | ||
mw.util.addPortletLink( | mw.util.addPortletLink( | ||
'p-tb', | 'p-tb', | ||
| Ред 53: | Ред 48: | ||
); | ); | ||
/ | // ---------- 4) PER-PAGE: Istorija (ova strana) ---------- | ||
mw.util.addPortletLink( | mw.util.addPortletLink( | ||
'p-tb', | 'p-tb', | ||
mw.util.getUrl(' | mw.util.getUrl(pageName, { action: 'history' }), | ||
'Istorija (pregled izmena)', | 'Istorija (pregled izmena)', | ||
't-fr-history', | 't-fr-history', | ||
| Ред 64: | Ред 57: | ||
); | ); | ||
/ | // ---------- 5) PER-PAGE: “Najbolji pregled” (diff) ---------- | ||
// Ako postoji stabilna revizija → diff stable → current | |||
// Ako ne postoji stabilna → diff current → prev (ili istorija je već iznad) | |||
var diffUrl; | |||
if (stableId > 0) { | |||
var | diffUrl = mw.util.getUrl(pageName, { diff: 'cur', oldid: stableId }); | ||
if ( | |||
} else { | } else { | ||
diffUrl = mw.util.getUrl(pageName, { diff: 'cur', oldid: 'prev' }); | |||
} | } | ||
mw.util.addPortletLink( | mw.util.addPortletLink( | ||
'p-tb', | 'p-tb', | ||
diffUrl, | |||
'Pregledaj izmene (diff)', | |||
't-fr-diff', | 't-fr-diff', | ||
'Otvori diff za najbrži pregled (stable→current ili cur→prev)' | |||
); | ); | ||
/ | // ---------- 6) STATUS (informativno + pametan link) ---------- | ||
// Bitno: "Status" NE može “da pregleda” klikom (za to mora forma sa tokenom). | |||
// Zato status vodi na najbolji ekran: | |||
// - ako je unreviewed → istorija (ili diff cur→prev), | |||
var statusText = ( | // - ako ima stable ali nije current → diff stable→current, | ||
// - ako je stable == current → istorija (čisto kao pregled). | |||
var statusText, statusHref, statusHint; | |||
if (stableId === 0) { | |||
statusText = 'Status: Nepregledano'; | |||
statusHref = mw.util.getUrl(pageName, { action: 'history' }); | |||
statusHint = 'Ova strana nema stabilnu reviziju. Otvara istoriju da možeš da pregledaš i odobriš.'; | |||
} else if (stableId === curId) { | |||
statusText = 'Status: Provereno'; | |||
statusHref = mw.util.getUrl(pageName, { action: 'history' }); | |||
statusHint = 'Stabilna revizija je trenutna. Otvara istoriju.'; | |||
} else { | |||
statusText = 'Status: Izmene na čekanju'; | |||
statusHref = mw.util.getUrl(pageName, { diff: 'cur', oldid: stableId }); | |||
statusHint = 'Postoji stabilna verzija, ali ima novih izmena. Otvara diff stable→current.'; | |||
} | |||
mw.util.addPortletLink( | |||
'p-tb', | 'p-tb', | ||
statusHref, | |||
statusText, | statusText, | ||
't-fr-status', | 't-fr-status', | ||
statusHint | |||
); | ); | ||
}); | }); | ||
Верзија на датум 8. фебруар 2026. у 17:26
// Gadget: FRQuickLinks (FlaggedRevs + Patrol helpers)
// Toolbox linkovi za sysop/patroller
// Radi na: članci (0), Vojna Enciklopedija: (4), Šablon: (10), Pomoć: (12), Kategorija: (14)
$(function () {
var ns = mw.config.get('wgNamespaceNumber');
// Dozvoljeni imenski prostori
var allowedNamespaces = [0, 4, 10, 12, 14];
if (allowedNamespaces.indexOf(ns) === -1) return;
// Samo sysop ili patroller
var groups = mw.config.get('wgUserGroups') || [];
if (!(groups.includes('sysop') || groups.includes('patroller'))) return;
var pageName = mw.config.get('wgPageName'); // npr. AB_23
var titleTxt = mw.config.get('wgTitle'); // npr. AB 23
// FlaggedRevs state (iz RLCONF)
var stableId = mw.config.get('wgStableRevisionId') || 0;
var curId = mw.config.get('wgCurRevisionId') || 0;
// ---------- 1) GLOBAL: Nepregledane ----------
mw.util.addPortletLink(
'p-tb',
mw.util.getUrl('Special:UnreviewedPages'),
'FlaggedRevs: nepregledane',
't-fr-unreviewed',
'Sve stranice koje još nisu pregledane'
);
// ---------- 2) GLOBAL: Izmene na čekanju ----------
mw.util.addPortletLink(
'p-tb',
mw.util.getUrl('Special:PendingChanges'),
'FlaggedRevs: izmene na čekanju',
't-fr-pending',
'Sve stranice koje imaju izmene koje čekaju proveru'
);
// ---------- 3) PER-PAGE: Stabilizacija (ova strana) ----------
mw.util.addPortletLink(
'p-tb',
mw.util.getUrl('Special:Stabilization', { page: pageName }),
'FlaggedRevs: stabilizacija',
't-fr-stabilize',
'Podešavanja stabilne verzije za "' + titleTxt + '"'
);
// ---------- 4) PER-PAGE: Istorija (ova strana) ----------
mw.util.addPortletLink(
'p-tb',
mw.util.getUrl(pageName, { action: 'history' }),
'Istorija (pregled izmena)',
't-fr-history',
'Istorija izmena za "' + titleTxt + '"'
);
// ---------- 5) PER-PAGE: “Najbolji pregled” (diff) ----------
// Ako postoji stabilna revizija → diff stable → current
// Ako ne postoji stabilna → diff current → prev (ili istorija je već iznad)
var diffUrl;
if (stableId > 0) {
diffUrl = mw.util.getUrl(pageName, { diff: 'cur', oldid: stableId });
} else {
diffUrl = mw.util.getUrl(pageName, { diff: 'cur', oldid: 'prev' });
}
mw.util.addPortletLink(
'p-tb',
diffUrl,
'Pregledaj izmene (diff)',
't-fr-diff',
'Otvori diff za najbrži pregled (stable→current ili cur→prev)'
);
// ---------- 6) STATUS (informativno + pametan link) ----------
// Bitno: "Status" NE može “da pregleda” klikom (za to mora forma sa tokenom).
// Zato status vodi na najbolji ekran:
// - ako je unreviewed → istorija (ili diff cur→prev),
// - ako ima stable ali nije current → diff stable→current,
// - ako je stable == current → istorija (čisto kao pregled).
var statusText, statusHref, statusHint;
if (stableId === 0) {
statusText = 'Status: Nepregledano';
statusHref = mw.util.getUrl(pageName, { action: 'history' });
statusHint = 'Ova strana nema stabilnu reviziju. Otvara istoriju da možeš da pregledaš i odobriš.';
} else if (stableId === curId) {
statusText = 'Status: Provereno';
statusHref = mw.util.getUrl(pageName, { action: 'history' });
statusHint = 'Stabilna revizija je trenutna. Otvara istoriju.';
} else {
statusText = 'Status: Izmene na čekanju';
statusHref = mw.util.getUrl(pageName, { diff: 'cur', oldid: stableId });
statusHint = 'Postoji stabilna verzija, ali ima novih izmena. Otvara diff stable→current.';
}
mw.util.addPortletLink(
'p-tb',
statusHref,
statusText,
't-fr-status',
statusHint
);
});