Код:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=Content-Type content="text/html; charset=windows-1251"> <TITLE>Калькулятор</TITLE> <style type="text/css"> <!-- #calc4chem { position: relative; top: 15px; width: 529px; height: 377px; margin: auto; border: 3px outset; background: #e4e4e4; text-align: center; color: #eee; } #kalkulator { position: absolute; top: 3px; left: 3px; width: 257px; height: 365px; border: 0px ridge #f00; background: #e4e4e4; color: #fff; } #biljeska { position: absolute; top: 3px; left: 267px; width: 256px; height: 365px; border: 0px ridge #999; background: #e4e4e4; color: #fff; } #konstante { position: absolute; top: 13px; left: 275px; width: 245px; height: 350px; border: 1px ridge #999; background: #fff; color: #fff; display: none; /*visibility: hidden; visible hidden */ text-align: center; overflow: auto; } #numformat { position: absolute; top: 138px; left: 3px; width: 245px; height: 225px; border: 1px ridge #999; display: none; background: #e4e4e4; color: #fff; } .constnaslov { width: 200px; color: #00f; text-align: center; font: normal 12px/125% sans-serif; margin: 5px; padding-bottom: 5px; border-bottom: 1px #cacaba solid; } .const { width: 200px; text-align: center; font: 11px/125% sans-serif; margin: 5px; padding-bottom: 5px; border-bottom: 1px #cacaba solid; } .const a:link { display: block; color: #900; text-decoration: none; } .const a:visited { display: block; color: #036; text-decoration: none; } .const a:active { display: block; color: #900; text-decoration: none; } .const a:hover { display: block; background: #eaeafa; color: #900; text-decoration: none; } .crta { position: absolute; top: 0px; left: 262px; width: 2px; height: 372px; border: 2px inset; background: #fff; /* groove ridge */ color: #fff; } .tipkovnica { position: absolute; top: 138px; left: 5px; width: 245px; height: 228px; background: #e4e4e4; } .displej { position: absolute; top: 10px; left: 6px; width: 240px; height: 82px; border: 2px ridge #eee; background: #eee; } #numauto, #numsci, #numfix, #nummem, #numrad, #numdeg, #numgrad { position: absolute; margin-top: 2px; width: 26px; height: 10px; font: normal 9px sans-serif; color: #ccc; display: inline; border: 0px solid #e00; background: #eee; } #numauto { left: 5px; color: #000; } #numsci { left: 37px; } #numfix { left: 62px; } #nummem { left: 107px; } #numrad { left: 154px; color: #000; } #numdeg { left: 180px; } #numgrad { left: 205px; } .upit { position: absolute; top: 27px; left: 6px; width: 225px; height: 25px; border: 0px; background: #eee; text-align: left; font: normal 9pt sans-serif; letter-spacing: 1px; color: #0a0; } .rezultat { position: absolute; top: 52px; left: 6px; width: 225px; height: 25px; border: 0px; background: #eee; text-align: right; font: bold 12pt sans-serif; letter-spacing: 1px; color: #00a; } .formatbr { position: absolute; top: 35px; left: 12px; width: 220px; height: 95px; border: 1px solid #cdcdcd; background: #e8e8e8; } .formatnaslov { position: relative; margin-top: 5px; font: normal 12pt cursive; text-align: center; } .automatik, .scienc, .fiksed { position: absolute; left: 6px; font: normal 10pt sans-serif; } .automatik {top: 10px;} .scienc {top: 38px;} .fiksed {top: 66px;} .decnaslov { position: absolute; top: 10px; left: 110px; width: 110px; text-align: center; font: normal 10pt sans-serif; color: #000; border: 0px solid #cdcdcd; } .decimal { position: absolute; top: 32px; left: 136px; width: 60px; height: 22px; } .separator { position: absolute; top: 70px; left: 65px; width: 150px; text-align: right; font: normal 10pt sans-serif; color: #000; border: 0px solid #cdcdcd; } .rad { position: absolute; top: 140px; left: 12px; width: 220px; height: 21px; border: 1px solid #cdcdcd; background: #e8e8e8; } .deg { position: relative; margin: 4px; top: -1px; font: normal 10pt sans-serif; } .cls { position: absolute; top: 103px; left: 217px; width: 30px; height: 22px; color: #f00; display: none; } .zadatak { position: absolute; top: 98px; left: 6px; width: 240px; height: 28px; border: 2px groove #eee; background: #fff; } .unos { position: absolute; top: 1px; left: 4px; width: 228px; height: 23px; border: 0px; font: bold 10pt cursive; color: #060; } .tekstarea { position: absolute; top: 10px; left: 8px; width: 238px; height: 317px; padding: 0px 0px 0px 5px; border: 2px groove #ccc; background: #fff; /*plavo*/ font: normal 9pt/150% monospace; color: #345678; overflow: auto; } .n1, .n2, .n3, .n4 { position: absolute; top: 340px; height: 24px; width: 80px; font: normal 9pt sans-serif; color: #000; } .n1 { left: 8px; } .n2 { left: 91px; } .n3 { left: 174px; } .n4 { top: 174px; left: 85px; } .n2copy { position: absolute; left: 0px; top: 206px; width: 242px; color: #aaa; font: normal 9pt sans-serif; text-align: center; } .b11, .b12, .b13, .b14, .b15, .b16, .b21, .b22, .b23, .b24, .b25, .b26, .b31, .b32, .b33, .b34, .b35, .b36 { position: absolute; height: 25px; width: 40px; padding: 0px; color: #000; font: normal 10pt monospace; } .b41, .b42, .b43, .b44, .b45, .b46, .b51, .b52, .b53, .b54, .b55, .b56, .b61, .b62, .b63, .b64, .b65, .b66, .b71, .b72, .b73, .b74, .b75, .b76 { position: absolute; height: 35px; width: 40px; padding: 0px; color: #000; } .b55, .b75 { position: absolute; height: 35px; width: 81px; font: normal 10pt sans-serif; color: #000; } .b75 { position: absolute; height: 35px; width: 81px; font: normal 15pt sans-serif; color: #050; } .b45, .b46 { font: normal 10pt sans-serif; color: #a00; } .b34 { font: normal 10pt sans-serif; } .b44, .b54, .b74 { font: bold 13pt sans-serif; color: #00f; } .b64 { font: normal 15pt serif; color: #00f; } .b41, .b42, .b43, .b51, .b52, .b53, .b61, .b62, .b63, .b71, .b72 { font: normal 12pt cursive; color: #575; } .b11, .b12, .b13, .b14, .b15, .b16 { top: 0px; } .b21, .b22, .b23, .b24, .b25, .b26 { top: 26px; } .b31, .b32, .b33, .b34, .b35, .b36 { top: 52px; } .b41, .b42, .b43, .b44, .b45, .b46 { top: 85px; } .b51, .b52, .b53, .b54, .b55, .b56 { top: 121px; } .b61, .b62, .b63, .b64, .b65, .b66 { top: 156px; } .b71, .b72, .b73, .b74, .b75, .b76 { top: 192px; } .b11, .b21, .b31, .b41, .b51, .b61, .b71 { left: 0px } .b12, .b22, .b32, .b42, .b52, .b62, .b72 { left: 41px } .b13, .b23, .b33, .b43, .b53, .b63, .b73 { left: 82px } .b14, .b24, .b34, .b44, .b54, .b64, .b74 { left: 123px } .b15, .b25, .b35, .b45, .b55, .b65, .b75 { left: 164px } .b16, .b26, .b36, .b46, .b56, .b66, .b76 { left: 205px } --> </style> <script type="text/javascript"> <!-- var EniG = " www.03www.su"; var que = ""; var ans = 0; var mem = 0; var broj = "0"; var tocka = 0; var eksp = 0; var baza = ""; var eksponent = 3; var rjesenje = 0; var decimala = 14; var asf = 0; var rdg = 0; var sep1000 = 0; var enter = ""; var mr = ""; var pi = 3.141592653589793; var e = 2.71828182845905; var abc = ""; //window.onerror = handleError; function start(){ enter = "\r\n"; mr = document.racunalo.memorija.value; document.racunalo.notes.value = enter + EniG + enter; var dan = new Date(); document.racunalo.notes.value += " " + dan.toLocaleString() + enter + enter; document.racunalo.zadatak.focus(); } function handleError() { //alert("YOU HAVE ENCOUNTERED A JAVASCRIPT ERROR"); document.racunalo.notes.value += " = Syntax Error\r\n"; document.racunalo.rezultat.value = "Syntax Error"; document.racunalo.zadatak.focus(); return true; } function memory(operator) { switch(operator) { case 1: // MS memorija = document.racunalo.rezultat.value; memorija = memorija.replace(/ /g,''); document.racunalo.memorija.value = memorija; document.racunalo.MR.title = mr + " (" + memorija + ")"; mem = parseFloat(memorija); stanje = (document.getElementById('nummem').style.color == '#000') ? '#ccc' : '#000'; document.getElementById('nummem').style.color = stanje; break; case 2: // MR var memorija = document.racunalo.memorija.value; if (memorija==0 || slovo(memorija.charAt(0))) {memorija = ""} document.racunalo.zadatak.value += memorija; break; case 3: // CLS if (document.racunalo.zadatak.value == "") {document.racunalo.rezultat.value = "";} else {document.racunalo.zadatak.value = ""; } break; case 4: // Mode vidi('numformat'); break; case 5: // Reset document.racunalo.notes.value = enter + EniG + enter; document.racunalo.memorija.value = ""; document.racunalo.MR.title = mr; decimala = 14; asf = 0; rdg = 0; sep1000 = 0; mem = 0; ans = 0; document.getElementById('numauto').style.color = '#000'; document.getElementById('numsci').style.color = '#ccc'; document.getElementById('numfix').style.color = '#ccc'; document.getElementById('nummem').style.color = '#ccc'; document.getElementById('numrad').style.color = '#000'; document.getElementById('numdeg').style.color = '#ccc'; document.getElementById('numgrad').style.color = '#ccc'; break; } document.racunalo.zadatak.focus(); } function dodajBroj(noviznak) { document.racunalo.zadatak.focus(); document.racunalo.zadatak.value += noviznak } function dodajConst(noviznak) { document.racunalo.zadatak.focus(); document.racunalo.zadatak.value += noviznak; vidi('konstante') } function izracunaj(zarez) { var pitanje = ""; var odgovor = ""; var mem = 0; //onerror = handleError; if (zarez >= 1) { if (document.racunalo.zadatak.value == "") { broj = document.racunalo.rezultat.value; } else { broj = document.racunalo.zadatak.value; if (ubacirezultat(broj.charAt(0))) { broj = document.racunalo.rezultat.value + broj; } } } for (var i=0; i<broj.length; i++) { var mm = broj.charAt(i); var mmup = broj.charAt(i+1); var mmdn = broj.charAt(i-1); if (mm == ",") {mm = ".";} else if (mm == "}" || mm == "]") {mm = ")";} else if (mm == "{" || mm == "[") {mm = "(";} else if (mm == " " || mm == "=") {mm = "";} else if (mm == "*" && mmup == "*") {mm = "^"; i += 1;} else if (mm == "+" && mmup == "-") {mm = "-"; i += 1;} else if (mm == "E" && kemilimat(mmup)) {mm = "e";} if (mm == "." && BrojAtoma(mmdn)==false) {mm = "0.";} else if (velikoslovo(mm)) {var kem = 1;} if (pitanje == "0") { if (operator(mm)) {} else if (mm != ".") {pitanje = "";} } //if (i == 0) { // if (mm == "0" && mmup == "0") {mm = "";} //} pitanje += mm; } if (zarez == 1) { document.racunalo.notes.value += pitanje; document.racunalo.upit.value = pitanje; if (kem == 1) { //var atom = "+" + pitanje; odgovor = masa(pitanje); } else { odgovor = zagrada(pitanje); } } else { odgovor = matematika(zarez, pitanje) } odgovor = odgovor.toString(); document.racunalo.oldrezultat.value = odgovor; ans = parseFloat(odgovor); izgledbroja(odgovor); document.racunalo.zadatak.value = ""; document.racunalo.zadatak.focus(); } function matematika(zarez, rjesenje) { var pitanje = ""; with (Math) { if (zarez == 2) { pitanje = rjesenje + "^2"; rjesenje = pow(rjesenje, 2) } else if (zarez == 3) { pitanje = rjesenje + "^(1/2)"; rjesenje = sqrt(rjesenje) } else if (zarez == 4) { pitanje = rjesenje + "*(-1)"; rjesenje = -rjesenje } else if (zarez == 5) { pitanje = "ln(" + rjesenje + ")"; rjesenje = log(rjesenje) } else if (zarez == 6) { pitanje = "e^" + rjesenje; rjesenje = pow(E, rjesenje) } else if (zarez == 7) { pitanje = "1/" + rjesenje; rjesenje = 1/rjesenje } else if (zarez == 8) { pitanje = "log(" + rjesenje + ")"; rjesenje = log(rjesenje)/LN10 } else if (zarez == 9) { pitanje = "10^" + rjesenje; rjesenje = pow(10, rjesenje) } else if (zarez >= 10 && zarez <= 12) { if (zarez == 10) { pitanje = "atan(" + rjesenje + ")"; rjesenje = atan(rjesenje) } else if (zarez == 11) { pitanje = "acos(" + rjesenje + ")"; rjesenje = acos(rjesenje) } else if (zarez == 12) { pitanje = "asin(" + rjesenje + ")"; rjesenje = asin(rjesenje) } if (document.racunalo.stupnjevi[1].checked) {rjesenje = (rjesenje * 180) / PI} else if (document.racunalo.stupnjevi[2].checked) {rjesenje = (rjesenje * 200) / PI} } else if (zarez >= 14 && zarez <= 16) { if (document.racunalo.stupnjevi[1].checked) {radijani = (rjesenje / 180) * PI} else if (document.racunalo.stupnjevi[2].checked) {radijani = (rjesenje / 200) * PI} else {radijani = rjesenje} if (zarez == 14) { pitanje = "tan(" + rjesenje + ")"; rjesenje = tan(radijani) } else if (zarez == 15) { pitanje = "cos(" + rjesenje + ")"; rjesenje = cos(radijani) } else if (zarez == 16) { pitanje = "sin(" + rjesenje + ")"; rjesenje = sin(radijani) } } else if (zarez == 17) { pitanje = rjesenje + "%"; rjesenje = rjesenje/100 } else if (zarez == 18) { pitanje = rjesenje + "ppm"; rjesenje = rjesenje/1000000 } else if (zarez == 20) { pitanje = rjesenje + "!"; rjesenje = factorial(rjesenje) } else if (zarez == 21) { eksponent = prompt("Unesite eksponent / Please enter exponent", 3); pitanje = rjesenje + "^" + eksponent; rjesenje = pow(rjesenje, eksponent) } else if (zarez == 22) { eksponent = prompt("Unesite korijen / Please enter root", 3); document.racunalo.notes.value += rjesenje + "^(1/" + eksponent + ")"; rjesenje = pow(rjesenje, (1/eksponent)) } } document.racunalo.notes.value += pitanje; document.racunalo.upit.value = pitanje; return rjesenje; } function zagrada(xbroj) { var intZagClose = 0 var intZagOpen = 0 var intXbroj = 0 var strNoviXbroj = "" var strNoviZbroj = ""; do { //document.racunalo.notes.value += enter + "intXbroj = " + intXbroj; 2+(2*(2+4)+3)^3+5 xbroj = xbroj.replace(/--/g,"-1*-"); intZagClose = xbroj.indexOf(")"); if (intZagClose != -1) { for (var i = intZagClose; i >= 0; i--) { if (xbroj.charAt(i)=="(") { intZagOpen = i; strNoviZbroj = xbroj.substring(intZagOpen+1,intZagClose); break; } } } else { strNoviZbroj = xbroj; } strNoviZbroj = strNoviZbroj + "*1"; strNoviZbroj = postotak(strNoviZbroj); strNoviZbroj = trigonometrija(strNoviZbroj); strNoviZbroj = logaritam(strNoviZbroj); strNoviZbroj = potencija(strNoviZbroj); strNoviZbroj = racun(strNoviZbroj); if (intZagClose != -1) { xbroj = xbroj.replace(xbroj.substring(intZagOpen, intZagClose+1), strNoviZbroj); } else { xbroj = strNoviZbroj; } } while (intZagClose > 0) return xbroj; } function racun(zbroj) { with (Math) {zbroj = eval(zbroj);} return zbroj; } function potencija(ulaz) { var intZagClose = 0 var intZagOpen = 0; var intXbroj = ulaz.indexOf("^"); //2+2^3+2,15^2+4 while (intXbroj > 0) { for (var i = intXbroj - 1; i >= 0; i--) { if (operator(ulaz.charAt(i)) && ulaz.charAt(i-1)!="e") { //if (i > 0 && operator(ulaz.charAt(i-1))) { intZagOpen = i+1; break; } } if (ulaz.charAt(i) == "-"){ if (i == 0) {intZagOpen = 0;} else if (i > 0 && operator(ulaz.charAt(i-1))) {intZagOpen = i;} } var strNoviXbroj = ulaz.substring(intZagOpen,intXbroj); for (var i = intXbroj + 2; i < ulaz.length; i++) { if (operator(ulaz.charAt(i)) && ulaz.charAt(i-1)!="e") {intZagClose = i-1; break} } var strNoviYbroj = ulaz.substring(intXbroj+1,intZagClose+1); if (strNoviXbroj == 'e') {strNoviXbroj = e}; //cps with (Math) { intXbroj = pow(strNoviXbroj, strNoviYbroj); } //if (i != 0 && ulaz.charAt(i-1)) {} // za negativne brojeve -3^2 = -9 ili 9 ulaz = ulaz.replace(ulaz.substring(intZagOpen, intZagClose+1), intXbroj); intXbroj = ulaz.indexOf("^"); } return ulaz; } function postotak(ulaz) { var intZagClose = 0; var intZagOpen = 0; var strDesnoFun = new Array ("!", "%"); for (var f = 0; f < 2; f++) { var intXbroj = ulaz.indexOf(strDesnoFun[f]); while (intXbroj > 0) { for (var i = intXbroj - 1; i >= 0; i--) { if (operator(ulaz.charAt(i)) && ulaz.charAt(i-1)!="e") {intZagOpen = i+1; break} } var strNoviXbroj = ulaz.substring(intZagOpen,intXbroj); intZagClose = intXbroj+1; with (Math) { if (f == 0) { intXbroj = factorial(strNoviXbroj); } else { intXbroj = strNoviXbroj/100; } } ulaz = ulaz.replace(ulaz.substring(intZagOpen, intZagClose), intXbroj); intXbroj = ulaz.indexOf(strDesnoFun[f]); } } return ulaz; } function trigonometrija(kut) { var intZagClose = 0 var intKut = 0 var strNoviKut = "" var strKrozPi = ")" var strPiKroz = ")"; switch(rdg) { case 1: strKrozPi = ")*180/pi"; strPiKroz = "*pi/180)"; break; case 2: strKrozPi = ")*200/pi"; strPiKroz = "*pi/200)"; break; default: strKrozPi = ")"; strPiKroz = ")"; } var strTrigFun = new Array ("sin", "cos", "tan"); for (var f = 0; f < 3; f++) { intKut = kut.indexOf(strTrigFun[f]); if (intKut >= 0) { do { //document.racunalo.notes.value += enter + intKut + enter; cos(2*(3+5)+3*(2+4))+1 2+(2*(2+cos(4))+3)+(3^3+5)*4 intZagClose = kut.length; for (var i = intKut+4; i < intZagClose; i++) { if (operator(kut.charAt(i)) && kut.charAt(i-1)!="e") { intZagClose = i; strNoviKut = kut.substring(intKut+3, intZagClose); break; } } if (intKut>0 && kut.charAt(intKut-1)=="a") { intKut = intKut - 1; strNoviKut = "a" + strTrigFun[f] + "(" + strNoviKut + strKrozPi; } else { strNoviKut = strTrigFun[f] + "(" + strNoviKut + strPiKroz; } strNoviKut = racun(strNoviKut); strNoviKut = Math.round(strNoviKut * Math.pow(10,14)) / Math.pow(10,14); kut = kut.replace(kut.substring(intKut, intZagClose), strNoviKut); intKut = kut.indexOf(strTrigFun[f]); } while (intKut != -1); } } return kut; } function logaritam(kut) { var intZagClose = 0 var intKut = 0 var strNoviKut = "" var strKrozPi = ")" var strPiKroz = ")"; // var e = 2.71828182845905 var strLogFun = new Array ("ln", "log"); for (var f = 0; f < 2; f++) { intKut = kut.indexOf(strLogFun[f]); if (intKut >= 0) { do { intZagClose = kut.length; for (var i = intKut; i < intZagClose; i++) { if (operator(kut.charAt(i)) && kut.charAt(i-1)!="e") { intZagClose = i; strNoviKut = kut.substring(intKut+strLogFun[f].length, intZagClose); break; } } if (f == 0) { if (intKut>0 && kut.charAt(intKut-1)=="a") { intKut = intKut - 1; strNoviKut = "pow(E," + strNoviKut + ")"; } else { strNoviKut = "log(" + strNoviKut + ")"; } } else { if (intKut>0 && kut.charAt(intKut-1)=="a") { intKut = intKut - 1; strNoviKut = "pow(10," + strNoviKut + ")"; } else { strNoviKut = "log(" + strNoviKut + ")/LN10"; } } strNoviKut = racun(strNoviKut); kut = kut.replace(kut.substring(intKut, intZagClose), strNoviKut); intKut = kut.indexOf(strLogFun[f]); } while (intKut != -1); } } return kut; } function izazareza(novibroj) { with (Math) { if (eksp == -1) { var duzina = tocka; if (duzina == -1) {duzina = novibroj.length} var desni = ""; if (duzina > 16) { var privremeni = round(novibroj*pow(10, 16)) + " "; var novie = privremeni.indexOf("e"); var lijevi = (privremeni.substring(0,novie)); lijevi = round(lijevi*pow(10, 15))/pow(10, 15) + " "; desni = (privremeni.substring(novie+2,privremeni.length-1)); desni = "e+" + (desni-18); } else { var lijevi = round(novibroj*pow(10, decimala))/pow(10, decimala) + " "; } } else { var lijevi = novibroj.substring(0,eksp); var desni = novibroj.substring(eksp,novibroj.length); lijevi = round(lijevi*pow(10, decimala))/pow(10, decimala) + " "; } lijevi = lijevi.substring(0,lijevi.length - 1); if (lijevi.charAt(0) == ".") {lijevi = "0" + lijevi;} if (decimala < 14) { if (lijevi.indexOf(".") == -1 && decimala != 0) {lijevi += "."} var nula = (tocka + decimala) - (lijevi.length - 1); if (nula > 0 && decimala > 0) { for (var n = 0; n < nula; n++) { lijevi += "0"; } } } return (lijevi + desni); } } function factorial(n) { if ((n == 0) || (n == 1)) { return 1; } else { var odgovor = (n * factorial(n-1)); return odgovor; } } function masa(atom) { with (Math) { var atominfo = false; var mm=""; var mmdn=""; var mmup=""; var znak=""; var izraz=""; var Pi=pi; var H=1.0079; var He=4.0026; var Li=6.941; var Be=9.0122; var B=10.811; var C=12.011; var N=14.007; var O=15.999; var F=18.998; var Ne=20.18; var Na=22.99; var Mg=24.305; var Al=26.982; var Si=28.086; var P=30.974; var S=32.065; var Cl=35.453; var Ar=39.948; var K=39.098; var Ca=40.078; var Sc=44.956; var Ti=47.867; var V=50.942; var Cr=51.996; var Mn=54.938; var Fe=55.845; var Co=58.933; var Ni=58.693; var Cu=63.546; var Zn=65.409; var Ga=69.723; var Ge=72.64; var As=74.922; var Se=78.96; var Br=79.904; var Kr=83.798; var Rb=85.468; var Sr=87.62; var Y=88.906; var Zr=91.224; var Nb=92.906; var Mo=95.94; var Tc=98; var Ru=101.07; var Rh=102.91; var Pd=106.42; var Ag=107.87; var Cd=112.41; var In=114.82; var Sn=118.71; var Sb=121.76; var Te=127.6; var I=126.9; var Xe=131.29; var Cs=132.91; var Ba=137.33; var La=138.91; var Ce=140.12; var Pr=140.91; var Nd=144.24; var Pm=145; var Sm=150.36; var Eu=151.96; var Gd=157.25; var Tb=158.93; var Dy=162.5; var Ho=164.93; var Er=167.26; var Tm=168.93; var Yb=173.04; var Lu=174.97; var Hf=178.49; var Ta=180.95; var W=183.84; var Re=186.21; var Os=190.23; var Ir=192.22; var Pt=195.08; var Au=196.97; var Hg=200.59; var Tl=204.38; var Pb=207.2; var Bi=208.98; var Po=209; var At=210; var Rn=222; var Fr=223; var Ra=226; var Ac=227; var Th=232.04; var Pa=231.04; var U=238.03; var Np=237; var Pu=244; var Am=243; var Cm=247; var Bk=247; var Cf=251; var Es=252; var Fm=257; var Md=258; var No=259; var Lr=262; var Rf=267; var Db=268; var Sg=271; var Bh=272; var Hs=277; var Mt=276; var Ds=281; var Rg=280; for (var i=0; i<atom.length; i++) { mm = atom.charAt(i); mmup = atom.charAt(i+1); bigup = mm.toUpperCase(); mmdn = atom.charAt(i-1); if (mm == "[") {mm = "("} else if (mm == "]") {mm = ")"} else if (mm == ",") {mm = "."} if (slovo(mm)) {atominfo = true} if (matoperator(mm)) {atominfo = false; znak=""} if (atominfo) { if (matoperator(mmup)) {znak=")"} if (matoperator(mmdn)) {izraz += "(" + mm + znak} else if (mmdn=="(") {izraz += mm + znak} else if (mmdn=="[") {izraz += mm + znak} else if (slovo(mm)) {izraz += "+" + mm + znak} else if (BrojAtoma(mmdn)) {izraz += mm + znak} else if (BrojAtoma(mm)) {izraz += "*" + mm + znak} else {izraz += mm + znak} } else {izraz += mm} } odgovor = eval(izraz); return odgovor; } } function slovo(znak) { var slovo="(ABCDEFGHIKLMNOPRSTUVWXYZ"; for (var i=0; i<slovo.length; i++) if (znak == slovo.charAt(i)) {return true} {return false} } function velikoslovo(znak) { var slovo="ABCDEFGHIKLMNOPRSTUVWXYZ"; for (var i=0; i<slovo.length; i++) if (znak == slovo.charAt(i)) {return true} {return false} } function maloslovo(znak) { var slovo="abcdefghiklmnoprstuvwxyz"; for (var i=0; i<slovo.length; i++) if (znak == slovo.charAt(i)) {return true} {return false} } function matoperator(znak) { var matoperator="*/+-"; for (var i=0; i<matoperator.length; i++) if (znak == matoperator.charAt(i)) {return true} if (znak == "") {return true} if (znak == null) {return true} return false } function operator(znak) { var matoperator="^*/+-"; if (matoperator.indexOf(znak) >= 0) {return true} {return false} } function ubacirezultat(znak) { var ubacirezultat="^*/+"; for (var i=0; i<ubacirezultat.length; i++) if (znak == ubacirezultat.charAt(i)) {return true} return false } function BrojAtoma(znak) { var atom = "1234567890"; for (var i=0; i<atom.length; i++) if (znak == atom.charAt(i)) {return true} {return false} } function kemilimat(znak) { var atom = "rsu"; if (atom.indexOf(znak) == -1) {return true} {return false} } function numformat(x){ var kut = new Array("auto", "sci", "fix"); decimala = x; var broj = document.racunalo.oldrezultat.value; if (decimala < 13) { document.racunalo.notes.value += "[" + kut[asf] + decimala + "]"; } else { decimala = 14; document.racunalo.notes.value += "[" + kut[asf] + "]"; } if (broj != "0" && broj != "") { izgledbroja(broj) } else { document.racunalo.notes.value += enter; } document.racunalo.zadatak.focus(); } function scifix(x) { var kut = new Array("numauto", "numsci", "numfix"); document.getElementById(kut[asf]).style.color = '#ccc'; asf = x; var broj = document.racunalo.oldrezultat.value; switch(x) { case 1: document.getElementById('numsci').style.color = '#000'; if (decimala == 14) { document.racunalo.notes.value += "[sci]"; } else { document.racunalo.notes.value += "[sci" + decimala + "]"; } break; case 2: document.getElementById('numfix').style.color = '#000'; document.racunalo.izaZareza.options[2].selected = true; if (decimala == 14) { decimala = 2; document.racunalo.notes.value += "[fix2]"; } else { document.racunalo.notes.value += "[fix" + decimala + "]"; } break; default: document.getElementById('numauto').style.color = '#000'; document.racunalo.izaZareza.options[14].selected = true; document.racunalo.notes.value += "[auto]"; decimala = 14; } if (broj != "0" && broj != "") {izgledbroja(broj)} document.racunalo.zadatak.focus(); } function raddeg(x) { var kut = new Array("numrad", "numdeg", "numgrad"); document.getElementById(kut[rdg]).style.color = "#ccc"; rdg = x; document.getElementById(kut[x]).style.color = "#000"; document.racunalo.zadatak.focus(); } function seplk() { var broj = document.racunalo.oldrezultat.value; if (document.getElementById('seplk').checked) { document.getElementById('seplk').checked = false; sep1000 = 0; } else { document.getElementById('seplk').checked = true; sep1000 = 1; } if (broj.length > 3) {izgledbroja(broj)} } function izgledbroja(broj) { var nule = "000000000000000"; var minus = ""; if (broj.charAt(0) == "-") {minus = "-";} if (asf == 2) { if (Math.eval(broj+"*"+minus+"1-1e-"+decimala) < 0) {broj = "0"} } var eplace = broj.indexOf("e"); if (eplace > 0) { var x = broj.substring(0, eplace); var y = broj.substring(eplace); } else if (asf == 1) { var x = parseFloat(broj) * 1E50; broj = x.toString(); eplace = broj.indexOf("e"); x = broj.substring(0, eplace); var y = broj.substring(eplace+1); y = parseInt(y) - 50; y = "e" + y; } else { var x = broj; var y = ""; } var oplace = broj.indexOf("."); broj = parseInt(x); if (oplace == -1) {x = "0";} {x = "0" + x.substring(oplace);} x = parseFloat(x); with (Math) { x = round(x * pow(10,decimala)) / pow(10,decimala); broj = abs(broj) + x; } x = broj.toString(); oplace = x.indexOf("."); //document.racunalo.notes.value += enter + "oplace_1 = " + oplace; if (oplace == 0) { broj = "0" + x + nule.substring(0, decimala); } else if (oplace > 0) { x = x.concat(nule); broj = x.substring(0, oplace); broj += x.substring(oplace, oplace+decimala+1); } else { broj = x + "." + nule.substring(0, decimala); } if (decimala == 14) {broj = parseFloat(broj)} broj = minus.concat(broj, y); //PROBA POCETAK if (sep1000) { //document.racunalo.notes.value += enter + "separator_1 = " + broj; var rezultat = ""; var strexp = ""; oplace = broj.indexOf('.'); //if (oplace == -1) {oplace = 0;} eplace = broj.indexOf('e'); if (eplace == -1) {eplace = broj.length;} {strexp = broj.substring(eplace);} var tri = 0; for (var i=oplace+1; i<eplace; i++) { tri += 1; if (tri == 3) { rezultat += broj.charAt(i) + " "; tri = 0; } else { rezultat += broj.charAt(i); } } rezultat += strexp //document.racunalo.notes.value += enter + "separator_2 = " + rezultat; if (oplace > -1) { rezultat = "." + rezultat; tri = 0; for (var i=oplace-1; i>=0; i--) { if (tri == 3) { rezultat = broj.charAt(i) + " " + rezultat; tri = 0; } else { rezultat = broj.charAt(i) + rezultat; } tri += 1; } } rezultat = rezultat.replace("- ", "-"); broj = rezultat; //document.racunalo.notes.value += enter + "separator_3 = " + rezultat; } //PROBA KRAJ document.racunalo.rezultat.value = broj; document.racunalo.notes.value += " = " + broj + enter; return broj; } function zaokruzi_new(ebroj) { // max 16 decimala //var n=16; var x=ebroj.toExponential(decimala); document.racunalo.notes.value += enter + "toExponential = " + x + enter; var x=ebroj.toPrecision(decimala); document.racunalo.notes.value += "toPrecision = " + x + enter; var x=ebroj.toFixed(decimala); document.racunalo.notes.value += "toFixed = " + x + enter; document.racunalo.rezultat.value = x; document.racunalo.notes.value += " = " + x + enter; } function vidi(me) { //if (document.getElementById) { stanje = (document.getElementById(me).style.display == 'block') ? 'none' : 'block'; document.getElementById(me).style.display = stanje; //document.getElementById(me).style.visibility = stanje //} } //Eni Generalic, Split, Create: 1999/10/14; Update: 2008/03/01 // Copyright © 2008 by EniG. // Multiple onload function created by: Simon Willison // http://simonwillison.net/2004/May/26/addLoadEvent/ function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { if (oldonload) { oldonload(); } func(); } } } addLoadEvent(start); // --> </script> </head> <body> <h1 style="text-align:center;font: bold 24px Arial,sans-serif; color:#FFCC66;;text-shadow: 1px 1px 2px #000;behavior: url(byn.htc);}"> <script type="text/javascript"> document.write(document.title) </script></h1> <div id="calc4chem"> <form action="2011-8-22.html" name="racunalo"> <input type="hidden" name="oldrezultat" value=""> <input type="hidden" name="memorija" value="Memory recall"> <div id="kalkulator"> <div class="displej"> <input type="text" name="numauto" value="AUTO" id="numauto" onfocus="ascifix[0].click()"> <input type="text" name="numsci" value="SCI" id="numsci" onfocus="ascifix[1].click()"> <input type="text" name="numfix" value="FIX" id="numfix" onfocus="ascifix[2].click()"> <input type="text" name="nummem" value="MEM" id="nummem" onfocus="MS.click()"> <input type="text" name="numrad" value="RAD" id="numrad" onfocus="stupnjevi[0].click()"> <input type="text" name="numdeg" value="DEG" id="numdeg" onfocus="stupnjevi[1].click()"> <input type="text" name="numgrad" value="GRAD" id="numgrad" onfocus="stupnjevi[2].click()"> <input type="text" name="upit" value="Problem" onClick="this.select()" class="upit"> <input type="text" name="rezultat" value="Solution" onClick="this.select()" class="rezultat"> </div> <div class="zadatak"> <input type="text" name="zadatak" value="" onKeyDown="if (event.keyCode==13) {enter.click()}" class="unos"> </div> <input type="button" name="cls" value="Cls" title="Clear" onClick="memory(3)" class="cls"> <div class="tipkovnica"> <input type="button" name="sqrt" value="√¯" title="Square root" onClick="izracunaj(3)" class="b11"> <input type="button" name="root" value="y√¯x" title="Root" onClick="izracunaj(22)" class="b12"> <input type="button" name="ln" value="ln" title="Natural logarithm" onClick="izracunaj(5)" class="b13"> <input type="button" name="log" value="log" title="Common logarithm" onClick="izracunaj(8)" class="b14"> <input type="button" name="tan" value="tan" title="Tangent" onClick="izracunaj(14)" class="b15"> <input type="button" name="atan" value="atan" title="Arc tangent" onClick="izracunaj(10)" class="b16"> <input type="button" name="kvadrat" value="x²" title="Square" onClick="izracunaj(2)" class="b21"> <input type="button" name="potencija" value="x^y" title="Power" onClick="izracunaj(21)" class="b22"> <input type="button" name="aln" value="e^x" title="Natural antilogarithm" onClick="izracunaj(6)" class="b23"> <input type="button" name="alog" value="10^x" title="Common antilogarithm" onClick="izracunaj(9)" class="b24"> <input type="button" name="cos" value="cos" title="Cosine" onClick="izracunaj(15)" class="b25"> <input type="button" name="acos" value="acos" title="Arc cosine" onClick="izracunaj(11)" class="b26"> <input type="button" name="sign" value="+/-" title="Sign change" onClick="izracunaj(4)" class="b31"> <input type="button" name="1/x" value="1/x" title="Reciprocal" onClick="izracunaj(7)" class="b32"> <input type="button" name="fact" value="x!" title="Factorial" onClick="izracunaj(20)" class="b33"> <input type="button" name="postotak" value="%" title="Percent" onClick="izracunaj(17)" class="b34"> <input type="button" name="sin" value="sin" title="Sine" onClick="izracunaj(16)" class="b35"> <input type="button" name="asin" value="asin" title="Arc sine" onClick="izracunaj(12)" class="b36"> <input type="button" name="7" value="7" title="Seven" onClick="dodajBroj(7)" class="b41"> <input type="button" name="8" value="8" title="Eight" onClick="dodajBroj(8)" class="b42"> <input type="button" name="9" value="9" title="Nine" onClick="dodajBroj(9)" class="b43"> <input type="button" name="djeljeno" value="÷" title="Division" onClick="dodajBroj('/')" class="b44"> <input type="button" name="MS" value="MS" title="Memory store" onClick="memory(1)" class="b45"> <input type="button" name="MR" value="MR" title="Memory recall" onClick="memory(2)" class="b46"> <input type="button" name="4" value="4" title="Four" onClick="dodajBroj(4)" class="b51"> <input type="button" name="5" value="5" title="Five" onClick="dodajBroj(5)" class="b52"> <input type="button" name="6" value="6" title="Six" onClick="dodajBroj(6)" class="b53"> <input type="button" name="puta" value="×" title="Multiplication" onClick="dodajBroj('*')" class="b54"> <input type="button" name="con" value="Constants" title="Physical Constants" onClick="vidi('konstante'); return false;" class="b55"> <input type="button" name="1" value="1" title="One" onClick="dodajBroj(1)" class="b61"> <input type="button" name="2" value="2" title="Two" onClick="dodajBroj(2)" class="b62"> <input type="button" name="3" value="3" title="Three" onClick="dodajBroj(3)" class="b63"> <input type="button" name="minus" value="-" title="Subtraction" onClick="dodajBroj('-')" class="b64"> <input type="button" name="lijevo" value="(" title="Parentheses" onClick="dodajBroj('(')" class="b65"> <input type="button" name="desno" value=")" title="Parentheses" onClick="dodajBroj(')')" class="b66"> <input type="button" name="0" value="0" title="Zero" onClick="dodajBroj(0)" class="b71"> <input type="button" name="." value="." title="Decimal point" onClick="dodajBroj('.')" class="b72"> <input type="button" name="exp" value="exp" title="Exponent" onClick="dodajBroj('e')" class="b73"> <input type="button" name="plus" value="+" title="Addition" onClick="dodajBroj('+')" class="b74"> <input type="button" name="enter" value="=" title="Calculate" onClick="izracunaj(1)" class="b75"> </div> <!-- END tipkovnica --> <div id="numformat"> <p class="formatnaslov">Number formats</p> <div class="formatbr"> <div class="automatik"> <input type="radio" name="ascifix" checked title="Automatic" onClick="scifix(0)"> <a href="javascript:document.racunalo.ascifix[0].click()" onMouseOver="self.status='Automatic'; return true">Auto</a> </div> <div class="scienc"> <input type="radio" name="ascifix" title="Scientific notation" onClick="scifix(1)"> <a href="javascript:document.racunalo.ascifix[1].click()" onMouseOver="self.status='Scientific notation'; return true">Sci</a> </div> <div class="fiksed"> <input type="radio" name="ascifix" title="Fixed number of decimal places" onClick="scifix(2)"> <a href="javascript:document.racunalo.ascifix[2].click()" onMouseOver="self.status='Fixed number of decimal places'; return true">Fix</a> </div> <div class="decnaslov">Decimals</div> <select name="izaZareza" SIZE="1" onChange="numformat(this.selectedIndex)" class="decimal"> <option value="0"> 0 </option> <option value="1"> 1 </option> <option value="2"> 2 </option> <option value="3"> 3 </option> <option value="4"> 4 </option> <option value="5"> 5 </option> <option value="6"> 6 </option> <option value="7"> 7 </option> <option value="8"> 8 </option> <option value="9"> 9 </option> <option value="10"> 10 </option> <option value="11"> 11 </option> <option value="12"> 12 </option> <option value="13"> ---- </option> <option value="14" selected> auto </option> </select> <div class="separator"> <a href="javascript:seplk()" onMouseOver="self.status='Separator tisu?ica'; return true">1000 separator </a> <input type="checkbox" id="seplk" onClick="seplk()"> </div> </div> <div class="rad"> <input type="radio" name="stupnjevi" checked title="Radians" onClick="raddeg(0)"> <span class="deg"> <a href="javascript:document.racunalo.stupnjevi[0].click()" onMouseOver="self.status='Radians'; return true">Rad </a> </span> <input type="radio" name="stupnjevi" title="Degrees" onClick="raddeg(1)"> <span class="deg"> <a href="javascript:document.racunalo.stupnjevi[1].click()" onMouseOver="self.status='Degrees'; return true">Deg </a> </span> <input type="radio" name="stupnjevi" title="Grads" onClick="raddeg(2)"> <span class="deg"> <a href="javascript:document.racunalo.stupnjevi[2].click()" onMouseOver="self.status='Grads'; return true">Grad</a> </span> </div> <input type="button" name="close" value="Close" title="Close Form" onClick="memory(4)" class="n4"> </div> </div> <div id="biljeska"> <textarea name="notes" class="tekstarea">