').attr('id','loading'));
+ socket.emit('open', '');
+});
+
+// Get file list
+function getFiles(directory) {
+ directory = directory.replace("//","/");
+ directory = directory.replace("|","'");
+ let directoryClean = directory.replace("'","|");
+ if ((directory !== '/') && (directory.endsWith('/'))) {
+ directory = directory.slice(0, -1);
+ }
+ $('#filebrowser').empty();
+ $('#filebrowser').append($('
').attr('id','loading'));
+ socket.emit('getfiles', directory);
+}
+
+// Render file list
+async function renderFiles(data) {
+ let dirs = data[0];
+ let files = data[1];
+ let directory = data[2];
+ let baseName = directory.split('/').slice(-1)[0];
+ let parentFolder = directory.replace(baseName,'');
+ let parentLink = $('
').addClass('directory').attr('onclick', 'getFiles(\'' + parentFolder + '\');').text('..');
+ let directoryClean = directory.replace("'","|");
+ if (directoryClean == '/') {
+ directoryClean = '';
+ }
+ let table = $('').addClass('fileTable');
+ let tableHeader = $('');
+ for await (name of ['Name', 'Type', 'Delete (NO WARNING)']) {
+ tableHeader.append($('').text(name));
+ }
+ let parentRow = $(' | ');
+ for await (item of [parentLink, $('').text('Parent'), $(' | ')]) {
+ parentRow.append(item);
+ }
+ table.append(tableHeader,parentRow);
+ $('#filebrowser').empty();
+ $('#filebrowser').data('directory', directory);
+ $('#filebrowser').append($('').text(directory));
+ $('#filebrowser').append(table);
+ if (dirs.length > 0) {
+ for await (let dir of dirs) {
+ let tableRow = $(' ');
+ let dirClean = dir.replace("'","|");
+ let link = $('').addClass('directory').attr('onclick', 'getFiles(\'' + directoryClean + '/' + dirClean + '\');').text(dir);
+ let type = $(' | ').text('Dir');
+ let del = $(' | ').append($(' | | |