Introduce a helper function bindButton to do the button event binding with nice error logging.

This commit is contained in:
Isaac Connor 2021-01-16 13:15:34 -05:00
parent 1e59c5bbde
commit 6586aa6338
1 changed files with 10 additions and 0 deletions

View File

@ -813,6 +813,16 @@ function manageModalBtns(id) {
}); });
} }
function bindButton(selector, action, data, func) {
var elements = $j(selector);
if ( !elements.length ) {
console.log("Nothing found for " + selector);
return;
}
elements.on(action, data, func);
}
function human_filesize(size, precision = 2) { function human_filesize(size, precision = 2) {
var units = Array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); var units = Array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
var step = 1024; var step = 1024;