mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 17:12:13 -06:00
show loading progress for huge documents
This commit is contained in:
parent
23e4b9002f
commit
331cf37054
|
@ -2503,17 +2503,34 @@ var showfile = (function () {
|
||||||
r.show = function (url, no_push) {
|
r.show = function (url, no_push) {
|
||||||
var xhr = new XHR();
|
var xhr = new XHR();
|
||||||
xhr.url = url;
|
xhr.url = url;
|
||||||
|
xhr.fname = uricom_dec(url.split('/').pop())[0];
|
||||||
xhr.no_push = no_push;
|
xhr.no_push = no_push;
|
||||||
xhr.ts = Date.now();
|
xhr.ts = Date.now();
|
||||||
xhr.open('GET', url.split('?')[0] + '?raw', true);
|
xhr.open('GET', url.split('?')[0] + '?raw', true);
|
||||||
xhr.onreadystatechange = load_cb;
|
xhr.onprogress = loading;
|
||||||
|
xhr.onloadend = load_cb;
|
||||||
xhr.send();
|
xhr.send();
|
||||||
};
|
};
|
||||||
|
|
||||||
function load_cb() {
|
function loading(e) {
|
||||||
if (this.readyState != XHR.DONE)
|
if (e.total < 1024 * 256)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
var m = 'Loading text document:\n\n' + esc(this.fname) + '\n\n' +
|
||||||
|
f2f(e.loaded / 1024 / 1024, 1) + ' of ' +
|
||||||
|
f2f(e.total / 1024 / 1024, 1) + ' MiB loaded';
|
||||||
|
|
||||||
|
if (!this.toasted) {
|
||||||
|
this.toasted = 1;
|
||||||
|
return toast.inf(573, m);
|
||||||
|
}
|
||||||
|
ebi('toastb').innerHTML = lf2br(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
function load_cb(e) {
|
||||||
|
if (this.toasted)
|
||||||
|
toast.hide();
|
||||||
|
|
||||||
if (!xhrchk(this, "could not load textfile:\n\nerror ", "404, file not found"))
|
if (!xhrchk(this, "could not load textfile:\n\nerror ", "404, file not found"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue