util.js ensures `WebAssembly`, `Notification`, and `FormData`
are always declared, setting them false when not available
This commit is contained in:
ed 2024-04-02 20:25:06 +00:00
parent a080759a03
commit 34c32e3e89
3 changed files with 13 additions and 13 deletions

View file

@ -7480,7 +7480,7 @@ var msel = (function () {
(function () { (function () {
if (!window.FormData) if (!FormData)
return; return;
var form = QS('#op_new_md>form'), var form = QS('#op_new_md>form'),
@ -7502,7 +7502,7 @@ var msel = (function () {
(function () { (function () {
if (!window.FormData) if (!FormData)
return; return;
var form = QS('#op_mkdir>form'), var form = QS('#op_mkdir>form'),
@ -7696,7 +7696,7 @@ function show_md(md, name, div, url, depth) {
if (depth) { if (depth) {
clmod(div, 'raw', 1); clmod(div, 'raw', 1);
div.textContent = "--[ " + name + " ]---------\r\n" + md; 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--; wfp_debounce.n--;

View file

@ -17,7 +17,7 @@ function goto_up2k() {
var up2k = null, var up2k = null,
up2k_hooks = [], up2k_hooks = [],
hws = [], 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'; m = 'will use ' + sha_js + ' instead of native sha512 due to';
try { try {
@ -717,7 +717,7 @@ function Donut(uc, st) {
sfx(); sfx();
// firefox may forget that filedrops are user-gestures so it can skip this: // 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); new Notification(uc.nagtxt);
} }
@ -779,7 +779,7 @@ function up2k_init(subtle) {
}; };
setTimeout(function () { setTimeout(function () {
if (window.WebAssembly && !hws.length) if (WebAssembly && !hws.length)
fetch(SR + '/.cpr/w.hash.js' + CB); fetch(SR + '/.cpr/w.hash.js' + CB);
}, 1000); }, 1000);
@ -869,7 +869,7 @@ function up2k_init(subtle) {
bcfg_bind(uc, 'turbo', 'u2turbo', turbolvl > 1, draw_turbo); bcfg_bind(uc, 'turbo', 'u2turbo', turbolvl > 1, draw_turbo);
bcfg_bind(uc, 'datechk', 'u2tdate', turbolvl < 3, null); bcfg_bind(uc, 'datechk', 'u2tdate', turbolvl < 3, null);
bcfg_bind(uc, 'az', 'u2sort', u2sort.indexOf('n') + 1, set_u2sort); 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, 'upnag', 'upnag', false, set_upnag);
bcfg_bind(uc, 'upsfx', 'upsfx', false, set_upsfx); bcfg_bind(uc, 'upsfx', 'upsfx', false, set_upsfx);
@ -1347,7 +1347,7 @@ function up2k_init(subtle) {
var evpath = get_evpath(), var evpath = get_evpath(),
draw_each = good_files.length < 50; 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++) for (var a = 0; a < Math.min(navigator.hardwareConcurrency || 4, 16); a++)
hws.push(new Worker(SR + '/.cpr/w.hash.js' + CB)); hws.push(new Worker(SR + '/.cpr/w.hash.js' + CB));
@ -2950,7 +2950,7 @@ function up2k_init(subtle) {
} }
function set_hashw() { function set_hashw() {
if (!window.WebAssembly) { if (!WebAssembly) {
bcfg_set('hashw', uc.hashw = false); bcfg_set('hashw', uc.hashw = false);
toast.err(10, L.u_nowork); toast.err(10, L.u_nowork);
} }
@ -2967,7 +2967,7 @@ function up2k_init(subtle) {
nopenag(); nopenag();
} }
if (!window.Notification || !HTTPS) if (!Notification || !HTTPS)
return nopenag(); return nopenag();
if (en && Notification.permission == 'default') 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); bcfg_set('upnag', uc.upnag = false);
ebi('nthread_add').onclick = function (e) { ebi('nthread_add').onclick = function (e) {

View file

@ -182,7 +182,7 @@ function vis_exh(msg, url, lineNo, columnNo, error) {
if (url.indexOf('easymde.js') + 1) if (url.indexOf('easymde.js') + 1)
return; // clicking the preview pane 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 return; // ff<52
crashed = true; crashed = true;
@ -1474,7 +1474,7 @@ var toast = (function () {
clmod(obj, 'vis'); clmod(obj, 'vis');
r.visible = false; r.visible = false;
r.tag = obj; r.tag = obj;
if (!window.WebAssembly) if (!WebAssembly)
te = setTimeout(function () { te = setTimeout(function () {
obj.className = 'hide'; obj.className = 'hide';
}, 500); }, 500);