User:Kaster/e-ije.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
Documentation for this user script can be added at User:Kaster/e-ije. |
//E-Ije "on the fly" by Kašter
var promjeneInterfejs = new Array(
new Array('n-recentchanges','Скорашње измјене','Skorašnje izmjene'),
new Array('t-whatlinkshere','Шта је повезано овдје','Šta je povezano ovdje'),
new Array('t-recentchangeslinked','Сродне промјене','Srodne promjene'),
new Array('ca-move','премјести','premjesti')
);
var promjeneLinkovi = new Array(
new Array('Технологија и примењене уметности','Tehnologija i primenjene umetnosti','Технологија и примијењене умјетности','Tehnologija i primijenjene umjetnosti'),
new Array('Правила и смернице','Pravila i smernice','Правила и смјернице','Pravila i smjernice'),
new Array('Уметност','Umetnost','Умјетност','Umjetnost'),
new Array('Вести','Vesti','Вијести','Vijesti'),
new Array('Песак','Pesak','Пијесак','Pijesak'),
new Array('Речник','Rečnik','Ријечник','Riječnik')
);
function isIje() {
var sada = new Date();
var dan = sada.getDate();
// parnim IJEKAVSKI
return (dan % 2 == 0);
}
function isLatinica() {
var latinicaObj = document.getElementById('ca-varlang-1');
if (latinicaObj) {
var liClassObj = latinicaObj.getAttributeNode("class");
if (liClassObj && liClassObj.nodeValue=='selected') {
return true;
} else {
return false;
}
} else {
return false;
}
}
if (isIje()) {
var latinica = isLatinica();
// Interfejs
for (var i = 0; i < promjeneInterfejs.length; i++) {
var recentChangesObj = document.getElementById(promjeneInterfejs[i][0]);
if (recentChangesObj) {
var recentChangesA = recentChangesObj.firstChild;
if (recentChangesA) {
if (latinica) {
recentChangesA.firstChild.nodeValue = promjeneInterfejs[i][2];
} else {
recentChangesA.firstChild.nodeValue = promjeneInterfejs[i][1];
}
}
}
}
// Linkovi
if (promjeneLinkovi.length > 0) {
var aObjekti = document.getElementsByTagName('a');
if (aObjekti) {
for (var j = 0; j < promjeneLinkovi.length; j++) {
for (var k = 0; k < aObjekti.length; k++) {
if (aObjekti[k] && aObjekti[k].firstChild && aObjekti[k].firstChild.nodeValue) {
if (latinica) {
if (aObjekti[k].firstChild.nodeValue == promjeneLinkovi[j][1]) {
aObjekti[k].firstChild.nodeValue = promjeneLinkovi[j][3];
}
} else {
if (aObjekti[k].firstChild.nodeValue == promjeneLinkovi[j][0]) {
aObjekti[k].firstChild.nodeValue = promjeneLinkovi[j][2];
}
}
}
}
}
}
}
}