cosmic/templates/webheader.tmpl

47 lines
1.9 KiB
Cheetah
Raw Normal View History

<!DOCTYPE html>
2019-03-24 01:11:48 +00:00
<html lang="en">
<head>
<meta charset=utf-8>
<meta http-equiv=X-UA-Compatible content="IE=edge">
<meta name=viewport content="shrink-to-fit=no,width=device-width,height=device-height,initial-scale=1,user-scalable=1">
<!-- Rocket favicon by Adrien Coquet from the Noun Project -->
2019-02-05 22:34:43 +00:00
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<meta name="msapplication-TileColor" content="#00a300">
<meta name="theme-color" content="#ffffff">
2019-10-31 16:02:17 +00:00
<!-- I'm sorry you have to see JavaScript on this site, but it's here to
enable a manual dark mode toggle. When dark mode support improves I
can probably remove this again. -->
<script type="text/javascript">
2019-10-31 16:58:22 +00:00
function setMode(mode, val) {
if (val) document.body.classList.add(mode)
else document.body.classList.remove(mode)
Array.from(document.querySelectorAll('a'))
.filter( el => el.href.indexOf('cosmic.voyage') !== -1)
.map( el => {
var url = el.href
var p = url.indexOf('?') !== -1 ? url.substr(url.indexOf('?')) : ''
var baseURL = url.split('?')[0]
const params = new URLSearchParams(p)
if (val) {
params.append(mode, 1)
} else {
params.delete(mode)
}
p = params.toString()
el.href = baseURL + (p ? '?' + p : '')
})
}
2019-10-31 16:51:12 +00:00
2019-10-31 16:58:22 +00:00
window.addEventListener('DOMContentLoaded', function() {
var params = new URLSearchParams(window.location.search)
if (params.has('dark')) {
setMode('dark', true)
} else if (params.has('light')) {
setMode('light', true)
2019-10-31 16:54:01 +00:00
}
})
2019-10-31 16:02:17 +00:00
</script>