forked from jolth/Report-GPS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
87 lines (70 loc) · 1.75 KB
/
index.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
var net = Object();
net.READY_STATE_UNINITIALIZED=0;
net.READY_STATE_LOADING=1;
net.READY_STATE_LOADED=2;
net.READY_STATE_INTERACTIVE=3;
net.READY_STATE_COMPLETE=4;
net.load = function(url, f, fError){
this.url = url;
this.request = null;
this.onloadXML(url);
this.onload = f;
this.onerror = (fError) ? fError: this.defaultError;
}
net.load.prototype = {
onloadXML : function(url) {
if(window.XMLHttpRequest){
this.request = new XMLHttpRequest();
} else if (window.ActiveXObject){
this.request = new ActiveXObject("Microsoft.XMLHTTP");
}
if(this.request){
try {
var inst = this;
this.request.onreadystatechange = function () {
inst.onReadyState.call(inst);
}
window.setInterval ( function () {
//salert(this);
inst.request.open('GET', inst.url, true);
inst.request.send(null);
}, 1000);
} catch (e) {
this.defaultError.call(this);
}
}
},
onReadyState : function(){
if(this.request.readyState == net.READY_STATE_COMPLETE){
if(this.request.status == 200){
this.onload.call(this);
} else {
this.defaultError.call(this);
}
}
},
defaultError : function(){
alert("Error al obtener los datos"
+ "\n readyState: " + this.request.readyState
+ "\nStatus: " + this.request.status );
//"\nError: " + error || '');
}
}
// Loading:
function showContent(){
document.getElementById('show').innerHTML = this.request.responseText;
}
function show(){
var loader = new net.load('/gps.log', showContent);
}
window.onload = show;
</script>
</head>
<body>
<pre id="show"></pre>
</body>
</html>