ots/frontend/index.html
Knut Ahlers e572d2f545
Port to Vue3 and TypeScript
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2025-05-01 13:25:11 +02:00

67 lines
1.9 KiB
HTML

<!doctype html>
<html lang="en" data-bs-theme="light">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
{{ range (list "fa-solid-900.woff2" "fa-brands-400.woff2") }}
<link
as="font"
crossorigin="anonymous"
href="{{ . }}"
integrity="{{ assetSRI . }}"
rel="preload"
>
{{ end }}
<link
crossorigin="anonymous"
href="app.css"
integrity="{{ assetSRI `app.css` }}"
rel="stylesheet"
>
<title>{{ .Customize.AppTitle }}</title>
<script nonce="{{ .InlineContentNonce }}">
window.getThemeFromStorage = () => localStorage.getItem('set-color-scheme') || 'auto'
window.getTheme = () => {
const colorScheme = window.getThemeFromStorage()
if (!colorScheme || colorScheme === 'auto') {
return window.matchMedia('(prefers-color-scheme: light)').matches ? 'light' : 'dark'
}
return colorScheme
}
window.refreshTheme = () => {
document.querySelector('html').setAttribute('data-bs-theme', window.getTheme())
}
window.setTheme = (theme) => {
localStorage.setItem('set-color-scheme', theme)
window.refreshTheme()
}
// Very early load of theme definition to avoid flickering
document.addEventListener('DOMContentLoaded', () => window.refreshTheme())
// Template variable from Golang process
window.maxSecretExpire = {{ .MaxSecretExpiry }}
window.version = "{{ .Version }}"
window.OTSCustomize = JSON.parse('{{ .Customize.ToJSON }}')
window.useFormalLanguage = {{ .Customize.UseFormalLanguage | mustToJson }}
</script>
</head>
<body>
<div id="app"></div>
<script
crossorigin="anonymous"
integrity="{{ assetSRI `app.js` }}"
src="app.js"
></script>
</body>
</html>