aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--desktop/sources/scripts/client.js2
-rw-r--r--desktop/sources/scripts/commander.js6
-rw-r--r--desktop/sources/scripts/lib/theme.js13
3 files changed, 19 insertions, 2 deletions
diff --git a/desktop/sources/scripts/client.js b/desktop/sources/scripts/client.js
index 8b0d432..0dfeeda 100644
--- a/desktop/sources/scripts/client.js
+++ b/desktop/sources/scripts/client.js
@@ -12,7 +12,7 @@
/* global Theme */
function Client () {
- this.version = 148
+ this.version = 149
this.library = library
this.theme = new Theme(this)
diff --git a/desktop/sources/scripts/commander.js b/desktop/sources/scripts/commander.js
index 1560e84..3156461 100644
--- a/desktop/sources/scripts/commander.js
+++ b/desktop/sources/scripts/commander.js
@@ -45,7 +45,11 @@ function Commander (client) {
// Effects
rot: (p) => { client.cursor.rotate(p.int) },
// Themeing
- color: (p) => { client.theme.set('b_med', p.parts[0]); client.theme.set('b_inv', p.parts[1]); client.theme.set('b_high', p.parts[2]) },
+ color: (p) => {
+ client.theme.set('b_med', p.parts[0])
+ client.theme.set('b_inv', p.parts[1])
+ client.theme.set('b_high', p.parts[2])
+ },
// Edit
find: (p) => { client.cursor.find(p.str) },
select: (p) => { client.cursor.select(p.x, p.y, p.w, p.h) },
diff --git a/desktop/sources/scripts/lib/theme.js b/desktop/sources/scripts/lib/theme.js
index 8856e47..4853609 100644
--- a/desktop/sources/scripts/lib/theme.js
+++ b/desktop/sources/scripts/lib/theme.js
@@ -73,6 +73,13 @@ function Theme (client) {
this.load(this.default)
}
+ this.set = (key, val) => {
+ if (!val) { return }
+ const hex = (`${val}`.substr(0, 1) !== '#' ? '#' : '') + `${val}`
+ if (!isColor(hex)) { console.warn('Theme', `${hex} is not a valid color.`); return }
+ this.active[key] = hex
+ }
+
this.read = (key) => {
return this.active[key]
}
@@ -143,6 +150,10 @@ function Theme (client) {
return true
}
+ function isColor (hex) {
+ return /^#([0-9A-F]{3}){1,2}$/i.test(hex)
+ }
+
function isJson (text) {
try { JSON.parse(text); return true } catch (error) { return false }
}
@@ -150,4 +161,6 @@ function Theme (client) {
function isHtml (text) {
try { new DOMParser().parseFromString(text, 'text/xml'); return true } catch (error) { return false }
}
+
+ console.log(isColor('#72dec2'))
}