From c8f51adfaacde53f5477f7ce533e0daaeab58acb Mon Sep 17 00:00:00 2001 From: df Date: Fri, 16 Apr 2021 10:29:27 +0000 Subject: [PATCH] Add Download button --- webif/html/browse/script.js | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/webif/html/browse/script.js b/webif/html/browse/script.js index be4a9bf..daf0075 100755 --- a/webif/html/browse/script.js +++ b/webif/html/browse/script.js @@ -10,7 +10,7 @@ var plugins = { dmenu_prepare: {} }; -// pattern matches directory path prefix +// pattern matches directory path prefix and suffix var pathre = /.*\/|\.[^.]*$/g; // IDs of size, img elements for folders use RFC4648 s5 encoding of name @@ -808,6 +808,15 @@ var $dialog = $('#dialogue').dialog({ 'Retrieving data...'); } }); +/* insert button-like Download link before Play */ +$('#play').before(function(i){ + var dl = document.createElement('a'); + dl.setAttribute('class', this.className); + dl.id = this.id + 'DL'; + dl.innerHTML = 'Download'; + return dl; +}); + function doplay(it) { var file = $dialog.attr('file'); @@ -864,12 +873,18 @@ $('a.bf').click(function(e) { type: type }); - $dialog.attr('file', file); - $dialog.attr('type', type); + if (type == 'ts') { + if (opt.attr('odencd') != 0) { + /* encrypted: link to be enabled once populated */ + $('#playDL').disable(); + /* ... but if no DLNA never Play */ + if (opt.attr('dlna') != 1) $('#play').disable(); + } + } else { + /* generic: enable Play once media file is parsed */ + $('#play').disable(); + } - if (!(type == 'ts' && - (opt.attr('odencd') == 0 || opt.attr('dlna') == 1))) - $('#play').button('disable'); $dialog.dialog('open'); });