Suradnik:GregorB/CitationFix.js
Izgled
Napomena: Nakon objave možda ćete trebati očistiti međuspremnik svog preglednika kako biste vidjeli promjene.
- Firefox / Safari: držite Shift i pritisnite Reload, ili pritisnite bilo Ctrl-F5 ili Ctrl-R (⌘-R na Macu)
- Google Chrome: pritisnite Ctrl-Shift-R (⌘-Shift-R na Macu)
- Internet Explorer / Edge: držite Ctrl i kliknite Refresh, ili pritisnite Ctrl-F5
- Opera: pritisnite Ctrl-F5.
// CitationFix.js je skripta za proširenje funkcionalnosti wikEd-a, naprednog alata za uređivanje (v. Moje postavke > Dodaci > wikEd).
// Skripta omogućuje da se jednim klikom svi pozivi predloška Citiranje weba (Cite web) u nekom članku pretvore u pozive predloška Citiranje www.
// Za upute v. stranicu za razgovor (Razgovor sa suradnikom:GregorB/CitationFix.js).
var wikEdConfig = {
// define custom buttons
// button number: [id, class, tooltip, image url, width, height, alt text, onclick handler code were obj is the button element]
button: {
100: ['wikEdDiv', 'wikEdButton', 'Popravi predloške za citiranje', '/media/wikipedia/commons/6/67/WikEd_logo.png', '16', '16', 'Cite web', 'WikEdEditButton(this, this.id, null, CitationFixHandler);' ]
},
// define custom button bars
// button name: [id outer, class outer, id inner, class inner, height, grip title, button numbers]
buttonBar: {
'custom1': ['wikEdButtonBarCustom1', 'wikEdButtonBarCustom1', 'wikEdButtonsCustom1', 'wikEdButtonsCustom1', 44, 'My custom buttons', [100] ]
}
};
function CitationFixHandler(obj) {
function ParamReplace(match, pipe, paramName, eq, offset, string) {
var paramArraySrc = ['title', 'author', 'authorlink', 'last', 'first', 'coauthors', 'editor', 'publisher', 'language', 'work', 'pages', 'date', 'month', 'year', 'accessdate', 'archiveurl', 'archivedate', 'quote'];
var paramArrayDest = ['naslov', 'autor', 'autorlink', 'prezime', 'ime', 'koautori', 'urednik', 'izdavač', 'jezik', 'rad', 'stranice', 'dan', 'mjesec', 'godina', 'preuzeto' ,'arhivurl', 'arhivdatum', 'citat'];
var index = paramArraySrc.indexOf(paramName);
if (index != -1) paramName = paramArrayDest[index];
return pipe + paramName + eq;
}
function CitationReplace(match, curly, templateName, params, offset, string) {
params = params.replace(/(\|\s*)([a-z]+)(\s*=)/g, ParamReplace);
return curly + 'citiranje www' + params;
}
WikEdGetText(obj, 'selection, cursor');
if (obj.selection.plain != '') {
obj.changed = obj.selection;
}
else {
WikEdGetText(obj, 'whole');
obj.changed = obj.whole;
}
obj.changed.plain = obj.changed.plain.replace(/({{\s*)([Cc]itiranje weba|[Cc]ite web)\b([\s\S]*?}})/g, CitationReplace)
obj.changed.keepSel = true;
return;
}