|
|
|
@ -9205,6 +9205,7 @@ function saveWithParts(fSendCommand, fCallback, fCallbackRequest, oAdditionalDat
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function loadFileContent(url, callback) {
|
|
|
|
|
console.error(url);
|
|
|
|
|
asc_ajax({
|
|
|
|
|
url: url,
|
|
|
|
|
dataType: "text",
|
|
|
|
@ -9227,86 +9228,90 @@ function getImageFromChanges (name) {
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
function openFileCommand(binUrl, changesUrl, Signature, callback) {
|
|
|
|
|
var bError = false, oResult = new OpenFileResult(), bEndLoadFile = false, bEndLoadChanges = false;
|
|
|
|
|
var onEndOpen = function() {
|
|
|
|
|
if (bEndLoadFile && bEndLoadChanges) {
|
|
|
|
|
if (callback) {
|
|
|
|
|
callback(bError, oResult);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
var sFileUrl = binUrl;
|
|
|
|
|
sFileUrl = sFileUrl.replace(/\\/g, "/");
|
|
|
|
|
|
|
|
|
|
if (!window['IS_NATIVE_EDITOR']) {
|
|
|
|
|
asc_ajax({
|
|
|
|
|
url: sFileUrl,
|
|
|
|
|
dataType: "text",
|
|
|
|
|
success: function(result) {
|
|
|
|
|
//получаем url к папке с файлом
|
|
|
|
|
var url;
|
|
|
|
|
var nIndex = sFileUrl.lastIndexOf("/");
|
|
|
|
|
url = (-1 !== nIndex) ? sFileUrl.substring(0, nIndex + 1) : sFileUrl;
|
|
|
|
|
if (0 < result.length) {
|
|
|
|
|
oResult.bSerFormat = Signature === result.substring(0, Signature.length);
|
|
|
|
|
oResult.data = result;
|
|
|
|
|
oResult.url = url;
|
|
|
|
|
} else {
|
|
|
|
|
bError = true;
|
|
|
|
|
}
|
|
|
|
|
bEndLoadFile = true;
|
|
|
|
|
onEndOpen();
|
|
|
|
|
},
|
|
|
|
|
error: function() {
|
|
|
|
|
bEndLoadFile = true;
|
|
|
|
|
bError = true;
|
|
|
|
|
onEndOpen();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (null != changesUrl) {
|
|
|
|
|
getJSZipUtils().getBinaryContent(changesUrl, function(err, data) {
|
|
|
|
|
bEndLoadChanges = true;
|
|
|
|
|
if (err) {
|
|
|
|
|
bError = true;
|
|
|
|
|
onEndOpen();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
oZipChanges = new (require('jszip'))(data);
|
|
|
|
|
oResult.changes = [];
|
|
|
|
|
for (var i in oZipChanges.files) {
|
|
|
|
|
if (i.endsWith('.json')) {
|
|
|
|
|
// Заглушка на имя файла (стоило его начинать с цифры)
|
|
|
|
|
oResult.changes[parseInt(i.slice('changes'.length))] = JSON.parse(oZipChanges.files[i].asText());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
onEndOpen();
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
bEndLoadChanges = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (window['IS_NATIVE_EDITOR']) {
|
|
|
|
|
var result = window["native"]["openFileCommand"](sFileUrl, changesUrl, Signature);
|
|
|
|
|
|
|
|
|
|
var url;
|
|
|
|
|
var nIndex = sFileUrl.lastIndexOf("/");
|
|
|
|
|
url = (-1 !== nIndex) ? sFileUrl.substring(0, nIndex + 1) : sFileUrl;
|
|
|
|
|
if (0 < result.length) {
|
|
|
|
|
oResult.bSerFormat = Signature === result.substring(0, Signature.length);
|
|
|
|
|
oResult.data = result;
|
|
|
|
|
oResult.url = url;
|
|
|
|
|
} else {
|
|
|
|
|
bError = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bEndLoadFile = true;
|
|
|
|
|
onEndOpen();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
function openFileCommand(binUrl, changesUrl, Signature, callback) {
|
|
|
|
|
var bError = false, oResult = new OpenFileResult(), bEndLoadFile = false, bEndLoadChanges = false;
|
|
|
|
|
var onEndOpen = function() {
|
|
|
|
|
console.error("this is where we should decrypt");
|
|
|
|
|
if (bEndLoadFile && bEndLoadChanges) {
|
|
|
|
|
if (callback) {
|
|
|
|
|
callback(bError, oResult);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
var sFileUrl = binUrl;
|
|
|
|
|
sFileUrl = sFileUrl.replace(/\\/g, "/");
|
|
|
|
|
|
|
|
|
|
if (!window['IS_NATIVE_EDITOR']) {
|
|
|
|
|
asc_ajax({
|
|
|
|
|
url: sFileUrl,
|
|
|
|
|
dataType: "text",
|
|
|
|
|
success: function(result) {
|
|
|
|
|
//получаем url к папке с файлом
|
|
|
|
|
var url;
|
|
|
|
|
var nIndex = sFileUrl.lastIndexOf("/");
|
|
|
|
|
url = (-1 !== nIndex) ? sFileUrl.substring(0, nIndex + 1) : sFileUrl;
|
|
|
|
|
if (0 < result.length) {
|
|
|
|
|
oResult.bSerFormat = Signature === result.substring(0, Signature.length);
|
|
|
|
|
oResult.data = result;
|
|
|
|
|
oResult.url = url;
|
|
|
|
|
} else {
|
|
|
|
|
bError = true;
|
|
|
|
|
}
|
|
|
|
|
bEndLoadFile = true;
|
|
|
|
|
onEndOpen();
|
|
|
|
|
console.error(oResult); // XXX
|
|
|
|
|
},
|
|
|
|
|
error: function() {
|
|
|
|
|
bEndLoadFile = true;
|
|
|
|
|
bError = true;
|
|
|
|
|
onEndOpen();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (null != changesUrl) {
|
|
|
|
|
console.error("null changesUrl"); // XXX
|
|
|
|
|
getJSZipUtils().getBinaryContent(changesUrl, function(err, data) {
|
|
|
|
|
bEndLoadChanges = true;
|
|
|
|
|
if (err) {
|
|
|
|
|
bError = true;
|
|
|
|
|
onEndOpen();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
oZipChanges = new (require('jszip'))(data);
|
|
|
|
|
oResult.changes = [];
|
|
|
|
|
for (var i in oZipChanges.files) {
|
|
|
|
|
if (i.endsWith('.json')) {
|
|
|
|
|
// Заглушка на имя файла (стоило его начинать с цифры)
|
|
|
|
|
oResult.changes[parseInt(i.slice('changes'.length))] =
|
|
|
|
|
JSON.parse(oZipChanges.files[i].asText());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
onEndOpen();
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
bEndLoadChanges = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (window['IS_NATIVE_EDITOR']) {
|
|
|
|
|
console.error("is native editor");
|
|
|
|
|
var result = window["native"]["openFileCommand"](sFileUrl, changesUrl, Signature);
|
|
|
|
|
|
|
|
|
|
var url;
|
|
|
|
|
var nIndex = sFileUrl.lastIndexOf("/");
|
|
|
|
|
url = (-1 !== nIndex) ? sFileUrl.substring(0, nIndex + 1) : sFileUrl;
|
|
|
|
|
if (0 < result.length) {
|
|
|
|
|
oResult.bSerFormat = Signature === result.substring(0, Signature.length);
|
|
|
|
|
oResult.data = result;
|
|
|
|
|
oResult.url = url;
|
|
|
|
|
} else {
|
|
|
|
|
bError = true;
|
|
|
|
|
}
|
|
|
|
|
bEndLoadFile = true;
|
|
|
|
|
onEndOpen();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
function sendCommand(editor, fCallback, rdata, dataContainer) {
|
|
|
|
|
//json не должен превышать размера 2097152, иначе при его чтении будет exception
|
|
|
|
|
var docConnectionId = editor.CoAuthoringApi.getDocId();
|
|
|
|
|