Webengineering-Filemanager/Frontend/static/js/dropdown.js
H4CK3R-01 87353a48ff - Improved documentation
- Added images
    - Fixed mistakes
- Added build script for zip file
2021-07-29 14:37:02 +02:00

31 lines
973 B
JavaScript

function download_file(path, mimetype) {
let file = path.split('/');
let filename = file[file.length - 1];
httpGetAsync(base_url + path, null, function (response, code) {
if (code === 200) {
let element = document.createElement('a');
element.setAttribute('href', 'data:' + mimetype + ',' + encodeURIComponent(response));
element.setAttribute('download', filename);
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
} else {
try_to_parse_error(response);
}
});
}
function remove_file(filename) {
httpDeleteAsync(base_url + filename, null, function (response, code) {
if (code === 200) {
create_success_view("Successfully deleted.");
path_changed();
} else {
try_to_parse_error(response);
}
});
}