0 Members and 1 Guest are viewing this topic.
tabId = '';function getRandomTabId(){ tabId = Math.random().toString(36); setCookie('OmnomBrowserTab',tabId,1);}function isCurrent(){ if(getCookie('OmnomBrowserTab')==tabId){ return true; } return false;}function registerFocusHandler(){ focusHandlerRegistered = true; window.self.addEventListener('blur',function(){ bIsBlurred = true; },false); window.self.addEventListener('focus',function(){ setCookie('OmnomBrowserTab',tabId,1); bIsBlurred = false; },false);}
Ok, i think that chance is small enough to ignore
date -u +"%j%H%M%S%N"
instant = { id:'', update:function(){ var self = this; ls.set('OmnomBrowserTab',self.id); ls.set('OmnomNewInstant','false'); }, init:function(){ var self = this; self.id = Math.random().toString(36)+(new Date()).getTime().toString(); ls.set('OmnomBrowserTab',self.id); $(window) .focus(function(){ self.update(); }) .unload(function(){ ls.set('OmnomNewInstant','true'); }); }, current:function(){ var self = this; if(ls.get('OmnomNewInstant')=='true'){ self.update(); } return self.id == ls.get('OmnomBrowserTab'); } }
ls = { getCookie:function(c_name){ var i,x,y,ARRcookies=document.cookie.split(";"); for(i=0;i<ARRcookies.length;i++){ x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("=")); y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1); x=x.replace(/^\s+|\s+$/g,""); if(x==c_name){ return unescape(y); } } }, setCookie:function(c_name,value,exdays) { var exdate=new Date(); exdate.setDate(exdate.getDate() + exdays); var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString()); document.cookie=c_name + "=" + c_value; }, support:function(){ try{ return 'localStorage' in window && window['localStorage'] !== null; }catch(e){ return false; } }, get:function(name){ if(this.support()){ return localStorage.getItem(name); } return this.getCookie(name); }, set:function(name,value){ if(this.support()){ localStorage.setItem(name,value); }else{ this.setCookie(name,value,30); } } }