-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtimestamp46.html
100 lines (87 loc) · 2.69 KB
/
timestamp46.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
88
89
90
91
92
93
94
95
96
97
98
99
100
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html><head>
<title> pcf </title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-2">
</head>
<body>
<script type="text/javascript">
var web_server_url4 = "http://ipv4/index.php?"
var web_server_url6 = "http://ipv6/index.php?"
function createXmlHttpRequestObject() {
var xmlhttp;
try {
xmlhttp = new XMLHttpRequest(); //should work on all browsers except IE6 or older
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHttp"); //browser is IE6 or older
} catch (e) {
// ignore error
}
}
if (!xmlhttp) {
alert ("Error creating the XMLHttpRequest object.");
}
else {
return xmlhttp;
}
}
function uploadDataGeneric(web_server_url, statusblock, proto) {
try {
var xmlHttp = createXmlHttpRequestObject();
xmlHttp.open("POST", web_server_url, true);
xmlHttp.onreadystatechange = function(){
if ((xmlHttp.readyState==4) && (xmlHttp.status==200)) {
}
}
curr = (new Date).getTime();
i = 0;
do {
prev = curr;
curr = (new Date).getTime();
i++;
} while (curr - prev != 1)
var params = "ts=" + curr;
xmlHttp.send(params);
document.getElementById(statusblock).innerHTML = proto + params + " success " + i;
document.getElementById(statusblock).style.backgroundColor = "lime";
} catch (e) {
document.getElementById(statusblock).innerHTML = proto + " failure" + e;
document.getElementById(statusblock).style.backgroundColor = "red";
// alert(e.toString());
}
return false;
}
function uploadData6() {
uploadDataGeneric(web_server_url6, 'ipv6status', "IPv6: ");
return false;
}
function uploadData4() {
uploadDataGeneric(web_server_url4, 'ipv4status', "IPv4: ");
return false;
}
/// Code borrowed from http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript
var urlParams;
(window.onpopstate = function () {
var match,
pl = /\+/g, // Regex for replacing addition symbol with a space
search = /([^&=]+)=?([^&]*)/g,
decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); },
query = window.location.search.substring(1);
urlParams = {};
while (match = search.exec(query))
urlParams[decode(match[1])] = decode(match[2]);
})();
var refresh;
if ("refresh" in urlParams) {
refresh = urlParams["refresh"];
}
else {
refresh = 1000;
}
setInterval(uploadData4, refresh);
setInterval(uploadData6, refresh);
document.write("<p>PCF web page, refresh every " + (refresh / 1000) + " seconds.</p>");
</script>
<div id="ipv4status" style="background-color: white;">IPv4: inactive</div>
<div id="ipv6status" style="background-color: white;">IPv6: inactive</div>
</body></html>