var timer = null; var event_array; var max_events; var bg; $(document).ready(function(){ max_events=localStorage["events"]; if(localStorage["events"]==undefined){ localStorage["events"]="20"; } bg=chrome.extension.getBackgroundPage(); if(timer) { clearTimeout(timer); } timer =setTimeout(mainPoP , 2000 ); }); function mainPoP(){ if(bg.check()){ showEvents(); } else { showUrlError(); } } function showUrlError(){ var res=document.createDocumentFragment(); var r = document.getElementById('e'); var eve=document.createElement('div'); eve.id="event_temp"; eve.setAttribute("class","b"); var p = document.createElement('a'); p.href="options.html"; p.target="_blank"; p.innerText="Configure ip address,API password, user name and password with correct values"; eve.appendChild(p); res.appendChild(eve); r.parentNode.insertBefore(res,r); $('.loader').hide(); $('div.b').show(); if(timer) { clearTimeout(timer); } timer =setTimeout(refresh , 1000 ); } function showDataError(){ var res=document.createDocumentFragment(); var r = document.getElementById('e'); var eve=document.createElement('div'); eve.id="event_temp"; eve.setAttribute("class","b"); var p = document.createElement('a'); p.innerText="Error in fetching data!! Check your internet connection"; eve.appendChild(p); res.appendChild(eve); r.parentNode.insertBefore(res,r); $('.loader').hide(); $('div.b').show(); if(timer) { clearTimeout(timer); } timer =setTimeout(refresh , 1000 ); } function showEvents(){ var allEvents=bg.fetchEvents(); var r = document.getElementById('e'); var res=document.createDocumentFragment(); var eve=document.createElement('div'); eve.id="event_temp"; eve.setAttribute("class","b"); var i=0; if(allEvents.length>0){ while(i