-
Notifications
You must be signed in to change notification settings - Fork 8
/
now.html
177 lines (170 loc) · 5.58 KB
/
now.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>
<meta charset=utf-8>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="application-name" content="TVHadmin">
<link rel="manifest" href="manifest.webmanifest" crossorigin="use-credentials">
<title>TVHadmin - What's On Now?</title>
<script src="include.js"></script>
<script>
function updateTimeline() {
var now = Date.now()/1000;
const bars = document.querySelectorAll('.percent');
for (const bar of bars) {
const done = bar.querySelector('.elapsed');
var start = parseInt(done.dataset.start);
var stop = parseInt(done.dataset.stop);
var duration = stop - start;
var elapsed = now - start;
var pc = 0;
if (stop > start) pc = 100*elapsed/duration;
if (pc > 100) {
update(0);
return;
}
done.style.width = pc + '%';
bar.title = (Math.round(elapsed/60)) + ' min / ' + (duration/60) + ' min';
}
if (cookies.REFR) {
var sync = (now % 60) * 1000;
setTimeout(updateTimeline, 63000-sync); // Avoid race
}
}
async function update(first) {
const utime = Date.now()/1000;
var date = strftime('%A, %e %b %Y', utime);
var time = strftime('%H:%M', utime);
td = document.getElementById("date");
td.innerHTML = date;
var events = await get_epg_now('');
var table = document.getElementById("list").getElementsByTagName('tbody')[0];
var i = 0;
for (const c of channels) {
if (!(media.All)) {
if (intersect(c.tags, media) == 0) continue;
}
if (lcn) var name = `${c.number} ${c.name}`;
else var name = c.name;
if (first) {
var row = table.insertRow(-1);
row.className = 'row_alt';
}
else var row = table.children[i];
var e = events.find(m => m.channelUuid === c.uuid);
if (e) {
var start = strftime('%H:%M', e.start);
var end = strftime('%H:%M', e.stop);
var summ = '';
if (e.summary) summ = e.summary;
else if (e.description) summ = e.description;
var s = `<td class='col_duration'>${start} - ${end}` +
`<table class='percent'><tr>` +
`<td class='elapsed' data-start='${e.start}' data-stop=${e.stop}><img src='images/spacer.gif' width=1 height=1 alt=''></td>` +
`<td class='remaining'><img src='images/spacer.gif' width=1 height=1 alt=''></td></tr></table></td>` +
`<td class='col_channel'><div class='channel_name'>`;
if (cookies.ICONS && c.icon_public_url) {
s += `<img src="/${c.icon_public_url}" height='48' width='80' alt="${name}" title="${name}">`;
}
else s += `${name}`;
s += `</div></td><td class='col_title'><div class='epg_title'>${e.title}</div><div class='epg_subtitle'>${summ}</div></td>`;
if (!e.dvrState || e.dvrState != 'scheduled' && e.dvrState != 'recording') {
s += `<td><a href='now.html' onclick='create_by_event(event, "${e.eventId}", this)'><img src='images/rec_button1.png' alt='record' title='record'></a></td>`;
}
else {
s += "<td><img src='images/rec.png' alt='Recording' title='Recording'></td>";
}
}
else {
var s = `<td></td><td class='col_channel'><div class='channel_name'>`;
if (cookies.ICONS && c.icon_public_url) {
s += `<img src="/${c.icon_public_url}" height='48' width='80' alt="${name}" title="${name}"></div></td><td>No EPG available</td><td></td>`;
}
else s += `${name}</div></td><td>No EPG available</td><td></td>`;
}
s += `<td class='col_stream'><a href='/play/ticket/stream/channel/${c.uuid}?title=${c.name}`;
if (cookies.SUUID) s += `&profile=${cookies.SUUID}`
s += `' download='${c.uuid}.m3u'><img src='images/play.png' title='Play'></a></td>`;
row.innerHTML = s;
i++;
}
updateTimeline()
}
function click_tag(prefix, tagID) {
var chk;
if (document.getElementById(tagID).checked) chk = 1;
else chk = -1;
sessionStorage.setItem((prefix+tagID), chk);
location.reload();
}
</script>
</head>
<body>
<div id="container">
<div id="navigation">
<div class="logo">
<img src="images/logo.png" alt="TVHeadend Logo" width="150">
</div>
<div class="nav_bar">
</div>
</div>
<div id='layout'>
<div id='banner'>
<table>
<tr>
<td class='col_title'><div id='mobmenu'>☰</div> <h1>What's On Now</h1></td>
<td id='mediatags'></td>
</tr>
</table>
</div>
<div id='wrapper'>
<div id='whatson'>
<table class='list' id='list'>
<thead>
<tr class='newday'>
<td colspan='5'><span class='date_long' id='date'></span></td>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
</div>
<script>
var channels, lcn, media;
async function main() {
lcn = 0;
if (cookies.CSORT == "1") lcn = 1;
[ tags, channels ] = await Promise.all([get_channeltags(), get_channels(lcn)]);
var s = "<span class='wideonly'>";
media = [];
for (var key in cookies) {
if (key.startsWith("Tag_")) {
var tag = decodeURIComponent(key.substring(4));
s = s + "<div class='media'>" +
`<label for='${tag}'>${tag}:</label>` +
`<input type='checkbox' name='${tag}' id='${tag}' onchange='click_tag("Now_", "${tag}")'`;
if (sessionStorage.getItem("Now_"+tag)) {
if (sessionStorage.getItem("Now_"+tag) == 1) {
s = s + " checked";
media[tags[tag]] = 1;
}
}
else if (cookies[("Now_"+key.substring(4))]) {
s = s + " checked";
media[tags[tag]] = 1;
}
s = s + "></div>";
}
}
s = s + "</span>";
var td = document.getElementById("mediatags");
td.innerHTML = s;
update(1);
}
main();
</script>
</body>
</html>