mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-13 19:40:22 +03:00
Integrates Save to File and Clear Output buttons, plus some minor iNav compatibility patches
48 lines
No EOL
1 KiB
JavaScript
48 lines
No EOL
1 KiB
JavaScript
/*global $*/
|
|
'use strict';
|
|
|
|
function constrain(input, min, max) {
|
|
|
|
if (input < min) {
|
|
return min;
|
|
}
|
|
|
|
if (input > max) {
|
|
return max;
|
|
}
|
|
|
|
return input;
|
|
}
|
|
|
|
function zeroPad(value, width) {
|
|
value = "" + value;
|
|
|
|
while (value.length < width) {
|
|
value = "0" + value;
|
|
}
|
|
|
|
return value;
|
|
}
|
|
|
|
function generateFilename(prefix, suffix) {
|
|
var date = new Date();
|
|
var filename = prefix;
|
|
|
|
if (CONFIG) {
|
|
if (CONFIG.flightControllerIdentifier) {
|
|
filename = CONFIG.flightControllerIdentifier + '_' + filename;
|
|
}
|
|
if (CONFIG.name && CONFIG.name.trim() !== '') {
|
|
filename = filename + '_' + CONFIG.name.trim().replace(' ', '_');
|
|
}
|
|
}
|
|
|
|
filename = filename + '_' + date.getFullYear()
|
|
+ zeroPad(date.getMonth() + 1, 2)
|
|
+ zeroPad(date.getDate(), 2)
|
|
+ '_' + zeroPad(date.getHours(), 2)
|
|
+ zeroPad(date.getMinutes(), 2)
|
|
+ zeroPad(date.getSeconds(), 2);
|
|
|
|
return filename + '.' + suffix;
|
|
} |