/* ***************************************************************** * Blognotifier.js - Tipic Inc. * 16-12-04 - ginomi * *************************************************************** */ //vars------------------------------ var timeoutID; var count_=0; var poll_url='/blognotifier/pop'; var reload_time=10000; //main code-------------------------- if (document.referrer == "" || document.referrer.indexOf(document.location.hostname) == -1 ) { //window.status='calling: do_polling('+poll_url+', first_time = true, notify = true)'; //fd: defer loading do_polling(poll_url,true,true); setTimeout ("do_polling('" + poll_url + "',true,true);",3000); //window.status='called: do_polling('+poll_url+', first_time = true, notify = true)'; }else { //window.status='calling: do_polling('+poll_url+', first_time = true, notify = false)'; //fd: defer loading do_polling(poll_url,true,false); setTimeout("do_polling('" + poll_url + "',true,false);",3000); //window.status='called: do_polling('+poll_url+', first_time = true, notify = false)'; } //functions------------------------- function show_msg(title, msg) { focus(); window.status='trigger received!'; overlib(msg, FOLLOWSCROLL, STICKY, CAPTION, title, WIDTH,400, RELX,10, RELY,10, CSSCLASS, TEXTFONTCLASS,'fontClassOL', FGCLASS,'fgClassOL', BGCLASS,'bgClassOL', CAPTIONFONTCLASS,'capfontClassOL', CLOSECLICK); } function stop_reloading() { clearTimeout(timeoutID); } function set_reload_time(time_) { stop_reloading(); timeoutID = setTimeout('do_polling(poll_url, false, false)',time_); count_++; if(count_ > 1) window.status='reload(); time set at: '+time_+' counted: '+count_; } function getXMLhttpRequest() { var xmlhttp=false; /*@cc_on @*/ /*@if (@_jscript_version >= 5) // JScript gives us Conditional compilation, we can cope with old IE versions. // and security blocked creation of the objects. try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { xmlhttp = false; } } @end @*/ if (!xmlhttp && typeof XMLHttpRequest!='undefined') xmlhttp = new XMLHttpRequest(); return xmlhttp; } function parseResponseAndNotify(resp) { if(resp.length <5) return; var mycode=resp.substring(0,5); if(mycode=='WAIT:') { //iterate var temp=resp.substring(5, resp.length); var mytime=parseInt(temp); if(mytime 0) parseResponseAndNotify(req.responseText); } }; //build param string var _params=''; if(first_time) { _params+='&first_time=yes'; } if(notify) { _params+='¬ify=yes'; } req.open('GET', myurl + '?rdm='+ (new Date()).getTime() + _params); req.setRequestHeader("Pragma", "no-cache"); //finally send! req.send(null); } } function notifyUID(ruid) { var req = getXMLhttpRequest(); if (req) { req.onreadystatechange = function() { if (req.readyState == 4 && req.status == 200) { //if(req.responseText.length >0) //alert(req.responseText); } }; req.open('GET', '/blognotifier/trigger?uid='+ruid + + '&rdm='+(new Date()).getTime()); req.setRequestHeader("Pragma", "no-cache"); req.send(null); } }