|
|
@ -54,7 +54,7 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
var CHECKPOINT_INTERVAL = 100;
|
|
|
|
var CHECKPOINT_INTERVAL = 100;
|
|
|
|
var DISPLAY_RESTORE_BUTTON = false;
|
|
|
|
var DISPLAY_RESTORE_BUTTON = false;
|
|
|
|
var NEW_VERSION = 2;
|
|
|
|
var NEW_VERSION = 3;
|
|
|
|
var PENDING_TIMEOUT = 30000;
|
|
|
|
var PENDING_TIMEOUT = 30000;
|
|
|
|
var READ_ONLY_REFRESH_DATA_DELAY = 15000;
|
|
|
|
var READ_ONLY_REFRESH_DATA_DELAY = 15000;
|
|
|
|
|
|
|
|
|
|
|
@ -278,11 +278,16 @@ define([
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// DEPRECATED from version 3
|
|
|
|
// Loading a checkpoint reorder the sheet starting from ID "5".
|
|
|
|
// Loading a checkpoint reorder the sheet starting from ID "5".
|
|
|
|
// We have to reorder it manually when a checkpoint is created
|
|
|
|
// We have to reorder it manually when a checkpoint is created
|
|
|
|
// so that the messages we send to the realtime channel are
|
|
|
|
// so that the messages we send to the realtime channel are
|
|
|
|
// loadable by users joining after the checkpoint
|
|
|
|
// loadable by users joining after the checkpoint
|
|
|
|
var fixSheets = function () {
|
|
|
|
var fixSheets = function () {
|
|
|
|
|
|
|
|
// Starting from version 3, we don't need to fix the sheet IDs anymore
|
|
|
|
|
|
|
|
// because we reload onlyoffice whenever we receive a checkpoint
|
|
|
|
|
|
|
|
if (!APP.migrate || (content && content.version > 2)) { return; }
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
var editor = getEditor();
|
|
|
|
var editor = getEditor();
|
|
|
|
// if we are not in the sheet app
|
|
|
|
// if we are not in the sheet app
|
|
|
@ -742,12 +747,24 @@ define([
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var handleAuth = function (obj, send) {
|
|
|
|
var handleAuth = function (obj, send) {
|
|
|
|
setEditable(false);
|
|
|
|
//setEditable(false);
|
|
|
|
ooChannel.lastHash = getLastCp().hash;
|
|
|
|
|
|
|
|
|
|
|
|
var changes = [];
|
|
|
|
|
|
|
|
if (content.version > 2) {
|
|
|
|
|
|
|
|
ooChannel.queue.forEach(function (data) {
|
|
|
|
|
|
|
|
Array.prototype.push.apply(changes, data.msg.changes);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
ooChannel.ready = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ooChannel.cpIndex += ooChannel.queue.length;
|
|
|
|
|
|
|
|
var last = ooChannel.queue.pop();
|
|
|
|
|
|
|
|
if (last) { ooChannel.lastHash = last.hash; }
|
|
|
|
|
|
|
|
}
|
|
|
|
send({
|
|
|
|
send({
|
|
|
|
type: "authChanges",
|
|
|
|
type: "authChanges",
|
|
|
|
changes: []
|
|
|
|
changes: changes
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// Answer to the auth command
|
|
|
|
// Answer to the auth command
|
|
|
|
var p = getParticipants();
|
|
|
|
var p = getParticipants();
|
|
|
|
send({
|
|
|
|
send({
|
|
|
@ -1006,6 +1023,9 @@ define([
|
|
|
|
var url = URL.createObjectURL(blob);
|
|
|
|
var url = URL.createObjectURL(blob);
|
|
|
|
var lock = readOnly || APP.migrate;
|
|
|
|
var lock = readOnly || APP.migrate;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Starting from version 3, we can use the view mode again
|
|
|
|
|
|
|
|
var mode = (content && content.version > 2 && lock) ? "view" : "edit";
|
|
|
|
|
|
|
|
|
|
|
|
// Config
|
|
|
|
// Config
|
|
|
|
APP.ooconfig = {
|
|
|
|
APP.ooconfig = {
|
|
|
|
"document": {
|
|
|
|
"document": {
|
|
|
@ -1072,31 +1092,35 @@ define([
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"onDocumentReady": function () {
|
|
|
|
"onDocumentReady": function () {
|
|
|
|
// The doc is ready, fix the worksheets IDs and push the queue
|
|
|
|
// DEPRECATED: from version 3, the queue is sent again during init
|
|
|
|
fixSheets();
|
|
|
|
if (APP.migrate && ((content.version || 1) <= 2)) {
|
|
|
|
// Push changes since last cp
|
|
|
|
// The doc is ready, fix the worksheets IDs and push the queue
|
|
|
|
ooChannel.ready = true;
|
|
|
|
fixSheets();
|
|
|
|
ooChannel.queue.forEach(function (data) {
|
|
|
|
// Push changes since last cp
|
|
|
|
ooChannel.send(data.msg);
|
|
|
|
ooChannel.ready = true;
|
|
|
|
});
|
|
|
|
ooChannel.queue.forEach(function (data) {
|
|
|
|
if (!readOnly) {
|
|
|
|
ooChannel.send(data.msg);
|
|
|
|
var last = ooChannel.queue.pop();
|
|
|
|
});
|
|
|
|
if (last) { ooChannel.lastHash = last.hash; }
|
|
|
|
if (!readOnly) {
|
|
|
|
}
|
|
|
|
var last = ooChannel.queue.pop();
|
|
|
|
ooChannel.cpIndex += ooChannel.queue.length;
|
|
|
|
if (last) { ooChannel.lastHash = last.hash; }
|
|
|
|
// Apply existing locks
|
|
|
|
}
|
|
|
|
deleteOfflineLocks();
|
|
|
|
ooChannel.cpIndex += ooChannel.queue.length;
|
|
|
|
APP.onLocal();
|
|
|
|
|
|
|
|
handleNewLocks(oldLocks, content.locks || {});
|
|
|
|
// Apply existing locks
|
|
|
|
// Allow edition
|
|
|
|
deleteOfflineLocks();
|
|
|
|
|
|
|
|
APP.onLocal();
|
|
|
|
if (lock) {
|
|
|
|
handleNewLocks(oldLocks, content.locks || {});
|
|
|
|
setTimeout(function () {
|
|
|
|
// Allow edition
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (lock) {
|
|
|
|
|
|
|
|
setTimeout(function () {
|
|
|
|
|
|
|
|
setEditable(true);
|
|
|
|
|
|
|
|
getEditor().setViewModeDisconnect();
|
|
|
|
|
|
|
|
}, 60000);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
setEditable(true);
|
|
|
|
setEditable(true);
|
|
|
|
getEditor().setViewModeDisconnect();
|
|
|
|
}
|
|
|
|
}, 5000);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
setEditable(true);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (isLockedModal.modal && force) {
|
|
|
|
if (isLockedModal.modal && force) {
|
|
|
@ -1108,12 +1132,12 @@ define([
|
|
|
|
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'),
|
|
|
|
h('span', Messages.oo_sheetMigration_loading)
|
|
|
|
h('span', Messages.oo_sheetMigration_loading) // XXX tell them that it will take ~ 1min)
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
UI.openCustomModal(UI.dialog.customModal(div, {buttons: []}));
|
|
|
|
UI.openCustomModal(UI.dialog.customModal(div, {buttons: []}));
|
|
|
|
setTimeout(function () {
|
|
|
|
setTimeout(function () {
|
|
|
|
makeCheckpoint(true);
|
|
|
|
makeCheckpoint(true);
|
|
|
|
}, 5000);
|
|
|
|
}, 60000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1773,6 +1797,17 @@ define([
|
|
|
|
$(APP.helpMenu.menu).after(msg);
|
|
|
|
$(APP.helpMenu.menu).after(msg);
|
|
|
|
readOnly = true;
|
|
|
|
readOnly = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (content && content.version === 2) {
|
|
|
|
|
|
|
|
APP.migrate = true;
|
|
|
|
|
|
|
|
// Registedred users can start the migration
|
|
|
|
|
|
|
|
if (common.isLoggedIn()) {
|
|
|
|
|
|
|
|
content.migration = true;
|
|
|
|
|
|
|
|
APP.onLocal();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
var msg = h('div.alert.alert-warning.cp-burn-after-reading', Messages.oo_sheetMigration_anonymousEditor);
|
|
|
|
|
|
|
|
$(APP.helpMenu.menu).after(msg);
|
|
|
|
|
|
|
|
readOnly = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// If the sheet is locked by an offline user, remove it
|
|
|
|
// If the sheet is locked by an offline user, remove it
|
|
|
|