mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 09:02:15 -06:00
up2k: folder-upload without drag/drop
This commit is contained in:
parent
8ee9de4291
commit
37c84021a2
|
@ -25,6 +25,9 @@ var Ls = {
|
|||
"hz": "sample rate"
|
||||
},
|
||||
|
||||
"m_ok": "OK",
|
||||
"m_ng": "Cancel",
|
||||
|
||||
"ht_s": "second!s",
|
||||
"ht_m": "minute!s",
|
||||
"ht_h": "hour!s",
|
||||
|
@ -101,6 +104,9 @@ var Ls = {
|
|||
"udt_srch": "Search",
|
||||
"udt_drop": "drop it here",
|
||||
|
||||
"u_nav_m": '<h6>aight, what do you have?</h6><code>Enter</code> = Files (one or more)\n<code>ESC</code> = One folder (including subfolders)',
|
||||
"u_nav_b": '<a href="#" id="modal-ok">Files</a><a href="#" id="modal-ng">One folder</a>',
|
||||
|
||||
"cl_opts": "switches",
|
||||
"cl_themes": "theme",
|
||||
"cl_langs": "language",
|
||||
|
@ -394,6 +400,9 @@ var Ls = {
|
|||
"hz": "lyd-oppløsning"
|
||||
},
|
||||
|
||||
"m_ok": "OK",
|
||||
"m_ng": "Avbryt",
|
||||
|
||||
"ht_s": "sekund!er",
|
||||
"ht_m": "minutt!er",
|
||||
"ht_h": "time!r",
|
||||
|
@ -470,6 +479,9 @@ var Ls = {
|
|||
"udt_srch": "Søk",
|
||||
"udt_drop": "Slipp filene her",
|
||||
|
||||
"u_nav_m": '<h6>hva har du?</h6><code>Enter</code> = Filer (én eller flere)\n<code>ESC</code> = Én mappe (inkludert undermapper)',
|
||||
"u_nav_b": '<a href="#" id="modal-ok">Filer</a><a href="#" id="modal-ng">Én mappe</a>',
|
||||
|
||||
"cl_opts": "brytere",
|
||||
"cl_themes": "utseende",
|
||||
"cl_langs": "språk",
|
||||
|
@ -747,6 +759,7 @@ if (Ls.eng && L != Ls.eng) {
|
|||
if (!L[k])
|
||||
L[k] = Ls.eng[k];
|
||||
}
|
||||
modal.load();
|
||||
|
||||
|
||||
// toolbar
|
||||
|
|
|
@ -236,6 +236,10 @@ html.y #tth {
|
|||
max-height: 30em;
|
||||
overflow: auto;
|
||||
}
|
||||
#modalc td {
|
||||
text-align: unset;
|
||||
padding: .2em;
|
||||
}
|
||||
@media (min-width: 40em) {
|
||||
#modalc {
|
||||
min-width: 30em;
|
||||
|
|
|
@ -941,7 +941,16 @@ function up2k_init(subtle) {
|
|||
|
||||
function nav() {
|
||||
start_actx();
|
||||
ebi('file' + fdom_ctr).click();
|
||||
|
||||
// too buggy on chrome <= 72
|
||||
var m = / Chrome\/([0-9]+)\./.exec(navigator.userAgent);
|
||||
if (m && parseInt(m[1]) < 73)
|
||||
return ebi('file' + fdom_ctr).click();
|
||||
|
||||
modal.confirm(L.u_nav_m,
|
||||
function () { ebi('file' + fdom_ctr).click(); },
|
||||
function () { ebi('dir' + fdom_ctr).click(); },
|
||||
null, L.u_nav_b);
|
||||
}
|
||||
ebi('u2btn').onclick = nav;
|
||||
|
||||
|
@ -1034,6 +1043,28 @@ function up2k_init(subtle) {
|
|||
}
|
||||
ebi('drops').onclick = offdrag; // old ff
|
||||
|
||||
function gotdir(e) {
|
||||
ev(e);
|
||||
var good_files = [],
|
||||
nil_files = [],
|
||||
bad_files = [];
|
||||
|
||||
for (var a = 0, aa = e.target.files.length; a < aa; a++) {
|
||||
var fobj = e.target.files[a],
|
||||
dst = good_files;
|
||||
|
||||
try {
|
||||
if (fobj.size < 1)
|
||||
dst = nil_files;
|
||||
}
|
||||
catch (ex) {
|
||||
dst = bad_files;
|
||||
}
|
||||
dst.push([fobj, fobj.webkitRelativePath]);
|
||||
}
|
||||
return read_dirs(null, [], [], good_files, nil_files, bad_files);
|
||||
}
|
||||
|
||||
function gotfile(e) {
|
||||
ev(e);
|
||||
nenters = 0;
|
||||
|
@ -1350,9 +1381,13 @@ function up2k_init(subtle) {
|
|||
function more_one_file() {
|
||||
fdom_ctr++;
|
||||
var elm = mknod('div');
|
||||
elm.innerHTML = '<input id="file{0}" type="file" name="file{0}[]" multiple="multiple" tabindex="-1" />'.format(fdom_ctr);
|
||||
elm.innerHTML = (
|
||||
'<input id="file{0}" type="file" name="file{0}[]" multiple="multiple" tabindex="-1" />' +
|
||||
'<input id="dir{0}" type="file" name="dir{0}[]" multiple="multiple" tabindex="-1" webkitdirectory />'
|
||||
).format(fdom_ctr);
|
||||
ebi('u2form').appendChild(elm);
|
||||
ebi('file' + fdom_ctr).onchange = gotfile;
|
||||
ebi('dir' + fdom_ctr).onchange = gotdir;
|
||||
}
|
||||
more_one_file();
|
||||
|
||||
|
|
|
@ -1248,9 +1248,16 @@ var modal = (function () {
|
|||
cb_up = null,
|
||||
cb_ok = null,
|
||||
cb_ng = null,
|
||||
prim = '<a href="#" id="modal-ok">OK</a>',
|
||||
sec = '<a href="#" id="modal-ng">Cancel</a>',
|
||||
tok, tng, prim, sec, ok_cancel;
|
||||
|
||||
r.load = function () {
|
||||
tok = (window.L && L.m_ok) || 'OK';
|
||||
tng = (window.L && L.m_ng) || 'Cancel';
|
||||
prim = '<a href="#" id="modal-ok">' + tok + '</a>';
|
||||
sec = '<a href="#" id="modal-ng">' + tng + '</a>';
|
||||
ok_cancel = WINDOWS ? prim + sec : sec + prim;
|
||||
};
|
||||
r.load();
|
||||
|
||||
r.busy = false;
|
||||
|
||||
|
@ -1357,17 +1364,17 @@ var modal = (function () {
|
|||
r.show(html);
|
||||
}
|
||||
|
||||
r.confirm = function (html, cok, cng, fun) {
|
||||
r.confirm = function (html, cok, cng, fun, btns) {
|
||||
q.push(function () {
|
||||
_confirm(lf2br(html), cok, cng, fun);
|
||||
_confirm(lf2br(html), cok, cng, fun, btns);
|
||||
});
|
||||
next();
|
||||
}
|
||||
function _confirm(html, cok, cng, fun) {
|
||||
function _confirm(html, cok, cng, fun, btns) {
|
||||
cb_ok = cok;
|
||||
cb_ng = cng === undefined ? cok : cng;
|
||||
cb_up = fun;
|
||||
html += '<div id="modalb">' + ok_cancel + '</div>';
|
||||
html += '<div id="modalb">' + (btns || ok_cancel) + '</div>';
|
||||
r.show(html);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue