Enter names in the fields, then click “Submit” to submit the form:
var ime, imeSredjeno; var runaInt;
function start(){ //alert("inside start!"); //var arrInteger = [6,11,15,3]; //6+11 = 17+15=32=5+3 = 8 OK //var proracun = zbirIntVrednosti(arrInteger); //document.write("Zbir je: " + proracun);
document.forms[0].first_name.addEventListener("keyup", function(){validate('first_name')}); document.forms[0].last_name.addEventListener("keyup", function(){validate('last_name')});
}
//napravi f-ju za obradu texta! function validate(f){ var val = document.forms[0][f].value; switch (f){ case 'first_name': case 'last_name': //var RegExp = /^[a-zA-Z]+$/; var RegExp = /^[a-zA-Z\sćčšđžĆČŠĐŽабвфгкдјезжнилљмнњопрстуцчћшАБВФГКДЈЕЗЖНИЛЉМНЊОПРСТУЦЧЋШ]+$/; //namesti reg ex za unos naših slova! (dodatno...) //var msg = "This field must only contain letters!"; var msg = "Ovo polje mora sadržati slova!"; break; } if (!(RegExp.test(val))){ document.getElementById(f+'_p').innerHTML = "" + msg + ''; return false; }else{ document.getElementById(f+'_p').innerHTML = "OK"; return true; }
//za email: //var RegExp = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
//za pid: //var RegExp = /^[0-9]{12,13}$/; }
var srediInput = function(text){
text = text.toUpperCase(); text = transliterate(text);
return text; }
//var intArr = {}; //niz za smestanje int vrednosti za konacni zbir
var zbirIntVrednosti = function(intArr){ rezultat = 0;
for(var i = 0; i
");
rezultat += intArr[i];
//document.write("Rezultat za sada je: " + rezultat+"
");
if (rezultat > 18){ var a = Math.floor(rezultat/10); var b = rezultat%10; var c = a+b;
rezultat = c;
//document.write("korekcija rezultata je: " + rezultat+"
");
}
}
return rezultat;
}
/* 2. Runa – Berenginja / Božanstvo – Matislava / Slovo – B 3. Runa – Vetar / Božanstvo – Veles / Slova – V i F 4. Runa – Krada / Božanstvo – Ognjenbog / Slova – G i K 5. Runa – Dajbog / Božanstvo – Dažbog / Slovo – D 6. Runa – Jeste / Božanstvo – Živa / Slova – J i E 7. Runa – Rok / Božanstvo – Svetovid / Slova Z, Ž i H 8. Runa – Istok / Božanstvo – Morana / Slovo – I 9. Runa – Ljelja / Božanstva – Vesna i Lada / Slova – L i Lj 10. Runa – Mir / Božanstvo – Mokoš / Slovo – M 11. Runa – Nužda / Božanstvo – Vij / Slova – N i Nj 12. Runa – Opora / Božanstvo – Triglav / Slovo – O 13. Runa – Perun / Božanstvo – Perun / Slovo – P 14. Runa – Raduga / Božanstva – Radgost, Stribog / Slovo – R 15. Runa – Sila / Božanstvo – Horz / Slovo – S 16. Runa – Treba / Božanstvo – Devana / Slovo – T 17. Runa – Ud / Božanstvo – Jarilo / Slovo – U 18. Runa – Crnobog / Božanstvo – Crnobog / Slova – C, Ć, Č, Š */
var runaIntToName = function(number){ var Runa;
switch (number){ case 2: Runa = {r_ime:"Berenginja", r_bog:"Matislava"} break; case 3: Runa = {r_ime:"Vetar", r_bog:"Veles"} break; case 4: Runa = {r_ime:"Krada", r_bog:"Ognjenbog"} break; case 5: Runa = {r_ime:"Dajbog", r_bog:"Dažbog"} break; case 6: Runa = {r_ime:"Jeste", r_bog:"Živa"} break; case 7: Runa = {r_ime:"Rok", r_bog:"Svetovid"} break; case 8: Runa = {r_ime:"Istok", r_bog:"Morana"} break; case 9: Runa = {r_ime:"Ljelja", r_bog:"Vesna i Lada"} break; case 10: Runa = {r_ime:"Mir", r_bog:"Mokoš"} break; case 11: Runa = {r_ime:"Nužda", r_bog:"Vij"} break; case 12: Runa = {r_ime:"Opora", r_bog:"Triglav"} break; case 13: Runa = {r_ime:"Perun", r_bog:"Perun"} break; case 14: Runa = {r_ime:"Raduga", r_bog:"Radgost, Stribog"} break; case 15: Runa = {r_ime:"Sila", r_bog:"Horz"} break; case 16: Runa = {r_ime:"Treba", r_bog:"Devana"} break; case 17: Runa = {r_ime:"Ud", r_bog:"Jarilo"} break; case 18: Runa = {r_ime:"Crnobog", r_bog:"Crnobog"} break; }
return Runa; }
var transliterate = function(text) {
text = text
//.replace(new RegExp('/\s', 'g'), '') .replace(/\s/g, '')
//posebni slučajevi ide na početak: Đ,đ, LJ, NJ , .... dodaj Č, Ć, Š, Ž ! .replace(new RegExp('LJ', 'g'), 'Љ') .replace(new RegExp('NJ', 'g'), 'Њ') .replace(new RegExp('Đ', 'g'), 'DJ') .replace(new RegExp('Ž', 'g'), 'Ж')
//.replace(new RegExp(Č, 'g'), 'Ч') ne moze ovako .replace(new RegExp('Č', 'g'), 'Ч') .replace(new RegExp('Ć', 'g'), 'Ћ') .replace(new RegExp('Š', 'g'), 'Ш')
.replace(new RegExp(String.fromCharCode(65), 'g'), 'А') .replace(new RegExp(String.fromCharCode(66), 'g'), 'Б') .replace(new RegExp(String.fromCharCode(67), 'g'), 'Ц') .replace(new RegExp(String.fromCharCode(68), 'g'), 'Д') .replace(new RegExp(String.fromCharCode(69), 'g'), 'Е') .replace(new RegExp(String.fromCharCode(70), 'g'), 'Ф') .replace(new RegExp(String.fromCharCode(71), 'g'), 'Г') .replace(new RegExp(String.fromCharCode(72), 'g'), 'Х') .replace(new RegExp(String.fromCharCode(73), 'g'), 'И') .replace(new RegExp(String.fromCharCode(74), 'g'), 'Ј') .replace(new RegExp(String.fromCharCode(75), 'g'), 'К') .replace(new RegExp(String.fromCharCode(76), 'g'), 'Л') .replace(new RegExp(String.fromCharCode(77), 'g'), 'М') .replace(new RegExp(String.fromCharCode(78), 'g'), 'Н') .replace(new RegExp(String.fromCharCode(79), 'g'), 'О') .replace(new RegExp(String.fromCharCode(80), 'g'), 'П') .replace(new RegExp(String.fromCharCode(82), 'g'), 'Р') .replace(new RegExp(String.fromCharCode(83), 'g'), 'С') .replace(new RegExp(String.fromCharCode(84), 'g'), 'Т') .replace(new RegExp(String.fromCharCode(85), 'g'), 'У') .replace(new RegExp(String.fromCharCode(86), 'g'), 'В') .replace(new RegExp(String.fromCharCode(90), 'g'), 'З') //.replace(new RegExp(String.fromCharCode(142), 'g'), 'Ж') zasto ovo ne radi?
return text; };
//document.write(transliterate(ime)+"
");
//document.write(typeof imeTrans +"
");
/*
document.write(arr[0] + "
");
document.write(arr[1] + "
");
document.write(arr[2] + "
");
document.write(arr[3] + "
");*/
/*
var charCode = "a".charCodeAt(0);
//console.log(charCode);
document.write(charCode+"
");
*/
/*
var arr = [3,5,2,6,1,6,0,4,20];
arr.sort();
document.write(arr + "
");
arr.sort(function compareNumbers(a,b){
return a-b;
});
document.write(arr);*/
var slova = [
/* 'А', 'Д', 'Ј', 'У', 'Р'*/
'А', 'Б', 'В', 'Ф', 'Г', 'К', 'Д', 'Ј', 'Е', 'З', 'Ж', 'H', 'И', 'Л', 'Љ', 'М', 'Н', 'Њ', 'O', 'П', 'Р', 'С', 'Т', 'У', 'Ц', 'Ч', 'Ћ', 'Ш'
/* 'A', 'B', 'V', 'F', 'G', 'K', 'D', 'J', 'E', 'Z', 'Ž', 'H', 'I', 'L', 'LJ', 'M', 'N','NJ','O', 'P', 'R', 'S', 'T', 'U', 'C', 'Č', 'Ć','Š'
A(1),B(2),V(3), F(3),G(4), K(4), D(5), J(6), E(6), Z(7), Ž(7), H(7), I(8), L(9), LJ(9), M(10), N(11), NJ(11), O(12), P(13), R(14), S(15), T(16), U(17), C(18), Č(18), Ć(18), Š(18);
*/ ]
var vrednostiSlova = { А:1, Б:2, В:3, Ф:3, Г:4, К:4, Д:5, Ј:6, Е:6, З:7, Ж:7, Х:7, И:8, Л:9, Љ:9, М:10, Н:11, Њ:11, О:12, П:13, Р:14, С:15, Т:16, У:17, Ц:18, Ч:18, Ћ:18, Ш:18 }
//document.write("Duzina niza imena je: " +arr.length+ "
");
var runaIntVrednost = function(text) { var rezultat = 0; var arr = {};// = a.split(""); arr = text.split("");
for(var i=0;i< arr.length ;i++) {
//document.write("Prolazim kroz: " + i + " član niza: " + arr[i] +"
");
for(var slovo in slova) {
//document.write("Usao u podpetlju:
");
//document.write("Poredim: " + arr[i] + " i " + slova[slovo] +"
");
//document.write("Vrednost slova "+ slova[slovo] + " je " +vrednostiSlova[slova[slovo]] +"
");
if ( arr[i] == slova[slovo])
{
//document.write("Rezultat pre sabiranja za sada je: " + rezultat+"
");
//document.write("poklapanje!
");
rezultat += vrednostiSlova[slova[slovo]];
//document.write("Rezultat za sada je: " + rezultat+"
");
if (rezultat > 18){ var a = Math.floor(rezultat/10); var b = rezultat%10; var c = a+b;
rezultat = c;
//document.write("korekcija rezultata je: " + rezultat+"
");
}
}
}
}
//document.write("Rezultat je: " + rezultat +"
");
return rezultat;
}
function calculator(){ //alert("inside calculator!"); if(validate('first_name') && validate('last_name')){
//alert("Form is submitted..." + document.forms[0].first_name.value);
ime = document.forms[0].first_name.value; prezime = document.forms[0].last_name.value;
imeSredjeno = srediInput(ime); prezimeSredjeno = srediInput(prezime);
runaImeInt = runaIntVrednost(imeSredjeno); runaPrezimeInt = runaIntVrednost(prezimeSredjeno);
runaNazivIme = runaIntToName(runaImeInt);
//alert("Naziv rune imena: " + runaNazivIme.r_ime + " Bozanstvo: " + runaNazivIme.r_bog);
document.getElementsByName('output RunaIme')[0].value= runaNazivIme.r_ime;
document.getElementsByName('output RunaIme')[1].value= runaNazivIme.r_bog;
//document.write(imeSredjeno + "
");
var arrInteger = [runaImeInt, runaPrezimeInt]; //6+11 = 17+15=32=5+3 = 8 OK //var proracun = zbirIntVrednosti(arrInteger);
runaNaziv = runaIntToName(zbirIntVrednosti(arrInteger));
//alert("Naziv rune: " + runaNaziv.r_ime + " Bozanstvo: " + runaNaziv.r_bog); document.getElementsByName('output Runa')[0].value= runaNaziv.r_ime; document.getElementsByName('output Runa')[1].value= runaNaziv.r_bog;
return true;
}else{
alert("Check your form!");
return false;
}
};
//document.write(rezultat+"
");
//A:1, D:5, J:6, U:17, R:14 //5+6+17+14+5+6+1 = 54
//11+17+14+5+6+1= //28+14+5+6+1= //10+14+5+6+1= //24+5+6+1= //6+5+6+1= //11+6+1 = 18
/* var arr = ["Belgrade", "Paris", "Berlin"]; for (var city in arr) { document.write(arr[city] + " "); } */
/* A, B, V, F, G, K, D, J, E, Z, Ž, H, I, L, LJ, M, N, NJ, O, P, R, S, T, U, C, Č, Ć, Š; --dva slova su mi posebni slucajevi:
//ovaj deo izbaciti (pretvorim sva slova u upperCase) .replace(new RegExp(String.fromCharCode(97), 'g'), 'а') .replace(new RegExp(String.fromCharCode(98), 'g'), 'б') .replace(new RegExp(String.fromCharCode(99), 'g'), 'ц') .replace(new RegExp(String.fromCharCode(100), 'g'), 'д') .replace(new RegExp(String.fromCharCode(101), 'g'), 'е') .replace(new RegExp(String.fromCharCode(102), 'g'), 'ф') .replace(new RegExp(String.fromCharCode(103), 'g'), 'г') .replace(new RegExp(String.fromCharCode(104), 'g'), 'х') .replace(new RegExp(String.fromCharCode(105), 'g'), 'и') .replace(new RegExp(String.fromCharCode(106), 'g'), 'ј') .replace(new RegExp(String.fromCharCode(107), 'g'), 'к') .replace(new RegExp(String.fromCharCode(108), 'g'), 'л') .replace(new RegExp(String.fromCharCode(109), 'g'), 'м') .replace(new RegExp(String.fromCharCode(110), 'g'), 'н') .replace(new RegExp(String.fromCharCode(111), 'g'), 'о') .replace(new RegExp(String.fromCharCode(112), 'g'), 'п') .replace(new RegExp(String.fromCharCode(114), 'g'), 'р') .replace(new RegExp(String.fromCharCode(115), 'g'), 'с') .replace(new RegExp(String.fromCharCode(116), 'g'), 'т') .replace(new RegExp(String.fromCharCode(117), 'g'), 'у') .replace(new RegExp(String.fromCharCode(118), 'g'), 'в') .replace(new RegExp(String.fromCharCode(122), 'g'), 'з');
text = 'Aleksandar Kolarov'; //text = text.replace(new RegExp('/\s', 'g'), ''); text = text.replace(/\s/g, ""); //alert("Vrednost imena je..." + text); document.write(text); */
/* radno
Char Dec Hex Oct A 65 41 101 */
/* .replace(/\u044C/g, "'") .replace(/\u0431/g, 'b') .replace(/\u044E/g, 'yu');
.replace(/\String.fromCharCode(67)/g, 'Ц') //ovo ne radi
.replace(/B/g, 'Б') //ovo radi .replace(/String.fromCharCode(67)/g, 'Ц') //ovo ne radi, zasto? */
//return target.replace(new RegExp(search, 'g'), replacement);
//.replace(/\String.fromCharCode(65)/g, 'А') //.replace(/B/g, 'Б')