diff --git a/desktop/sources/scripts/dotgrid.js b/desktop/sources/scripts/dotgrid.js index 249bfe6..877523e 100644 --- a/desktop/sources/scripts/dotgrid.js +++ b/desktop/sources/scripts/dotgrid.js @@ -232,7 +232,7 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y) let file = e.dataTransfer.files[0]; - if(!file.path || file.path.indexOf(".dot") < 0 && file.path.indexOf(".grid") < 0){ console.log("Dotgrid","Not a dot file"); return; } + if(!file || !file.path || file.path.indexOf(".dot") < 0 && file.path.indexOf(".grid") < 0){ console.warn("Dotgrid","Not a dot file"); return; } let reader = new FileReader(); reader.onload = function(e){ diff --git a/desktop/sources/scripts/lib/theme.js b/desktop/sources/scripts/lib/theme.js index cac78d1..5e4a75a 100644 --- a/desktop/sources/scripts/lib/theme.js +++ b/desktop/sources/scripts/lib/theme.js @@ -18,18 +18,21 @@ function Theme(default_theme = {background: "#222", f_high: "#fff", f_med: "#777 this.install = function(host = document.body,callback) { + console.log("Theme","Installing..") host.appendChild(this.el) this.callback = callback } this.start = function() { + console.log("Theme","Starting..") let storage = is_json(localStorage.theme) ? JSON.parse(localStorage.theme) : this.collection.default; this.load(!storage.background ? this.collection.default : storage) } this.save = function(theme) { + console.log("Theme","Saving..") this.active = theme; localStorage.setItem("theme", JSON.stringify(theme)); } @@ -133,7 +136,7 @@ function Theme(default_theme = {background: "#222", f_high: "#fff", f_med: "#777 let file = e.dataTransfer.files[0]; - if(!file.name){ console.warn("Theme","Unnamed file."); return; } + if(!file || !file.name){ console.warn("Theme","Unnamed file."); return; } if(file.name.indexOf(".thm") < 0 && file.name.indexOf(".svg") < 0){ console.warn("Theme","Skipped, not a theme"); return; } let reader = new FileReader(); diff --git a/desktop/sources/scripts/picker.js b/desktop/sources/scripts/picker.js index a0cd873..d092fab 100644 --- a/desktop/sources/scripts/picker.js +++ b/desktop/sources/scripts/picker.js @@ -87,8 +87,13 @@ function Picker() document.getElementById("option_color").children[0].style.stroke = hex; } - this.listen = function(e) + this.listen = function(e,is_down = false) { + if(is_down && !is_color_char(e.key)){ + e.preventDefault(); + return; + } + if(e.key == "Enter"){ this.validate(); e.preventDefault(); @@ -114,5 +119,12 @@ function Picker() return re.test(val) } + function is_color_char(val) + { + let re = /[0-9A-Fa-f]/g; + return re.test(val) + } + + this.input.onkeydown = function(event){ dotgrid.picker.listen(event,true); } this.input.onkeyup = function(event){ dotgrid.picker.listen(event); }; } \ No newline at end of file