]> code.octet-stream.net Git - broadcaster/blob - templates/playlist.html
Solve race condition when updating files or playlists and notifying radios
[broadcaster] / templates / playlist.html
1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4 <meta charset="UTF-8">
5 <meta name="viewport" content="width=device-width, initial-scale=1.0">
6 <title>Broadcaster</title>
7 <script type="text/javascript">
8 function deleteItem(sender) {
9 sender.parentNode.remove();
10 }
11 function addItem() {
12 const p = document.createElement('p');
13 const temp = document.getElementById('item-template');
14 p.innerHTML = temp.innerHTML;
15 const marker = document.getElementById('add-item');
16 const parent = marker.parentNode;
17 parent.insertBefore(p, marker);
18 }
19 </script>
20 </head>
21 <body>
22 <main>
23 <h1>A specific playlist</h1>
24 <h2>
25 {{if .Playlist.Id}}
26 Edit Playlist
27 {{else}}
28 Create New Playlist
29 {{end}}
30 </h2>
31 <form action="/playlist/submit" method="POST">
32 <input type="hidden" name="playlistId" value="{{.Playlist.Id}}">
33 <p>
34 <input type="checkbox" id="playlistEnabled" name="playlistEnabled" value="1" {{if .Playlist.Enabled}} checked {{end}}>
35 <label for="playlistEnabled">Playlist enabled?</label><br>
36 </p>
37 <p>
38 <label for="playlistName">Name:</label>
39 <input type="text" id="playlistName" name="playlistName" value="{{.Playlist.Name}}">
40 </p>
41 <p>
42 <label for="playlistStartTime">Transmission Start:</label>
43 <input type="datetime-local" id="playlistStartTime" name="playlistStartTime" value="{{.Playlist.StartTime}}">
44 </p>
45 <h3>Playlist Items</h3>
46 {{range .Entries}}
47 <p>
48 Wait until
49 <input type="text" name="delaySeconds" value="{{.DelaySeconds}}">
50 seconds from
51 <select name="isRelative">
52 <option value="0">start of transmission</option>
53 <option value="1" {{if .IsRelative}} selected="selected" {{end}}>previous item</option>
54 </select>
55 then play
56 <select name="filename">{{$f := .Filename}}
57 <option value="">(no file selected)</option>
58 {{range $.Files}}
59 <option value="{{.}}" {{if eq . $f }} selected="selected" {{end}}>{{.}}</option>
60 {{end}}
61 </select>
62 <a href="#" onclick="deleteItem(this)">(Delete Item)</a>
63 </p>
64 {{end}}
65 <p>
66 <a href="#" onclick="addItem()" id="add-item">Add Item</a>
67 </p>
68 <p>
69 <input type="submit" value="Save Playlist">
70 </p>
71 </form>
72 {{if .Playlist.Id}}
73 <h3>Delete</h3>
74 <form action="/playlist/delete" method="POST">
75 <input type="hidden" name="playlistId" value="{{.Playlist.Id}}">
76 <p>
77 <input type="submit" value="Delete Playlist">
78 </p>
79 </form>
80 {{end}}
81 <template id="item-template">
82 Wait until
83 <input type="text" name="delaySeconds" value="0">
84 seconds from
85 <select name="isRelative">
86 <option value="0">start of transmission</option>
87 <option value="1">previous item</option>
88 </select>
89 then play
90 <select name="filename">
91 <option value="">(no file selected)</option>
92 {{range $.Files}}
93 <option value="{{.}}">{{.}}</option>
94 {{end}}
95 </select>
96 <a href="#" onclick="deleteItem(this)">(Delete Item)</a>
97 </template>
98 </main>
99 </body>
100 </html>