-
Notifications
You must be signed in to change notification settings - Fork 8
/
channels.html
174 lines (169 loc) · 5.95 KB
/
channels.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
<!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 - 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>
</div>
<div id='layout'>
<div id='banner'>
<form name='whatandwhen' method='GET' action='channels.html' id='whatandwhen' hidden>
<table>
<tr>
<td class='col_title'><div id='mobmenu'>☰</div> <h1>Channels</h1></td>
<td>Channel: <select name='which' size='1' id='select_channel' onchange='formSubmit()'></select></td>
<td>
<label>All Dates <input type='checkbox' name='all' id='all' onchange='formSubmit()'></label>
<a href='channels.html' id='left' hidden><img src='images/left.png'></a>
<select name='when' size='1' id='select_date' onchange='formSubmit()'></select>
<a href='channels.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 channel_dropdown = document.getElementById("select_channel");
let opt = document.createElement("option");
opt.setAttribute("value", -1);
opt.text = "Select Channel";
channel_dropdown.appendChild(opt);
var i = 0;
channels.forEach(function(c) {
let opt = document.createElement("option");
opt.setAttribute("value", i);
if (lcn) opt.text = `${c.number} ${c.name}`;
else opt.text = `${c.name}`;
channel_dropdown.appendChild(opt);
i++;
});
var which = params.get("which");
if (which) channel_dropdown.selectedIndex = Number(which) + 1;
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 next = 0;
var date_dropdown = document.getElementById("select_date");
if (params.has("all")) {
document.getElementById("all").checked = true;
date_dropdown.style.visibility = "hidden";
}
else {
let left = document.getElementById("left");
let right = document.getElementById("right");
let prev = when - 86400;
if (prev >= today) {
left.href += `?which=${which}&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);
next = when + 86400;
if (next < day) {
right.href += `?which=${which}&when=${next}`;
right.hidden = false;
}
date_dropdown.style.visibility = "visible";
}
document.getElementById("whatandwhen").hidden = false;
if (which) {
var table = document.createElement("TABLE");
table.className = 'list';
var row = table.insertRow(-1);
row.className = 'heading';
var title = row.insertCell();
title.setAttribute('colspan', '4');
if (lcn) title.innerHTML = `<span class='channel_name'>${channels[which].number} ${channels[which].name}</span>`;
else title.innerHTML = `<span class='channel_name'>${channels[which].name}</span>`;
var events = await get_epg(channels[which].name, 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='channels.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='channels.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;
});
var content = document.getElementById("content");
content.appendChild(table);
}
}
main();
</script>
</body>
</html>