diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index 1c6eeb74..d5811b94 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -1326,6 +1326,7 @@ function apply_perms(perms) { document.body.setAttribute('perms', perms.join(' ')); var have_write = has(perms, "write"), + have_read = has(perms, "read"), tds = QSA('#u2conf td'); for (var a = 0; a < tds.length; a++) { @@ -1336,6 +1337,11 @@ function apply_perms(perms) { if (window['up2k']) up2k.set_fsearch(); + + ebi('widget').style.display = have_read ? '' : 'none'; + ebi('files').style.display = have_read ? '' : 'none'; + if (!have_read) + goto('up2k'); } diff --git a/copyparty/web/up2k.js b/copyparty/web/up2k.js index 54d0e6a0..31b54fcc 100644 --- a/copyparty/web/up2k.js +++ b/copyparty/web/up2k.js @@ -420,6 +420,8 @@ function up2k_init(have_crypto) { ebi('u2notbtn').innerHTML = ''; } + var suggest_up2k = 'this is the basic uploader; up2k is better'; + var shame = 'your browser disables sha512 unless you use https', is_https = (window.location + '').indexOf('https:') === 0; @@ -441,34 +443,43 @@ function up2k_init(have_crypto) { } // show uploader if the user only has write-access - if (!ebi('files')) + var perms = (document.body.getAttribute('perms') + '').split(' '); + if (!has(perms, 'read')) goto('up2k'); - // shows or clears an error message in the basic uploader ui - function setmsg(msg) { + // shows or clears a message in the basic uploader ui + function setmsg(msg, type) { if (msg !== undefined) { - ebi('u2err').setAttribute('class', 'err'); + ebi('u2err').setAttribute('class', type); ebi('u2err').innerHTML = msg; } else { ebi('u2err').setAttribute('class', ''); ebi('u2err').innerHTML = ''; } + if (msg == suggest_up2k) { + ebi('u2yea').onclick = function (e) { + ev(e); + goto('up2k'); + }; + } } // switches to the basic uploader with msg as error message function un2k(msg) { - setmsg(msg); + setmsg(msg, 'err'); return false; } // handle user intent to use the basic uploader instead ebi('u2nope').onclick = function (e) { ev(e); - setmsg(); + setmsg(suggest_up2k, 'msg'); goto('bup'); }; + setmsg(suggest_up2k, 'msg'); + if (!String.prototype.format) { String.prototype.format = function () { var args = arguments; diff --git a/copyparty/web/upload.css b/copyparty/web/upload.css index 99c72770..ed279348 100644 --- a/copyparty/web/upload.css +++ b/copyparty/web/upload.css @@ -19,6 +19,10 @@ color: #f87; padding: .5em; } +#u2err.msg { + color: #999; + padding: .5em; +} #u2btn { color: #eee; background: #555; diff --git a/copyparty/web/upload.html b/copyparty/web/upload.html index 22354b46..e940eaad 100644 --- a/copyparty/web/upload.html +++ b/copyparty/web/upload.html @@ -36,7 +36,7 @@
parallel uploads | +parallel uploads: | @@ -99,5 +99,5 @@ |
( if you don't need lastmod timestamps, resumable uploads or progress bars just use the basic uploader)
+( you can use the basic uploader if you don't need lastmod timestamps, resumable uploads, or progress bars )
diff --git a/docs/minimal-up2k.html b/docs/minimal-up2k.html new file mode 100644 index 00000000..72ef1b12 --- /dev/null +++ b/docs/minimal-up2k.html @@ -0,0 +1,29 @@ + + + + +show advanced options