Skip to content

Commit

Permalink
Optimized Code
Browse files Browse the repository at this point in the history
  • Loading branch information
n-ce authored May 26, 2022
1 parent 4bbbc75 commit f5e276a
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions script.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
if (localStorage.getItem('theme') != null) {
document.body.style.backgroundColor = 'black';
}

const text = document.querySelector('textarea');
text.value = localStorage.getItem('key');
text.oninput = () => {
Expand All @@ -12,19 +8,26 @@ let clean = () => {
location.reload();
}
let c;
let darkMode = () => {
document.body.style.backgroundColor = 'black';
document.querySelector('meta[name="theme-color"]').setAttribute("content", 'black');
text.style.color = 'white';
localStorage.setItem('theme','black');
c = true;
}
if (localStorage.getItem('theme') == 'black') {
darkMode();
}

let theme = () => {
if (c == null) {
document.body.style.backgroundColor = 'black';
document.querySelector('meta[name="theme-color"]').setAttribute("content", 'black');
text.style.color = 'white';
localStorage.setItem('theme','black');
c = true;
darkMode();
}
else {
document.body.style.backgroundColor = 'white';
document.querySelector('meta[name="theme-color"]').setAttribute("content", 'white');
text.style.color = 'black';
localStorage.setItem('theme',null);
localStorage.setItem('theme','white');
c = null;
}
}
Expand Down

0 comments on commit f5e276a

Please sign in to comment.