forked from dave-p/TVHadmin-JS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchannels.html
196 lines (190 loc) · 7.02 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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<!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">
<title>TVHadmin - Channels</title>
<script src="include.js"></script>
<script>
window.addEventListener('load',function() {
var mytop=document.getElementById("mobmenu");
mytop.addEventListener('click', function() {
var mynav=document.getElementById("navigation");
if (mynav.classList.contains('focus'))
mynav.classList.remove('focus');
else mynav.classList.add('focus');
});
},false);
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='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 links = await get_links();
var slinks = []
links.forEach(function(l) {
slinks[l["serieslink"]] = 1;
});
var lcn = 0;
if (cookies.CSORT == "1") lcn = 1;
var channels = await get_channels(lcn);
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;
var dt = new Date()/1000;
var today = dt - (dt%86400) + (cookies.EPGSTART * 3600)
if (params.get("when")) var when = Number(params.get("when"));
else var when = today;
var date_dropdown = document.getElementById("select_date");
if (params.get("all")) {
document.getElementById("all").checked = true;
date_dropdown.style.visibility = "hidden";
}
else date_dropdown.style.visibility = "visible";
if (!params.get("all")) {
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);
var next = when + 86400;
if (next < day) {
right.href += `?which=${which}&when=${next}`;
right.hidden = false;
}
}
else var next = 0;
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, next);
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>