|
|
|
@ -375,6 +375,32 @@ define([
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var onUploaded = function (ev, data, err) {
|
|
|
|
|
if (ev.newTemplate) {
|
|
|
|
|
if (err) {
|
|
|
|
|
console.error(err);
|
|
|
|
|
return void UI.warn(Messages.error);
|
|
|
|
|
}
|
|
|
|
|
var _content = ev.newTemplate;
|
|
|
|
|
_content.hashes = {};
|
|
|
|
|
_content.hashes[1] = {
|
|
|
|
|
file: data.url,
|
|
|
|
|
index: 0,
|
|
|
|
|
version: NEW_VERSION
|
|
|
|
|
};
|
|
|
|
|
_content.version = NEW_VERSION;
|
|
|
|
|
_content.channel = Hash.createChannelId();
|
|
|
|
|
sframeChan.query('Q_SAVE_AS_TEMPLATE', {
|
|
|
|
|
toSave: JSON.stringify({
|
|
|
|
|
content: _content
|
|
|
|
|
}),
|
|
|
|
|
title: ev.title
|
|
|
|
|
}, function () {
|
|
|
|
|
UI.alert(Messages.templateSaved);
|
|
|
|
|
Feedback.send('OO_TEMPLATE_CREATED');
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
content.saveLock = undefined;
|
|
|
|
|
if (err) {
|
|
|
|
|
console.error(err);
|
|
|
|
@ -2334,10 +2360,11 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null
|
|
|
|
|
if (editor) {
|
|
|
|
|
try { getEditor().asc_setRestriction(true); } catch (e) {}
|
|
|
|
|
}
|
|
|
|
|
var content = parsed.content;
|
|
|
|
|
var _content = parsed.content;
|
|
|
|
|
|
|
|
|
|
// Get checkpoint
|
|
|
|
|
var hashes = content.hashes || {};
|
|
|
|
|
var hashes = _content.hashes || {};
|
|
|
|
|
var medias = _content.mediasSources;
|
|
|
|
|
var idx = sortCpIndex(hashes);
|
|
|
|
|
var lastIndex = idx[idx.length - 1];
|
|
|
|
|
var lastCp = hashes[lastIndex] || {};
|
|
|
|
@ -2347,10 +2374,12 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null
|
|
|
|
|
// Last hash
|
|
|
|
|
var fromHash = 'NONE';
|
|
|
|
|
|
|
|
|
|
content.mediasSources = medias;
|
|
|
|
|
|
|
|
|
|
sframeChan.query('Q_GET_HISTORY_RANGE', {
|
|
|
|
|
href: href,
|
|
|
|
|
password: pw,
|
|
|
|
|
channel: content.channel,
|
|
|
|
|
channel: _content.channel,
|
|
|
|
|
lastKnownHash: fromHash,
|
|
|
|
|
toHash: toHash,
|
|
|
|
|
}, function (err, data) {
|
|
|
|
@ -2615,6 +2644,29 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null
|
|
|
|
|
if ($template && typeof($template.appendTo) === 'function') {
|
|
|
|
|
$template.appendTo(toolbar.$drawer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Save as template
|
|
|
|
|
if (!metadataMgr.getPrivateData().isTemplate) {
|
|
|
|
|
var templateObj = {
|
|
|
|
|
//rt: cpNfInner.chainpad,
|
|
|
|
|
getTitle: function () { return cpNfInner.metadataMgr.getMetadata().title; },
|
|
|
|
|
callback: function (title) {
|
|
|
|
|
var newContent = {};
|
|
|
|
|
newContent.mediasSources = content.mediasSources;
|
|
|
|
|
var text = getContent();
|
|
|
|
|
var blob = new Blob([text], {type: 'plain/text'});
|
|
|
|
|
var file = getFileType();
|
|
|
|
|
blob.name = title || (metadataMgr.getMetadataLazy().title || file.doc) + '.' + file.type;
|
|
|
|
|
var data = {
|
|
|
|
|
newTemplate: newContent,
|
|
|
|
|
title: title
|
|
|
|
|
};
|
|
|
|
|
APP.FM.handleFile(blob, data);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
var $templateButton = common.createButton('template', true, templateObj);
|
|
|
|
|
toolbar.$drawer.append($templateButton);
|
|
|
|
|
}
|
|
|
|
|
})();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|