Skip to content
Snippets Groups Projects
Commit 3304d397 authored by jkerdreu's avatar jkerdreu
Browse files

Cleanup..




git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Python/branches/0.7@2944 b32b6428-25c9-4566-ad07-03861ab6144f
parent 5bc6b1ca
Branches
No related tags found
No related merge requests found
......@@ -5,40 +5,56 @@
<input type="checkbox" onchange={ chk } checked={checked}>
<span class="slider round" id="{ switch_id }"></span>
</label>
<button class="modal_btn" id="{ btn_id }" onclick={ btn }>&nbsp;</button>
<button class="modal_btn" id="{ btn_id }" onclick={ btn }>&nbsp;</button>
</div>
<dialog id="{dialog_id}" class="lamp_modal">
<input type="color" id="{color_input_id}" onchange={ color_input }/>
<h3>Settings</h3>
<div>
<label>
<span>Color</span>
<input type="color" id="{color_input_id}" onchange={ color_input }/>
</label>
</div>
<div>
<label>
<span>Brightness</span>
<input type="range" id="{brightness_input_id}" onchange={ brightness_input } min="0" max="100" value="{brightness}"/>
</label>
</div>
<div>
<label>
<span>White Balance</span>
<input type="range" id="{white_balance_input_id}" onchange={ white_balance_input } min="0" max="100" value="{white_balance}"/>
</label>
</div>
</dialog>
<script>
this.addr = opts.xaal_addr
this.switch_id = 'sw_'+ new Date().getTime()
this.dialog_id = 'dialog_'+ new Date().getTime()
this.btn_id = 'btn_'+new Date().getTime()
this.color_input_id = 'color_'+new Date().getTime()
//console.log(new Date().getTime())
this.dialog_id = objID('dialog')
this.btn_id = objID('btn')
this.color_input_id = objID('color_input')
receive(data) {
state = data['attributes']['light']
hsv = data['attributes']['hsv']
mode = data['attributes']['mode']
if (state == true) {
this.checked = true
rgb=hsv2rgb(hsv[0], hsv[1], hsv[2])
r = Math.round(rgb[0] * 255)
g = Math.round(rgb[1] * 255)
b = Math.round(rgb[2] * 255)
color=rgbToHex(r,g,b)
//_("#"+this.switch_id).style.background = color
_("#"+this.btn_id).style.background = color
_("#"+this.color_input_id).value = color
if (mode == 'color') {
rgb=hsv2rgb(hsv[0], hsv[1], hsv[2])
r = Math.round(rgb[0] * 255)
g = Math.round(rgb[1] * 255)
b = Math.round(rgb[2] * 255)
color=rgbToHex(r,g,b)
_("#"+this.btn_id).style.background = color
_("#"+this.color_input_id).value = color
}
}
else {
this.checked = false
......@@ -46,6 +62,13 @@
this.update()
}
function objID(name) {
l = 10000000000000
b = Math.round(Math.random() * l)
return name +'_'+ b.toString()
}
/* ============================================================ */
/* Color functions */
/* ============================================================ */
......@@ -60,7 +83,6 @@
return [60*(h<0?h+6:h), v&&c/v, v];
}
function componentToHex(c) {
var hex = c.toString(16);
return hex.length == 1 ? "0" + hex : hex;
......@@ -83,17 +105,14 @@
sio_send_request(this.addr,'turn_on',{})
else
sio_send_request(this.addr,'turn_off',{})
//_("#"+this.switch_id).style.background = 'var(--color2)'
}
btn(e) {
//_("#"+this.dialog_id).hidden = false
_("#"+this.dialog_id).showModal()
}
color_input(e) {
color = e.target.value
//_("#"+this.switch_id).style.background = color
_("#"+this.btn_id).style.background = color
rgb = hexToRgb(color)
......@@ -101,7 +120,6 @@
sio_send_request(this.addr,'set_hsv',{'hsv':r})
}
</script>
<style>
......@@ -119,9 +137,10 @@
}
.lamp_modal {
/*color: var(--color2); */
background-color: var(--color4);
width: 300px;
border: 1px solid var(--color2);
border: 1px solid var(--color3);
}
</style>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment