From 34829639f8f7028435dca6cd1e0572a4f2f92937 Mon Sep 17 00:00:00 2001
From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com>
Date: Wed, 1 Jul 2020 16:49:39 +0800
Subject: [PATCH] Update onemoe.html
---
theme/onemoe.html | 127 ++++++++++++++++++++++------------------------
1 file changed, 61 insertions(+), 66 deletions(-)
diff --git a/theme/onemoe.html b/theme/onemoe.html
index d06d1ee..431b2cc 100644
--- a/theme/onemoe.html
+++ b/theme/onemoe.html
@@ -25,23 +25,9 @@
-
+
-
+
@@ -123,7 +109,7 @@
-
+
@@ -448,11 +434,14 @@
function changelanguage(str)
{
if (str=='Language') str = '';
- document.cookie='language='+str+'; path=/';
+ var expd = new Date();
+ expd.setTime(expd.getTime()+(2*60*60*1000));
+ var expires = "expires="+expd.toGMTString();
+ document.cookie='language='+str+'; path=/; '+expires;
location.href = location.href;
}
- var root = '';
+ /*var root = '';
function path_format(path) {
path = '/' + path + '/';
while (path.indexOf('//') !== -1) {
@@ -472,7 +461,7 @@
}
e.innerHTML += paths[paths.length - 1];
e.innerHTML = e.innerHTML.replace(/\s\/\s$/, '')
- });
+ });*/
var $url = document.getElementById('url');
if ($url) {
@@ -793,20 +782,55 @@
tr1.setAttribute('data-to',1);
var td1=document.createElement('td');
tr1.appendChild(td1);
- td1.setAttribute('style','width:30%');
+ td1.setAttribute('style','width:30%;word-break:break-word;');
td1.setAttribute('id','upfile_td1_'+timea+'_'+i);
td1.innerHTML=(file.webkitRelativePath||file.name)+'
'+size_format(file.size);
var td2=document.createElement('td');
tr1.appendChild(td2);
td2.setAttribute('id','upfile_td2_'+timea+'_'+i);
- td2.innerHTML=' ...';
if (file.size>100*1024*1024*1024) {
td2.innerHTML='
';
uploadbuttonshow();
return;
}
+ upbigfilename = encodeURIComponent((file.webkitRelativePath||file.name));
+
+ function getext(str) {
+ strarry=str.split('.');
+ ext=strarry[strarry.length-1].toLowerCase();
+ var reg = new RegExp(".","g");
+ var a = str.replace(reg,"");
+ if (a == ext) ext = "";
+ else ext = "." + ext;
+ return ext;
+ }
+ var ext = getext(file.webkitRelativePath||file.name);
+ var spark = new SparkMD5.ArrayBuffer();
+ var reader = new FileReader();
+ var chunksize=10*1024*1024;
+ var asize = 0;
+ function readblob(start) {
+ var end=start+chunksize;
+ var blob = file.slice(start,end);
+ reader.readAsArrayBuffer(blob);
+ }
+ readblob(asize);
+
+ reader.onload = function(e){
+ td2.innerHTML=' md5: '+(asize*100/file.size).toFixed(2)+'%';
+ var binary = this.result;
+ spark.append(binary);
+ asize += chunksize;
+ if (asize < file.size) {
+ readblob(asize);
+ } else {
+ var filemd5 = spark.end();
+ td2.innerHTML='md5: '+filemd5;
+ upbigfilename = filemd5+ext;
+
+ td2.innerHTML=' ...';
var xhr1 = new XMLHttpRequest();
- xhr1.open("GET", '?action=upbigfile&upbigfilename='+ encodeURIComponent((file.webkitRelativePath||file.name)) +'&filesize='+ file.size +'&lastModified='+ file.lastModified);
+ xhr1.open("GET", '?action=upbigfile&upbigfilename='+ upbigfilename +'&filesize='+ file.size +'&lastModified='+ file.lastModified);
xhr1.setRequestHeader('x-requested-with','XMLHttpRequest');
xhr1.send(null);
xhr1.onload = function(e){
@@ -819,14 +843,23 @@
uploadbuttonshow();
} else {
td2.innerHTML=' ...';
- binupfile(file,html['uploadUrl'],timea+'_'+i);
+ binupfile(file,html['uploadUrl'],timea+'_'+i, upbigfilename);
}
}
+ if (xhr1.status==409) {
+ td2.innerHTML='md5: '+filemd5;
+ tdnum = timea+'_'+i;
+ document.getElementById('upfile_td1_'+tdnum).innerHTML='
';
+ }
if (i
+ }
+ }
+
}
}
function size_format(num) {
@@ -847,7 +880,7 @@
}
return num.toFixed(2) + ' GB';
}
- function binupfile(file,url,tdnum){
+ function binupfile(file,url,tdnum,filename){
var label=document.getElementById('upfile_td2_'+tdnum);
var reader = new FileReader();
var StartStr='';
@@ -868,9 +901,7 @@
var a = html['nextExpectedRanges'][0];
newstartsize = Number( a.slice(0,a.indexOf("-")) );
StartTime = new Date();
-
asize = newstartsize;
-
if (newstartsize==0) {
StartStr=':' +StartTime.toLocaleString()+'
' ;
} else {
@@ -884,19 +915,9 @@
reader.readAsArrayBuffer(blob);
}
readblob(asize);
-
- var spark = new SparkMD5.ArrayBuffer();
-
+
reader.onload = function(e){
var binary = this.result;
-
- spark.append(binary);
- if (asize < newstartsize) {
- asize += chunksize;
- readblob(asize);
- return;
- }
-
var xhr = new XMLHttpRequest();
xhr.open("PUT", url, true);
//xhr.setRequestHeader('x-requested-with','XMLHttpRequest');
@@ -917,38 +938,12 @@
if (response['size']>0) {
// contain size, upload finish. 有size说明是最终返回,上传结束
var xhr3 = new XMLHttpRequest();
- xhr3.open("GET", '?action=del_upload_cache&filelastModified='+file.lastModified+'&filesize='+file.size+'&filename='+encodeURIComponent((file.webkitRelativePath||file.name)));
+ xhr3.open("GET", '?action=del_upload_cache&filelastModified='+file.lastModified+'&filesize='+file.size+'&filename='+filename);
xhr3.setRequestHeader('x-requested-with','XMLHttpRequest');
xhr3.send(null);
xhr3.onload = function(e){
console.log(xhr3.responseText+','+xhr3.status);
}
-
- var filemd5 = spark.end();
- var xhr4 = new XMLHttpRequest();
- xhr4.open("GET", '?action=uploaded_rename&filename='+encodeURIComponent((file.webkitRelativePath||file.name))+'&filemd5='+filemd5);
- xhr4.setRequestHeader('x-requested-with','XMLHttpRequest');
- xhr4.send(null);
- xhr4.onload = function(e){
- console.log(xhr4.responseText+','+xhr4.status);
- var filename;
- //if (xhr4.status==200) filename = JSON.parse(xhr4.responseText)['name'];
- //if (xhr4.status==409) filename = filemd5 + (file.webkitRelativePath||file.name).substr((file.webkitRelativePath||file.name).indexOf('.'));
- filename = JSON.parse(xhr4.responseText)['name'];
- if (filename=='') {
- alert('');
- uploadbuttonshow();
- return;
- }
- var lasturl = location.href;
- if (lasturl.substr(lasturl.length-1)!='/') lasturl += '/';
- lasturl += filename + '?preview';
- //window.open(lasturl);
- document.getElementById('upfile_a_'+tdnum).href = lasturl;
- document.getElementById('upfile_a1_'+tdnum).href = filename;
- document.getElementById('upfile_cpbt_'+tdnum).style.display = "";
- }
-
EndTime=new Date();
MiddleStr = ':'+EndTime.toLocaleString()+'
';
if (newstartsize==0) {
@@ -976,7 +971,7 @@
xhr.send(binary);
}
} else {
- if (window.location.pathname.indexOf('%23')>0||(file.webkitRelativePath||file.name).indexOf('%23')>0) {
+ if (window.location.pathname.indexOf('%23')>0||filename.indexOf('%23')>0) {
label.innerHTML='';
} else {
label.innerHTML=''+xhr2.responseText+'';