|
|
@ -55,6 +55,7 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
var CHECKPOINT_INTERVAL = 50;
|
|
|
|
var CHECKPOINT_INTERVAL = 50;
|
|
|
|
var DISPLAY_RESTORE_BUTTON = false;
|
|
|
|
var DISPLAY_RESTORE_BUTTON = false;
|
|
|
|
|
|
|
|
var NEW_VERSION = 2;
|
|
|
|
|
|
|
|
|
|
|
|
var debug = function (x) {
|
|
|
|
var debug = function (x) {
|
|
|
|
if (!window.CP_DEV_MODE) { return; }
|
|
|
|
if (!window.CP_DEV_MODE) { return; }
|
|
|
@ -79,7 +80,8 @@ define([
|
|
|
|
var content = {
|
|
|
|
var content = {
|
|
|
|
hashes: {},
|
|
|
|
hashes: {},
|
|
|
|
ids: {},
|
|
|
|
ids: {},
|
|
|
|
mediasSources: {}
|
|
|
|
mediasSources: {},
|
|
|
|
|
|
|
|
version: NEW_VERSION
|
|
|
|
};
|
|
|
|
};
|
|
|
|
var oldHashes = {};
|
|
|
|
var oldHashes = {};
|
|
|
|
var oldIds = {};
|
|
|
|
var oldIds = {};
|
|
|
@ -270,11 +272,23 @@ define([
|
|
|
|
};
|
|
|
|
};
|
|
|
|
oldHashes = JSON.parse(JSON.stringify(content.hashes));
|
|
|
|
oldHashes = JSON.parse(JSON.stringify(content.hashes));
|
|
|
|
content.saveLock = undefined;
|
|
|
|
content.saveLock = undefined;
|
|
|
|
|
|
|
|
// If this is a migration, set the new version
|
|
|
|
|
|
|
|
if (APP.migrate) {
|
|
|
|
|
|
|
|
delete content.migration;
|
|
|
|
|
|
|
|
content.version = NEW_VERSION;
|
|
|
|
|
|
|
|
}
|
|
|
|
APP.onLocal();
|
|
|
|
APP.onLocal();
|
|
|
|
APP.realtime.onSettle(function () {
|
|
|
|
APP.realtime.onSettle(function () {
|
|
|
|
fixSheets();
|
|
|
|
fixSheets();
|
|
|
|
UI.log(Messages.saved);
|
|
|
|
UI.log(Messages.saved);
|
|
|
|
APP.realtime.onSettle(function () {
|
|
|
|
APP.realtime.onSettle(function () {
|
|
|
|
|
|
|
|
if (APP.migrate) {
|
|
|
|
|
|
|
|
UI.removeModals();
|
|
|
|
|
|
|
|
UI.alert(Messages.oo_sheetMigration_complete, function () {
|
|
|
|
|
|
|
|
common.gotoURL();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
if (ev.callback) {
|
|
|
|
if (ev.callback) {
|
|
|
|
return void ev.callback();
|
|
|
|
return void ev.callback();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -313,6 +327,7 @@ define([
|
|
|
|
APP.FM.handleFile(blob, data);
|
|
|
|
APP.FM.handleFile(blob, data);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
var makeCheckpoint = function (force) {
|
|
|
|
var makeCheckpoint = function (force) {
|
|
|
|
|
|
|
|
if (!common.isLoggedIn()) { return; }
|
|
|
|
var locked = content.saveLock;
|
|
|
|
var locked = content.saveLock;
|
|
|
|
if (!locked || !isUserOnline(locked) || force) {
|
|
|
|
if (!locked || !isUserOnline(locked) || force) {
|
|
|
|
content.saveLock = myOOId;
|
|
|
|
content.saveLock = myOOId;
|
|
|
@ -520,6 +535,16 @@ define([
|
|
|
|
type: "documentOpen",
|
|
|
|
type: "documentOpen",
|
|
|
|
data: {"type":"open","status":"ok","data":{"Editor.bin":obj.openCmd.url}}
|
|
|
|
data: {"type":"open","status":"ok","data":{"Editor.bin":obj.openCmd.url}}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
if (APP.migrate && !readOnly) {
|
|
|
|
|
|
|
|
var div = h('div.cp-oo-x2tXls', [
|
|
|
|
|
|
|
|
h('span.fa.fa-spin.fa-spinner'),
|
|
|
|
|
|
|
|
h('span', Messages.oo_sheetMigration_loading)
|
|
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
UI.openCustomModal(UI.dialog.customModal(div, {buttons: []}));
|
|
|
|
|
|
|
|
setTimeout(function () {
|
|
|
|
|
|
|
|
makeCheckpoint(true);
|
|
|
|
|
|
|
|
}, 1000);
|
|
|
|
|
|
|
|
}
|
|
|
|
// Update current index
|
|
|
|
// Update current index
|
|
|
|
var last = ooChannel.queue.pop();
|
|
|
|
var last = ooChannel.queue.pop();
|
|
|
|
if (last) { ooChannel.lastHash = last.hash; }
|
|
|
|
if (last) { ooChannel.lastHash = last.hash; }
|
|
|
@ -696,7 +721,7 @@ define([
|
|
|
|
var startOO = function (blob, file) {
|
|
|
|
var startOO = function (blob, file) {
|
|
|
|
if (APP.ooconfig) { return void console.error('already started'); }
|
|
|
|
if (APP.ooconfig) { return void console.error('already started'); }
|
|
|
|
var url = URL.createObjectURL(blob);
|
|
|
|
var url = URL.createObjectURL(blob);
|
|
|
|
var lock = readOnly;// || !common.isLoggedIn();
|
|
|
|
var lock = readOnly || APP.migrate;
|
|
|
|
|
|
|
|
|
|
|
|
// Config
|
|
|
|
// Config
|
|
|
|
APP.ooconfig = {
|
|
|
|
APP.ooconfig = {
|
|
|
@ -748,7 +773,13 @@ define([
|
|
|
|
'#file-menu-panel { top: 28px !important; }' + // Position of the "File" menu
|
|
|
|
'#file-menu-panel { top: 28px !important; }' + // Position of the "File" menu
|
|
|
|
'#left-btn-spellcheck, #left-btn-about { display: none !important; }'+
|
|
|
|
'#left-btn-spellcheck, #left-btn-about { display: none !important; }'+
|
|
|
|
'div.btn-users.dropdown-toggle { display: none; !important }';
|
|
|
|
'div.btn-users.dropdown-toggle { display: none; !important }';
|
|
|
|
|
|
|
|
if (readOnly) {
|
|
|
|
|
|
|
|
css += '#toolbar { display: none !important; }';
|
|
|
|
|
|
|
|
}
|
|
|
|
$('<style>').text(css).appendTo($tb);
|
|
|
|
$('<style>').text(css).appendTo($tb);
|
|
|
|
|
|
|
|
setTimeout(function () {
|
|
|
|
|
|
|
|
$(window).trigger('resize');
|
|
|
|
|
|
|
|
});
|
|
|
|
if (UI.findOKButton().length) {
|
|
|
|
if (UI.findOKButton().length) {
|
|
|
|
UI.findOKButton().on('focusout', function () {
|
|
|
|
UI.findOKButton().on('focusout', function () {
|
|
|
|
window.setTimeout(function () { UI.findOKButton().focus(); });
|
|
|
|
window.setTimeout(function () { UI.findOKButton().focus(); });
|
|
|
@ -1360,7 +1391,7 @@ define([
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$rightside.append($forget);
|
|
|
|
$rightside.append($forget);
|
|
|
|
|
|
|
|
|
|
|
|
var helpMenu = common.createHelpMenu(['beta', 'oo']);
|
|
|
|
var helpMenu = APP.helpMenu = common.createHelpMenu(['beta', 'oo']);
|
|
|
|
$('#cp-app-oo-editor').prepend(common.getBurnAfterReadingWarning());
|
|
|
|
$('#cp-app-oo-editor').prepend(common.getBurnAfterReadingWarning());
|
|
|
|
$('#cp-app-oo-editor').prepend(helpMenu.menu);
|
|
|
|
$('#cp-app-oo-editor').prepend(helpMenu.menu);
|
|
|
|
toolbar.$drawer.append(helpMenu.button);
|
|
|
|
toolbar.$drawer.append(helpMenu.button);
|
|
|
@ -1402,6 +1433,28 @@ define([
|
|
|
|
Title.updateTitle(Title.defaultTitle);
|
|
|
|
Title.updateTitle(Title.defaultTitle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var version = '';
|
|
|
|
|
|
|
|
// Old version detected: use the old OO and start the migration if we can
|
|
|
|
|
|
|
|
if (content && !content.version) {
|
|
|
|
|
|
|
|
version = 'v1/';
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var s = h('script', {
|
|
|
|
|
|
|
|
type:'text/javascript',
|
|
|
|
|
|
|
|
src: '/common/onlyoffice/'+version+'web-apps/apps/api/documents/api.js'
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#cp-app-oo-editor').append(s);
|
|
|
|
|
|
|
|
|
|
|
|
if (metadataMgr.getPrivateData().burnAfterReading && content && content.channel) {
|
|
|
|
if (metadataMgr.getPrivateData().burnAfterReading && content && content.channel) {
|
|
|
|
sframeChan.event('EV_BURN_PAD', content.channel);
|
|
|
|
sframeChan.event('EV_BURN_PAD', content.channel);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1423,6 +1476,7 @@ define([
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var reloadPopup = false;
|
|
|
|
config.onRemote = function () {
|
|
|
|
config.onRemote = function () {
|
|
|
|
if (initializing) { return; }
|
|
|
|
if (initializing) { return; }
|
|
|
|
var userDoc = APP.realtime.getUserDoc();
|
|
|
|
var userDoc = APP.realtime.getUserDoc();
|
|
|
@ -1430,6 +1484,9 @@ define([
|
|
|
|
if (json.metadata) {
|
|
|
|
if (json.metadata) {
|
|
|
|
metadataMgr.updateMetadata(json.metadata);
|
|
|
|
metadataMgr.updateMetadata(json.metadata);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var wasMigrating = content.migration;
|
|
|
|
|
|
|
|
|
|
|
|
content = json.content;
|
|
|
|
content = json.content;
|
|
|
|
if (content.hashes) {
|
|
|
|
if (content.hashes) {
|
|
|
|
var latest = getLastCp(true);
|
|
|
|
var latest = getLastCp(true);
|
|
|
@ -1451,6 +1508,15 @@ define([
|
|
|
|
handleNewLocks(oldLocks, content.locks);
|
|
|
|
handleNewLocks(oldLocks, content.locks);
|
|
|
|
oldLocks = JSON.parse(JSON.stringify(content.locks));
|
|
|
|
oldLocks = JSON.parse(JSON.stringify(content.locks));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (content.migration) {
|
|
|
|
|
|
|
|
setEditable(false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wasMigrating && !content.migration && !reloadPopup) {
|
|
|
|
|
|
|
|
reloadPopup = true;
|
|
|
|
|
|
|
|
UI.alert(Messages.oo_sheetMigration_complete, function () {
|
|
|
|
|
|
|
|
common.gotoURL();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
pinImages();
|
|
|
|
pinImages();
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|