|
|
@ -409,7 +409,7 @@ define([
|
|
|
|
}
|
|
|
|
}
|
|
|
|
myUniqueOOId = undefined;
|
|
|
|
myUniqueOOId = undefined;
|
|
|
|
setMyId();
|
|
|
|
setMyId();
|
|
|
|
APP.docEditor.destroyEditor(); // Kill the old editor
|
|
|
|
if (APP.docEditor) { APP.docEditor.destroyEditor(); } // Kill the old editor
|
|
|
|
$('iframe[name="frameEditor"]').after(h('div#cp-app-oo-placeholder')).remove();
|
|
|
|
$('iframe[name="frameEditor"]').after(h('div#cp-app-oo-placeholder')).remove();
|
|
|
|
ooLoaded = false;
|
|
|
|
ooLoaded = false;
|
|
|
|
oldLocks = {};
|
|
|
|
oldLocks = {};
|
|
|
@ -546,6 +546,9 @@ define([
|
|
|
|
return new Blob([newText], {type: 'text/plain'});
|
|
|
|
return new Blob([newText], {type: 'text/plain'});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
var loadLastDocument = function (lastCp, onCpError, cb) {
|
|
|
|
var loadLastDocument = function (lastCp, onCpError, cb) {
|
|
|
|
|
|
|
|
if (!lastCp || !lastCp.file) {
|
|
|
|
|
|
|
|
return void onCpError('EEMPTY');
|
|
|
|
|
|
|
|
}
|
|
|
|
ooChannel.cpIndex = lastCp.index || 0;
|
|
|
|
ooChannel.cpIndex = lastCp.index || 0;
|
|
|
|
ooChannel.lastHash = lastCp.hash;
|
|
|
|
ooChannel.lastHash = lastCp.hash;
|
|
|
|
var parsed = Hash.parsePadUrl(lastCp.file);
|
|
|
|
var parsed = Hash.parsePadUrl(lastCp.file);
|
|
|
@ -611,6 +614,52 @@ define([
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var openVersionHash = function (version) {
|
|
|
|
|
|
|
|
readOnly = true;
|
|
|
|
|
|
|
|
var hashes = content.hashes || {};
|
|
|
|
|
|
|
|
var sortedCp = Object.keys(hashes).map(Number).sort(function (a, b) {
|
|
|
|
|
|
|
|
return hashes[a].index - hashes[b].index;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
var s = version.split('.');
|
|
|
|
|
|
|
|
if (s.length !== 2) { return; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var major = Number(s[0]);
|
|
|
|
|
|
|
|
var cpId = sortedCp[major - 1];
|
|
|
|
|
|
|
|
var nextCpId = sortedCp[major];
|
|
|
|
|
|
|
|
var cp = hashes[cpId] || {};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var minor = Number(s[1]) + 1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var toHash = cp.hash || 'NONE';
|
|
|
|
|
|
|
|
var fromHash = nextCpId ? hashes[nextCpId].hash : 'NONE';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sframeChan.query('Q_GET_HISTORY_RANGE', {
|
|
|
|
|
|
|
|
channel: content.channel,
|
|
|
|
|
|
|
|
lastKnownHash: fromHash,
|
|
|
|
|
|
|
|
toHash: toHash,
|
|
|
|
|
|
|
|
}, function (err, data) {
|
|
|
|
|
|
|
|
if (err) { return void console.error(err); }
|
|
|
|
|
|
|
|
if (!Array.isArray(data.messages)) { return void console.error('Not an array!'); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var messages = (data.messages || []).slice(1, minor).forEach(function (obj) {
|
|
|
|
|
|
|
|
try { obj.msg = JSON.parse(obj.msg); } catch (e) { console.error(e); }
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
loadLastDocument(cp, function () {
|
|
|
|
|
|
|
|
var file = getFileType();
|
|
|
|
|
|
|
|
var type = common.getMetadataMgr().getPrivateData().ooType;
|
|
|
|
|
|
|
|
var blob = loadInitDocument(type, true);
|
|
|
|
|
|
|
|
ooChannel.queue = messages;
|
|
|
|
|
|
|
|
resetData(blob, file);
|
|
|
|
|
|
|
|
UI.removeLoadingScreen();
|
|
|
|
|
|
|
|
}, function (blob, file) {
|
|
|
|
|
|
|
|
ooChannel.queue = messages;
|
|
|
|
|
|
|
|
resetData(blob, file);
|
|
|
|
|
|
|
|
UI.removeLoadingScreen();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var openRtChannel = function (cb) {
|
|
|
|
var openRtChannel = function (cb) {
|
|
|
|
if (rtChannel.ready) { return void cb(); }
|
|
|
|
if (rtChannel.ready) { return void cb(); }
|
|
|
|
var chan = content.channel || Hash.createChannelId();
|
|
|
|
var chan = content.channel || Hash.createChannelId();
|
|
|
@ -1763,10 +1812,10 @@ define([
|
|
|
|
makeCheckpoint(true);
|
|
|
|
makeCheckpoint(true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$save.appendTo(toolbar.$bottomM);
|
|
|
|
$save.appendTo(toolbar.$bottomM);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
(function () {
|
|
|
|
(function () {
|
|
|
|
/* add a history button */
|
|
|
|
/* add a history button */
|
|
|
|
// XXX move out of dev mode
|
|
|
|
|
|
|
|
var commit = function () {
|
|
|
|
var commit = function () {
|
|
|
|
APP.stopHistory = true;
|
|
|
|
APP.stopHistory = true;
|
|
|
|
makeCheckpoint(true);
|
|
|
|
makeCheckpoint(true);
|
|
|
@ -1831,7 +1880,7 @@ define([
|
|
|
|
History.create(common, histConfig);
|
|
|
|
History.create(common, histConfig);
|
|
|
|
}).appendTo(toolbar.$drawer);
|
|
|
|
}).appendTo(toolbar.$drawer);
|
|
|
|
})();
|
|
|
|
})();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (window.CP_DEV_MODE || DISPLAY_RESTORE_BUTTON) {
|
|
|
|
if (window.CP_DEV_MODE || DISPLAY_RESTORE_BUTTON) {
|
|
|
|
common.createButton('', true, {
|
|
|
|
common.createButton('', true, {
|
|
|
|
name: 'delete',
|
|
|
|
name: 'delete',
|
|
|
@ -1978,6 +2027,11 @@ define([
|
|
|
|
sframeChan.event('EV_BURN_PAD', content.channel);
|
|
|
|
sframeChan.event('EV_BURN_PAD', content.channel);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (privateData.ooVersionHash) {
|
|
|
|
|
|
|
|
return void openVersionHash(privateData.ooVersionHash);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var useNewDefault = content.version && content.version >= 2;
|
|
|
|
var useNewDefault = content.version && content.version >= 2;
|
|
|
|
openRtChannel(function () {
|
|
|
|
openRtChannel(function () {
|
|
|
|
setMyId();
|
|
|
|
setMyId();
|
|
|
|