# HG changeset patch # User Tero Marttila # Date 1398977753 -10800 # Node ID ee05d89bde77bf1d5a0ba0dfa611a762e7d8dc4f # Parent 9ebf1a2cee3aba16115c67d8ff64b588f379eac2 dmx-web: ajax updates diff -r 9ebf1a2cee3a -r ee05d89bde77 static/dmx.js --- a/static/dmx.js Thu May 01 23:44:42 2014 +0300 +++ b/static/dmx.js Thu May 01 23:55:53 2014 +0300 @@ -1,3 +1,8 @@ +/* + * Get current value for given head/attr. + * + * Returns undefined if no such attr. + */ function dmx_input (head, attr) { var value = $('.dmx-input#' + head + '-' + attr).val(); @@ -11,6 +16,23 @@ } /* + * Update current output value. + */ +function dmx_update (input) { + var name = input.attr('name'); + var value = input.val(); + + console.log("dmx_update: " + name + ": " + value); + + var data = { }; data[name] = value; + + $.ajax({ + type: 'POST', + data: data, + }); +} + +/* * Update color for head. */ function dmx_color (head) { @@ -46,7 +68,10 @@ */ function slider_input (input, slider) { // bind - input.change(function () { _slider_input(input, slider); }); + input.change(function () { + dmx_update(input); + _slider_input(input, slider); + }); // initialize _slider_input(input, slider); @@ -78,6 +103,8 @@ dmx_color(head); } + // send output + dmx_update(input); }, });