|
|
@ -76,6 +76,7 @@ define([
|
|
|
|
var privateData = metadataMgr.getPrivateData();
|
|
|
|
var privateData = metadataMgr.getPrivateData();
|
|
|
|
var readOnly = false;
|
|
|
|
var readOnly = false;
|
|
|
|
var offline = false;
|
|
|
|
var offline = false;
|
|
|
|
|
|
|
|
var ooLoaded = false;
|
|
|
|
var pendingChanges = {};
|
|
|
|
var pendingChanges = {};
|
|
|
|
var config = {};
|
|
|
|
var config = {};
|
|
|
|
var content = {
|
|
|
|
var content = {
|
|
|
@ -302,6 +303,11 @@ define([
|
|
|
|
index: ev.index
|
|
|
|
index: ev.index
|
|
|
|
};
|
|
|
|
};
|
|
|
|
oldHashes = JSON.parse(JSON.stringify(content.hashes));
|
|
|
|
oldHashes = JSON.parse(JSON.stringify(content.hashes));
|
|
|
|
|
|
|
|
var hasDrawings = checkDrawings();
|
|
|
|
|
|
|
|
if (hasDrawings) {
|
|
|
|
|
|
|
|
content.locks = {};
|
|
|
|
|
|
|
|
content.ids = {};
|
|
|
|
|
|
|
|
}
|
|
|
|
// If this is a migration, set the new version
|
|
|
|
// If this is a migration, set the new version
|
|
|
|
if (APP.migrate) {
|
|
|
|
if (APP.migrate) {
|
|
|
|
delete content.migration;
|
|
|
|
delete content.migration;
|
|
|
@ -363,6 +369,23 @@ define([
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var resetData = function (blob, type) {
|
|
|
|
|
|
|
|
if (!isLockedModal.modal) {
|
|
|
|
|
|
|
|
isLockedModal.modal = UI.openCustomModal(isLockedModal.content);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
myUniqueOOId = undefined;
|
|
|
|
|
|
|
|
setMyId();
|
|
|
|
|
|
|
|
APP.docEditor.destroyEditor(); // Kill the old editor
|
|
|
|
|
|
|
|
$('iframe[name="frameEditor"]').after(h('div#cp-app-oo-placeholder')).remove();
|
|
|
|
|
|
|
|
ooLoaded = false;
|
|
|
|
|
|
|
|
oldLocks = {};
|
|
|
|
|
|
|
|
Object.keys(pendingChanges).forEach(function (key) {
|
|
|
|
|
|
|
|
clearTimeout(pendingChanges[key]);
|
|
|
|
|
|
|
|
delete pendingChanges[key];
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
startOO(blob, type, true);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var saveToServer = function () {
|
|
|
|
var saveToServer = function () {
|
|
|
|
var text = getContent();
|
|
|
|
var text = getContent();
|
|
|
|
var blob = new Blob([text], {type: 'plain/text'});
|
|
|
|
var blob = new Blob([text], {type: 'plain/text'});
|
|
|
@ -378,10 +401,11 @@ var hasDrawings = checkDrawings();
|
|
|
|
console.log(hasDrawings);
|
|
|
|
console.log(hasDrawings);
|
|
|
|
|
|
|
|
|
|
|
|
if (hasDrawings) {
|
|
|
|
if (hasDrawings) {
|
|
|
|
|
|
|
|
ooChannel.ready = false;
|
|
|
|
|
|
|
|
ooChannel.queue = [];
|
|
|
|
data.callback = function () {
|
|
|
|
data.callback = function () {
|
|
|
|
console.error('reload');
|
|
|
|
console.error('reload');
|
|
|
|
$('iframe[name="frameEditor"]').after(h('div#cp-app-oo-placeholder')).remove();// XXX
|
|
|
|
resetData(blob, file);
|
|
|
|
startOO(blob, file, true); // XXX
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -500,6 +524,7 @@ if (hasDrawings) {
|
|
|
|
var getParticipants = function () {
|
|
|
|
var getParticipants = function () {
|
|
|
|
var users = metadataMgr.getMetadata().users;
|
|
|
|
var users = metadataMgr.getMetadata().users;
|
|
|
|
var i = 1;
|
|
|
|
var i = 1;
|
|
|
|
|
|
|
|
var myIdx = false;
|
|
|
|
var p = Object.keys(content.ids || {}).map(function (id) {
|
|
|
|
var p = Object.keys(content.ids || {}).map(function (id) {
|
|
|
|
var nId = id.slice(0,32);
|
|
|
|
var nId = id.slice(0,32);
|
|
|
|
var ooId = content.ids[id].ooid;
|
|
|
|
var ooId = content.ids[id].ooid;
|
|
|
@ -870,7 +895,6 @@ if (hasDrawings) {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var ooLoaded = false;
|
|
|
|
|
|
|
|
var startOO = function (blob, file, force) {
|
|
|
|
var startOO = function (blob, file, force) {
|
|
|
|
if (APP.ooconfig && !force) { return void console.error('already started'); }
|
|
|
|
if (APP.ooconfig && !force) { return void console.error('already started'); }
|
|
|
|
var url = URL.createObjectURL(blob);
|
|
|
|
var url = URL.createObjectURL(blob);
|
|
|
@ -942,7 +966,6 @@ if (hasDrawings) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"onDocumentReady": function () {
|
|
|
|
"onDocumentReady": function () {
|
|
|
|
|
|
|
|
|
|
|
|
// The doc is ready, fix the worksheets IDs and push the queue
|
|
|
|
// The doc is ready, fix the worksheets IDs and push the queue
|
|
|
|
fixSheets();
|
|
|
|
fixSheets();
|
|
|
|
// Push changes since last cp
|
|
|
|
// Push changes since last cp
|
|
|
@ -960,6 +983,12 @@ if (hasDrawings) {
|
|
|
|
// Allow edition
|
|
|
|
// Allow edition
|
|
|
|
setEditable(true);
|
|
|
|
setEditable(true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isLockedModal.modal && force) {
|
|
|
|
|
|
|
|
isLockedModal.modal.closeModal();
|
|
|
|
|
|
|
|
delete isLockedModal.modal;
|
|
|
|
|
|
|
|
$('#cp-app-oo-editor > iframe')[0].contentWindow.focus();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (APP.migrate && !readOnly) {
|
|
|
|
if (APP.migrate && !readOnly) {
|
|
|
|
var div = h('div.cp-oo-x2tXls', [
|
|
|
|
var div = h('div.cp-oo-x2tXls', [
|
|
|
|
h('span.fa.fa-spin.fa-spinner'),
|
|
|
|
h('span.fa.fa-spin.fa-spinner'),
|
|
|
@ -1711,9 +1740,7 @@ if (hasDrawings) {
|
|
|
|
loadLastDocument(lastCp, function () {
|
|
|
|
loadLastDocument(lastCp, function () {
|
|
|
|
// On error, do nothing
|
|
|
|
// On error, do nothing
|
|
|
|
}, function (blob, type) {
|
|
|
|
}, function (blob, type) {
|
|
|
|
$('iframe[name="frameEditor"]').after(h('div#cp-app-oo-placeholder'))
|
|
|
|
resetData(blob, type);
|
|
|
|
.remove();// XXX
|
|
|
|
|
|
|
|
startOO(blob, type, true);
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -1743,6 +1770,11 @@ if (hasDrawings) {
|
|
|
|
var latest = getLastCp(true);
|
|
|
|
var latest = getLastCp(true);
|
|
|
|
var newLatest = getLastCp();
|
|
|
|
var newLatest = getLastCp();
|
|
|
|
if (newLatest.index > latest.index) {
|
|
|
|
if (newLatest.index > latest.index) {
|
|
|
|
|
|
|
|
var hasDrawings = checkDrawings();
|
|
|
|
|
|
|
|
if (hasDrawings) {
|
|
|
|
|
|
|
|
ooChannel.ready = false;
|
|
|
|
|
|
|
|
ooChannel.queue = [];
|
|
|
|
|
|
|
|
}
|
|
|
|
// New checkpoint
|
|
|
|
// New checkpoint
|
|
|
|
sframeChan.query('Q_OO_SAVE', {
|
|
|
|
sframeChan.query('Q_OO_SAVE', {
|
|
|
|
hash: newLatest.hash,
|
|
|
|
hash: newLatest.hash,
|
|
|
|