diff --git a/.vscode/settings.json b/.vscode/settings.json index c0e7979d..2a96d0e2 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -22,7 +22,7 @@ "terminal.ansiBrightCyan": "#9cf0ed", "terminal.ansiBrightWhite": "#ffffff", }, - "python.testing.pyTestEnabled": false, + "python.testing.pytestEnabled": false, "python.testing.nosetestsEnabled": false, "python.testing.unittestEnabled": true, "python.testing.unittestArgs": [ diff --git a/copyparty/web/up2k.js b/copyparty/web/up2k.js index 8229df5f..218414c6 100644 --- a/copyparty/web/up2k.js +++ b/copyparty/web/up2k.js @@ -37,20 +37,60 @@ window.onerror = function (msg, url, lineNo, columnNo, error) { hcroak(html.join('\n')); }; + +// https://stackoverflow.com/a/950146 +function import_js(url, cb) { + var head = document.head || document.getElementsByTagName('head')[0]; + var script = document.createElement('script'); + script.type = 'text/javascript'; + script.src = url; + + script.onreadystatechange = cb; + script.onload = cb; + + head.appendChild(script); +} + + function o(id) { return document.getElementById(id); } + (function () { - // hide basic uploader - o('up2k').style.display = 'block'; - o('bup').style.display = 'none'; + // show modal message + function showmodal(msg) { + o('u2notbtn').innerHTML = msg; + o('u2btn').style.display = 'none'; + o('u2notbtn').style.display = 'block'; + o('u2conf').style.opacity = '0.5'; + } + + // hide modal message + function unmodal() { + o('u2notbtn').style.display = 'none'; + o('u2btn').style.display = 'block'; + o('u2conf').style.opacity = '1'; + o('u2notbtn').innerHTML = ''; + } + + // might need sha512 polyfill when non-https (thx webkit (again)) + var have_crypto = window.crypto && crypto.subtle && crypto.subtle.digest; + var shame = 'your browser disables sha512 unless you use https' + //have_crypto = false; // upload ui hidden by default, clicking the header shows it o('u2tgl').onclick = function (e) { e.preventDefault(); o('u2tgl').style.display = 'none'; o('u2body').style.display = 'block'; + + if (!have_crypto && !window.asmCrypto) { + showmodal('
( if you don't need resumable uploads and progress bars just use the basic uploader)