Created
August 2, 2015 17:11
-
-
Save lukyth/070f0c9bed5548bd7bce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Document</title> | |
</head> | |
<body> | |
<script src=jquery-2.1.4.min.js></script> | |
<script> | |
var old_id=""; | |
var data =""; | |
var rooms; | |
var dataArr=[]; | |
var message=""; | |
function onGetDeviceID(id){ | |
var keys = id.split(","); | |
for(var i=0;i<keys.length;i++){ | |
// $.post("http://exceed.cupco.de/noti_view.php?msg="+message+"&id="+keys[i]); | |
$.post("http://exceed.cupco.de/noti_view.php",{msg : message , id : keys[i]}); | |
} | |
} | |
function getDeviceID(){ | |
$.get("http://exceed.cupco.de/iot/linkceed/noti",onGetDeviceID); | |
} | |
function onGetFireEvent(result){ | |
if(data =="" || data != result){ | |
var eachRoom = result.split("/"); | |
eachRoom.splice(eachRoom.length-1,1); | |
if(eachRoom.length < dataArr.length){ | |
// message = "Cleared" | |
// getDeviceID(); | |
dataArr = eachRoom; | |
}else{ | |
for(var i=0;i<eachRoom.length;i++){ | |
var eachRoomData = eachRoom[i].split(","); | |
console.log("1 : " + result, "2 : " +dataArr,"3 : " + result.indexOf(eachRoom[i])<0); | |
if(eachRoom.length != dataArr.length || eachRoom[i] != dataArr[i]){ | |
if(eachRoomData[1] == "0"){ | |
message = "Room " + eachRoomData[0]+" is on fire"; | |
} | |
if(eachRoomData[1] == "1"){ | |
message = "Room " + eachRoomData[0]+" : Fireman arrived"; | |
} | |
if(eachRoomData[1] == "2"){ | |
message = "Room " + eachRoomData[0]+" is extinguished"; | |
} | |
if(eachRoomData[1] == "3"){ | |
message = "Room " + eachRoomData[0]+" is secure"; | |
} | |
getDeviceID(); | |
if(eachRoom.length > dataArr.length){ | |
dataArr.push(eachRoom[i]); | |
}else{ | |
dataArr.splice(i,1); | |
dataArr.splice(i,0,eachRoom[i]); | |
} | |
} | |
} | |
} | |
data = result; | |
} | |
} | |
function getFireEvent(){ | |
$.get("http://exceed.cupco.de/iot/linkceed/data",onGetFireEvent); | |
} | |
setInterval(getFireEvent,1000); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment