Fixed issue with theme

This commit is contained in:
Devine Lu Linvega 2018-03-06 08:19:21 +13:00
parent d8a2fa4403
commit 9e5f84e56c
2 changed files with 30 additions and 4 deletions

View File

@ -9,17 +9,23 @@ function Theme()
this.start = function()
{
this.load(localStorage.theme && localStorage.theme.background ? localStorage.theme : this.default);
this.load(localStorage.theme ? localStorage.theme : this.default, this.default);
window.addEventListener('dragover',this.drag_enter);
window.addEventListener('drop', this.drag);
document.head.appendChild(this.el)
}
this.load = function(t)
this.load = function(t, fall_back)
{
var theme = is_json(t) ? JSON.parse(t).data : t.data;
if(!theme.background){ return; }
if(!theme || !theme.background){
if(fall_back) {
theme = fall_back.data;
} else {
return;
}
}
var css = `
:root {
@ -36,7 +42,7 @@ function Theme()
this.active = theme;
this.el.textContent = css;
localStorage.setItem("theme", JSON.stringify(theme));
localStorage.setItem("theme", JSON.stringify({data: theme}));
}
this.reset = function()

20
npm-debug.log Normal file
View File

@ -0,0 +1,20 @@
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'start' ]
2 info using npm@3.10.10
3 info using node@v6.11.4
4 verbose stack Error: ENOENT: no such file or directory, open '/Users/VillaMoirai/Github/HundredRabbits/Dotgrid/package.json'
4 verbose stack at Error (native)
5 verbose cwd /Users/VillaMoirai/Github/HundredRabbits/Dotgrid
6 error Darwin 16.7.0
7 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
8 error node v6.11.4
9 error npm v3.10.10
10 error path /Users/VillaMoirai/Github/HundredRabbits/Dotgrid/package.json
11 error code ENOENT
12 error errno -2
13 error syscall open
14 error enoent ENOENT: no such file or directory, open '/Users/VillaMoirai/Github/HundredRabbits/Dotgrid/package.json'
15 error enoent ENOENT: no such file or directory, open '/Users/VillaMoirai/Github/HundredRabbits/Dotgrid/package.json'
15 error enoent This is most likely not a problem with npm itself
15 error enoent and is related to npm not being able to find a file.
16 verbose exit [ -2, true ]