forked from dave-p/TVHadmin-JS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
favourites.html
173 lines (165 loc) · 5.99 KB
/
favourites.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
<!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 - Favourite Channels</title>
<script src="include.js"></script>
<script>
function formSubmit() {
document.whatandwhen.submit();
}
</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 class="navi"><a href="now.html">What's On Now</a></div>
<div class="navi"><a href="timeline.html">Timeline</a></div>
<div class="navi"><a href="channels.html">Channels</a></div>
<div class="navi"><a href="favourites.html">Favourite Channels</a></div>
<div class="navi"><a href="timers.html">Timers</a></div>
<div class="navi"><a href="recordings.html">Recordings</a></div>
<div class="navi"><a href="links.html">Series Links</a></div>
<div class="navi"><a href="status.html">Status</a></div>
<div class="navi"><a href="config.html">Configuration</a></div>
<form action="search.html" method="GET" name="search" class="search" onsubmit="return checkForm()">
<input type="text" name="find"><br>
<input type="submit" name="submit" value="Search">
</form>
</div>
</div>
<div id='layout'>
<div id='banner'>
<form name='whatandwhen' method='GET' action='favourites.html' id='whatandwhen' hidden>
<table>
<tr>
<td class='col_title'><div id='mobmenu'>☰</div> <h1>Favourite Channels</h1></td>
<td>
<a href='favourites.html' id='left' hidden><img src='images/left.png'></a>
<select name='when' size='1' id='select_date' onchange='formSubmit()'></select>
<a href='favourites.html' id='right' hidden><img src='images/right.png'></a>
</td>
</tr>
</table>
</form>
</div>
<div id='wrapper'>
<div id='content'>
</div>
</div>
</div>
</div>
<script>
async function main() {
const params = new URLSearchParams(window.location.search);
var lcn = 0;
if (cookies.CSORT == "1") lcn = 1;
const [ links, channels ] = await Promise.all([get_links(), get_channels(lcn)]);
var slinks = []
links.forEach(function(l) {
slinks[l["serieslink"]] = 1;
});
var channelnames = channels.map(e => e.name);
let d = new Date();
var dt = d/1000;
var today = dt - (dt%86400) + d.getTimezoneOffset()*60 + (cookies.EPGSTART * 3600)
if (params.has("when")) var when = Number(params.get("when"));
else var when = today;
var date_dropdown = document.getElementById("select_date");
let left = document.getElementById("left");
let right = document.getElementById("right");
let prev = when - 86400;
if (prev >= today) {
left.href += `?when=${prev}`;
left.hidden = false;
}
var day = today;
for(i=0; i<8; i++) {
let d = strftime("%a %d/%n", day);
let opt = document.createElement("option");
opt.setAttribute("value", day);
opt.text = d;
date_dropdown.appendChild(opt);
day += 86400;
}
date_dropdown.selectedIndex = Math.floor((when-today)/86400);
var next = when + 86400;
if (next < day) {
right.href += `?when=${next}`;
right.hidden = false;
}
document.getElementById("whatandwhen").hidden = false;
var content = document.getElementById("content");
if (cookies.selected_channels) {
for (var c of cookies.selected_channels) {
if (!channelnames.includes(c)) continue;
var table = document.createElement("TABLE");
table.className = 'list';
var row = table.insertRow(-1);
row.className = 'heading';
var title = row.insertCell();
title.setAttribute('colspan', '4');
title.innerHTML = `<span class='channel_name'>${c}</span>`;
var events = await get_epg(c, when+1, next-1);
var last_date = ' ';
events.forEach(function(e) {
if (next == 0) {
let d = strftime("%A %d/%n", e.start);
if (d != last_date) {
row = table.insertRow(-1);
row.className = 'newday';
row.innerHTML = `<td colspan='5'><span class='date_long'>${d}</span></td>`;
last_date = d;
}
}
row = table.insertRow(-1);
row.className = 'row_alt';
let start = strftime("%H:%M", e.start);
let stop = strftime("%H:%M", e.stop);
let desc = '';
if (e.summary) desc = e.summary;
else if (e.description) desc = e.description;
let s = `<td class='col_duration'>${start} - ${stop}</td>` +
`<td class='col_title'>` +
`<div class='epg_title'>${e.title}</div>` +
`<div class='epg_subtitle'>${desc}</div></td>`;
if (e.dvrState == 'scheduled' || e.dvrState == 'recording') {
if (slinks[e.serieslinkUri]) {
s += "<td></td><td><img src='images/rec.png' title='Series recording scheduled'></td>";
}
else {
s += "<td><img src='images/rec.png' title='Recording scheduled'></td>";
}
}
else {
s += `<td><a href='favourites.html' onclick='create_by_event(event, "${e.eventId}", this)'><img src='images/rec_button1.png' title='record'></a></td>`;
if (e.serieslinkUri) {
s += `<td><a href='favourites.html' onclick='create_by_series(event, "${e.eventId}", this)'><img src='images/rec_buttonS.png' title='record series'></a></td>`;
}
else {
s += "<td></td>";
}
}
row.innerHTML = s;
});
content.append(table);
}
}
else {
var msg = document.createElement("DIV");
msg.className = 'epg_title';
msg.innerHTML = "No favourite channels have been defined.";
content.append(msg);
}
}
main();
</script>
</body>
</html>