|
|
|
define([
|
|
|
|
'jquery',
|
|
|
|
'/common/toolbar3.js',
|
|
|
|
'json.sortify',
|
|
|
|
'/bower_components/nthen/index.js',
|
|
|
|
'/common/sframe-common.js',
|
|
|
|
'/common/common-interface.js',
|
|
|
|
'/api/config',
|
|
|
|
'/customize/messages.js',
|
|
|
|
'/customize/application_config.js',
|
|
|
|
'/bower_components/chainpad/chainpad.dist.js',
|
|
|
|
|
|
|
|
'/bower_components/file-saver/FileSaver.min.js',
|
|
|
|
|
|
|
|
'css!/bower_components/bootstrap/dist/css/bootstrap.min.css',
|
|
|
|
'less!/bower_components/components-font-awesome/css/font-awesome.min.css',
|
|
|
|
'less!/customize/src/less2/main.less',
|
|
|
|
], function (
|
|
|
|
$,
|
|
|
|
Toolbar,
|
|
|
|
JSONSortify,
|
|
|
|
nThen,
|
|
|
|
SFCommon,
|
|
|
|
UI,
|
|
|
|
ApiConfig,
|
|
|
|
Messages,
|
|
|
|
AppConfig,
|
|
|
|
ChainPad)
|
|
|
|
{
|
|
|
|
var saveAs = window.saveAs;
|
|
|
|
|
|
|
|
var APP = window.APP = {
|
|
|
|
$: $
|
|
|
|
};
|
|
|
|
|
|
|
|
var stringify = function (obj) {
|
|
|
|
return JSONSortify(obj);
|
|
|
|
};
|
|
|
|
|
|
|
|
var toolbar;
|
|
|
|
|
|
|
|
var andThen = function (common) {
|
|
|
|
var config = {};
|
|
|
|
|
|
|
|
var getContent = APP.getContent = function () {
|
|
|
|
//window.frames[0].editor.asc_nativeGetFile();
|
|
|
|
return '';
|
|
|
|
};
|
|
|
|
|
|
|
|
var loadDocument = function (newPad) {
|
|
|
|
var type = common.getMetadataMgr().getPrivateData().ooType;
|
|
|
|
var file = {};
|
|
|
|
switch(type) {
|
|
|
|
case 'oodoc':
|
|
|
|
file.type = 'docx';
|
|
|
|
file.title = 'test.docx';
|
|
|
|
file.doc = 'text';
|
|
|
|
break;
|
|
|
|
case 'oocell':
|
|
|
|
file.type = 'xlsx';
|
|
|
|
file.title = 'test.xlsx';
|
|
|
|
file.doc = 'spreadsheet';
|
|
|
|
break;
|
|
|
|
case 'ooslide':
|
|
|
|
file.type = 'pptx';
|
|
|
|
file.title = 'test.pptx';
|
|
|
|
file.doc = 'presentation';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!newPad && false) {
|
|
|
|
// TODO
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var newText;
|
|
|
|
switch (type) {
|
|
|
|
case 'oocell' :
|
|
|
|
newText = 'XLSY;v2;3554;BQEQDAAAAhQMAAADgAIAAASeAgAAACwEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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SG1Tb3lMYTJ4TjJWM0ZvSWJBM2YySjFDQXRmR0M4UzQ5SFVYSEtqbVJWNE1BZjVzdnozUmdEVjNGQ3NVdXFRUTFaUHR6SEhVYmVQZHZCZHJteVJyRmptUkFrTzF2b3IvUjVsdkVsL2ZnVUZLazJyUjJva2J6N2NRS3pGOHJOV0pKeHB5MnFIZFZTQWZucXhKSUlQRzdNU3I2algwdjE4bldxVmhiSTZoSUVhSEhzOVREZXZXRFZTclVpUGRJbkIydHV5c3JCUkN1WTVqWkZlaElKcFNWVFk0MlNYNXVzbVZpZXg4ekFZMllxU09TYk51OERBY2FYdEExdmFXZkZlbFd0TnJxUDBKSVJVRU8yRC94QTl0ekFGWlZndGdEUHB5MDRXcFhnUnM0NXdueFpYSm8yZTVHS013dHFCa0lpNnl2czQ3T3poVWVjNzc2Y0FhdlJKcklPS3YwQ1kvbkM4VUJ2ZTVUZWtFa0wwK3h5bzZDUUZlc3Q3UmtITTJndzY2QkdSazVjeTNENDhtbjR1SElKNklHUWYvV2xIZmpHVmxiRzFaektHcGk2QkJXZDhub3c0eWdmQ2oyRHJKazRabzRHYXMvTjdpS214a0hvcC8yNGpYRzBUaDVkWldvc0p1TFVXOVpNbkd4Z3dBR3d5NDBmTHRhOTlWN1JDWXc2NDlSa1VCSGZ2QUp4NWgwdUZib3VnVEI4TFJteHJLMHhNalVOME9zUFZJTlR0ZDFtc3JrT2g4OGZHMTkvMWJDS1l2Z20zZXRSL0JVMzZ0VEluZkI1Z2V6N2dETlhxZDRmcWlEL09pcEp3dCs1UU
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
newText = '';
|
|
|
|
}
|
|
|
|
var blob = new Blob([newText], {type: 'text/plain'});
|
|
|
|
var url = URL.createObjectURL(blob);
|
|
|
|
|
|
|
|
APP.ooconfig = {
|
|
|
|
"document": {
|
|
|
|
"fileType": file.type,
|
|
|
|
"key": "fresh",
|
|
|
|
"title": file.title,
|
|
|
|
"url": url
|
|
|
|
},
|
|
|
|
"documentType": file.doc,
|
|
|
|
"editorConfig": {
|
|
|
|
customization: {
|
|
|
|
chat: false,
|
|
|
|
logo: {
|
|
|
|
url: "/bounce/#" + encodeURIComponent('https://www.onlyoffice.com')
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"user": {
|
|
|
|
"id": "", //"c0c3bf82-20d7-4663-bf6d-7fa39c598b1d",
|
|
|
|
"name": "", //"John Smith"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"events": {
|
|
|
|
"onDocumentStateChange": function (evt) {
|
|
|
|
if (evt.data) {
|
|
|
|
console.log('in change (local)');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
console.log("in change (remote)");
|
|
|
|
},
|
|
|
|
"onReady": function(/*evt*/) { console.log("in onReady"); },
|
|
|
|
"onAppReady": function(/*evt*/) { console.log("in onAppReady"); },
|
|
|
|
"onDownloadAs": function (evt) { console.log("in onDownloadAs", evt); }
|
|
|
|
}
|
|
|
|
};
|
|
|
|
window.onbeforeunload = function () {
|
|
|
|
var ifr = document.getElementsByTagName('iframe')[0];
|
|
|
|
if (ifr) { ifr.remove(); }
|
|
|
|
};
|
|
|
|
APP.docEditor = new DocsAPI.DocEditor("cp-app-oo-placeholder", APP.ooconfig);
|
|
|
|
};
|
|
|
|
|
|
|
|
var readOnly = false;
|
|
|
|
var initializing = true;
|
|
|
|
var $bar = $('#cp-toolbar');
|
|
|
|
var Title;
|
|
|
|
var cpNfInner;
|
|
|
|
var metadataMgr = common.getMetadataMgr();
|
|
|
|
|
|
|
|
config = {
|
|
|
|
readOnly: readOnly,
|
|
|
|
patchTransformer: ChainPad.NaiveJSONTransformer,
|
|
|
|
// cryptpad debug logging (default is 1)
|
|
|
|
// logLevel: 0,
|
|
|
|
validateContent: function (content) {
|
|
|
|
try {
|
|
|
|
JSON.parse(content);
|
|
|
|
return true;
|
|
|
|
} catch (e) {
|
|
|
|
console.log("Failed to parse, rejecting patch");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
var setEditable = function (state) {
|
|
|
|
console.log(state);
|
|
|
|
};
|
|
|
|
|
|
|
|
var stringifyInner = function (textValue) {
|
|
|
|
var obj = {
|
|
|
|
content: textValue,
|
|
|
|
metadata: metadataMgr.getMetadataLazy()
|
|
|
|
};
|
|
|
|
// stringify the json and send it into chainpad
|
|
|
|
return stringify(obj);
|
|
|
|
};
|
|
|
|
|
|
|
|
APP.onLocal = config.onLocal = function () {
|
|
|
|
if (initializing) { return; }
|
|
|
|
if (readOnly) { return; }
|
|
|
|
|
|
|
|
var data = getContent();
|
|
|
|
console.log('onLocal, data avalable');
|
|
|
|
var content = stringifyInner(data);
|
|
|
|
APP.realtime.contentUpdate(content);
|
|
|
|
};
|
|
|
|
|
|
|
|
config.onInit = function (info) {
|
|
|
|
readOnly = metadataMgr.getPrivateData().readOnly;
|
|
|
|
|
|
|
|
Title = common.createTitle({});
|
|
|
|
|
|
|
|
var configTb = {
|
|
|
|
displayed: [
|
|
|
|
'userlist',
|
|
|
|
'title',
|
|
|
|
'useradmin',
|
|
|
|
'spinner',
|
|
|
|
'newpad',
|
|
|
|
'share',
|
|
|
|
'limit',
|
|
|
|
'unpinnedWarning'
|
|
|
|
],
|
|
|
|
title: Title.getTitleConfig(),
|
|
|
|
metadataMgr: metadataMgr,
|
|
|
|
readOnly: readOnly,
|
|
|
|
realtime: info.realtime,
|
|
|
|
sfCommon: common,
|
|
|
|
$container: $bar,
|
|
|
|
$contentContainer: $('#cp-app-oo-container')
|
|
|
|
};
|
|
|
|
toolbar = APP.toolbar = Toolbar.create(configTb);
|
|
|
|
Title.setToolbar(toolbar);
|
|
|
|
|
|
|
|
var $rightside = toolbar.$rightside;
|
|
|
|
|
|
|
|
if (common.isLoggedIn()) {
|
|
|
|
common.createButton('hashtag', true).appendTo($rightside);
|
|
|
|
}
|
|
|
|
|
|
|
|
var $forget = common.createButton('forget', true, {}, function (err) {
|
|
|
|
if (err) { return; }
|
|
|
|
setEditable(false);
|
|
|
|
});
|
|
|
|
$rightside.append($forget);
|
|
|
|
};
|
|
|
|
|
|
|
|
config.onReady = function (info) {
|
|
|
|
if (APP.realtime !== info.realtime) {
|
|
|
|
APP.realtime = info.realtime;
|
|
|
|
}
|
|
|
|
|
|
|
|
var userDoc = APP.realtime.getUserDoc();
|
|
|
|
var isNew = false;
|
|
|
|
var newDoc = '';
|
|
|
|
if (userDoc === "" || userDoc === "{}") { isNew = true; }
|
|
|
|
|
|
|
|
if (userDoc !== "") {
|
|
|
|
var hjson = JSON.parse(userDoc);
|
|
|
|
|
|
|
|
if (hjson && hjson.metadata) {
|
|
|
|
metadataMgr.updateMetadata(hjson.metadata);
|
|
|
|
}
|
|
|
|
if (typeof (hjson) !== 'object' || Array.isArray(hjson) ||
|
|
|
|
(hjson.metadata && typeof(hjson.metadata.type) !== 'undefined' &&
|
|
|
|
hjson.metadata.type !== 'oo')) {
|
|
|
|
var errorText = Messages.typeError;
|
|
|
|
UI.errorLoadingScreen(errorText);
|
|
|
|
throw new Error(errorText);
|
|
|
|
}
|
|
|
|
newDoc = hjson.content;
|
|
|
|
} else {
|
|
|
|
Title.updateTitle(Title.defaultTitle);
|
|
|
|
}
|
|
|
|
|
|
|
|
loadDocument(newDoc);
|
|
|
|
|
|
|
|
initializing = false;
|
|
|
|
setEditable(!readOnly);
|
|
|
|
UI.removeLoadingScreen();
|
|
|
|
};
|
|
|
|
|
|
|
|
config.onRemote = function () {
|
|
|
|
if (initializing) { return; }
|
|
|
|
var userDoc = APP.realtime.getUserDoc();
|
|
|
|
var json = JSON.parse(userDoc);
|
|
|
|
if (json.metadata) {
|
|
|
|
metadataMgr.updateMetadata(json.metadata);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
config.onAbort = function () {
|
|
|
|
// inform of network disconnect
|
|
|
|
setEditable(false);
|
|
|
|
toolbar.failed();
|
|
|
|
UI.alert(Messages.common_connectionLost, undefined, true);
|
|
|
|
};
|
|
|
|
|
|
|
|
config.onConnectionChange = function (info) {
|
|
|
|
setEditable(info.state);
|
|
|
|
if (info.state) {
|
|
|
|
initializing = true;
|
|
|
|
UI.findOKButton().click();
|
|
|
|
} else {
|
|
|
|
UI.alert(Messages.common_connectionLost, undefined, true);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
cpNfInner = common.startRealtime(config);
|
|
|
|
|
|
|
|
cpNfInner.onInfiniteSpinner(function () {
|
|
|
|
setEditable(false);
|
|
|
|
UI.confirm(Messages.realtime_unrecoverableError, function (yes) {
|
|
|
|
if (!yes) { return; }
|
|
|
|
common.gotoURL();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
common.onLogout(function () { setEditable(false); });
|
|
|
|
};
|
|
|
|
|
|
|
|
var main = function () {
|
|
|
|
var common;
|
|
|
|
|
|
|
|
nThen(function (waitFor) {
|
|
|
|
$(waitFor(function () {
|
|
|
|
UI.addLoadingScreen();
|
|
|
|
}));
|
|
|
|
SFCommon.create(waitFor(function (c) { APP.common = common = c; }));
|
|
|
|
}).nThen(function (/*waitFor*/) {
|
|
|
|
andThen(common);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
main();
|
|
|
|
});
|