mirror of
https://github.com/CopterExpress/clever-show.git
synced 2026-05-26 15:13:26 +00:00
101 lines
3.5 KiB
JavaScript
101 lines
3.5 KiB
JavaScript
let animationInput = document.getElementById('animationFile');
|
|
let configInput = document.getElementById('configFile');
|
|
let arucoInput = document.getElementById('arucoFile');
|
|
let launchInput = document.getElementById('launchFile');
|
|
|
|
animationInput.onchange = function (e) {
|
|
spinner.style.display = 'inline-block';
|
|
setTimeout(function () {
|
|
if (animationInput.files.length > 0) {
|
|
let fileReq = new XMLHttpRequest();
|
|
let fileFormData = new FormData();
|
|
for (let i = 0; i < animationInput.files.length; i++) {
|
|
fileFormData.append(animationInput.files[i].name, animationInput.files[i]);
|
|
}
|
|
fileReq.open("POST", '/set/animation', false);
|
|
fileReq.send(fileFormData);
|
|
spinner.style.display = 'none';
|
|
}
|
|
}, 20);
|
|
};
|
|
|
|
configInput.onchange = function (e) {
|
|
spinner.style.display = 'inline-block';
|
|
setTimeout(function () {
|
|
if (configInput.files.length > 0) {
|
|
let fileReq = new XMLHttpRequest();
|
|
let fileFormData = new FormData();
|
|
for (let i = 0; i < configInput.files.length; i++) {
|
|
fileFormData.append(configInput.files[i].name, configInput.files[i]);
|
|
}
|
|
let ips = [];
|
|
table.getSelectedRows().forEach(function (element) {
|
|
ips.push(element._row.data.ip);
|
|
});
|
|
fileFormData.append('ips', ips);
|
|
fileReq.open("POST", '/set/config', false);
|
|
fileReq.send(fileFormData);
|
|
spinner.style.display = 'none';
|
|
}
|
|
}, 20);
|
|
};
|
|
|
|
arucoInput.onchange = function (e) {
|
|
spinner.style.display = 'inline-block';
|
|
setTimeout(function () {
|
|
if (arucoInput.files.length > 0) {
|
|
let fileReq = new XMLHttpRequest();
|
|
let fileFormData = new FormData();
|
|
fileFormData.append(arucoInput.files[0].name, arucoInput.files[0]);
|
|
fileReq.open("POST", '/set/aruco', false);
|
|
fileReq.send(fileFormData);
|
|
spinner.style.display = 'none';
|
|
}
|
|
}, 20);
|
|
};
|
|
|
|
launchInput.onchange = function (e) {
|
|
spinner.style.display = 'inline-block';
|
|
setTimeout(function () {
|
|
if (launchInput.files.length > 0) {
|
|
let fileReq = new XMLHttpRequest();
|
|
let fileFormData = new FormData();
|
|
for (let i = 0; i < launchInput.files.length; i++) {
|
|
fileFormData.append(launchInput.files[i].name, launchInput.files[i]);
|
|
}
|
|
let ips = [];
|
|
table.getSelectedRows().forEach(function (element) {
|
|
ips.push(element._row.data.ip);
|
|
});
|
|
fileFormData.append('ips', ips);
|
|
fileReq.open("POST", '/set/launch', false);
|
|
fileReq.send(fileFormData);
|
|
spinner.style.display = 'none';
|
|
}
|
|
}, 20);
|
|
};
|
|
|
|
function sendRows(selectedRows, file, file_type) {
|
|
spinner.style.display = 'inline-block';
|
|
setTimeout(function () {
|
|
selectedRows.forEach(function (element) {
|
|
if (file) {
|
|
let fileReq = new XMLHttpRequest();
|
|
let fileFormData = new FormData();
|
|
fileFormData.append("file", file);
|
|
fileReq.open("POST", '/set/' + file_type + '?ip=' + element._row.data.ip, false);
|
|
fileReq.send(fileFormData);
|
|
}
|
|
element.deselect();
|
|
});
|
|
spinner.style.display = 'none';
|
|
}, 20);
|
|
}
|
|
|
|
function sendSelected() {
|
|
sendRows(table.getSelectedRows());
|
|
}
|
|
|
|
function sendAll() {
|
|
sendRows(table.getRows());
|
|
} |