-
Notifications
You must be signed in to change notification settings - Fork 8
/
config.html
318 lines (305 loc) · 12.1 KB
/
config.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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
<!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 - a front-end for TVHeadend></title>
<script src="include.js"></script>
<script>
function one2two() {
m1len = m1.length ;
for ( i=0; i<m1len ; i++){
if (m1.options[i].selected == true ) {
m2len = m2.length;
m2.options[m2len]= new Option(m1.options[i].text);
}
}
for ( i = (m1len -1); i>=0; i--){
if (m1.options[i].selected == true ) {
m1.options[i] = null;
}
}
}
function two2one() {
m2len = m2.length ;
for ( i=0; i<m2len ; i++){
if (m2.options[i].selected == true ) {
m1len = m1.length;
m1.options[m1len]= new Option(m2.options[i].text);
}
}
for ( i=(m2len-1); i>=0; i--) {
if (m2.options[i].selected == true ) {
m2.options[i] = null;
}
}
}
function selectAll() {
for (i=0; i<m2.length; i++) {
m2.options[i].selected = true;
}
}
/*!
* Serialize all form data into an array
* (c) 2018 Chris Ferdinandi, MIT License, https://gomakethings.com
*/
function saveForm(form) {
var serialized = {};
for (var i = 0; i < form.elements.length; i++) {
var field = form.elements[i];
if (!field.name || field.disabled || field.type === 'file' || field.type === 'reset' || field.type === 'submit' || field.type === 'button') continue;
if (field.type === 'select-multiple') {
var choices = [];
for (var n = 0; n < field.options.length; n++) {
if (!field.options[n].selected) continue;
choices.push(field.options[n].value);
}
if (choices.length > 0) {
serialized[field.name] = choices;
}
}
else if ((field.type !== 'checkbox' && field.type !== 'radio') || field.checked) {
serialized[field.name] = field.value;
}
}
return serialized;
}
function reloadForm(form, cookies) {
for (var i = 0; i < form.elements.length; i++) {
var field = form.elements[i];
if (!field.name || field.type === 'select-multiple' || field.type === 'submit' || field.type === 'button') continue;
if (field.type === 'checkbox' && (field.name in cookies)) {
field.checked = true;
}
else if (field.type === 'radio' && (field.name in cookies) && (field.value == cookies[field.name])) {
field.checked = true;
}
else if (field.type === 'select-one' && (field.name in cookies) && (cookies[field.name] !== 'None')) {
field.value = cookies[field.name];
}
}
var myChannels = form.selected_channels;
cookies.selected_channels.forEach(function(channel) {
var option = document.createElement("option");
option.text = option.label = channel;
myChannels.add(option);
});
}
function tag_boxes(tags, cookies, id, prefix) {
let taglist = document.getElementById(id);
let s = "";
for (k in tags) {
let ut = encodeURIComponent(k);
if (cookies["Tag_"+ut]) {
let g = prefix + ut;
s = s + k + ": <input type='checkbox' name='" + g + "'>";
}
}
taglist.innerHTML = s;
}
async function get_stream_profiles() {
const response = await fetch("/api/profile/list");
const profiles = await response.json();
let a = [];
for (const p of profiles.entries) {
const r = await fetch(`/api/raw/export?uuid=${p.key}`);
const s = await r.json();
a.push(s[0])
}
return a;
}
</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>Configuration</h1>
</td>
</tr>
</table>
</div>
<div id='config'>
<form action="config.html" method="post" name="FormName" id="myForm">
<table class="group">
<tr class="heading">
<td colspan="2"><h2>TVHeadend Server</h2></td>
</tr>
<tr class='row_alt' id='prof' title="TVheadend profile to use for recordings."></tr>
<tr class='row_alt' id='sprof' title="TVheadend profile to use for streaming."></tr>
</table>
<table class='group'>
<tr class='heading'>
<td colspan='2'><h2>Preferences</h2></td>
</tr>
<tr class='row_alt' title='Select display theme'>
<td class='col_label'><h5>Display theme:</h5></td>
<td class='col_value'><label for='T0'>Light:</label><input type='radio' name='THEME' id='T0' value='0'><label for='T1'>Dark:</label><input type='radio' name='THEME' id='T1' value='1'><label for='T2'>Blue:</label><input type='radio' name='THEME' id='T2' value='2'>
</td>
</tr>
<tr class='row_alt' title='Time after which entries appear on tomorrow's EPG. Useful if you watch TV after midnight'>
<td class='col_label'><h5>EPG Day starts at:</h5></td>
<td class='col_value'>
<select name='EPGSTART'><option value='0'>0:00</option><option value='1'>1:00</option><option value='2'>2:00</option><option value='3'>3:00</option><option value='4'>4:00</option><option value='5'>5:00</option><option value='6'>6:00</option></select>
</td>
</tr>
<tr class='row_alt' title='Screen shown when entering TVHadmin'>
<td class='col_label'><h5>Home Page:</h5></td>
<td class='col_value'>
<select name='HOME'><option value='now'>What's On Now?</option><option value='timeline'>Timeline</option><option value='channels'>Channels</option><option value='favourites'>Favourite Channels</option><option value='timers'>Timers</option><option value='recordings'>Recordings</option><option value='links'>Series Links</option><option value='status'>Status</option><option value='config'>Configuration</option></select>
</td>
</tr>
<tr class='row_alt' title='Sort channels by name or Logical Channel Number'>
<td class='col_label'><h5>Channels Sort Order:</h5></td>
<td class='col_value'><label for='C0'>Name:</label><input type='radio' name='CSORT' id='C0' value='0'><label for='C1'>LCN:</label><input type='radio' name='CSORT' id='C1' value='1'>
</td>
</tr>
<tr class='row_alt' title='Refresh the Whats On Now and Timeline screens every minute'>
<td class='col_label'><h5>Refresh Whats On Now and Timeline screens:</h5></td>
<td class='col_value'><input type='checkbox' name='REFR'></td>
</tr>
<tr class='row_alt' title='Refresh the status screen every 5 seconds'>
<td class='col_label'><h5>Refresh status screen:</h5></td>
<td class='col_value'><input type='checkbox' name='REFS'></td>
</tr>
<tr class='row_alt' title='Show icon instead of channel name. Needs picons installed and imagecache enabled on TVHeadend'>
<td class='col_label'><h5>Show channel icons in What's On Now & Recordings:</h5></td>
<td class='col_value'><input type='checkbox' name='ICONS'></td>
</tr>
<tr class='row_alt' title='Show timer conflicts. Multiple tuner option is experimental and needs ADMIN privilege.'>
<td class='col_label'><h5>Detect timer clashes:</h5></td>
<td class='col_value'>
<label for='T0'>Off:</label><input type='radio' name='CLASHDET' id='T0' value='0'>
<label for='T1'>Single tuner:</label><input type='radio' name='CLASHDET' id='T1' value='1'>
<label for='T2'>Multiple tuners:</label><input type='radio' name='CLASHDET' id='T2' value='2'>
</td>
</tr>
<tr class='row_alt' title='Time period for the Timeline screen'>
<td class='col_label'><h5>Timeline length:</h5></td>
<td class='col_value'>
<select name='TIMESPAN'><option value='2'>2 hours</option><option value='4'>4 hours</option><option value='6'>6 hours</option></select>
</td>
</tr>
<tr class='row_alt' title='Which TVH tags are to be used for filtering. Click 'Save' after changing this selection to update the other preferences'>
<td class='col_label'><h5>Media Tags to use for selection:</h5></td>
<td class='col_value' id='alltags'></td>
</tr>
</table>
<table class='group'>
<tr class='heading'>
<td colspan='2'><h2>Defaults</h2></td>
</tr>
<tr class='row_alt' title='Default filter setting for the What's On Now screen'>
<td class='col_label'><h5>Show in What's On Now:</h5></td>
<td class='col_value' id='nowtags'></td>
</tr>
<tr class='row_alt' title='Default filter setting for the Timeline screen'>
<td class='col_label'><h5>Show in Timeline:</h5></td>
<td class='col_value' id='timetags'></td>
</tr>
<tr class='row_alt' title='Default filter setting for the Recordings screen'>
<td class='col_label'><h5>Show in Recordings:</h5></td>
<td class='col_value' id='rectags'></td>
</tr>
<tr class='row_alt' title='Sort recordings by date or by title (ignoring 'New:')'>
<td class='col_label'><h5>Recordings Sort Order:</h5></td>
<td class='col_value'><label for='B0'>Date Fwd:</label><input type='radio' name='SORT' id='B0' value='0'><label for='B1'>Date Rev:</label><input type='radio' name='SORT' id='B1' value='1'><label for='B2'>Title:</label><input type='radio' name='SORT' id='B2' value='2'></td>
</tr>
</table>
<table class='group'>
<tr class='heading'>
<td colspan='3'><h2>Favourite Channels</h2></td>
</tr>
<tr class='row_alt'>
<td class='col_channels'>
<select name='all_channels' size='8' multiple='multiple' class='channels'></select>
</td>
<td style='text-align: center;'>
<input type='button' onClick='one2two()' value='>>>>>'><br>
<input type='button' onClick='two2one()' value='<<<<<'>
</td>
<td class='col_wanted_channels'>
<select name='selected_channels' size='8' multiple='multiple' class='channels'></select>
</td>
</tr>
</table>
<div id="buttons">
<input type="submit" class="submit" name="save" value="Save" onclick="selectAll()">
</div>
</form>
</div>
</div>
</div>
<script>
var m1 = document.FormName.all_channels;
var m2 = document.FormName.elements.selected_channels;
async function main() {
let form = document.getElementById("myForm");
form.addEventListener("submit", event => {
let formdata = JSON.stringify(saveForm(form));
document.cookie = "TVHadmin="+encodeURIComponent(formdata)+"; Max-Age=315360000; SameSite=Lax";
});
let profiles = await get_profiles();
var s = "<td class='col_label'><h5>Recording Profile:</h5></td>" +
"<td class='col_value'><select name='UUID'>";
for (const p of profiles) {
if (!p.enabled) continue;
let sel = '';
if (p.name == '') {
p.name = '(default)';
if (cookies.UUID == 'None') sel = 'selected';
}
if (p.uuid === cookies.UUID) sel = 'selected';
s = s + `<option value='${p.uuid}' ${sel}>${p.name}</option>`;
}
s += "</select></td>";
let proflist = document.getElementById("prof");
proflist.innerHTML = s;
let stream_profiles = await get_stream_profiles();
s = "<td class='col_label'><h5>Stream Profile:</h5></td>" +
"<td class='col_value'><select name='SUUID'>";
for (const p of stream_profiles) {
let sel = '';
if (!cookies.SUUID && p.default) sel = 'selected';
else if (p.uuid === cookies.SUUID) sel = 'selected';
s += `<option value='${p.uuid}' ${sel}>${p.name}</option>`;
}
s += "</select></td>";
let sproflist = document.getElementById("sprof");
sproflist.innerHTML = s;
let tags = await get_channeltags();
let taglist = document.getElementById("alltags");
s = "";
for (k in tags) {
let g = encodeURIComponent("Tag_" + k);
s = s + k + ": <input type='checkbox' name='" + g + "'>";
}
taglist.innerHTML = s;
tag_boxes(tags, cookies, "nowtags", "Now_");
tag_boxes(tags, cookies, "timetags", "Tim_");
tag_boxes(tags, cookies, "rectags", "Rec_");
var channels = await get_channels(0);
var allchannels = document.FormName.all_channels;
channels.forEach(function(channel) {
var option = document.createElement("option");
option.text = option.label = channel.name;
allchannels.add(option);
});
reloadForm(form, cookies);
}
main();
</script>
</body>
</html>