mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 09:02:15 -06:00
golf:
util.js ensures `WebAssembly`, `Notification`, and `FormData` are always declared, setting them false when not available
This commit is contained in:
parent
a080759a03
commit
34c32e3e89
|
@ -7480,7 +7480,7 @@ var msel = (function () {
|
|||
|
||||
|
||||
(function () {
|
||||
if (!window.FormData)
|
||||
if (!FormData)
|
||||
return;
|
||||
|
||||
var form = QS('#op_new_md>form'),
|
||||
|
@ -7502,7 +7502,7 @@ var msel = (function () {
|
|||
|
||||
|
||||
(function () {
|
||||
if (!window.FormData)
|
||||
if (!FormData)
|
||||
return;
|
||||
|
||||
var form = QS('#op_mkdir>form'),
|
||||
|
@ -7696,7 +7696,7 @@ function show_md(md, name, div, url, depth) {
|
|||
if (depth) {
|
||||
clmod(div, 'raw', 1);
|
||||
div.textContent = "--[ " + name + " ]---------\r\n" + md;
|
||||
return toast.warn(10, errmsg + (window.WebAssembly ? 'failed to load marked.js' : 'your browser is too old'));
|
||||
return toast.warn(10, errmsg + (WebAssembly ? 'failed to load marked.js' : 'your browser is too old'));
|
||||
}
|
||||
|
||||
wfp_debounce.n--;
|
||||
|
|
|
@ -17,7 +17,7 @@ function goto_up2k() {
|
|||
var up2k = null,
|
||||
up2k_hooks = [],
|
||||
hws = [],
|
||||
sha_js = window.WebAssembly ? 'hw' : 'ac', // ff53,c57,sa11
|
||||
sha_js = WebAssembly ? 'hw' : 'ac', // ff53,c57,sa11
|
||||
m = 'will use ' + sha_js + ' instead of native sha512 due to';
|
||||
|
||||
try {
|
||||
|
@ -717,7 +717,7 @@ function Donut(uc, st) {
|
|||
sfx();
|
||||
|
||||
// firefox may forget that filedrops are user-gestures so it can skip this:
|
||||
if (uc.upnag && window.Notification && Notification.permission == 'granted')
|
||||
if (uc.upnag && Notification && Notification.permission == 'granted')
|
||||
new Notification(uc.nagtxt);
|
||||
}
|
||||
|
||||
|
@ -779,7 +779,7 @@ function up2k_init(subtle) {
|
|||
};
|
||||
|
||||
setTimeout(function () {
|
||||
if (window.WebAssembly && !hws.length)
|
||||
if (WebAssembly && !hws.length)
|
||||
fetch(SR + '/.cpr/w.hash.js' + CB);
|
||||
}, 1000);
|
||||
|
||||
|
@ -869,7 +869,7 @@ function up2k_init(subtle) {
|
|||
bcfg_bind(uc, 'turbo', 'u2turbo', turbolvl > 1, draw_turbo);
|
||||
bcfg_bind(uc, 'datechk', 'u2tdate', turbolvl < 3, null);
|
||||
bcfg_bind(uc, 'az', 'u2sort', u2sort.indexOf('n') + 1, set_u2sort);
|
||||
bcfg_bind(uc, 'hashw', 'hashw', !!window.WebAssembly && (!subtle || !CHROME || MOBILE || VCHROME >= 107), set_hashw);
|
||||
bcfg_bind(uc, 'hashw', 'hashw', !!WebAssembly && (!subtle || !CHROME || MOBILE || VCHROME >= 107), set_hashw);
|
||||
bcfg_bind(uc, 'upnag', 'upnag', false, set_upnag);
|
||||
bcfg_bind(uc, 'upsfx', 'upsfx', false, set_upsfx);
|
||||
|
||||
|
@ -1347,7 +1347,7 @@ function up2k_init(subtle) {
|
|||
var evpath = get_evpath(),
|
||||
draw_each = good_files.length < 50;
|
||||
|
||||
if (window.WebAssembly && !hws.length) {
|
||||
if (WebAssembly && !hws.length) {
|
||||
for (var a = 0; a < Math.min(navigator.hardwareConcurrency || 4, 16); a++)
|
||||
hws.push(new Worker(SR + '/.cpr/w.hash.js' + CB));
|
||||
|
||||
|
@ -2950,7 +2950,7 @@ function up2k_init(subtle) {
|
|||
}
|
||||
|
||||
function set_hashw() {
|
||||
if (!window.WebAssembly) {
|
||||
if (!WebAssembly) {
|
||||
bcfg_set('hashw', uc.hashw = false);
|
||||
toast.err(10, L.u_nowork);
|
||||
}
|
||||
|
@ -2967,7 +2967,7 @@ function up2k_init(subtle) {
|
|||
nopenag();
|
||||
}
|
||||
|
||||
if (!window.Notification || !HTTPS)
|
||||
if (!Notification || !HTTPS)
|
||||
return nopenag();
|
||||
|
||||
if (en && Notification.permission == 'default')
|
||||
|
@ -2989,7 +2989,7 @@ function up2k_init(subtle) {
|
|||
};
|
||||
}
|
||||
|
||||
if (uc.upnag && (!window.Notification || Notification.permission != 'granted'))
|
||||
if (uc.upnag && (!Notification || Notification.permission != 'granted'))
|
||||
bcfg_set('upnag', uc.upnag = false);
|
||||
|
||||
ebi('nthread_add').onclick = function (e) {
|
||||
|
|
|
@ -182,7 +182,7 @@ function vis_exh(msg, url, lineNo, columnNo, error) {
|
|||
if (url.indexOf('easymde.js') + 1)
|
||||
return; // clicking the preview pane
|
||||
|
||||
if (url.indexOf('deps/marked.js') + 1 && !window.WebAssembly)
|
||||
if (url.indexOf('deps/marked.js') + 1 && !WebAssembly)
|
||||
return; // ff<52
|
||||
|
||||
crashed = true;
|
||||
|
@ -1474,7 +1474,7 @@ var toast = (function () {
|
|||
clmod(obj, 'vis');
|
||||
r.visible = false;
|
||||
r.tag = obj;
|
||||
if (!window.WebAssembly)
|
||||
if (!WebAssembly)
|
||||
te = setTimeout(function () {
|
||||
obj.className = 'hide';
|
||||
}, 500);
|
||||
|
|
Loading…
Reference in a new issue