function langlist(){ if(document.getElementById("language_list").style.display == 'block'){ document.getElementById("language_list").style.display = 'none'; }else{ document.getElementById("language_list").style.display = 'block'; } } function disableSelection(target){ if (typeof target.onselectstart!="undefined") //IE route target.onselectstart=function(){return false} else if (typeof target.style.MozUserSelect!="undefined") //Firefox route target.style.MozUserSelect="none" else //All other route (ie: Opera) target.onmousedown=function(){return false} target.style.cursor = "default" } function jConfirm(div,eYes,eCancel){ $(div).dialog( 'destroy' ); $(div).dialog({ autoOpen: false, bgiframe: true, resizable: false, width:360, height:160, modal: true, overlay: { backgroundColor: '#000', opacity: 0.5 }, buttons: { Yes: function() { eval(eYes); $(this).dialog('close'); }, Cancel: function() { eval(eCancel); $(this).dialog('close'); } } }); $(div).dialog("open"); } var Url = { // public method for url encoding encode : function (string) { return escape(this._utf8_encode(string)); }, // public method for url decoding decode : function (string) { return this._utf8_decode(unescape(string)); }, // private method for UTF-8 encoding _utf8_encode : function (string) { string = string.replace(/\r\n/g,"\n"); var utftext = ""; for (var n = 0; n < string.length; n++) { var c = string.charCodeAt(n); if (c < 128) { utftext += String.fromCharCode(c); } else if((c > 127) && (c < 2048)) { utftext += String.fromCharCode((c >> 6) | 192); utftext += String.fromCharCode((c & 63) | 128); } else { utftext += String.fromCharCode((c >> 12) | 224); utftext += String.fromCharCode(((c >> 6) & 63) | 128); utftext += String.fromCharCode((c & 63) | 128); } } return utftext; }, // private method for UTF-8 decoding _utf8_decode : function (utftext) { var string = ""; var i = 0; var c = c1 = c2 = 0; while ( i < utftext.length ) { c = utftext.charCodeAt(i); if (c < 128) { string += String.fromCharCode(c); i++; } else if((c > 191) && (c < 224)) { c2 = utftext.charCodeAt(i+1); string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); i += 2; } else { c2 = utftext.charCodeAt(i+1); c3 = utftext.charCodeAt(i+2); string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); i += 3; } } return string; } } function submitenter(e) { var keycode; if (window.event) keycode = window.event.keyCode; else if (e) keycode = e.which; else return true; if (keycode == 13) { document.loginform.submit(); return false; } else return true; } function DHTMLSound(surl) { document.getElementById("dummyspan").innerHTML= ""; } var mailpointer function newmailblink(variable){ var mystr if(parent.document.title=='Haket Skribentforum'){ if(variable==1){mystr=' nytt meddelande'}else{mystr=' nya meddelanden'} parent.document.title='Du har ' + variable + mystr; } else{ document.title='Haket Skribentforum'; } } function newmail(variable){ if (variable>0){ clearInterval(mailpointer); mailpointer = setInterval("newmailblink(" + variable + ");",1000); }else{ clearInterval(mailpointer); document.title='Haket Skribentforum'; } } function ajaxGetmc(){ var xmlHttp; try{ xmlHttp=new XMLHttpRequest(); } catch (e){ try{ xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e){ try{ xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } // If no ajax support - message. MAYBE TODO: a doc.loc to a non ajax page? catch (e){ alert("AJAX FEL"); return false; } } } xmlHttp.onreadystatechange=function(){ if(xmlHttp.readyState==4) { // Variables set by callback var all = 0; var mail = 0; var comments = 0; var track = 0; var usersonline = 0; var online = 0; var friends = 0; var tmp_b; var expdate = new Date (); // Tempint stores prev number of received messages and compares // S mute gets s_mute from asp on page load. TODO: Make on the fly var temp_int = 0; var s_mute = 0; // Var b is set to the result from callback var b = xmlHttp.responseText var temp = new Array(); //Split callback string to an array temp = b.split('|'); mail = temp[0]; comments = temp[1]; track = temp[2]; usersonline = temp[3]; s_mute = temp[4]; online = parseInt(temp[5]); friends = parseInt(temp[6]); tmp_b = temp[7]; eval(tmp_b); // Add mail, comments and tracking to one var (for playsound) all = parseInt(mail) + parseInt(comments) + parseInt(track); // Setting temp_int to prev mailcount from global, then setting global to current mail count temp_int = GetCookie("parent_mail"); console.log('Previous message count=' + temp_int); console.log('New message count=' + all); // parent_mail_no = all; var expdate = new Date (); FixCookieDate (expdate); // Correct for Mac date bug - call only once for given Date object! expdate.setTime (expdate.getTime() + (1 * 60 * 60 * 1000)); // 24 hrs from now SetCookie ("parent_mail", all, expdate); // if global mailcount is larger than temp_int (prev global mail count then do) if (GetCookie("parent_mail")>temp_int && s_mute==0) { DHTMLSound('/sound/notify.wav'); } // This previously handled frameupdate timer, TODO: HANDLE AJAX TIMER if (online) { // document.getElementById("onlinestatus").innerHTML = ' (Du är aktiv)' } else { // parent.doUpdate(600); // document.getElementById("onlinestatus").innerHTML = ' (du är inaktiv)' } // Update Inner HTML and images using variables set by callback TODO: 1 nytt / 2 nya // document.getElementById("usersonline").innerHTML = 'Totalt '+usersonline+' inloggade'; if(mail>0){ document.getElementById("topmenu_info_email").style.background = 'url(/_design/default/icons/32/Email.png)'; document.getElementById("mailcount").innerHTML = mail; document.getElementById("a_mail").title = 'Du har ' + mail + ' mail' }else{ document.getElementById("topmenu_info_email").style.background = 'url(/_design/default/icons/32/Email_inactive.png)'; document.getElementById("mailcount").innerHTML = ''; document.getElementById("a_mail").title = 'Inga nya meddelanden' } if(comments>0){ document.getElementById("topmenu_info_comments").style.background = 'url(/_design/default/icons/32/Comment.png)'; document.getElementById("commentcount").innerHTML = comments; document.getElementById("a_comments").title = 'Du har ' + comments + ' kommentarer' }else{ document.getElementById("topmenu_info_comments").style.background = 'url(/_design/default/icons/32/Comment_inactive.png)'; document.getElementById("commentcount").innerHTML = ''; document.getElementById("a_comments").title = 'Inga nya kommentarer' } if(track>0){ document.getElementById("topmenu_info_tracking").style.background = 'url(/_design/default/icons/32/Info.png)' document.getElementById("a_track").title = 'Du har ' + track + ' bevakning'; }else{ document.getElementById("topmenu_info_tracking").style.background = 'url(/_design/default/icons/32/Info_inactive.png)'; document.getElementById("a_track").title = 'Du har inga nya bevakningar' } if(friends>0){ document.getElementById("topmenu_info_friends").style.background = 'url(/_design/default/icons/32/heart.png)' document.getElementById("friendcount").innerHTML = friends; document.getElementById("a_friends").title = 'Du har ' + friends + ' vänförfrågningar' }else{ document.getElementById("topmenu_info_friends").style.background = 'url(/_design/default/icons/32/heart_inactive.png)'; document.getElementById("friendcount").innerHTML = ''; document.getElementById("a_friends").title = 'Inga nya vänförfrågningar' } newmail(all); } } xmlHttp.open("GET","/callbacks/mini_info_getmc.asp?nocache="+Math.random(),true); xmlHttp.send(null); }