var xhr; function ajax(typa,divid,prop,urlid,parameter,cback,pushUrl,kill) { if (document.getElementById("hornvalmynd")) { if (urlid!="hornval.php") { document.getElementById("hornvalmynd").style.display="none"; } } if (document.getElementById("debug")) { document.getElementById("debug").remove(); } "use strict"; $(window).bind('popstate', function(){ window.location.href = window.location.href; }); var $this = $(this), data = $this.find('.firstInput').serialize(), method = $this.attr('method'), action = $this.attr('action'); if(xhr){ if(kill==1) { xhr.abort(); } } xhr=$.ajax({ type: typa, url: urlid, data: parameter, cache: false, beforeSend: function() { if (cback=="synahnappa") { document.getElementById('dim').style.display='block'; } }, success: function(svar){ if (divid!="") { if (prop=='value') { $('#'+divid).value(svar); } else if (prop=='height') { $('#'+divid).height(svar); } else if (prop=='backgroundColor') { $('#'+divid).css("background-color",svar); } else if (prop=='display') { $('#'+divid).css("display",svar); } else if (prop=='color') { $('#'+divid).css("color",svar); } else if (prop=='disabled') { if (svar=='disabled') { $('#'+divid).attr('disabled','disabled'); } else { $('#'+divid).removeAttr('disabled'); } } else if (prop=='htmlplus') { var svar1=document.getElementById(divid).innerHTML; var svar2=svar1+svar; document.getElementById(divid).innerHTML=svar2; } else { $('#'+divid).html(svar); } } if (typeof pushUrl !== "undefined") { if (pushUrl!="") { //alert('skrifa í '); var kaka=unescape(decodeURI(getCookie('sidasta'))); var pu=pussa(pushUrl); var puAnSlash=pu; pu="/"+pu; if (pu!=kaka) { document.title=puAnSlash+" - Íslenskt orðanet"; history.pushState({url:puAnSlash},null,pu); setCookie("naestsidasta", getCookie['sidasta'], 3650); setCookie("sidasta", pu, 3650); analyctics(); } } } }, complete: function(svar) { if (cback=="synahnappa") { document.getElementById('dim').style.display='none'; } //ekki else if (cback=="adgreina_nefnimyndir") { if (svar['responseText'].substring(0,11)!="Engin samsv") { ajax('POST','haegri','','/umsysla/info_ogreint.php',parameter); } } else if (cback=="nyajaxleit") { skorun(divid); nyajaxleit(divid,parameter); } else if (cback=='select_stepXnyajaxleit') { select_step(divid,parameter); nyajaxleit(divid,parameter); } else if (cback=='textayfirlit') { keyra('/umsysla/hjalparsidur.php','haegri'); } else if (cback>'') { window[cback](divid,parameter); } } }); } function qsleit(qs,variable) { var vars = qs.split('&'); for (var i = 0; i < vars.length; i++) { var pair = vars[i].split('='); if (decodeURIComponent(pair[0]) == variable) { return decodeURIComponent(pair[1]); } } } function ajaxleit(valinnFlid,valinFletta,nokill) { if (typeof valinFletta === "undefined") { //fletta ekki send yfir var x=document.getElementById("leit").value; } else { //var x=strip_tags(valinFletta); var x=valinFletta; } var par="str="+x+"&valinnFlid="+valinnFlid; if (typeof nokill === "undefined") { if (x=="") { document.getElementById("leitardiv").className="leitardiv leitardivXL"; document.getElementById("leitarhjalp").className="leitarvjalp leitarhjalpXL cursorNohov"; document.getElementById("leitarvideo").className="leitarvideo leitarvideoXL"; document.getElementById("leit").className="leit leitXL"; document.getElementById("leitarvideo").style.display="none"; document.getElementById("hovertexti").className="hjalparhoverXL"; document.getElementById("spurnhringur").className="flatmerkiXL"; document.getElementById("flettulisti").style.display="block"; } else { document.getElementById("leitardiv").className="leitardiv"; document.getElementById("leitarhjalp").className="leitarhjalp cursorNohov"; document.getElementById("leitarvideo").className="leitarvideo"; document.getElementById("leit").className="leit"; document.getElementById("leitarvideo").style.display="none"; document.getElementById("hovertexti").className="hjalparhover"; document.getElementById("spurnhringur").className="flatmerki"; document.getElementById("flettulisti").style.display="block"; } document.getElementById("haegri").innerHTML=""; ajax("POST","flettulisti","","/leit.php",par,"","",1); } else { document.getElementById("leitardiv").className="leitardiv"; ajax("POST","flettulisti","","/leit.php",par,"","",""); } } function ajaxleitFraUrl(fletta,push) { fletta=fletta.replace(/\s\s+/g, ' '); //eyðir tvöföldu stafabili fletta=fletta.replace(/\[/g, ''); //eyðir hornklofum fletta=fletta.replace(/\]/g, ''); //eyðir hornklofum fletta=fletta.replace(/\(/g, ''); //eyðir svigum fletta=fletta.replace(/\)/g, ''); //eyðir svigum fletta=fletta.replace(/,/g, ''); //eyðir kommum fletta=fletta.replace(/;/g, ''); //eyðir semikommum document.getElementById("leit").value=fletta; var par="str="+fletta; if (push=1) { ajax("POST","flettulisti","","/leit.php",par,"",fletta,1); } else { ajax("POST","flettulisti","","/leit.php",par,"","",1); } } function ajaxvenslaleit(valinnFlid) { var x=document.getElementById("venslaleit").value; var par="str="+x+"&valinnFlid="+valinnFlid; ajax("POST","venslaleitarval","","/venslaleit.php",par); //document.getElementById("haegri").innerHTML=""; } function staekkaValinn(flid) { var i; var tags = document.getElementById("flettulisti").getElementsByTagName("div"); var total = tags.length; var el; for (i=0;i]+)>)/ig,""); //strip_tags str=str.replace(/\s\s+/g, ' '); //eyðir tvöföldu stafabili str=str.trim(); str=str.replace(new RegExp(" ", 'g'),"_"); //bil verður undirstrik return str; } function rekja(frumflid,grannflid) { if (document.getElementById("rekja"+grannflid).style.display=="none") { //byrja á að loka öllum hinum gluggunum var node_listi = document.querySelectorAll('*[id^="rekja"]'); for (var i = 0; i < node_listi.length; ++i) { var item = node_listi[i]; // Calling myNodeList.item(i) isn't necessary in JavaScript item.style.display="none"; item.innerHTML=""; } var par="frumflid="+frumflid+"&grannflid="+grannflid; ajax("POST","rekja"+grannflid,"","/rekjaGrannheiti.php",par); document.getElementById("rekja"+grannflid).style.display=""; } else { document.getElementById("rekja"+grannflid).style.display="none"; } } function sjaMeira(stafur) { document.getElementById('meira_'+stafur).style.display="block"; document.getElementById('sjameira').innerHTML="
Langsóttari vensl"; } function syna_nidurstodur(flid,typNr,litur,radnumer,mark,talning) { var erTil=false; var i=-1; for (i=-1;i<9;i++) { erTil=document.getElementById("flipi"+i); if (erTil) { if (i==typNr) { document.getElementById("flipi"+i).className = "tab baklitur"+i; document.getElementById("meginmal").style.borderColor=litur; } else { document.getElementById("flipi"+i).className = "tab daufbaklitur"+i; } } } //var typ=["hugtok","por","skyldheiti","grannheiti","samheiti","andheiti","stiklur","samsett","setngerd"]; var typ=["hugtok","por","skyldheiti","grannheiti","metin_vensl","osamb","samsett","setngerd"]; typ[-1]="yfirlit"; var par="flid="+flid+"&typ="+typ[typNr]+"&radnumer="+radnumer+"&mark="+mark+"&talning="+talning; document.getElementById("meginmal").innerHTML=""; ajax("POST","meginmal","","/utkoma_"+typ[typNr]+".php",par,"select_step"); } function valmynd() { var v=document.getElementById("hornvalmynd"); if (v.style.display=="none") { ajax("POST","hornvalmynd","","/hornval.php"); v.style.display='block'; } else { v.style.display='none'; } } function valmynd_loka() { var v=document.getElementById("hornvalmynd"); if (v.style.display=="none") { ajax("POST","hornvalmynd","","/hornval.php"); v.style.display='block'; } else { v.style.display='none'; } } function velja_ur_hjalp(flid,fletta) { valmynd_loka(); var divsToHide = document.getElementsByClassName("fancybox-overlay"); for(var i = 0; i < divsToHide.length; i++) { divsToHide[i].style.display="none"; } document.getElementById("leitardiv").className="leitardiv"; document.getElementById("leit").className="leit"; velja_haegri(flid,fletta); } function velja_haegri(flid,fletta,malidfletta) { fletta=fletta.replace(/\s+/g," "); fletta=fletta.replace(/\s/g,"_"); fletta=fletta.replace(/\[/g, ''); //eyðir hornklofum fletta=fletta.replace(/\]/g, ''); //eyðir hornklofum fletta=fletta.replace(/\(/g, ''); //eyðir svigum fletta=fletta.replace(/\)/g, ''); //eyðir svigum fletta=fletta.replace(/,/g, ''); //eyðir kommum fletta=fletta.replace(/;/g, ''); //eyðir semikommum fletta=fletta.trim(); var leitarfletta=fletta.replace(/_/g," "); document.getElementById('leitarvideo').style.display='none'; /*if (malidfletta !== undefined) { //malidfeltta gefin upp document.getElementById('leit').value=malidfletta; var par="id="+flid+"&start=-1&fletta="+fletta; ajax("POST","haegri","","/utkoma.php",par,"nyajaxleit",malidfletta); } else {*/ document.getElementById('leit').value=leitarfletta; var par="id="+flid+"&start=-1&fletta="+fletta; ajax("POST","haegri","","/utkoma.php",par,"nyajaxleit",fletta); //} } function veljaHugtak(flid,fletta,urelt) { staekkaValinn(flid); var fletta=fletta.split("/")[0]; var par="id="+flid+"&start=0&fletta="+fletta; document.getElementById('leitarvideo').style.display='none'; ajax("POST","haegri","","/utkoma.php",par,"select_stepXnyajaxleit",fletta,0); document.getElementById('leit').value=fletta; } function velja(flid,fletta) { staekkaValinn(flid); document.getElementById('leitarvideo').style.display='none'; //var leitarfletta=strip_tags(fletta); var leitarfletta=fletta; leitarfletta=leitarfletta.replace(/\s+/g," "); leitarfletta=leitarfletta.trim(); document.getElementById('leit').value=leitarfletta; var par="id="+flid+"&start=-1"; ajax("POST","haegri","","/utkoma.php",par,"skorun",leitarfletta); } function veljaVensl(flid1, flid2, fletta2) { var par="flid1="+flid1+"&flid2="+flid2; var i; var tags = document.getElementById("venslaleitarval").getElementsByTagName("p"); var total = tags.length; var el; for (i=0;i]+)>)/ig,""); return txt; } function radaSkyldheitum(flid,rodun) { par="flid="+flid+"&radnumer=3&rod="+rodun+"&typ=skyldheiti"; ajax("POST","meginmal","","/utkoma_skyldheiti.php",par,"select_step"); } function radaGrannheitum(flid,rodun) { par="flid="+flid+"&radnumer=3&rod="+rodun+"&typ=grannheiti"; ajax("POST","meginmal","","/utkoma_grannheiti.php",par,"select_step"); } function am() { window.location.href="http://arnastofnun.is/"; } function hasClass(element, cls) { return (' ' + element.className + ' ').indexOf(' ' + cls + ' ') > -1; } function leitarhjalp(x) { if (x==1) { document.getElementById('flettulisti').style.display='none'; document.getElementById('leitarvideo').style.display='block'; } else { document.getElementById('leitarvideo').style.display='none'; } } function ath_ovirkur() { alert("Þetta er sýnidæmi – hnappurinn er ekki virkur.\n\nFlettu á næstu síðu til að sjá hvað gerist næst."); } function rsSkipta(id,key,linufjoldi) { var txt=document.getElementById("rs"+id+"-"+key).innerHTML; var linutexti=document.getElementById("x"+id).innerHTML; document.getElementById("x"+id).innerHTML=txt; for(var i=key;i>0;i--) { document.getElementById("rs"+id+"-"+i).innerHTML = document.getElementById("rs"+id+"-"+(i-1)).innerHTML; } document.getElementById("rs"+id+"-0").innerHTML=linutexti; var x=""; var y=""; for(i=0;i<(linufjoldi-1);i++) { x=document.getElementById("rs"+id+"-"+i).innerHTML; y=document.getElementById("rs"+id+"-"+(i+1)).innerHTML; if (x>y) { document.getElementById("rs"+id+"-"+(i+1)).innerHTML=x; document.getElementById("rs"+id+"-"+i).innerHTML=y; } } }