2024-08-31 01:03:37 +08:00

30 lines
1.1 KiB
JavaScript
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var page = {
// 读取二进制流文件内容转换成html
getFileInfo: function(callback){
var tipsLoading = Tips.loadingMask(false,'加载中',0.5);
var xhr = new XMLHttpRequest();
xhr.open('GET', FILE_INFO.fileUrl);
xhr.responseType = "arraybuffer";
xhr.addEventListener("progress", function (evt) { //监听进度事件
if (evt.lengthComputable) {
var percent = evt.loaded / evt.total;
tipsLoading.title(Math.round(percent*100)+'%');
}
}, false);
xhr.onload = function (e) {
// var data = new Uint8Array(xhr.response);
var data = xhr.response;
if(!data){tipsLoading.close();tipsLoading = false;return;};
var file = {name: FILE_INFO.fileName, ext: FILE_INFO.fileExt, content: data};
callback(file, tipsLoading);
};
xhr.send();
},
// 错误提示
showTips: function(msg){
$("#msgbox #message").html(msg);
$("#msgbox").removeClass('hidden');
$(".page-box").addClass('hidden');
// $("body").addClass('page-loaded');
}
}