Skip to content

Commit

Permalink
Update themes.js
Browse files Browse the repository at this point in the history
Added an error-protection
  • Loading branch information
CuzImBisonratte authored Sep 10, 2021
1 parent 2d12dc9 commit 633e785
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions themes.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ ThemeColorTextDark = "#818181";
ThemeButtonNameLight = "Hell";
ThemeButtonNameDark = "Dunkel";


// Initialize the Themes-variable
var theme;

// Funktion, die die Farbänderungen auführt
function changeToTheme(backgroundColor,textColor,themeName){
Expand All @@ -24,8 +25,16 @@ function changeToTheme(backgroundColor,textColor,themeName){
function initializeTheme(){

// Aktuelles Theme abrufen
theme = localStorage.getItem("theme");

try{
theme = localStorage.getItem("theme");
}
catch(e) {
if(e.name == "NS_ERROR_FILE_CORRUPTED") {
localStorage.clear();
theme = localStorage.getItem("theme");
}
}

//Theme auf gespeichertes Theme setzen
if(theme=="light"){

Expand All @@ -48,7 +57,15 @@ initializeTheme();
function toggleTheme(){

// Aktuelles Theme abrufen
theme = localStorage.getItem("theme");
try{
theme = localStorage.getItem("theme");
}
catch(e) {
if(e.name == "NS_ERROR_FILE_CORRUPTED") {
localStorage.clear();
theme = localStorage.getItem("theme");
}
}

// Theme basierend auf Aktuellem theme ändern
if(theme=="dark"){
Expand Down

0 comments on commit 633e785

Please sign in to comment.