filesbox/web/dist/photopea/code/start.js

2 lines
4.4 KiB
JavaScript
Raw Permalink Normal View History

2024-07-26 06:10:54 +00:00
(function(){var t=function(){for(var e=new Object,i=window.location.search.slice(1).split("&"),o=0;o<i.length;o++){var r=i[o].indexOf("=");r>0&&(e[i[o].substring(0,r)]=i[o].substring(r+1))}return e}(),c=function(e){for(var i=document.cookie,o=i.split("; "),r=0;r<o.length;r++){var n=o[r].split("=");if(n[0]==e)return n[1]}return""};function b(){for(var e=[],i="0123456789abcdef",o=0;o<36;o++)e[o]=i.substr(Math.floor(Math.random()*16),1);e[14]="4",e[19]=i.substr(e[19]&3|8,1),e[8]=e[13]=e[18]=e[23]="";var r=e.join("");return r}window.uuid=b();var v=function(e){var i=e.fileName;document.title=(i?i+" - ":"")+"\u5728\u7EBFPS - Photopea\u56FE\u7247\u7F16\u8F91",$(".file-title span").html(i)},p=function(e){return new Blob([e],{type:"image/jpeg"})},w=function(e,i){var o=new FileReader;o.onload=function(){i&&i(this.result)},o.readAsArrayBuffer(e)};function m(e,i){return e.lastModifiedDate=new Date,e.name=i,new File([e],i,{type:e.type,lastModified:Date.now()})}var E=setInterval(function(){var e=filesboxEditor.J1.cY;e.length&&(clearInterval(E),g())},300),x=[56,66,80,83,0,1,0,0,0,0,0,0,0,3,0,0,2,-48,0,0,5,0,0,8,0,3,0,0,0,0,0,0,1,108,56,66,73,77],F=arrayBuffer=new Int8Array(x).buffer,I=function(){if(v(FilesBOXINFO),!FilesBOXINFO.fileUrl)return!1;$.ajax({type:"GET",url:FilesBOXINFO.fileUrl,xhrFields:{responseType:"blob"},processDownload:function(e){},success:function(e){if(!!e){if(e.size==0)return filesboxEditor.setFileContent(F);w(e,function(i){filesboxEditor.setFileContent(i)})}}})};t.sourceID&&c("token")&&t.domain&&$.ajax({type:"get",url:decodeURIComponent(t.domain)+"/api/disk/preview",headers:{token:c("token")},contentType:"application/json",data:{sourceID:t.sourceID,busType:"cloud",shareCode:t.shareCode||void 0},dataType:"json",async:!1,success:function(e){if(e.success){var i=e.data||{},o=i.downloadUrl||"";window.FilesBOXINFO={fileUrl:o,fileName:i.name},window.fileInfoxx=i,setTimeout(function(){window.filesboxEditor&&(filesboxEditor.setFileContent=function(r){filesboxEditor.file.qt({name:FilesBOXINFO.fileName},r,filesboxEditor.jM,null)},filesboxEditor.currentFile=function(){return filesboxEditor.J1.PJ},filesboxEditor.file.download=filesboxEditor.file.save,filesboxEditor.file.save=function(r,n){var a=filesboxEditor.currentFile(),l="psb,ai,psd,png,jpg,jpeg,svg,gif,bmp,emf,webp,ppm,tif,tiff,ico,dds,tga".split(","),d=s(a.name);if(s(n)!=fileInfoxx.fileType)return filesboxEditor.file.download(r,n);if(l.indexOf(d)==-1){filesboxEditor.file.download(r,n);return}r=f(s(fileInfoxx.name));var u=p(r),h=m(u,fileInfoxx.name);parent.window.selectuploadx=1,parent.window.newVersionId=t.sourceID,parent.window.filesboxUploader.addFiles(h),parent.window.filesboxUploadSuccess=P=>{layer.msg("\u4FDD\u5B58\u6210\u529F",{icon:1,time:2e3},function(){})}},I())},300)}else layer.msg(e.message)},error:function(e){}});var g=function(){var e=filesboxEditor.J1.jF,i=filesboxEditor.J1.cY,o="file,edit,image,layer,select,filter,view,window,more".split(",");if(!!i){for(var r=0;r<i.length;r++){var n=$(i[r].u);if(n.addClass("toolbar-menu toolbar-"+o[r]),o[r]=="file"){var a=n.children("div").eq(6).hide(),l='<span class="check"></span><span class="label">',d="\u4FDD\u5B58",u="\u4E0B\u8F7Dpsd";$('<div class="enab" data-action="download-psd">'+l+u+"</span></div>").insertAfter(a),$('<div class="enab" data-action="save">'+l+d+'</span><span class="right">\u2318+S</span></div>').insertAfter(a)}}y()}},y=function(){$("body").delegate("[data-action]","click",function(){var e=$(this).attr("data-action");switch(filesboxEditor.toolbarHide=function(){filesboxEditor.lQ.Y3()},e){case"save":var i=f((fileInfoxx.fileType||"").toUpperCase()),o=filesboxEditor.currentFile()||{name:"test.psd"};filesboxEditor.file.save(i,fileInfoxx.name),filesboxEditor.toolbarHide();break;case"download-psd":var i=f("psd"),o=filesboxEditor.currentFile()||{name:"test.psd"};filesboxEditor.file.download(i,o.name),filesboxEditor.toolbarHide();break;case"open-local":filesboxEditor.jM.aej();break;default:break}})},s=function(e){var i=e.substr(e.lastIndexOf(".")+1)||"";return i.toLowerCase()},f=function(e){var i=filesboxE