|
|
@ -24,6 +24,9 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
$(function () {
|
|
|
|
$(function () {
|
|
|
|
Cryptpad.addLoadingScreen();
|
|
|
|
Cryptpad.addLoadingScreen();
|
|
|
|
|
|
|
|
var onConnectError = function (info) {
|
|
|
|
|
|
|
|
Cryptpad.errorLoadingScreen(Messages.websocketError);
|
|
|
|
|
|
|
|
};
|
|
|
|
var toolbar;
|
|
|
|
var toolbar;
|
|
|
|
|
|
|
|
|
|
|
|
var secret = Cryptpad.getSecrets();
|
|
|
|
var secret = Cryptpad.getSecrets();
|
|
|
@ -36,6 +39,8 @@ define([
|
|
|
|
/* Initialize Fabric */
|
|
|
|
/* Initialize Fabric */
|
|
|
|
var canvas = module.canvas = new Fabric.Canvas('canvas');
|
|
|
|
var canvas = module.canvas = new Fabric.Canvas('canvas');
|
|
|
|
var $canvas = $('canvas');
|
|
|
|
var $canvas = $('canvas');
|
|
|
|
|
|
|
|
var $controls = $('#controls');
|
|
|
|
|
|
|
|
var $canvasContainer = $('canvas').parents('.canvas-container');
|
|
|
|
|
|
|
|
|
|
|
|
var $width = $('#width');
|
|
|
|
var $width = $('#width');
|
|
|
|
var updateBrushWidth = function () {
|
|
|
|
var updateBrushWidth = function () {
|
|
|
@ -61,6 +66,9 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
var setEditable = function (bool) {
|
|
|
|
var setEditable = function (bool) {
|
|
|
|
if (readOnly && bool) { return; }
|
|
|
|
if (readOnly && bool) { return; }
|
|
|
|
|
|
|
|
if (bool) { $controls.show(); }
|
|
|
|
|
|
|
|
else { $controls.hide(); }
|
|
|
|
|
|
|
|
|
|
|
|
canvas.isDrawingMode = bool;
|
|
|
|
canvas.isDrawingMode = bool;
|
|
|
|
if (!bool) {
|
|
|
|
if (!bool) {
|
|
|
|
canvas.deactivateAll();
|
|
|
|
canvas.deactivateAll();
|
|
|
@ -69,7 +77,7 @@ define([
|
|
|
|
canvas.forEachObject(function (object) {
|
|
|
|
canvas.forEachObject(function (object) {
|
|
|
|
object.selectable = bool;
|
|
|
|
object.selectable = bool;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$canvas.css('border-color', bool? 'black': 'red');
|
|
|
|
$canvasContainer.css('border-color', bool? 'black': 'red');
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var saveImage = module.saveImage = function () {
|
|
|
|
var saveImage = module.saveImage = function () {
|
|
|
@ -115,6 +123,20 @@ define([
|
|
|
|
myUserName = myID;
|
|
|
|
myUserName = myID;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var suggestName = function (fallback) {
|
|
|
|
|
|
|
|
if (document.title === defaultName) {
|
|
|
|
|
|
|
|
return fallback || "";
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return document.title || defaultName;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var renameCb = function (err, title) {
|
|
|
|
|
|
|
|
if (err) { return; }
|
|
|
|
|
|
|
|
document.title = title;
|
|
|
|
|
|
|
|
module.onLocal();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var config = module.config = {
|
|
|
|
var config = module.config = {
|
|
|
|
initialState: '{}',
|
|
|
|
initialState: '{}',
|
|
|
|
websocketURL: Cryptpad.getWebsocketURL(),
|
|
|
|
websocketURL: Cryptpad.getWebsocketURL(),
|
|
|
@ -148,6 +170,11 @@ define([
|
|
|
|
if (readOnly) {delete config.changeNameID; }
|
|
|
|
if (readOnly) {delete config.changeNameID; }
|
|
|
|
toolbar = module.toolbar = Toolbar.create($bar, info.myID, info.realtime, info.getLag, userList, config);
|
|
|
|
toolbar = module.toolbar = Toolbar.create($bar, info.myID, info.realtime, info.getLag, userList, config);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var $rightside = $bar.find('.' + Toolbar.constants.rightside);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var $export = Cryptpad.createButton('export', true, {}, saveImage);
|
|
|
|
|
|
|
|
$rightside.append($export);
|
|
|
|
|
|
|
|
|
|
|
|
var editHash;
|
|
|
|
var editHash;
|
|
|
|
var viewHash = Cryptpad.getViewHashFromKeys(info.channel, secret.keys);
|
|
|
|
var viewHash = Cryptpad.getViewHashFromKeys(info.channel, secret.keys);
|
|
|
|
|
|
|
|
|
|
|
@ -168,20 +195,6 @@ define([
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var suggestName = function (fallback) {
|
|
|
|
|
|
|
|
if (document.title === defaultName) {
|
|
|
|
|
|
|
|
return fallback || "";
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return document.title || defaultName;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var renameCb = function (err, title) {
|
|
|
|
|
|
|
|
if (err) { return; }
|
|
|
|
|
|
|
|
document.title = title;
|
|
|
|
|
|
|
|
onLocal();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var updateTitle = function (newTitle) {
|
|
|
|
var updateTitle = function (newTitle) {
|
|
|
|
if (newTitle === document.title) { return; }
|
|
|
|
if (newTitle === document.title) { return; }
|
|
|
|
// Change the title now, and set it back to the old value if there is an error
|
|
|
|
// Change the title now, and set it back to the old value if there is an error
|
|
|
@ -242,6 +255,7 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
if (readOnly) { setEditable(false); }
|
|
|
|
if (readOnly) { setEditable(false); }
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
setEditable(false);
|
|
|
|
|
|
|
|
|
|
|
|
var stringifyInner = function (textValue) {
|
|
|
|
var stringifyInner = function (textValue) {
|
|
|
|
var obj = {
|
|
|
|
var obj = {
|
|
|
@ -296,6 +310,7 @@ define([
|
|
|
|
realtime: realtime
|
|
|
|
realtime: realtime
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Cryptpad.removeLoadingScreen();
|
|
|
|
setEditable(true);
|
|
|
|
setEditable(true);
|
|
|
|
initializing = false;
|
|
|
|
initializing = false;
|
|
|
|
onRemote();
|
|
|
|
onRemote();
|
|
|
@ -347,6 +362,11 @@ define([
|
|
|
|
Cryptpad.ready(function (err, env) {
|
|
|
|
Cryptpad.ready(function (err, env) {
|
|
|
|
andThen();
|
|
|
|
andThen();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
Cryptpad.onError(function (info) {
|
|
|
|
|
|
|
|
if (info) {
|
|
|
|
|
|
|
|
onConnectError();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|