This commit is contained in:
Scott Idem
2020-02-21 18:15:42 -05:00
parent 4382e97987
commit 7bb17de8f6
2 changed files with 30 additions and 4 deletions

View File

@@ -112,7 +112,7 @@ function index_open_file_buttons(class_name) {
console.log('Indexing open file buttons...');
console.log('****************** Indexing ******************');
var class_elements = document.getElementsByClassName(class_name);
console.log(class_elements);
//console.log(class_elements);
for (var i = 0; i < class_elements.length; i++) {
// Do not use an anonymous function. If you do then it will keep adding event listeners.
@@ -155,3 +155,24 @@ function format_bytes(bytes, decimals = 2) {
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
}
function shorten_filename(filename) {
let length = filename.length;
let char_over = filename.length-45;
let new_filename = null;
let wildcards = char_over;
if (char_over > 0) {
let part1 = filename.slice(0, 20);
if (char_over > 5) {
wildcards = 5;
} else {
}
let part2 = '.'.repeat(wildcards);
let part3 = filename.slice(-20);
new_filename = part1+part2+part3;
} else {
new_filename = filename;
}
return new_filename;
}