mirror of
https://github.com/0x1d/esp8266-laser.git
synced 2025-12-14 18:15:22 +01:00
33 lines
878 B
JavaScript
33 lines
878 B
JavaScript
Sui.ready(() => {
|
|
let debugResponse = (data) => {
|
|
$('#response').html(data);
|
|
};
|
|
[{
|
|
api: 'MOTOR',
|
|
method: 'POST',
|
|
selector: '.motor.slider',
|
|
event: 'change',
|
|
data: function() {
|
|
let payload = {};
|
|
payload['motor' + this.getAttribute('data-motor-nr')] = this.value;
|
|
return Sui.util.serialize(payload);
|
|
},
|
|
onResponse: debugResponse
|
|
}, {
|
|
api: 'LASER',
|
|
method: 'POST',
|
|
selector: '.laser.slider',
|
|
event: 'change',
|
|
onResponse: debugResponse,
|
|
data: function() {
|
|
return Sui.util.serialize({
|
|
laser: this.value
|
|
});
|
|
}
|
|
}].forEach(Sui.link({
|
|
api: {
|
|
MOTOR: '/spirograph', // {motorNr}/{value}
|
|
LASER: '/spirograph' // {value}
|
|
}
|
|
}));
|
|
}); |