var timer = null; var allEvents=new Array(); var newEvents=new Array(); var oldEvents=new Array(); var api_div_numbers=21; $(window).load(function() { initilise(); if(timer) { clearTimeout(timer); } timer =setTimeout(main , 100 ); }); function fetchEvents(){ return oldEvents; } function main() { var url=localStorage["ip_address"]+'/include/api.php?op=get&op2=events&return_type=csv&apipass='+localStorage["api_pass"]+'&user='+localStorage["user_name"]+'&pass='+localStorage["pass"]; var feedUrl = url; localStorage["data_check"]="true"; req = new XMLHttpRequest(); req.onload = handleResponse; req.onerror = handleError; req.open("GET", feedUrl, true); req.send(null); } function handleError() { localStorage["data_check"]="false"; if(timer) { clearTimeout(timer); } timer =setTimeout(main , 1000); } function handleResponse() { var doc = req.responseText; if (doc=="auth error") { localStorage["data_check"]="false"; if(timer) { clearTimeout(timer); } timer =setTimeout(main , 1000); } else{ var n=doc.search("404 Not Found"); if(n>0){ localStorage["data_check"]="false"; if(timer) { clearTimeout(timer); } timer =setTimeout(main , 1000); } else{ localStorage["data_check"]="true" getEvents(doc); } } } function getEvents(reply){ if(check()){ all_event_array=reply.split("\n"); allEvents=divideArray(all_event_array); if(oldEvents.length==0){ oldEvents=allEvents; } newEvents=fetchNewEvents(allEvents,oldEvents); if(newEvents.length!=0){ for(var k=0;k' + title + '
' + event + ''; } function check(){ if (localStorage["data_check"]=="true" && localStorage["ip_address"] != null && localStorage["api_pass"] != null &&localStorage["user_name"]!=null &&localStorage["pass"]!=null && localStorage["ip_address"] != "" && localStorage["api_pass"] != "" &&localStorage["user_name"]!="" &&localStorage["pass"]!=""){ return true; } else return false; } function initilise(){ if(localStorage["ip_address"]==undefined){ localStorage["ip_address"]="http://firefly.artica.es/pandora_demo"; } if(localStorage["api_pass"]==undefined){ localStorage["api_pass"]="doreik0"; } if(localStorage["user_name"]==undefined){ localStorage["user_name"]="demo"; } if(localStorage["pass"]==undefined){ localStorage["pass"]="demo"; } if(localStorage["critical"]==null){ localStorage["critical"]="11"; } if(localStorage["informational"]==null){ localStorage["informational"]="1"; } if(localStorage["maintenance"]==null){ localStorage["maintenance"]="10"; } if(localStorage["normal"]==null){ localStorage["normal"]="6"; } if(localStorage["warning"]==null){ localStorage["warning"]="2"; } if(localStorage["events"]==null){ localStorage["events"]=20; } if(localStorage["refresh"]==null){ localStorage["refresh"]="10"; } if(localStorage["ip_address"]==null){ localStorage["ip_address"]="http://firefly.artica.es/pandora_demo"; } if(localStorage["api_pass"]==null){ localStorage["api_pass"]="doreik0"; } if(localStorage["user_name"]==null){ localStorage["user_name"]="demo"; } if(localStorage["pass"]==null){ localStorage["pass"]="demo"; } if(localStorage["sound_alert"]==null){ localStorage["sound_alert"]="on"; } if(localStorage["changed"]==null){ localStorage["changed"]="false"; } if(localStorage["new_events"]==null){ localStorage["new_events"]=parseInt(localStorage["events"]); } }