write-only QoL mostly

This commit is contained in:
ed 2021-05-12 23:06:13 +02:00
parent f94aa46a11
commit c30dc0b546
5 changed files with 58 additions and 8 deletions

View file

@ -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');
}

View file

@ -420,6 +420,8 @@ function up2k_init(have_crypto) {
ebi('u2notbtn').innerHTML = '';
}
var suggest_up2k = 'this is the basic uploader; <a href="#" id="u2yea">up2k</a> is better';
var shame = 'your browser <a href="https://www.chromium.org/blink/webcrypto">disables sha512</a> unless you <a href="' + (window.location + '').replace(':', 's:') + '">use https</a>',
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;

View file

@ -19,6 +19,10 @@
color: #f87;
padding: .5em;
}
#u2err.msg {
color: #999;
padding: .5em;
}
#u2btn {
color: #eee;
background: #555;

View file

@ -36,7 +36,7 @@
<table id="u2conf">
<tr>
<td>parallel uploads</td>
<td>parallel uploads:</td>
<td rowspan="2">
<input type="checkbox" id="multitask" />
<label for="multitask" alt="continue hashing other files while uploading">🏃</label>
@ -99,5 +99,5 @@
</table>
<p id="u2foot"></p>
<p id="u2footfoot">( if you don't need lastmod timestamps, resumable uploads or progress bars just use the <a href="#" id="u2nope">basic uploader</a>)</p>
<p id="u2footfoot">( you can use the <a href="#" id="u2nope">basic uploader</a> if you don't need lastmod timestamps, resumable uploads, or progress bars )</p>
</div>

29
docs/minimal-up2k.html Normal file
View file

@ -0,0 +1,29 @@
<!--
save this as .epilogue.html inside a
write-only folder to declutter the UI
-->
<style>
/* make the up2k ui REALLY minimal by hiding a bunch of stuff: */
#ops, #tree, #path, /* main tabs and navigators (tree/breadcrumbs) */
#u2cleanup, #u2conf tr:first-child>td[rowspan]:not(#u2btn_cw), /* most of the config options */
#u2cards /* and the upload progress tabs */
{display:none!important} /* do it! */
/* add some margins because now it's weird */
.opview {margin-top: 2.5em}
#op_up2k {margin-top: 5em}
/* and embiggen the upload button */
#u2conf #u2btn, #u2btn {padding:1.5em 0}
</style>
<a href="#" onclick="this.parentNode.innerHTML='';">show advanced options</a>