diff options
author | David Lamparter <equinox@diac24.net> | 2013-09-12 22:16:32 +0000 |
---|---|---|
committer | root <root@beaglebone.local.sublab.org> | 2013-09-12 22:16:32 +0000 |
commit | 64939115e9235a9ec0791cd0581cb0ad2cb97178 (patch) | |
tree | 9027e59ae9a4a70fe4a0593a6db356892bdaa420 /svg/subcan.js | |
parent | 435894d757e7a207fb052fef11f602cd496e00b8 (diff) |
svg: workable color picker
Diffstat (limited to 'svg/subcan.js')
-rw-r--r-- | svg/subcan.js | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/svg/subcan.js b/svg/subcan.js index 7254044..6c56062 100644 --- a/svg/subcan.js +++ b/svg/subcan.js @@ -1,3 +1,6 @@ +/* JSON object global ref */ +var data = null; + function simple_xpath(expr) { var root = document.documentElement; var iter = document.evaluate(expr, root, @@ -15,6 +18,7 @@ function simple_xpath(expr) { var picktgt = null; var picktimer = null; +var picker; function picker_end() { node = simple_xpath('//*[contains(svg:title, "'+picktgt+'=")]')[0]; @@ -22,8 +26,8 @@ function picker_end() { node.style.stroke = '#b0b0b0'; picktgt = null; - var picker = document.getElementById('picker'); - picker.style.visibility = 'hidden'; + var pickelem = document.getElementById('picker'); + pickelem.style.visibility = 'hidden'; } function picker_begin(target) { @@ -37,14 +41,16 @@ function picker_begin(target) { node.style.stroke = '#ff7700'; picktgt = target; - var picker = document.getElementById('picker'); - picker.style.visibility = 'visible'; - picktimer = window.setTimeout(picker_end, 2500); + picker.setRgb(data[picktgt]); + + var pickelem = document.getElementById('picker'); + pickelem.style.visibility = 'visible'; + picktimer = window.setTimeout(picker_end, 5000); } function picker_refresh() { window.clearTimeout(picktimer); - picktimer = window.setTimeout(picker_end, 2500); + picktimer = window.setTimeout(picker_end, 5000); } function on_picker(hex, hsv, rgb) { @@ -52,7 +58,7 @@ function on_picker(hex, hsv, rgb) { picker_refresh(); $.jsonRPC.request('light_set', { - params: [id, [rgb.r, rgb.g, rgb.b]], + params: [picktgt, [rgb.r, rgb.g, rgb.b]], error: function(result) { console.log('light_set RGB error', result); }, |