diff --git a/api/debug_list.php b/api/debug_list.php
new file mode 100644
index 0000000..6e66379
--- /dev/null
+++ b/api/debug_list.php
@@ -0,0 +1,5 @@
+
+{"status":"success","data":[
+ {"id":"62.216.8.197\/10.0.0.18","0":"62.216.8.197\/10.0.0.18","remoteip":"62.216.8.197","1":"62.216.8.197","localip":"10.0.0.18","2":"10.0.0.18","wifiboxid":"Joopie","3":"Joop","hidden":"0","4":"0","date":"2013-10-03 17:24:33","5":"2013-10-03 17:24:33"},
+ {"id":"62.216.8.197\/10.0.0.29","0":"62.216.8.197\/10.0.0.29","remoteip":"62.216.8.197","1":"62.216.8.197","localip":"10.0.0.29","2":"10.0.0.29","wifiboxid":"Doodle3D-87354C","3":"Doodle3D-87354C","hidden":"0","4":"0","date":"2013-10-03 17:52:19","5":"2013-10-03 17:52:19"}],
+ "debug":{"time":1380817181,"hourago":1380813581,"remoteip":"62.216.8.197"}}
diff --git a/index.html b/index.html
index ece242d..20cacc0 100644
--- a/index.html
+++ b/index.html
@@ -17,7 +17,7 @@
-
+
@@ -31,14 +31,7 @@
diff --git a/js/main.js b/js/main.js
index 4dd4c5e..bc8744e 100644
--- a/js/main.js
+++ b/js/main.js
@@ -46,7 +46,7 @@ function retrieveList() {
//spinner.spin($preloader[0]);
$.ajax({
- url: "api/list.php",
+ url: "api/debug_list.php",
dataType: 'json',
success: function(response){
//console.log("retrieveList response: ",response);
@@ -63,9 +63,20 @@ function retrieveList() {
});
}
function updateList(boxes) {
- $list.empty();
numBoxesChecking = 0;
numBoxesFound = 0;
+
+ // remove displayed, but unlisted boxes
+ $list.find("a").each(function(index, element) {
+ var localip = $(element).attr("id");
+ var wifiboxid = $(element).text();
+ var found = false;
+ jQuery.each(boxes, function (index,box) {
+ if(box.localip == localip && box.wifiboxid == wifiboxid) found = true;
+ });
+ if(!found) $(element).parent().remove();
+ })
+
jQuery.each(boxes, function (index,box) {
checkBox(box);
});
@@ -80,22 +91,33 @@ function checkBox(box) {
success: function(response){
if(response.status == "success") {
numBoxesFound++;
- var url = "http://"+box.localip;
- if(boxIsListed(url)) return;
-
- $list.append(""+box.wifiboxid+"");
+ addBox(box);
+ } else {
+ removeBox(box);
}
numBoxesChecking--;
updateIntro();
}
}).fail(function() {
numBoxesChecking--;
+ removeBox(box);
updateIntro();
});
}
-function boxIsListed(url){
- return $list.find("a[href|='"+url+"']").length > 0;
+
+function addBox(box) {
+ if(boxExists(box.localip)) return;
+ var url = "http://"+box.localip;
+ var element = ""+box.wifiboxid+"";
+ $(element).hide().appendTo($list).fadeIn(500);
}
+function boxExists(localip){
+ return $list.find("a[id|='"+localip+"']").length > 0;
+}
+function removeBox(box) {
+ $list.remove("a[id|='"+box.localip+"']");
+}
+
function updateIntro() {
if(numBoxesChecking <= 0) {
if(numBoxesFound > 0) {