light theme works too with query param
Some checks reported errors
continuous-integration/drone/push Build encountered an error
Some checks reported errors
continuous-integration/drone/push Build encountered an error
This commit is contained in:
parent
ad3c15dbcc
commit
3cd47f4335
|
@ -16,45 +16,35 @@
|
||||||
can probably remove this again. -->
|
can probably remove this again. -->
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var params = new URLSearchParams(window.location.search)
|
var params = new URLSearchParams(window.location.search)
|
||||||
var dark = params.has('dark')
|
|
||||||
|
|
||||||
function setDark(val) {
|
function setMode(mode, val) {
|
||||||
if (val) {
|
if (val) document.body.classList.add(mode)
|
||||||
document.body.classList.add('dark')
|
else document.body.classList.remove(mode)
|
||||||
if (typeof Array.from === 'function') {
|
|
||||||
Array.from(document.querySelectorAll('a'))
|
if (typeof Array.from === 'function') {
|
||||||
.filter( el => el.href.indexOf('cosmic.voyage') !== -1)
|
Array.from(document.querySelectorAll('a'))
|
||||||
.map( el => {
|
.filter( el => el.href.indexOf('cosmic.voyage') !== -1)
|
||||||
var url = el.href
|
.map( el => {
|
||||||
var p = url.indexOf('?') !== -1 ? url.substr(url.indexOf('?')) : ''
|
var url = el.href
|
||||||
var baseURL = url.split('?')[0]
|
var p = url.indexOf('?') !== -1 ? url.substr(url.indexOf('?')) : ''
|
||||||
const params = new URLSearchParams(p)
|
var baseURL = url.split('?')[0]
|
||||||
params.append('dark', 1)
|
const params = new URLSearchParams(p)
|
||||||
p = params.toString()
|
if (val) {
|
||||||
el.href = baseURL + (p ? '?' + p : '')
|
params.append(mode, 1)
|
||||||
})
|
} else {
|
||||||
}
|
params.delete(mode)
|
||||||
} else {
|
}
|
||||||
document.body.classList.remove('dark')
|
p = params.toString()
|
||||||
if (typeof Array.from === 'function') {
|
el.href = baseURL + (p ? '?' + p : '')
|
||||||
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)
|
|
||||||
params.delete('dark')
|
|
||||||
p = params.toString()
|
|
||||||
el.href = baseURL + (p ? '?' + p : '')
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener('DOMContentLoaded', function() {
|
window.addEventListener('DOMContentLoaded', function() {
|
||||||
if (dark) {
|
if (params.has('dark')) {
|
||||||
setDark(true)
|
setMode('dark', true)
|
||||||
|
} else if (params.has('light')) {
|
||||||
|
setMode('light', true)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -84,6 +84,26 @@
|
||||||
color: rgb(62, 231, 123, 0.5);
|
color: rgb(62, 231, 123, 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Manually toggled light class on body */
|
||||||
|
body.light {
|
||||||
|
color: #333;
|
||||||
|
background-color: white;
|
||||||
|
background-image: url('/paper.png');
|
||||||
|
background-repeat: repeat;
|
||||||
|
}
|
||||||
|
|
||||||
|
.light a,
|
||||||
|
.light a:visited,
|
||||||
|
.light a:hover,
|
||||||
|
.light a:active {
|
||||||
|
color: #333;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.light .dim {
|
||||||
|
color: rgba(30, 30, 30, 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
.page-wrapper {
|
.page-wrapper {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user