summaryrefslogtreecommitdiff
path: root/static/scripts/theme.js
diff options
context:
space:
mode:
authorDavid Luevano Alvarado <david@luevano.xyz>2021-06-01 03:21:33 -0600
committerDavid Luevano Alvarado <david@luevano.xyz>2021-06-01 03:21:33 -0600
commit6d2c067f0d6bc78eef7ececcec3eba71cbb5d80c (patch)
treefeb9c3b13d2603526fee6fbd876f5bd8dfe5bcf2 /static/scripts/theme.js
parentbda8405ebdf2cad9cd2f316d6e5371fece798353 (diff)
add fork awesome, contact and donate pages, update general style and update readme
Diffstat (limited to 'static/scripts/theme.js')
-rw-r--r--static/scripts/theme.js35
1 files changed, 25 insertions, 10 deletions
diff --git a/static/scripts/theme.js b/static/scripts/theme.js
index 68a0cbb..489060f 100644
--- a/static/scripts/theme.js
+++ b/static/scripts/theme.js
@@ -16,14 +16,19 @@ window.onload = () => {
switch_theme.checked = false;
let theme = document.getElementById('theme-css');
- let code_theme = document.getElementById('code-theme-css');
- let href = theme.getAttribute('href');
- let code_href = code_theme.getAttribute('href');
+ let href = theme.getAttribute('href');
href = href.replace('dark.css', 'light.css');
- code_href = code_href.replace('solarized-dark.min.css', 'solarized-light.min.css');
theme.setAttribute('href', href);
- code_theme.setAttribute('href', code_href);
+
+ let code_theme = document.getElementById('code-theme-css');
+
+ let code_href;
+ if (code_theme !== null){
+ code_href = code_theme.getAttribute('href');
+ code_href = code_href.replace('solarized-dark.min.css', 'solarized-light.min.css');
+ code_theme.setAttribute('href', code_href);
+ }
}
}
@@ -43,23 +48,33 @@ function setTheme(){
// toggles between both themes, and then calls set theme to actually set it persistently.
function toggleTheme(){
let theme = document.getElementById('theme-css');
- let code_theme = document.getElementById('code-theme-css');
let href = theme.getAttribute('href');
- let code_href = code_theme.getAttribute('href');
+
+ let code_theme = document.getElementById('code-theme-css');
+ let code_href;
+ if (code_theme !== null){
+ code_href = code_theme.getAttribute('href');
+ }
if(href.endsWith('dark.css')){
href = href.replace('dark.css', 'light.css');
- code_href = code_href.replace('solarized-dark.min.css', 'solarized-light.min.css');
+ if (code_theme !== null){
+ code_href = code_href.replace('solarized-dark.min.css', 'solarized-light.min.css');
+ }
}
else if (href.endsWith('light.css')){
href = href.replace('light.css', 'dark.css');
- code_href = code_href.replace('solarized-light.min.css', 'solarized-dark.min.css');
+ if (code_theme !== null){
+ code_href = code_href.replace('solarized-light.min.css', 'solarized-dark.min.css');
+ }
}
else{
console.log('Wrong replacement.');
}
theme.setAttribute('href', href);
- code_theme.setAttribute('href', code_href);
+ if (code_theme !== null){
+ code_theme.setAttribute('href', code_href);
+ }
setTheme();
}