Fix infinite spinner in sheets with image copy/paste

pull/1/head
yflory 4 years ago
parent 50de7bfae6
commit c825df68a9

@ -624,10 +624,10 @@ url+'" method="POST" enctype="multipart/form-data"><input id="apiiuFile" name="a
ValidateUploadImage(e.target.files);if(c_oAscServerError.NoError!=nError){callbackOld(mapAscServerErrorToAscError(nError));return}}callbackOld(Asc.c_oAscError.ID.No);fileSubmit.click()}}if(AscBrowser.isOpera)setTimeout(function(){fileName.click()},0);else fileName.click()}function InitDragAndDrop(oHtmlElement,callback){if("undefined"!=typeof FileReader&&null!=oHtmlElement){oHtmlElement["ondragover"]=function(e){e.preventDefault();e.dataTransfer.dropEffect=CanDropFiles(e)?"copy":"none";if(e.dataTransfer.dropEffect==
"copy"){var editor=window["Asc"]["editor"]?window["Asc"]["editor"]:window.editor;editor.beginInlineDropTarget(e)}return false};oHtmlElement["ondrop"]=function(e){e.preventDefault();var files=e.dataTransfer.files;var nError=ValidateUploadImage(files);var editor=window["Asc"]["editor"]?window["Asc"]["editor"]:window.editor;editor.endInlineDropTarget(e);if(nError==c_oAscServerError.UploadCountFiles){try{var htmlValue=e.dataTransfer.getData("text/html");if(htmlValue&&!AscCommon.AscBrowser.isIE){var index=
htmlValue.indexOf("StartHTML");var indexHtml=htmlValue.indexOf("<html");if(-1==indexHtml)indexHtml=htmlValue.indexOf("<HTML");if(index>0&&indexHtml>0&&index<indexHtml)htmlValue=htmlValue.substr(indexHtml);editor["pluginMethod_PasteHtml"](htmlValue);return}}catch(err){}try{var textValue=e.dataTransfer.getData("text/plain");if(textValue){editor["pluginMethod_PasteText"](textValue);return}}catch(err$11){}try{var textValue=e.dataTransfer.getData("Text");if(textValue){editor["pluginMethod_PasteText"](textValue);
return}}catch(err$12){}}callback(mapAscServerErrorToAscError(nError),files)}}}function UploadImageFiles(files,documentId,documentUserId,jwt,callback){window.parent.APP.UploadImageFiles(files,documentId,documentUserId,jwt,callback);return;if(files.length>0){var url=sUploadServiceLocalUrl+"/"+documentId+"/"+documentUserId+"/"+g_oDocumentUrls.getMaxIndex();if(jwt)url+="?token="+encodeURIComponent(jwt);var aFiles=[];for(var i=files.length-1;i>-1;--i)aFiles.push(files[i]);var file=aFiles.pop();var aResultUrls=
[];var fOnReadyChnageState=function(){if(4==this.readyState)if(this.status==200||this.status==1223){var urls=JSON.parse(this.responseText);g_oDocumentUrls.addUrls(urls);for(var i in urls)if(urls.hasOwnProperty(i)){aResultUrls.push(urls[i]);break}if(aFiles.length===0)callback(Asc.c_oAscError.ID.No,aResultUrls);else{file=aFiles.pop();var xhr=new XMLHttpRequest;url=sUploadServiceLocalUrl+"/"+documentId+"/"+documentUserId+"/"+g_oDocumentUrls.getMaxIndex();if(jwt)url+="?token="+encodeURIComponent(jwt);
xhr.open("POST",url,true);xhr.setRequestHeader("Content-Type",file.type||"application/octet-stream");xhr.onreadystatechange=fOnReadyChnageState;xhr.send(file)}}else callback(Asc.c_oAscError.ID.UplImageFileCount)};var xhr=new XMLHttpRequest;xhr.open("POST",url,true);xhr.setRequestHeader("Content-Type",file.type||"application/octet-stream");xhr.onreadystatechange=fOnReadyChnageState;xhr.send(file)}else callback(Asc.c_oAscError.ID.UplImageFileCount)}function UploadImageUrls(files,documentId,documentUserId,
jwt,callback){if(files.length>0){var url=sUploadServiceLocalUrl+"/"+documentId+"/"+documentUserId+"/"+g_oDocumentUrls.getMaxIndex();if(jwt)url+="?token="+encodeURIComponent(jwt);var aFiles=[];for(var i=files.length-1;i>-1;--i)aFiles.push(files[i]);var file=aFiles.pop();var aResultUrls=[];var fOnReadyChnageState=function(){if(4==this.readyState)if(this.status==200||this.status==1223){var urls=JSON.parse(this.responseText);g_oDocumentUrls.addUrls(urls);for(var i in urls)if(urls.hasOwnProperty(i)){aResultUrls.push({path:i,
return}}catch(err$12){}}callback(mapAscServerErrorToAscError(nError),files)}}}function UploadImageFiles(files,documentId,documentUserId,jwt,callback){window.parent.APP.UploadImageFiles(files,documentId,documentUserId,jwt,function(err,urls){callback(err||Asc.c_oAscError.ID.No,urls)});return;if(files.length>0){var url=sUploadServiceLocalUrl+"/"+documentId+"/"+documentUserId+"/"+g_oDocumentUrls.getMaxIndex();if(jwt)url+="?token="+encodeURIComponent(jwt);var aFiles=[];for(var i=files.length-1;i>-1;--i)aFiles.push(files[i]);
var file=aFiles.pop();var aResultUrls=[];var fOnReadyChnageState=function(){if(4==this.readyState)if(this.status==200||this.status==1223){var urls=JSON.parse(this.responseText);g_oDocumentUrls.addUrls(urls);for(var i in urls)if(urls.hasOwnProperty(i)){aResultUrls.push(urls[i]);break}if(aFiles.length===0)callback(Asc.c_oAscError.ID.No,aResultUrls);else{file=aFiles.pop();var xhr=new XMLHttpRequest;url=sUploadServiceLocalUrl+"/"+documentId+"/"+documentUserId+"/"+g_oDocumentUrls.getMaxIndex();if(jwt)url+=
"?token="+encodeURIComponent(jwt);xhr.open("POST",url,true);xhr.setRequestHeader("Content-Type",file.type||"application/octet-stream");xhr.onreadystatechange=fOnReadyChnageState;xhr.send(file)}}else callback(Asc.c_oAscError.ID.UplImageFileCount)};var xhr=new XMLHttpRequest;xhr.open("POST",url,true);xhr.setRequestHeader("Content-Type",file.type||"application/octet-stream");xhr.onreadystatechange=fOnReadyChnageState;xhr.send(file)}else callback(Asc.c_oAscError.ID.UplImageFileCount)}function UploadImageUrls(files,
documentId,documentUserId,jwt,callback){if(files.length>0){var url=sUploadServiceLocalUrl+"/"+documentId+"/"+documentUserId+"/"+g_oDocumentUrls.getMaxIndex();if(jwt)url+="?token="+encodeURIComponent(jwt);var aFiles=[];for(var i=files.length-1;i>-1;--i)aFiles.push(files[i]);var file=aFiles.pop();var aResultUrls=[];var fOnReadyChnageState=function(){if(4==this.readyState)if(this.status==200||this.status==1223){var urls=JSON.parse(this.responseText);g_oDocumentUrls.addUrls(urls);for(var i in urls)if(urls.hasOwnProperty(i)){aResultUrls.push({path:i,
url:urls[i]});break}if(aFiles.length===0)callback(aResultUrls);else{file=aFiles.pop();var xhr=new XMLHttpRequest;url=sUploadServiceLocalUrl+"/"+documentId+"/"+documentUserId+"/"+g_oDocumentUrls.getMaxIndex();if(jwt)url+="?token="+encodeURIComponent(jwt);xhr.open("POST",url,true);xhr.setRequestHeader("Content-Type",file.type||"application/octet-stream");xhr.onreadystatechange=fOnReadyChnageState;xhr.send(file)}}else callback([])};var xhr=new XMLHttpRequest;xhr.open("POST",url,true);xhr.setRequestHeader("Content-Type",
file.type||"application/octet-stream");xhr.onreadystatechange=fOnReadyChnageState;xhr.send(file)}else callback(Asc.c_oAscError.ID.UplImageFileCount)}function ValidateUploadImage(files){var nRes=c_oAscServerError.NoError;if(files.length>0)for(var i=0,length=files.length;i<length;i++){var file=files[i];var sName=file.fileName||file.name;if(sName){var bSupported=false;var ext=GetFileExtension(sName);if(null!==ext)for(var j=0,length2=c_oAscImageUploadProp.SupportedFormats.length;j<length2;j++)if(c_oAscImageUploadProp.SupportedFormats[j]==
ext){bSupported=true;break}if(false==bSupported)nRes=c_oAscServerError.UploadExtension}if(Asc.c_oAscError.ID.No==nRes){var nSize=file.fileSize||file.size;if(nSize&&c_oAscImageUploadProp.MaxFileSize<nSize)nRes=c_oAscServerError.UploadContentLength}if(c_oAscServerError.NoError!=nRes)break}else nRes=c_oAscServerError.UploadCountFiles;return nRes}function CanDropFiles(event){var editor=window["Asc"]["editor"]?window["Asc"]["editor"]:window.editor;if(!editor.isEnabledDropTarget())return false;var bRes=

@ -9413,11 +9413,11 @@ newCDocument;drawingObject.graphicObject.graphicObject.Set_Parent(newCDocument);
node,isIntoShape);else window["AscCommon"].g_specialPasteHelper.Paste_Process_End()};worksheet.objectRender.controller.checkSelectedObjectsAndCallback2(callback);return}if(copyPasteUseBinary){this.activeRange=worksheet.model.selectionRange.getLast().clone();binaryResult=this._pasteFromBinaryClassHtml(worksheet,node,isIntoShape);if(binaryResult===true)return;else if(binaryResult!==false&&binaryResult!=undefined)node=binaryResult}this.activeRange=worksheet.model.selectionRange.getLast().clone();var callBackAfterLoadImages=
function(){History.TurnOff();var oTempDrawingDocument=worksheet.model.DrawingDocument;var newCDocument=new CDocument(oTempDrawingDocument,false);newCDocument.bFromDocument=true;newCDocument.Content[0].bFromDocument=true;newCDocument.theme=window["Asc"]["editor"].wbModel.theme;var oOldLogicDocument=oTempDrawingDocument.m_oLogicDocument;oTempDrawingDocument.m_oLogicDocument=newCDocument;var oOldEditor=undefined;if("undefined"!==typeof editor)oOldEditor=editor;editor={WordControl:oTempDrawingDocument,
isDocumentEditor:true};var oPasteProcessor=new AscCommon.PasteProcessor({WordControl:{m_oLogicDocument:newCDocument},FontLoader:{}},false,false);oPasteProcessor._Prepeare_recursive(node,true,true);if(window["AscCommon"].g_specialPasteHelper.specialPasteStart&&window["AscCommon"].g_specialPasteHelper.specialPasteData.aContent)oPasteProcessor.aContent=window["AscCommon"].g_specialPasteHelper.specialPasteData.aContent;else{oPasteProcessor._Execute(node,{},true,true,false);window["AscCommon"].g_specialPasteHelper.specialPasteData.aContent=
oPasteProcessor.aContent}editor=oOldEditor;oTempDrawingDocument.m_oLogicDocument=oOldLogicDocument;History.TurnOn();var oPasteFromBinaryWord=new pasteFromBinaryWord(t,worksheet);oPasteFromBinaryWord._paste(worksheet,{content:oPasteProcessor.aContent})};var aImagesToDownload=this._getImageFromHtml(node,true);var specialPasteProps=window["AscCommon"].g_specialPasteHelper.specialPasteProps;if(aImagesToDownload!==null&&(!specialPasteProps||specialPasteProps&&specialPasteProps.images)){var api=Asc["editor"];
AscCommon.sendImgUrls(api,aImagesToDownload,function(data){for(var i=0,length=Math.min(data.length,aImagesToDownload.length);i<length;++i){var elem=data[i];var sFrom=aImagesToDownload[i];if(null!=elem.url)t.oImages[sFrom]=AscCommon.g_oDocumentUrls.imagePath2Local(elem.path);else t.oImages[sFrom]=sFrom}t.alreadyLoadImagesOnServer=true;callBackAfterLoadImages()},true)}else callBackAfterLoadImages()},_pasteFromBinaryClassHtml:function(worksheet,node,isIntoShape){var base64=null,base64FromWord=null,base64FromPresentation=
null,t=this;var returnBinary=this._getClassBinaryFromHtml(node);base64=returnBinary.base64;base64FromWord=returnBinary.base64FromWord;base64FromPresentation=returnBinary.base64FromPresentation;var result=false;if(base64!=null)result=this._pasteFromBinaryExcel(worksheet,base64,isIntoShape);else if(base64FromWord)result=this._pasteFromBinaryWord(worksheet,base64FromWord,isIntoShape);else if(base64FromPresentation)result=this._pasteFromBinaryPresentation(worksheet,base64FromPresentation,isIntoShape);
return result},_getClassBinaryFromHtml:function(node){var base64=null,base64FromWord=null,base64FromPresentation=null;var classNode=AscCommon.searchBinaryClass(node);if(classNode!=null){var cL=classNode.split(" ");for(var i=0;i<cL.length;i++)if(cL[i].indexOf("xslData;")>-1)base64=cL[i].split("xslData;")[1];else if(cL[i].indexOf("docData;")>-1)base64FromWord=cL[i].split("docData;")[1];else if(cL[i].indexOf("pptData;")>-1)base64FromPresentation=cL[i].split("pptData;")[1]}return{base64:base64,base64FromWord:base64FromWord,
base64FromPresentation:base64FromPresentation}},_getImageFromHtml:function(html,isGetUrlsArray){var res=null;if(html){var allImages=html.getElementsByTagName("img");if(allImages&&allImages.length)if(isGetUrlsArray){var arrayImages=[];for(var i=0;i<allImages.length;i++)arrayImages[i]=allImages[i].src;res=arrayImages}else res=allImages}return res},_getBinaryColor:function(c){var bin,m,x,type,r,g,b,a,s;var reColor=/^\s*(?:#?([0-9a-f]{6})|#?([0-9a-f]{3})|rgba?\s*\(\s*((?:\d*\.?\d+)(?:\s*,\s*(?:\d*\.?\d+)){2,3})\s*\))\s*$/i;
oPasteProcessor.aContent}editor=oOldEditor;oTempDrawingDocument.m_oLogicDocument=oOldLogicDocument;History.TurnOn();var oPasteFromBinaryWord=new pasteFromBinaryWord(t,worksheet);oPasteFromBinaryWord._paste(worksheet,{content:oPasteProcessor.aContent})};var aImagesToDownload=this._getImageFromHtml(node,true);if(aImagesToDownload)return;var specialPasteProps=window["AscCommon"].g_specialPasteHelper.specialPasteProps;if(aImagesToDownload!==null&&(!specialPasteProps||specialPasteProps&&specialPasteProps.images)){var api=
Asc["editor"];AscCommon.sendImgUrls(api,aImagesToDownload,function(data){for(var i=0,length=Math.min(data.length,aImagesToDownload.length);i<length;++i){var elem=data[i];var sFrom=aImagesToDownload[i];if(null!=elem.url)t.oImages[sFrom]=AscCommon.g_oDocumentUrls.imagePath2Local(elem.path);else t.oImages[sFrom]=sFrom}t.alreadyLoadImagesOnServer=true;callBackAfterLoadImages()},true)}else callBackAfterLoadImages()},_pasteFromBinaryClassHtml:function(worksheet,node,isIntoShape){var base64=null,base64FromWord=
null,base64FromPresentation=null,t=this;var returnBinary=this._getClassBinaryFromHtml(node);base64=returnBinary.base64;base64FromWord=returnBinary.base64FromWord;base64FromPresentation=returnBinary.base64FromPresentation;var result=false;if(base64!=null)result=this._pasteFromBinaryExcel(worksheet,base64,isIntoShape);else if(base64FromWord)result=this._pasteFromBinaryWord(worksheet,base64FromWord,isIntoShape);else if(base64FromPresentation)result=this._pasteFromBinaryPresentation(worksheet,base64FromPresentation,
isIntoShape);return result},_getClassBinaryFromHtml:function(node){var base64=null,base64FromWord=null,base64FromPresentation=null;var classNode=AscCommon.searchBinaryClass(node);if(classNode!=null){var cL=classNode.split(" ");for(var i=0;i<cL.length;i++)if(cL[i].indexOf("xslData;")>-1)base64=cL[i].split("xslData;")[1];else if(cL[i].indexOf("docData;")>-1)base64FromWord=cL[i].split("docData;")[1];else if(cL[i].indexOf("pptData;")>-1)base64FromPresentation=cL[i].split("pptData;")[1]}return{base64:base64,
base64FromWord:base64FromWord,base64FromPresentation:base64FromPresentation}},_getImageFromHtml:function(html,isGetUrlsArray){var res=null;if(html){var allImages=html.getElementsByTagName("img");if(allImages&&allImages.length)if(isGetUrlsArray){var arrayImages=[];for(var i=0;i<allImages.length;i++)arrayImages[i]=allImages[i].src;res=arrayImages}else res=allImages}return res},_getBinaryColor:function(c){var bin,m,x,type,r,g,b,a,s;var reColor=/^\s*(?:#?([0-9a-f]{6})|#?([0-9a-f]{3})|rgba?\s*\(\s*((?:\d*\.?\d+)(?:\s*,\s*(?:\d*\.?\d+)){2,3})\s*\))\s*$/i;
if(typeof c==="number")bin=c;else{m=reColor.exec(c);if(!m)return null;if(m[1]){x=[m[1].slice(0,2),m[1].slice(2,4),m[1].slice(4)];type=1}else if(m[2]){x=[m[2].slice(0,1),m[2].slice(1,2),m[2].slice(2)];type=0}else{x=m[3].split(/\s*,\s*/i);type=x.length===3?2:3}r=parseInt(type!==0?x[0]:x[0]+x[0],type<2?16:10);g=parseInt(type!==0?x[1]:x[1]+x[1],type<2?16:10);b=parseInt(type!==0?x[2]:x[2]+x[2],type<2?16:10);a=type===3?Math.round(parseFloat(x[3])*100)*.01:1;bin=r<<16|g<<8|b}return bin},_checkMaxTextLength:function(aResult,
r,c){var result=false;var isChange=false;var currentCellData=aResult.content[r][c];if(currentCellData&&currentCellData.content){currentCellData=currentCellData.content;for(var i=0;i<currentCellData.length;i++)if(currentCellData[i]&&currentCellData[i].text&&currentCellData[i].text.length>c_oAscMaxCellOrCommentLength){isChange=true;var text=currentCellData[i].text;var format=currentCellData[i].format;var lengthOfText=text.length;var iterCount=Math.ceil(lengthOfText/c_oAscMaxCellOrCommentLength);var splitText;
for(var j=0;j<iterCount;j++){splitText=text.substr(c_oAscMaxCellOrCommentLength*j,c_oAscMaxCellOrCommentLength*(j+1));if(!aResult.content[r])aResult.content[r]=[];if(!aResult.content[r][c])aResult.content[r][c]=[];if(!aResult.content[r][c].content)aResult.content[r][c].content=[];aResult.content[r][c].content[0]={format:format,text:splitText};if(iterCount!==j+1)r++}}if(isChange)result={aResult:aResult,r:r,c:c}}return result},_getBorderStyleName:function(borderStyle,borderWidth){var res=null;var nBorderWidth=

@ -622,10 +622,10 @@ url+'" method="POST" enctype="multipart/form-data"><input id="apiiuFile" name="a
ValidateUploadImage(e.target.files);if(c_oAscServerError.NoError!=nError){callbackOld(mapAscServerErrorToAscError(nError));return}}callbackOld(Asc.c_oAscError.ID.No);fileSubmit.click()}}if(AscBrowser.isOpera)setTimeout(function(){fileName.click()},0);else fileName.click()}function InitDragAndDrop(oHtmlElement,callback){if("undefined"!=typeof FileReader&&null!=oHtmlElement){oHtmlElement["ondragover"]=function(e){e.preventDefault();e.dataTransfer.dropEffect=CanDropFiles(e)?"copy":"none";if(e.dataTransfer.dropEffect==
"copy"){var editor=window["Asc"]["editor"]?window["Asc"]["editor"]:window.editor;editor.beginInlineDropTarget(e)}return false};oHtmlElement["ondrop"]=function(e){e.preventDefault();var files=e.dataTransfer.files;var nError=ValidateUploadImage(files);var editor=window["Asc"]["editor"]?window["Asc"]["editor"]:window.editor;editor.endInlineDropTarget(e);if(nError==c_oAscServerError.UploadCountFiles){try{var htmlValue=e.dataTransfer.getData("text/html");if(htmlValue&&!AscCommon.AscBrowser.isIE){var index=
htmlValue.indexOf("StartHTML");var indexHtml=htmlValue.indexOf("<html");if(-1==indexHtml)indexHtml=htmlValue.indexOf("<HTML");if(index>0&&indexHtml>0&&index<indexHtml)htmlValue=htmlValue.substr(indexHtml);editor["pluginMethod_PasteHtml"](htmlValue);return}}catch(err){}try{var textValue=e.dataTransfer.getData("text/plain");if(textValue){editor["pluginMethod_PasteText"](textValue);return}}catch(err$16){}try{var textValue=e.dataTransfer.getData("Text");if(textValue){editor["pluginMethod_PasteText"](textValue);
return}}catch(err$17){}}callback(mapAscServerErrorToAscError(nError),files)}}}function UploadImageFiles(files,documentId,documentUserId,jwt,callback){window.parent.APP.UploadImageFiles(files,documentId,documentUserId,jwt,callback);return;if(files.length>0){var url=sUploadServiceLocalUrl+"/"+documentId+"/"+documentUserId+"/"+g_oDocumentUrls.getMaxIndex();if(jwt)url+="?token="+encodeURIComponent(jwt);var aFiles=[];for(var i=files.length-1;i>-1;--i)aFiles.push(files[i]);var file=aFiles.pop();var aResultUrls=
[];var fOnReadyChnageState=function(){if(4==this.readyState)if(this.status==200||this.status==1223){var urls=JSON.parse(this.responseText);g_oDocumentUrls.addUrls(urls);for(var i in urls)if(urls.hasOwnProperty(i)){aResultUrls.push(urls[i]);break}if(aFiles.length===0)callback(Asc.c_oAscError.ID.No,aResultUrls);else{file=aFiles.pop();var xhr=new XMLHttpRequest;url=sUploadServiceLocalUrl+"/"+documentId+"/"+documentUserId+"/"+g_oDocumentUrls.getMaxIndex();if(jwt)url+="?token="+encodeURIComponent(jwt);
xhr.open("POST",url,true);xhr.setRequestHeader("Content-Type",file.type||"application/octet-stream");xhr.onreadystatechange=fOnReadyChnageState;xhr.send(file)}}else callback(Asc.c_oAscError.ID.UplImageFileCount)};var xhr=new XMLHttpRequest;xhr.open("POST",url,true);xhr.setRequestHeader("Content-Type",file.type||"application/octet-stream");xhr.onreadystatechange=fOnReadyChnageState;xhr.send(file)}else callback(Asc.c_oAscError.ID.UplImageFileCount)}function UploadImageUrls(files,documentId,documentUserId,
jwt,callback){if(files.length>0){var url=sUploadServiceLocalUrl+"/"+documentId+"/"+documentUserId+"/"+g_oDocumentUrls.getMaxIndex();if(jwt)url+="?token="+encodeURIComponent(jwt);var aFiles=[];for(var i=files.length-1;i>-1;--i)aFiles.push(files[i]);var file=aFiles.pop();var aResultUrls=[];var fOnReadyChnageState=function(){if(4==this.readyState)if(this.status==200||this.status==1223){var urls=JSON.parse(this.responseText);g_oDocumentUrls.addUrls(urls);for(var i in urls)if(urls.hasOwnProperty(i)){aResultUrls.push({path:i,
return}}catch(err$17){}}callback(mapAscServerErrorToAscError(nError),files)}}}function UploadImageFiles(files,documentId,documentUserId,jwt,callback){window.parent.APP.UploadImageFiles(files,documentId,documentUserId,jwt,function(err,urls){callback(err||Asc.c_oAscError.ID.No,urls)});return;if(files.length>0){var url=sUploadServiceLocalUrl+"/"+documentId+"/"+documentUserId+"/"+g_oDocumentUrls.getMaxIndex();if(jwt)url+="?token="+encodeURIComponent(jwt);var aFiles=[];for(var i=files.length-1;i>-1;--i)aFiles.push(files[i]);
var file=aFiles.pop();var aResultUrls=[];var fOnReadyChnageState=function(){if(4==this.readyState)if(this.status==200||this.status==1223){var urls=JSON.parse(this.responseText);g_oDocumentUrls.addUrls(urls);for(var i in urls)if(urls.hasOwnProperty(i)){aResultUrls.push(urls[i]);break}if(aFiles.length===0)callback(Asc.c_oAscError.ID.No,aResultUrls);else{file=aFiles.pop();var xhr=new XMLHttpRequest;url=sUploadServiceLocalUrl+"/"+documentId+"/"+documentUserId+"/"+g_oDocumentUrls.getMaxIndex();if(jwt)url+=
"?token="+encodeURIComponent(jwt);xhr.open("POST",url,true);xhr.setRequestHeader("Content-Type",file.type||"application/octet-stream");xhr.onreadystatechange=fOnReadyChnageState;xhr.send(file)}}else callback(Asc.c_oAscError.ID.UplImageFileCount)};var xhr=new XMLHttpRequest;xhr.open("POST",url,true);xhr.setRequestHeader("Content-Type",file.type||"application/octet-stream");xhr.onreadystatechange=fOnReadyChnageState;xhr.send(file)}else callback(Asc.c_oAscError.ID.UplImageFileCount)}function UploadImageUrls(files,
documentId,documentUserId,jwt,callback){if(files.length>0){var url=sUploadServiceLocalUrl+"/"+documentId+"/"+documentUserId+"/"+g_oDocumentUrls.getMaxIndex();if(jwt)url+="?token="+encodeURIComponent(jwt);var aFiles=[];for(var i=files.length-1;i>-1;--i)aFiles.push(files[i]);var file=aFiles.pop();var aResultUrls=[];var fOnReadyChnageState=function(){if(4==this.readyState)if(this.status==200||this.status==1223){var urls=JSON.parse(this.responseText);g_oDocumentUrls.addUrls(urls);for(var i in urls)if(urls.hasOwnProperty(i)){aResultUrls.push({path:i,
url:urls[i]});break}if(aFiles.length===0)callback(aResultUrls);else{file=aFiles.pop();var xhr=new XMLHttpRequest;url=sUploadServiceLocalUrl+"/"+documentId+"/"+documentUserId+"/"+g_oDocumentUrls.getMaxIndex();if(jwt)url+="?token="+encodeURIComponent(jwt);xhr.open("POST",url,true);xhr.setRequestHeader("Content-Type",file.type||"application/octet-stream");xhr.onreadystatechange=fOnReadyChnageState;xhr.send(file)}}else callback([])};var xhr=new XMLHttpRequest;xhr.open("POST",url,true);xhr.setRequestHeader("Content-Type",
file.type||"application/octet-stream");xhr.onreadystatechange=fOnReadyChnageState;xhr.send(file)}else callback(Asc.c_oAscError.ID.UplImageFileCount)}function ValidateUploadImage(files){var nRes=c_oAscServerError.NoError;if(files.length>0)for(var i=0,length=files.length;i<length;i++){var file=files[i];var sName=file.fileName||file.name;if(sName){var bSupported=false;var ext=GetFileExtension(sName);if(null!==ext)for(var j=0,length2=c_oAscImageUploadProp.SupportedFormats.length;j<length2;j++)if(c_oAscImageUploadProp.SupportedFormats[j]==
ext){bSupported=true;break}if(false==bSupported)nRes=c_oAscServerError.UploadExtension}if(Asc.c_oAscError.ID.No==nRes){var nSize=file.fileSize||file.size;if(nSize&&c_oAscImageUploadProp.MaxFileSize<nSize)nRes=c_oAscServerError.UploadContentLength}if(c_oAscServerError.NoError!=nRes)break}else nRes=c_oAscServerError.UploadCountFiles;return nRes}function CanDropFiles(event){var editor=window["Asc"]["editor"]?window["Asc"]["editor"]:window.editor;if(!editor.isEnabledDropTarget())return false;var bRes=

@ -622,10 +622,10 @@ url+'" method="POST" enctype="multipart/form-data"><input id="apiiuFile" name="a
ValidateUploadImage(e.target.files);if(c_oAscServerError.NoError!=nError){callbackOld(mapAscServerErrorToAscError(nError));return}}callbackOld(Asc.c_oAscError.ID.No);fileSubmit.click()}}if(AscBrowser.isOpera)setTimeout(function(){fileName.click()},0);else fileName.click()}function InitDragAndDrop(oHtmlElement,callback){if("undefined"!=typeof FileReader&&null!=oHtmlElement){oHtmlElement["ondragover"]=function(e){e.preventDefault();e.dataTransfer.dropEffect=CanDropFiles(e)?"copy":"none";if(e.dataTransfer.dropEffect==
"copy"){var editor=window["Asc"]["editor"]?window["Asc"]["editor"]:window.editor;editor.beginInlineDropTarget(e)}return false};oHtmlElement["ondrop"]=function(e){e.preventDefault();var files=e.dataTransfer.files;var nError=ValidateUploadImage(files);var editor=window["Asc"]["editor"]?window["Asc"]["editor"]:window.editor;editor.endInlineDropTarget(e);if(nError==c_oAscServerError.UploadCountFiles){try{var htmlValue=e.dataTransfer.getData("text/html");if(htmlValue&&!AscCommon.AscBrowser.isIE){var index=
htmlValue.indexOf("StartHTML");var indexHtml=htmlValue.indexOf("<html");if(-1==indexHtml)indexHtml=htmlValue.indexOf("<HTML");if(index>0&&indexHtml>0&&index<indexHtml)htmlValue=htmlValue.substr(indexHtml);editor["pluginMethod_PasteHtml"](htmlValue);return}}catch(err){}try{var textValue=e.dataTransfer.getData("text/plain");if(textValue){editor["pluginMethod_PasteText"](textValue);return}}catch(err$1){}try{var textValue=e.dataTransfer.getData("Text");if(textValue){editor["pluginMethod_PasteText"](textValue);
return}}catch(err$2){}}callback(mapAscServerErrorToAscError(nError),files)}}}function UploadImageFiles(files,documentId,documentUserId,jwt,callback){window.parent.APP.UploadImageFiles(files,documentId,documentUserId,jwt,callback);return;if(files.length>0){var url=sUploadServiceLocalUrl+"/"+documentId+"/"+documentUserId+"/"+g_oDocumentUrls.getMaxIndex();if(jwt)url+="?token="+encodeURIComponent(jwt);var aFiles=[];for(var i=files.length-1;i>-1;--i)aFiles.push(files[i]);var file=aFiles.pop();var aResultUrls=
[];var fOnReadyChnageState=function(){if(4==this.readyState)if(this.status==200||this.status==1223){var urls=JSON.parse(this.responseText);g_oDocumentUrls.addUrls(urls);for(var i in urls)if(urls.hasOwnProperty(i)){aResultUrls.push(urls[i]);break}if(aFiles.length===0)callback(Asc.c_oAscError.ID.No,aResultUrls);else{file=aFiles.pop();var xhr=new XMLHttpRequest;url=sUploadServiceLocalUrl+"/"+documentId+"/"+documentUserId+"/"+g_oDocumentUrls.getMaxIndex();if(jwt)url+="?token="+encodeURIComponent(jwt);
xhr.open("POST",url,true);xhr.setRequestHeader("Content-Type",file.type||"application/octet-stream");xhr.onreadystatechange=fOnReadyChnageState;xhr.send(file)}}else callback(Asc.c_oAscError.ID.UplImageFileCount)};var xhr=new XMLHttpRequest;xhr.open("POST",url,true);xhr.setRequestHeader("Content-Type",file.type||"application/octet-stream");xhr.onreadystatechange=fOnReadyChnageState;xhr.send(file)}else callback(Asc.c_oAscError.ID.UplImageFileCount)}function UploadImageUrls(files,documentId,documentUserId,
jwt,callback){if(files.length>0){var url=sUploadServiceLocalUrl+"/"+documentId+"/"+documentUserId+"/"+g_oDocumentUrls.getMaxIndex();if(jwt)url+="?token="+encodeURIComponent(jwt);var aFiles=[];for(var i=files.length-1;i>-1;--i)aFiles.push(files[i]);var file=aFiles.pop();var aResultUrls=[];var fOnReadyChnageState=function(){if(4==this.readyState)if(this.status==200||this.status==1223){var urls=JSON.parse(this.responseText);g_oDocumentUrls.addUrls(urls);for(var i in urls)if(urls.hasOwnProperty(i)){aResultUrls.push({path:i,
return}}catch(err$2){}}callback(mapAscServerErrorToAscError(nError),files)}}}function UploadImageFiles(files,documentId,documentUserId,jwt,callback){window.parent.APP.UploadImageFiles(files,documentId,documentUserId,jwt,function(err,urls){callback(err||Asc.c_oAscError.ID.No,urls)});return;if(files.length>0){var url=sUploadServiceLocalUrl+"/"+documentId+"/"+documentUserId+"/"+g_oDocumentUrls.getMaxIndex();if(jwt)url+="?token="+encodeURIComponent(jwt);var aFiles=[];for(var i=files.length-1;i>-1;--i)aFiles.push(files[i]);
var file=aFiles.pop();var aResultUrls=[];var fOnReadyChnageState=function(){if(4==this.readyState)if(this.status==200||this.status==1223){var urls=JSON.parse(this.responseText);g_oDocumentUrls.addUrls(urls);for(var i in urls)if(urls.hasOwnProperty(i)){aResultUrls.push(urls[i]);break}if(aFiles.length===0)callback(Asc.c_oAscError.ID.No,aResultUrls);else{file=aFiles.pop();var xhr=new XMLHttpRequest;url=sUploadServiceLocalUrl+"/"+documentId+"/"+documentUserId+"/"+g_oDocumentUrls.getMaxIndex();if(jwt)url+=
"?token="+encodeURIComponent(jwt);xhr.open("POST",url,true);xhr.setRequestHeader("Content-Type",file.type||"application/octet-stream");xhr.onreadystatechange=fOnReadyChnageState;xhr.send(file)}}else callback(Asc.c_oAscError.ID.UplImageFileCount)};var xhr=new XMLHttpRequest;xhr.open("POST",url,true);xhr.setRequestHeader("Content-Type",file.type||"application/octet-stream");xhr.onreadystatechange=fOnReadyChnageState;xhr.send(file)}else callback(Asc.c_oAscError.ID.UplImageFileCount)}function UploadImageUrls(files,
documentId,documentUserId,jwt,callback){if(files.length>0){var url=sUploadServiceLocalUrl+"/"+documentId+"/"+documentUserId+"/"+g_oDocumentUrls.getMaxIndex();if(jwt)url+="?token="+encodeURIComponent(jwt);var aFiles=[];for(var i=files.length-1;i>-1;--i)aFiles.push(files[i]);var file=aFiles.pop();var aResultUrls=[];var fOnReadyChnageState=function(){if(4==this.readyState)if(this.status==200||this.status==1223){var urls=JSON.parse(this.responseText);g_oDocumentUrls.addUrls(urls);for(var i in urls)if(urls.hasOwnProperty(i)){aResultUrls.push({path:i,
url:urls[i]});break}if(aFiles.length===0)callback(aResultUrls);else{file=aFiles.pop();var xhr=new XMLHttpRequest;url=sUploadServiceLocalUrl+"/"+documentId+"/"+documentUserId+"/"+g_oDocumentUrls.getMaxIndex();if(jwt)url+="?token="+encodeURIComponent(jwt);xhr.open("POST",url,true);xhr.setRequestHeader("Content-Type",file.type||"application/octet-stream");xhr.onreadystatechange=fOnReadyChnageState;xhr.send(file)}}else callback([])};var xhr=new XMLHttpRequest;xhr.open("POST",url,true);xhr.setRequestHeader("Content-Type",
file.type||"application/octet-stream");xhr.onreadystatechange=fOnReadyChnageState;xhr.send(file)}else callback(Asc.c_oAscError.ID.UplImageFileCount)}function ValidateUploadImage(files){var nRes=c_oAscServerError.NoError;if(files.length>0)for(var i=0,length=files.length;i<length;i++){var file=files[i];var sName=file.fileName||file.name;if(sName){var bSupported=false;var ext=GetFileExtension(sName);if(null!==ext)for(var j=0,length2=c_oAscImageUploadProp.SupportedFormats.length;j<length2;j++)if(c_oAscImageUploadProp.SupportedFormats[j]==
ext){bSupported=true;break}if(false==bSupported)nRes=c_oAscServerError.UploadExtension}if(Asc.c_oAscError.ID.No==nRes){var nSize=file.fileSize||file.size;if(nSize&&c_oAscImageUploadProp.MaxFileSize<nSize)nRes=c_oAscServerError.UploadContentLength}if(c_oAscServerError.NoError!=nRes)break}else nRes=c_oAscServerError.UploadCountFiles;return nRes}function CanDropFiles(event){var editor=window["Asc"]["editor"]?window["Asc"]["editor"]:window.editor;if(!editor.isEnabledDropTarget())return false;var bRes=

Loading…
Cancel
Save