diff options
author | neauoire <[email protected]> | 2019-11-08 21:26:20 -0500 |
---|---|---|
committer | neauoire <[email protected]> | 2019-11-08 21:26:20 -0500 |
commit | cb983f78fb6d85db45709908e1c21ed5e9de82c4 (patch) | |
tree | e9b3070be2d56d0293a901a4b269a2b8db0319da | |
parent | 68a5622e91a16a733e72768ec905ea2b16a4da77 (diff) | |
download | Orca-cb983f78fb6d85db45709908e1c21ed5e9de82c4.tar.gz Orca-cb983f78fb6d85db45709908e1c21ed5e9de82c4.zip |
*
-rw-r--r-- | desktop/sources/scripts/client.js | 2 | ||||
-rw-r--r-- | desktop/sources/scripts/commander.js | 6 | ||||
-rw-r--r-- | desktop/sources/scripts/lib/theme.js | 13 |
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')) } |