-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpifinder.html
43 lines (40 loc) · 1.59 KB
/
pifinder.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Pi finder</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
</head>
<body>
<div id="result">Searching Pi...</div>
<script>
var tocheck = 255;
var find = false;
for(var i=0; i<=255; ++i) {
$.get("http://192.168.0."+i+":4242/picheck?ip="+encodeURIComponent("192.168.0."+i), function (data) {
if (data.substr(0, 2) == "ok") {
$('#result').html('Your Pi address is: '+data.substr(2)+', the Personal Cloud Vault can be access there: <a href="'+data.substr(2)+':4242">'+data.substr(2)+':4242</a>');
i+=255;
find = true;
}
--tocheck;
});
}
var tocheck2 = 255;
for(var i=0; i<=255; ++i) {
$.get("http://192.168.1."+i+":4242/picheck?ip="+encodeURIComponent("192.168.1."+i), function (data) {
if (data.substr(0, 2) == "ok") {
$('#result').html('Your Pi address is: '+data.substr(2)+', the Personal Cloud Vault can be access there: <a href="'+data.substr(2)+':4242">'+data.substr(2)+':4242</a>');
i+=255;
find = true;
}
--tocheck2;
});
}
setInterval(function(){
if(tocheck <= 0 && tocheck2 <= 0 && !find)
$('#result').html('Could not find your pi, please check that you are on the same router');
}, 500);
</script>
</body>
</html>