-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathindex.html
135 lines (121 loc) · 3.77 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Guild Wars 2 Timer</title>
<link href="bootstrap.min.css" rel="stylesheet">
<link href="index.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="bootstrap.min.js"></script>
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container">
<div class="page-header" id="header">
<h1 id="header-title">Guild Wars 2 Timer</h1>
<p class="lead">2014 Feature Pack updated world bosses time table.</p>
</div>
<div id="table-worldboss">
<div class="row table-header">
<div class="col-sm-4" id="wbname-title">World Boss</div>
<div class="col-sm-3" id="localtime-title">Local Time <span id="nowtime"></span></div>
<div class="col-sm-3" id="psttime-title">US Pacific Time (Server Time)</div>
<div class="col-sm-2" id="waypoint-title">Waypoint</div>
</div>
</div>
<div id="footer">
<p>Created and maintained by <a href="http://about.me/howar31" target="_blank">Howar31</a> @ 2014.04.17</p>
</div>
</div>
<script>
function getTimezone () {
var offset = new Date().getTimezoneOffset();
return (offset * -1 / 60);
}
function str2sec (str) {
var a = str.split(':');
return ((+a[0]) * 60 * 60 + (+a[1]) * 60);
}
function sec2str (sec) {
var hh = parseInt( sec / 3600 ) % 24;
var mm = parseInt( sec / 60 ) % 60;
var ss = sec % 60;
// return ((hh < 10 ? "0" + hh : hh) + ":" + (mm < 10 ? "0" + mm : mm) + ":" + (ss < 10 ? "0" + ss : ss));
return ((hh < 10 ? "0" + hh : hh) + ":" + (mm < 10 ? "0" + mm : mm));
}
function sortByTime(a, b) {
var now = new Date();
var nowoffset = str2sec(now.getHours()+":"+now.getMinutes());
var x = a.lcsec - nowoffset + 900;
var y = b.lcsec - nowoffset + 900;
if (x < 0) x += 86400;
if (y < 0) y += 86400;
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
}
//function sortByFirstName(a, b) {
// var x = a.FirstName.toLowerCase();
// var y = b.FirstName.toLowerCase();
// return ((x < y) ? -1 : ((x > y) ? 1 : 0));
//}
function getnowtime() {
var now = new Date();
var hh = now.getHours();
var mm = now.getMinutes();
var ss = now.getSeconds();
return ((hh < 10 ? "0" + hh : hh) + ":" + (mm < 10 ? "0" + mm : mm) + ":" + (ss < 10 ? "0" + ss : ss));
}
$( document ).ready(function() {
$("#localtime-title").append(" (UTC+"+getTimezone()+")");
refreshall();
setInterval(function() {
$("#nowtime").html(getnowtime());
},1000);
setInterval(function() {
refreshall();
},60000);
});
function refreshall () {
$(".row").slice(1).remove();
$.getJSON("./wbtime.json", function(json) {
var i = 0;
var k = 0;
var wbt = new Array();
while(json.worldboss[i]) {
var j = 0;
while(json.worldboss[i].uptime[j]) {
sec = str2sec(json.worldboss[i].uptime[j]);
lsec = sec + ((7 + getTimezone()) * 3600)
if (lsec >= 86400) lsec -= 86400;
wbt[k++] = {
name: json.worldboss[i].name,
uptime: json.worldboss[i].uptime[j],
upsec: sec,
lctime: sec2str(lsec),
lcsec: lsec,
scale: json.worldboss[i].scale,
waypoint: json.worldboss[i].waypoint
};
j++;
}
i++;
}
wbt.sort(sortByTime);
for (i = 0; i<k; i++) {
var tmp = '<div class="row">'
+'<div class="col-sm-4 wbname">'+wbt[i].name+'</div>'
+'<div class="col-sm-3 localtime">'+wbt[i].lctime+'</div>'
+'<div class="col-sm-3 psttime">'+wbt[i].uptime+'</div>'
+'<div class="col-sm-2 waypoint">'+wbt[i].waypoint+'</div>'
+'</div>';
$("#table-worldboss").append(tmp);
}
});
}
</script>
</body>
</html>