Commit d2909037 authored by Boris Kocherov's avatar Boris Kocherov

use jio storrage for save document images

disable "image upload blocking" on image jio save (probably it wrong)
use modified jio_putAttachment to save image:
* if attachId undefined then attachId = mimeType,sha1hashOfFile
* not save in jio storage if attach with checksumm already exist
* return attachId
* allow dataUri instead blob
use modified jio_getAttachment allow get attachment as dataUrl or
blobUrl (ooffice use blobUrl)
parent 5b7ac7d1
......@@ -80,26 +80,6 @@ var c_oAscError = Asc.c_oAscError;
cp['encodings'] = AscCommon.getEncodingParams();
this.handlers.trigger("asc_onAdvancedOptions", new AscCommon.asc_CAdvancedOptions(Asc.c_oAscAdvancedOptionsID.CSV, cp), AscCommon.c_oAscAdvancedOptionsAction.Open);
};
asc['spreadsheet_api'].prototype.asc_addImageDrawingObject = function(url)
{
var _url = window["AscDesktopEditor"]["LocalFileGetImageUrl"](url);
var ws = this.wb.getWorksheet();
if (ws)
{
var _url = window["AscDesktopEditor"]["LocalFileGetImageUrl"](url);
ws.objectRender.addImageDrawingObject(AscCommon.g_oDocumentUrls.getImageUrl(_url) , null);
}
};
asc['spreadsheet_api'].prototype.asc_showImageFileDialog = function()
{
window["AscDesktopEditor"]["LocalFileGetImageUrlFromOpenFileDialog"]();
};
asc['spreadsheet_api'].prototype.asc_addImage = function()
{
window["AscDesktopEditor"]["LocalFileGetImageUrlFromOpenFileDialog"]();
};
})(jQuery, window);
window["Asc"]['spreadsheet_api'].prototype.asc_setAdvancedOptions = function(idOption, option)
......
......@@ -2356,49 +2356,31 @@ var editor;
return ret;
};
spreadsheet_api.prototype.asc_addImageDrawingObject = function (imageUrl) {
var rData = {
"id": this.documentId,
"userid": this.documentUserId,
"c": "imgurl",
"saveindex": g_oDocumentUrls.getMaxIndex(),
"data": imageUrl
};
spreadsheet_api.prototype.asc_addImageDrawingObject = function(imageUrl, callback) {
var t = this;
this.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
this.fCurCallback = function (input) {
if (null != input && "imgurl" == input["type"]) {
if ("ok" == input["status"]) {
var data = input["data"];
var urls = {};
var firstUrl;
for (var i = 0; i < data.length; ++i) {
var elem = data[i];
if (elem.url) {
if (!firstUrl) {
firstUrl = elem.url;
}
urls[elem.path] = elem.url;
}
}
g_oDocumentUrls.addUrls(urls);
if (firstUrl) {
if (!callback) {
callback = function (url) {
//g_oDocumentUrls.addUrls(urls);
var ws = t.wb.getWorksheet();
ws.objectRender.addImageDrawingObject(firstUrl, null);
} else {
ws.objectRender.addImageDrawingObject('jio:' + url, null);
};
}
//this.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
return new RSVP.Queue()
.push(function () {
return imageUrl;
})
.push(AscCommon.downloadUrlAsBlob)
.push(function (blob) {
return Common.Gateway.jio_putAttachment(t.documentId, undefined, blob);
})
.push(callback)
//.push(function () {t.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);})
.push(undefined, function (error) {
console.log(error);
t.handlers.trigger("asc_onError", c_oAscError.ID.Unknown, c_oAscError.Level.NoCritical);
}
} else {
t.handlers.trigger("asc_onError", mapAscServerErrorToAscError(parseInt(input["data"])),
c_oAscError.Level.NoCritical);
}
} else {
t.handlers.trigger("asc_onError", c_oAscError.ID.Unknown, c_oAscError.Level.NoCritical);
}
t.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
};
sendCommand(this, null, rData);
//t.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
});
};
......@@ -2662,46 +2644,10 @@ var editor;
return;
}
var rData = {
"id": this.documentId,
"userid": this.documentUserId,
"c": "imgurl",
"saveindex": g_oDocumentUrls.getMaxIndex(),
"data": sImageUrl};
var t = this;
this.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
this.fCurCallback = function(input) {
if (null != input && "imgurl" == input["type"]) {
if ("ok" == input["status"]) {
var data = input["data"];
var urls = {};
var firstUrl;
for (var i = 0; i < data.length; ++i) {
var elem = data[i];
if (elem.url) {
if (!firstUrl) {
firstUrl = elem.url;
}
urls[elem.path] = elem.url;
}
}
g_oDocumentUrls.addUrls(urls);
if (firstUrl) {
fReplaceCallback(firstUrl);
this.asc_addImageDrawingObject(sImageUrl, function (url) {
fReplaceCallback('jio:' + url);
ws.objectRender.setGraphicObjectProps(props);
} else {
t.handlers.trigger("asc_onError", c_oAscError.ID.Unknown, c_oAscError.Level.NoCritical);
}
} else {
t.handlers.trigger("asc_onError", mapAscServerErrorToAscError(parseInt(input["data"])), c_oAscError.Level.NoCritical);
}
} else {
t.handlers.trigger("asc_onError", c_oAscError.ID.Unknown, c_oAscError.Level.NoCritical);
}
t.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
};
sendCommand(this, null, rData);
});
}
else{
ws.objectRender.setGraphicObjectProps(props);
......
This diff is collapsed.
......@@ -96,63 +96,69 @@
/////////////////////////////////////////////////////////
////////////// IMAGES ////////////////////////
/////////////////////////////////////////////////////////
//var prot = AscCommon.DocumentUrls.prototype;
//prot.mediaPrefix = 'media/';
//prot.init = function(urls) {
//};
//prot.getUrls = function() {
// return this.urls;
//};
//prot.addUrls = function(urls){
//};
//prot.addImageUrl = function(strPath, url){
//};
//prot.getImageUrl = function(strPath){
// if (0 === strPath.indexOf('theme'))
// return null;
//
// if (window.editor && window.editor.ThemeLoader && window.editor.ThemeLoader.ThemesUrl != "" && strPath.indexOf(window.editor.ThemeLoader.ThemesUrl) == 0)
// return null;
//
// return this.documentUrl + "/media/" + strPath;
//};
//prot.getImageLocal = function(url){
// var _first = this.documentUrl + "/media/";
// if (0 == url.indexOf(_first))
// return url.substring(_first.length);
//
// if (window.editor && window.editor.ThemeLoader && 0 == url.indexOf(editor.ThemeLoader.ThemesUrlAbs)) {
// return url.substring(editor.ThemeLoader.ThemesUrlAbs.length);
// }
//
// return null;
//};
//prot.imagePath2Local = function(imageLocal){
// return this.getImageLocal(imageLocal);
//};
//prot.getUrl = function(strPath){
// if (0 === strPath.indexOf('theme'))
// return null;
//
// if (window.editor && window.editor.ThemeLoader && window.editor.ThemeLoader.ThemesUrl != "" && strPath.indexOf(window.editor.ThemeLoader.ThemesUrl) == 0)
// return null;
//
// return this.documentUrl + "/media/" + strPath;
//};
//prot.getLocal = function(url){
// return this.getImageLocal(url);
//};
//
//AscCommon.sendImgUrls = function(api, images, callback)
//{
// var _data = [];
// for (var i = 0; i < images.length; i++)
// {
// var _url = window["AscDesktopEditor"]["LocalFileGetImageUrl"](images[i]);
// _data[i] = { url: images[i], path : AscCommon.g_oDocumentUrls.getImageUrl(_url) };
// }
// callback(_data);
//};
var prot = AscCommon.DocumentUrls.prototype;
prot.mediaPrefix = 'media/';
prot.init = function(urls) {
};
prot.getUrls = function() {
return this.urls;
};
prot.addUrls = function(urls){
};
prot.addImageUrl = function(strPath, url){
};
prot.getImageUrl = function(url){
var _first = "jio:";
if (0 === url.indexOf(_first))
return url;
if (0 === url.indexOf('theme'))
return null;
if (window.editor && window.editor.ThemeLoader && window.editor.ThemeLoader.ThemesUrl !== "" && url.indexOf(window.editor.ThemeLoader.ThemesUrl) === 0)
return null;
return _first + url;
//return this.documentUrl + "/media/" + strPath;
};
prot.getImageLocal = function(url){
//var _first = this.documentUrl + "/media/";
var _first = "jio:";
if (0 === url.indexOf(_first))
return url.substring(_first.length);
if (window.editor && window.editor.ThemeLoader && 0 == url.indexOf(editor.ThemeLoader.ThemesUrlAbs)) {
return url.substring(editor.ThemeLoader.ThemesUrlAbs.length);
}
return null;
};
prot.imagePath2Local = function(imageLocal){
return this.getImageLocal(imageLocal);
};
prot.getUrl = function(strPath){
if (0 === strPath.indexOf('theme'))
return null;
if (window.editor && window.editor.ThemeLoader && window.editor.ThemeLoader.ThemesUrl != "" && strPath.indexOf(window.editor.ThemeLoader.ThemesUrl) == 0)
return null;
return this.documentUrl + "/media/" + strPath;
};
prot.getLocal = function(url){
return this.getImageLocal(url);
};
AscCommon.sendImgUrls = function(api, images, callback)
{
var _data = [];
for (var i = 0; i < images.length; i++)
{
var _url = window["AscDesktopEditor"]["LocalFileGetImageUrl"](images[i]);
_data[i] = { url: images[i], path : AscCommon.g_oDocumentUrls.getImageUrl(_url) };
}
callback(_data);
};
/////////////////////////////////////////////////////////
//////////////// SAVE //////////////////////
......
"use strict";
AscCommon.readBlobAsDataURL = function (blob) {
var fr = new FileReader();
return new RSVP.Promise(function (resolve, reject, notify) {
fr.addEventListener("load", function () {
resolve(fr.result);
});
fr.addEventListener("error", reject);
fr.addEventListener("progress", notify);
fr.readAsDataURL(blob);
}, function () {
fr.abort();
});
};
AscCommon.downloadUrlAsBlob = function (url) {
var xhr = new XMLHttpRequest();
return new RSVP.Promise(function (resolve, reject) {
xhr.open("GET", url);
xhr.responseType = "blob";//force the HTTP response, response-type header to be blob
xhr.onload = function () {
if (this.status === 200) {
resolve(xhr.response);
} else {
reject(this.status)
}
};
xhr.onerror = reject;
xhr.send();
}, function () {
xhr.abort();
});
};
AscCommon.baseEditorsApi.prototype.jio_open = function () {
var t = this;
Common.Gateway.jio_get(t.documentId)
......
......@@ -899,7 +899,6 @@
}
else
{
this.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
AscCommon.UploadImageFiles(files, this.documentId, this.documentUserId, this.CoAuthoringApi.get_jwt(), function(error, url)
{
if (c_oAscError.ID.No !== error)
......@@ -910,7 +909,6 @@
{
t._addImageUrl(url);
}
t.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
});
}
};
......
......@@ -1324,38 +1324,16 @@
if (files.length > 0)
{
var file = files[0];
var url = sUploadServiceLocalUrl + '/' + documentId + '/' + documentUserId + '/' + g_oDocumentUrls.getMaxIndex();
if (jwt)
{
url += '/' + jwt;
}
var xhr = new XMLHttpRequest();
xhr.open('POST', url, true);
xhr.setRequestHeader('Content-Type', file.type || 'application/octet-stream');
xhr.onreadystatechange = function ()
{
if (4 == this.readyState)
{
if ((this.status == 200 || this.status == 1223))
Common.Gateway.jio_putAttachment(documentId, undefined, file)
.push(function (image_url)
{
var urls = JSON.parse(this.responseText);
g_oDocumentUrls.addUrls(urls);
var firstUrl;
for (var i in urls)
{
if (urls.hasOwnProperty(i))
callback(Asc.c_oAscError.ID.No, 'jio:' + image_url);
})
.push(undefined, function (error)
{
firstUrl = urls[i];
break;
}
}
callback(Asc.c_oAscError.ID.No, firstUrl);
}
else
console.log(error);
callback(Asc.c_oAscError.ID.UplImageFileCount);
}
};
xhr.send(file);
});
}
else
{
......
......@@ -179,19 +179,6 @@ Asc['asc_docs_api'].prototype.asc_DownloadAs = function(typeFile, bIsDownloadEve
this.asc_Save(false, true);
};
Asc['asc_docs_api'].prototype.AddImageUrl = function(url, imgProp)
{
var _url = window["AscDesktopEditor"]["LocalFileGetImageUrl"](url);
this.AddImageUrlAction(AscCommon.g_oDocumentUrls.getImageUrl(_url), imgProp);
};
Asc['asc_docs_api'].prototype.AddImage = function()
{
window["AscDesktopEditor"]["LocalFileGetImageUrlFromOpenFileDialog"]();
};
Asc['asc_docs_api'].prototype.asc_addImage = function()
{
window["AscDesktopEditor"]["LocalFileGetImageUrlFromOpenFileDialog"]();
};
Asc['asc_docs_api'].prototype.asc_isOffline = function()
{
return true;
......
......@@ -2746,58 +2746,11 @@ background-repeat: no-repeat;\
return;
}
this.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
this.fCurCallback = function(input)
{
if (null != input && "imgurl" == input["type"])
{
if ("ok" == input["status"])
{
var data = input["data"];
var urls = {};
var firstUrl;
for (var i = 0; i < data.length; ++i)
{
var elem = data[i];
if (elem.url)
{
if (!firstUrl)
{
firstUrl = elem.url;
}
urls[elem.path] = elem.url;
}
}
g_oDocumentUrls.addUrls(urls);
if (firstUrl)
{
image_url = firstUrl;
this.AddImageUrl(sImageUrl, function (url) {
//g_oDocumentUrls.addUrls(urls);
image_url = 'jio:' + url;
fApplyCallback();
}
else
{
oApi.sendEvent("asc_onError", c_oAscError.ID.Unknown, c_oAscError.Level.NoCritical);
}
}
else
{
oApi.sendEvent("asc_onError", mapAscServerErrorToAscError(parseInt(input["data"])), c_oAscError.Level.NoCritical);
}
}
else
{
oApi.sendEvent("asc_onError", c_oAscError.ID.Unknown, c_oAscError.Level.NoCritical);
}
oApi.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
};
var rData = {
"id" : this.documentId,
"userid" : this.documentUserId,
"c" : "imgurl",
"saveindex" : g_oDocumentUrls.getMaxIndex(),
"data" : sImageUrl
};
sendCommand(this, null, rData);
});
}
}
else
......@@ -3745,7 +3698,7 @@ background-repeat: no-repeat;\
// ToDo пока временная функция для стыковки.
this.AddImageUrl(url);
};
asc_docs_api.prototype.AddImageUrl = function(url)
asc_docs_api.prototype.AddImageUrl = function(url, callback)
{
if (g_oDocumentUrls.getLocal(url))
{
......@@ -3753,59 +3706,32 @@ background-repeat: no-repeat;\
}
else
{
var rData = {
"id" : this.documentId,
"userid" : this.documentUserId,
"c" : "imgurl",
"saveindex" : g_oDocumentUrls.getMaxIndex(),
"data" : url
var t = this,
start = url.slice(0, 6),
queue = new RSVP.Queue();
if (!callback) {
callback = function (url) {
//g_oDocumentUrls.addUrls(urls);
t.AddImageUrlAction('jio:' + url);
};
var t = this;
this.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
this.fCurCallback = function(input)
{
if (null != input && "imgurl" == input["type"])
{
if ("ok" == input["status"])
{
var data = input["data"];
var urls = {};
var firstUrl;
for (var i = 0; i < data.length; ++i)
{
var elem = data[i];
if (elem.url)
{
if (!firstUrl)
{
firstUrl = elem.url;
}
urls[elem.path] = elem.url;
}
}
g_oDocumentUrls.addUrls(urls);
if (firstUrl)
{
t.AddImageUrlAction(firstUrl);
}
else
{
t.sendEvent("asc_onError", c_oAscError.ID.Unknown, c_oAscError.Level.NoCritical);
}
}
else
{
t.sendEvent("asc_onError", mapAscServerErrorToAscError(parseInt(input["data"])), c_oAscError.Level.NoCritical);
}
}
else
{
queue.push(function () {
return url;
});
//this.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
if (0 !== start.indexOf('data:')) {
queue.push(AscCommon.downloadUrlAsBlob)
}
return queue.push(function (blob) {
return Common.Gateway.jio_putAttachment(t.documentId, undefined, blob);
})
.push(callback)
//.push(function () {t.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);})
.push(undefined, function (error) {
console.log(error);
t.sendEvent("asc_onError", c_oAscError.ID.Unknown, c_oAscError.Level.NoCritical);
}
t.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
};
sendCommand(this, null, rData);
//t.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
});
}
};
......@@ -3966,70 +3892,11 @@ background-repeat: no-repeat;\
}
else
{
this.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
if (window["AscDesktopEditor"])
{
var _url = window["AscDesktopEditor"]["LocalFileGetImageUrl"](sImageUrl);
_url = g_oDocumentUrls.getImageUrl(_url);
ImagePr.ImageUrl = _url;
fApplyCallback();
this.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
return;
}
this.fCurCallback = function(input)
{
if (null != input && "imgurl" == input["type"])
{
if ("ok" == input["status"])
{
var data = input["data"];
var urls = {};
var firstUrl;
for (var i = 0; i < data.length; ++i)
{
var elem = data[i];
if (elem.url)
{
if (!firstUrl)
{
firstUrl = elem.url;
}
urls[elem.path] = elem.url;
}
}
g_oDocumentUrls.addUrls(urls);
if (firstUrl)
{
ImagePr.ImageUrl = firstUrl;
this.AddImageUrl(sImageUrl, function (url) {
//g_oDocumentUrls.addUrls(urls);
ImagePr.ImageUrl = 'jio:' + url;
fApplyCallback();
}
else
{
oApi.sendEvent("asc_onError", c_oAscError.ID.Unknown, c_oAscError.Level.NoCritical);
}
}
else
{
oApi.sendEvent("asc_onError", mapAscServerErrorToAscError(parseInt(input["data"])), c_oAscError.Level.NoCritical);
}
}
else
{
oApi.sendEvent("asc_onError", c_oAscError.ID.Unknown, c_oAscError.Level.NoCritical);
}
oApi.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
};
var rData = {
"id" : this.documentId,
"userid" : this.documentUserId,
"c" : "imgurl",
"saveindex" : g_oDocumentUrls.getMaxIndex(),
"data" : sImageUrl
};
sendCommand(this, null, rData);
});
}
}
else
......
......@@ -186,19 +186,6 @@ Asc['asc_docs_api'].prototype.asc_DownloadAs = function(typeFile, bIsDownloadEve
this.asc_Save(false, true);
};
Asc['asc_docs_api'].prototype.AddImageUrl = function(url, imgProp)
{
var _url = window["AscDesktopEditor"]["LocalFileGetImageUrl"](url);
this.AddImageUrlAction(AscCommon.g_oDocumentUrls.getImageUrl(_url), imgProp);
};
Asc['asc_docs_api'].prototype.AddImage = function()
{
window["AscDesktopEditor"]["LocalFileGetImageUrlFromOpenFileDialog"]();
};
Asc['asc_docs_api'].prototype.asc_addImage = function()
{
window["AscDesktopEditor"]["LocalFileGetImageUrlFromOpenFileDialog"]();
};
Asc['asc_docs_api'].prototype.asc_isOffline = function()
{
return true;
......
......@@ -4503,7 +4503,7 @@ background-repeat: no-repeat;\
// ToDo пока временная функция для стыковки.
this.AddImageUrl(url);
};
asc_docs_api.prototype.AddImageUrl = function(url, imgProp)
asc_docs_api.prototype.AddImageUrl = function(url, imgProp, callback)
{
if (g_oDocumentUrls.getLocal(url))
{
......@@ -4511,59 +4511,29 @@ background-repeat: no-repeat;\
}
else
{
var rData = {
"id" : this.documentId,
"userid" : this.documentUserId,
"c" : "imgurl",
"saveindex" : g_oDocumentUrls.getMaxIndex(),
"data" : url
};
var t = this;
this.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
this.fCurCallback = function(input)
{
if (null != input && "imgurl" == input["type"])
{
if ("ok" == input["status"])
{
var data = input["data"];
var urls = {};
var firstUrl;
for (var i = 0; i < data.length; ++i)
{
var elem = data[i];
if (elem.url)
{
if (!firstUrl)
{
firstUrl = elem.url;
}
urls[elem.path] = elem.url;
}
}
g_oDocumentUrls.addUrls(urls);
if (firstUrl)
{
t.AddImageUrlAction(firstUrl, imgProp);
}
else
{
if (!callback) {
callback = function (url) {
//g_oDocumentUrls.addUrls(urls);
t.AddImageUrlAction('jio:' + url, imgProp);
};
}
//this.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
return new RSVP.Queue()
.push(function () {
return url;
})
.push(AscCommon.downloadUrlAsBlob)
.push(function (blob) {
return Common.Gateway.jio_putAttachment(t.documentId, undefined, blob);
})
.push(callback)
//.push(function () {t.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);})
.push(undefined, function (error) {
console.log(error);
t.sendEvent("asc_onError", c_oAscError.ID.Unknown, c_oAscError.Level.NoCritical);
}
}
else
{
t.sendEvent("asc_onError", mapAscServerErrorToAscError(parseInt(input["data"])), c_oAscError.Level.NoCritical);
}
}
else
{
t.sendEvent("asc_onError", c_oAscError.ID.Unknown, c_oAscError.Level.NoCritical);
}
t.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
};
sendCommand(this, null, rData);
//t.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
});
}
};
asc_docs_api.prototype.AddImageUrlAction = function(url, imgProp)
......@@ -4873,59 +4843,11 @@ background-repeat: no-repeat;\
return;
}
var rData = {
"id" : this.documentId,
"userid" : this.documentUserId,
"c" : "imgurl",
"saveindex" : g_oDocumentUrls.getMaxIndex(),
"data" : sImageToDownLoad
};
this.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
this.fCurCallback = function(input)
{
if (null != input && "imgurl" == input["type"])
{
if ("ok" == input["status"])
{
var data = input["data"];
var urls = {};
var firstUrl;
for (var i = 0; i < data.length; ++i)
{
var elem = data[i];
if (elem.url)
{
if (!firstUrl)
{
firstUrl = elem.url;
}
urls[elem.path] = elem.url;
}
}
g_oDocumentUrls.addUrls(urls);
if (firstUrl)
{
fReplaceCallback(firstUrl);
this.AddImageUrl(sImageToDownLoad, undefined, function (url) {
//g_oDocumentUrls.addUrls(urls);
fReplaceCallback('jio:' + url);
fApplyCallback();
}
else
{
oApi.sendEvent("asc_onError", c_oAscError.ID.Unknown, c_oAscError.Level.NoCritical);
}
}
else
{
oApi.sendEvent("asc_onError", mapAscServerErrorToAscError(parseInt(input["data"])), c_oAscError.Level.NoCritical);
}
}
else
{
oApi.sendEvent("asc_onError", c_oAscError.ID.Unknown, c_oAscError.Level.NoCritical);
}
oApi.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
};
sendCommand(this, null, rData);
});
}
else
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment