You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.0 KiB
JavaScript
48 lines
1.0 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;
|
|
} |