light theme works too with query param
continuous-integration/drone/push Build encountered an error
Details
continuous-integration/drone/push Build encountered an error
Details
This commit is contained in:
parent
ad3c15dbcc
commit
3cd47f4335
|
@ -16,45 +16,35 @@
|
|||
can probably remove this again. -->
|
||||
<script type="text/javascript">
|
||||
var params = new URLSearchParams(window.location.search)
|
||||
var dark = params.has('dark')
|
||||
|
||||
function setDark(val) {
|
||||
if (val) {
|
||||
document.body.classList.add('dark')
|
||||
if (typeof Array.from === 'function') {
|
||||
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.append('dark', 1)
|
||||
p = params.toString()
|
||||
el.href = baseURL + (p ? '?' + p : '')
|
||||
})
|
||||
}
|
||||
} else {
|
||||
document.body.classList.remove('dark')
|
||||
if (typeof Array.from === 'function') {
|
||||
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 : '')
|
||||
})
|
||||
}
|
||||
function setMode(mode, val) {
|
||||
if (val) document.body.classList.add(mode)
|
||||
else document.body.classList.remove(mode)
|
||||
|
||||
if (typeof Array.from === 'function') {
|
||||
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 : '')
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener('DOMContentLoaded', function() {
|
||||
if (dark) {
|
||||
setDark(true)
|
||||
if (params.has('dark')) {
|
||||
setMode('dark', true)
|
||||
} else if (params.has('light')) {
|
||||
setMode('light', true)
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
|
|
@ -84,6 +84,26 @@
|
|||
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 {
|
||||
text-align: center;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue