forked from xxpizzaxx/timerboard-net-fozziesov
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
177 lines (161 loc) · 6.82 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
<script src="//www.google.com/jsapi"></script>
<script>google.load("jquery", "1.3")</script>
<script src="js/bootstrap.min.js"></script>
<link href="css/font-awesome.min.css" rel="stylesheet">
<script src="js/mustache.js"></script>
<script src="js/jquery.tinysort.min.js"></script>
<script src="js/moment.min.js"></script>
<script src="js/system2region.json.js"></script>
<title>timerboard.net</title>
</head>
<body>
<nav class="navbar navbar-default">
<div class="container">
<div class="navbar-header">
<button class="navbar-toggle" data-target=".navbar-collapse" data-toggle="collapse" type="button" data-target=".navbar-ex1-collapse">
<span class="sr-only">
Toggle navigation
</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/"><i class="fa fa-calendar"></i> timerboard.net
</a></div>
<nav class="collapse navbar-collapse navbar-ex1-collapse" role="navigtion">
</nav>
</div>
</div>
</nav>
<div class="container">
<style type="text/css">
label { font-size: large;
text-align: right
}
input {width: 70%;
float: right;
}
</style>
<script src="js/countdown.js" type="text/javascript"></script>
<table class="table table-hover" id="timers">
<thead>
<tr>
<th><a href="#" onClick='sort("type");'>Type<span style="float:right;" id="type"></span></a></th>
<th><a href="#" onClick='sort("system");'>System<span style="float:right;" id="system"></span></a></th>
<th><a href="#" onClick='sort("region");'>Region<span style="float:right;" id="region"></span></a></th>
<th><a href="#" onClick='sort("owner");'>Owner<span style="float:right;" id="owner"></span></a></th>
<th><a href="#" onClick='sort("time");'>Time<span style="float:right;" id="time"></span></a></th>
<th><a href="#" onClick='sort("time");'>Remaining<span style="float:right;" id="remaining"></span></a></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<script type="text/template" id="timer_template">
<tr id="{{ id }}" class="timer_row">
<td class="type">{{ type }}</td>
<td class="system"><a href="http://evemaps.dotlan.net/search?q={{ system }}">{{ system }}</a></td>
<td class="region">{{ region }}</td>
<td class="owner"><a href="http://evemaps.dotlan.net/search?q={{ owner }}">{{ owner }}</a></td>
<td class="time" style="display: none;">{{ time }}</td>
<td class="calendartime" title="{{time}}">{{ calendartime }}</td>
<td class="remaining" style="width: 150px;"><span id="remaining.{{ id }}" style="font-family: monospace;"></span></td>
</tr>
</script>
<script>
timers = {};
var sortkey = "time";
var sort_asc = false;
function do_sort() {
$(".timer_row").tsort("."+sortkey, {order: sort_asc ? "asc" : "desc"});
console.log(sortkey+" "+sort_asc);
}
var ICON_ASC = '<i class="fa fa-sort-amount-asc"/></i>';
var ICON_DESC = '<i class="fa fa-sort-amount-desc"/></i>';
function sort(field) {
if (sortkey==field) {
sort_asc = !sort_asc;
$("#"+sortkey)[0].innerHTML = sort_asc ? ICON_ASC : ICON_DESC;
} else {
$("#"+sortkey)[0].innerHTML=""
sortkey = field;
$("#"+sortkey)[0].innerHTML = sort_asc ? ICON_ASC : ICON_DESC;
}
do_sort();
}
function add_timer(i, timer) {
if (!(timer["id"] in timers)) {
timers[timer["id"]] = countdown(
function(ts) {
var style = "<span>";
if (timer["realtime"] < new Date()) {
var style = "<span class='text-danger strong'>-"
}
document.getElementById("remaining." + timer["id"]).innerHTML = style+ts.days+"d "+ts.hours+"h "+ts.minutes+"m "+ts.seconds+"s </span>";
},
timer["realtime"],
countdown.DAYS|countdown.HOURS|countdown.MINUTES|countdown.SECONDS);
}
}
function timer_to_row(i, timer) {
if ($("#"+timer["id"]).length == 0) {
var template = $("#timer_template").html();
var completed = Mustache.to_html(template, timer);
$('#timers tbody').append(completed);
}
}
var typeLookup = {
1: "TCU",
2: "IHub",
3: "Station",
4: "Freeport"
};
// new stuff
websocket = new WebSocket("wss://api.pizza.moe/stream/sovereignty/campaigns/");
websocket.onopen = function(evt) { };
websocket.onclose = function(evt) { };
websocket.onmessage = function(evt) {
var event = JSON.parse(evt["data"]);
$.each(event["items"], function(i, e) {
var timer = {
type: typeLookup[e["eventType"]],
system: e["sourceSolarsystem"]["name"],
region: system2region[e["sourceSolarsystem"]["name"]],
time: e["startTime"],
realtime: moment(e["startTime"]),
calendartime: moment(e["startTime"]).calendar(),
owner: "None",
id: e["sourceSolarsystem"]["name"]+e["startTime"]
};
try {
timer["owner"] = e["defender"]["defender"]["name"];
}
catch (err) {
}
console.log(timer["id"]);
if (!(timer["id"] in timers)) {
timer_to_row(0, timer);
add_timer(0, timer);
do_sort();
};
});
};
websocket.onerror = function(evt) { };
sort("time");
</script>
</div>
<hr />
<footer>
<div class="container">
<p class=".small text-center text-muted">This site is a deployment of <a href="https://github.com/xxpizzaxx/timerboard-net-fozziesov">timerboard-net-fozziesov</a>, fed by data from <a href="https://github.com/xxpizzaxx/pizza-sov-relay">pizza-sov-relay</a> which are both available under the <a href="http://opensource.org/licenses/MIT">MIT License</a>.</p>
</div>
</footer>
</body>
<script>
$('#dtf').tooltip()
</script>
</html>