-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html.tmpl
41 lines (37 loc) · 1.69 KB
/
index.html.tmpl
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
<!DOCTYPE html>
<html>
<head>
<title>Radio in your TZ</title>
<script type="text/javascript">
window.onload = function() {
var locTz = Intl.DateTimeFormat().resolvedOptions().timeZone;
document.getElementById("detectedtz").innerHTML = locTz
var audElem = document.createElement('audio');
var supportsHLS = audElem.canPlayType('application/x-mpegURL');
{{ range $index, $element := .Streams }}
var {{ .JSID }}hlsbaseURL = window.location.origin + {{ .HLSURL }}
var {{ .JSID }}icybaseURL = window.location.origin + {{ .ICYURL }}
var {{ .JSID }}hlsstreamURL = {{ .JSID }}hlsbaseURL + "&tz=" + encodeURIComponent(locTz)
var {{ .JSID }}icystreamURL = {{ .JSID }}icybaseURL + "&tz=" + encodeURIComponent(locTz)
document.getElementById("{{ .JSID }}hlsurl").innerHTML = {{ .JSID }}hlsstreamURL;
document.getElementById("{{ .JSID }}icyurl").innerHTML = {{ .JSID }}icystreamURL;
if (supportsHLS) {
document.getElementById("{{ .JSID }}player").type = "application/x-mpegURL";
document.getElementById("{{ .JSID }}player").src = {{ .JSID }}hlsstreamURL;
} else {
document.getElementById("{{ .JSID }}player").src = {{ .JSID }}icystreamURL;
}
{{ end }}
}
</script>
</head>
<body>
<h1>Timezone: <span id="detectedtz"></span></h1>
{{ range $index, $element := .Streams }}
<h2>{{ .Name }} offset to your TZ</h2>
<p>HLS URL for detected TZ: <span id="{{ .JSID }}hlsurl"></span></p>
<p>Icecast URL for detected TZ: <span id="{{ .JSID }}icyurl"></span></p>
<audio id="{{ .JSID }}player" controls></audio>
{{ end }}
</body>
</html>