mirror of
https://github.com/9001/copyparty.git
synced 2025-08-18 01:22:13 -06:00
up2k.js: defer worker startup until needed
This commit is contained in:
parent
995cd10df8
commit
635ab25013
|
@ -408,7 +408,7 @@ class HttpCli(object):
|
||||||
self.out_headers.update(NO_CACHE)
|
self.out_headers.update(NO_CACHE)
|
||||||
return
|
return
|
||||||
|
|
||||||
n = "604800" if cache == "i" else cache or "69"
|
n = "604869" if cache == "i" else cache or "69"
|
||||||
self.out_headers["Cache-Control"] = "max-age=" + n
|
self.out_headers["Cache-Control"] = "max-age=" + n
|
||||||
|
|
||||||
def k304(self) -> bool:
|
def k304(self) -> bool:
|
||||||
|
@ -1714,7 +1714,7 @@ class HttpCli(object):
|
||||||
# send reply
|
# send reply
|
||||||
|
|
||||||
if is_compressed:
|
if is_compressed:
|
||||||
self.out_headers["Cache-Control"] = "max-age=573"
|
self.out_headers["Cache-Control"] = "max-age=604869"
|
||||||
else:
|
else:
|
||||||
self.permit_caching()
|
self.permit_caching()
|
||||||
|
|
||||||
|
|
|
@ -719,12 +719,10 @@ function up2k_init(subtle) {
|
||||||
"gotallfiles": [gotallfiles] // hooks
|
"gotallfiles": [gotallfiles] // hooks
|
||||||
};
|
};
|
||||||
|
|
||||||
if (window.WebAssembly) {
|
setTimeout(function () {
|
||||||
for (var a = 0; a < Math.min(navigator.hardwareConcurrency || 4, 16); a++)
|
if (window.WebAssembly && !hws.length)
|
||||||
hws.push(new Worker('/.cpr/w.hash.js'));
|
fetch('/.cpr/w.hash.js' + CB);
|
||||||
|
}, 1000);
|
||||||
console.log(hws.length + " hashers ready");
|
|
||||||
}
|
|
||||||
|
|
||||||
function showmodal(msg) {
|
function showmodal(msg) {
|
||||||
ebi('u2notbtn').innerHTML = msg;
|
ebi('u2notbtn').innerHTML = msg;
|
||||||
|
@ -1188,6 +1186,13 @@ 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) {
|
||||||
|
for (var a = 0; a < Math.min(navigator.hardwareConcurrency || 4, 16); a++)
|
||||||
|
hws.push(new Worker('/.cpr/w.hash.js' + CB));
|
||||||
|
|
||||||
|
console.log(hws.length + " hashers");
|
||||||
|
}
|
||||||
|
|
||||||
if (!uc.az)
|
if (!uc.az)
|
||||||
good_files.sort(function (a, b) {
|
good_files.sort(function (a, b) {
|
||||||
a = a[0].size;
|
a = a[0].size;
|
||||||
|
|
|
@ -7,6 +7,7 @@ if (!window['console'])
|
||||||
|
|
||||||
|
|
||||||
var wah = '',
|
var wah = '',
|
||||||
|
CB = '?_=' + Date.now(),
|
||||||
HALFMAX = 8192 * 8192 * 8192 * 8192,
|
HALFMAX = 8192 * 8192 * 8192 * 8192,
|
||||||
HTTPS = (window.location + '').indexOf('https:') === 0,
|
HTTPS = (window.location + '').indexOf('https:') === 0,
|
||||||
TOUCH = 'ontouchstart' in window,
|
TOUCH = 'ontouchstart' in window,
|
||||||
|
@ -15,8 +16,9 @@ var wah = '',
|
||||||
IPHONE = TOUCH && /iPhone|iPad|iPod/i.test(navigator.userAgent),
|
IPHONE = TOUCH && /iPhone|iPad|iPod/i.test(navigator.userAgent),
|
||||||
WINDOWS = navigator.platform ? navigator.platform == 'Win32' : /Windows/.test(navigator.userAgent);
|
WINDOWS = navigator.platform ? navigator.platform == 'Win32' : /Windows/.test(navigator.userAgent);
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
CB = '?' + document.currentScript.src.split('?').pop();
|
||||||
|
|
||||||
if (navigator.userAgentData.mobile)
|
if (navigator.userAgentData.mobile)
|
||||||
MOBILE = true;
|
MOBILE = true;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue