Make Canvas Work Again
This commit is contained in:
parent
4a173e30dc
commit
eeecb1baab
@ -4,6 +4,7 @@ www/code/codemirror*
|
|||||||
www/common/chainpad.js
|
www/common/chainpad.js
|
||||||
storage/kad.js
|
storage/kad.js
|
||||||
www/common/otaml.js
|
www/common/otaml.js
|
||||||
|
www/examples/canvas/fabric.js
|
||||||
|
|
||||||
server.js
|
server.js
|
||||||
NetFluxWebsocketSrv.js
|
NetFluxWebsocketSrv.js
|
||||||
|
|||||||
26125
www/examples/canvas/fabric.js
Normal file
26125
www/examples/canvas/fabric.js
Normal file
File diff suppressed because it is too large
Load Diff
@ -10,7 +10,7 @@ define([
|
|||||||
'json.sortify',
|
'json.sortify',
|
||||||
'/bower_components/chainpad-json-validator/json-ot.js',
|
'/bower_components/chainpad-json-validator/json-ot.js',
|
||||||
'/common/cryptpad-common.js',
|
'/common/cryptpad-common.js',
|
||||||
'/bower_components/fabric.js/dist/fabric.min.js',
|
'fabric.js',
|
||||||
'/bower_components/jquery/dist/jquery.min.js',
|
'/bower_components/jquery/dist/jquery.min.js',
|
||||||
'/bower_components/file-saver/FileSaver.min.js',
|
'/bower_components/file-saver/FileSaver.min.js',
|
||||||
//'/customize/pad.js'
|
//'/customize/pad.js'
|
||||||
@ -76,34 +76,47 @@ define([
|
|||||||
|
|
||||||
var config = module.config = {
|
var config = module.config = {
|
||||||
initialState: '{}',
|
initialState: '{}',
|
||||||
// TODO initialState ?
|
websocketURL: Cryptpad.getWebsocketURL(),
|
||||||
websocketURL: Config.websocketURL,
|
validateKey: secret.keys.validateKey,
|
||||||
//userName: Crypto.rand64(8),
|
readOnly: false, // TODO
|
||||||
channel: secret.channel,
|
channel: secret.channel,
|
||||||
//cryptKey: key,
|
crypto: Crypto.createEncryptor(secret.keys),
|
||||||
crypto: Crypto.createEncryptor(secret.key),
|
|
||||||
transformFunction: JsonOT.validate,
|
transformFunction: JsonOT.validate,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var editHash;
|
||||||
var onInit = config.onInit = function (info) {
|
var onInit = config.onInit = function (info) {
|
||||||
window.location.hash = info.channel + secret.key;
|
editHash = Cryptpad.getEditHashFromKeys(info.channel, secret.keys);
|
||||||
$(window).on('hashchange', function() {
|
|
||||||
window.location.reload();
|
Cryptpad.replaceHash(editHash);
|
||||||
});
|
|
||||||
|
//window.location.hash = info.channel + secret.key;
|
||||||
|
//$(window).on('hashchange', function() { window.location.reload(); });
|
||||||
};
|
};
|
||||||
|
|
||||||
var onRemote = config.onRemote = function () {
|
var Catch = function (f) {
|
||||||
|
return function () {
|
||||||
|
try {
|
||||||
|
f();
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
var onRemote = config.onRemote = Catch(function () {
|
||||||
if (initializing) { return; }
|
if (initializing) { return; }
|
||||||
var userDoc = module.realtime.getUserDoc();
|
var userDoc = module.realtime.getUserDoc();
|
||||||
|
|
||||||
canvas.loadFromJSON(userDoc);
|
canvas.loadFromJSON(userDoc);
|
||||||
canvas.renderAll();
|
canvas.renderAll();
|
||||||
};
|
});
|
||||||
|
|
||||||
var onLocal = config.onLocal = function () {
|
var onLocal = config.onLocal = Catch(function () {
|
||||||
if (initializing) { return; }
|
if (initializing) { return; }
|
||||||
var content = JSONSortify(canvas.toDatalessJSON());
|
var content = JSONSortify(canvas.toDatalessJSON());
|
||||||
module.patchText(content);
|
module.patchText(content);
|
||||||
};
|
});
|
||||||
|
|
||||||
var onReady = config.onReady = function (info) {
|
var onReady = config.onReady = function (info) {
|
||||||
var realtime = module.realtime = info.realtime;
|
var realtime = module.realtime = info.realtime;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user