mirror of
https://github.com/0x1d/esp8266-laser.git
synced 2025-12-18 03:16:40 +01:00
38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
Sui.ready(() => {
|
|
let debugResponse = (data) => {
|
|
document.querySelector('#response').html(data);
|
|
};
|
|
Sui.select('.collapsible').forEach((container) => {
|
|
container.querySelector('.heading').addEventListener('click', (item) => {
|
|
container.classList.toggle('open');
|
|
});
|
|
});
|
|
[{
|
|
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}
|
|
}
|
|
}));
|
|
}); |