mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 17:12:13 -06:00
archive format selection in browser
This commit is contained in:
parent
c8f59fb978
commit
426687b75e
|
@ -1473,6 +1473,7 @@ class HttpCli(object):
|
|||
),
|
||||
have_up2k_idx=("e2d" in vn.flags),
|
||||
have_tags_idx=("e2t" in vn.flags),
|
||||
have_zip=(not self.args.no_zip),
|
||||
logues=logues,
|
||||
title=html_escape(self.vpath),
|
||||
srv_info=srv_info,
|
||||
|
|
|
@ -41,10 +41,12 @@
|
|||
<div id="op_cfg" class="opview opbox">
|
||||
<h3>key notation</h3>
|
||||
<div id="key_notation"></div>
|
||||
{%- if have_zip %}
|
||||
<h3>folder download</h3>
|
||||
<div id="arc_fmt"></div>
|
||||
{%- endif %}
|
||||
<h3>tooltips</h3>
|
||||
<div>
|
||||
<a id="tooltips" class="tglbtn" href="#">enable</a>
|
||||
</div>
|
||||
<div><a id="tooltips" class="tglbtn" href="#">enable</a></div>
|
||||
</div>
|
||||
|
||||
<h1 id="path">
|
||||
|
|
|
@ -1149,6 +1149,7 @@ var treectl = (function () {
|
|||
|
||||
filecols.set_style();
|
||||
mukey.render();
|
||||
arcfmt.render();
|
||||
reload_tree();
|
||||
reload_browser();
|
||||
}
|
||||
|
@ -1559,6 +1560,70 @@ function addcrc() {
|
|||
})();
|
||||
|
||||
|
||||
var arcfmt = (function () {
|
||||
if (!ebi('arc_fmt'))
|
||||
return { "render": function () { } };
|
||||
|
||||
var html = [],
|
||||
arcfmts = ["tar", "zip", "zip_dos", "zip_crc"],
|
||||
arcv = ["tar", "zip=utf8", "zip", "zip=crc"];
|
||||
|
||||
for (var a = 0; a < arcfmts.length; a++) {
|
||||
var k = arcfmts[a];
|
||||
html.push(
|
||||
'<span><input type="radio" name="arcfmt" value="' + k + '" id="arcfmt_' + k + '">' +
|
||||
'<label for="arcfmt_' + k + '">' + k + '</label></span>');
|
||||
}
|
||||
ebi('arc_fmt').innerHTML = html.join('\n');
|
||||
|
||||
var fmt = sread("arc_fmt") || "zip";
|
||||
ebi('arcfmt_' + fmt).checked = true;
|
||||
|
||||
function render() {
|
||||
var arg = arcv[arcfmts.indexOf(fmt)],
|
||||
tds = document.querySelectorAll('#files tbody td:first-child a');
|
||||
|
||||
for (var a = 0, aa = tds.length; a < aa; a++) {
|
||||
var o = tds[a], txt = o.textContent, href = o.getAttribute('href');
|
||||
if (txt != 'tar' && txt != 'zip')
|
||||
continue;
|
||||
|
||||
var ofs = href.lastIndexOf('?');
|
||||
if (ofs < 0)
|
||||
throw 'missing arg in url';
|
||||
|
||||
o.setAttribute("href", href.slice(0, ofs + 1) + arg);
|
||||
o.textContent = fmt.split('_')[0];
|
||||
}
|
||||
}
|
||||
|
||||
function try_render() {
|
||||
try {
|
||||
render();
|
||||
}
|
||||
catch (ex) {
|
||||
console.log("arcfmt failed: " + ex);
|
||||
}
|
||||
}
|
||||
|
||||
function change_fmt(e) {
|
||||
ev(e);
|
||||
fmt = this.getAttribute('value');
|
||||
swrite("arc_fmt", fmt);
|
||||
try_render();
|
||||
}
|
||||
|
||||
var o = document.querySelectorAll('#arc_fmt input');
|
||||
for (var a = 0; a < o.length; a++) {
|
||||
o[a].onchange = change_fmt;
|
||||
}
|
||||
|
||||
return {
|
||||
"render": try_render
|
||||
};
|
||||
})();
|
||||
|
||||
|
||||
function ev_row_tgl(e) {
|
||||
ev(e);
|
||||
filecols.toggle(this.parentElement.parentElement.getElementsByTagName('span')[0].textContent);
|
||||
|
@ -1611,3 +1676,4 @@ function reload_browser(not_mp) {
|
|||
}
|
||||
reload_browser(true);
|
||||
mukey.render();
|
||||
arcfmt.render();
|
||||
|
|
Loading…
Reference in a new issue