Sha256: 7fd5d5646c1d10960efbf86e30a610d5b8aff95a50833b32929b0bc1f5149cf7
Contents?: true
Size: 765 Bytes
Versions: 3
Compression:
Stored size: 765 Bytes
Contents
$(".light").click(function () { // Get current image $image = $(this); // Extract parameters from id $parameters = $image.attr("id").split('-'); $line = $parameters[0]; $light = $parameters[1]; $old_state = $parameters[2]; // Swicht status if ($old_state == '0') { $state = '1'; } else { $state = '0'; } // Make url to change status $url = $line + '/' + $light + '/' + $state; // And call it $.get($url, function(data) { // Get page resut & extract new state $newstate = data.split(':')[1]; // Make new src & id $src = "images/" + $light + "-" + $newstate + ".png"; $id = $line + '-' + $light + '-' + $newstate; // And update it $image.attr('src', $src); $image.attr('id', $id); }); });
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
traffic_light_pi_server-0.0.3 | lib/public/traffic-light.js |
traffic_light_pi_server-0.0.2 | lib/public/traffic-light.js |
traffic_light_pi_server-0.0.1 | lib/public/traffic-light.js |