|
|
@ -28,6 +28,8 @@ define([
|
|
|
|
};
|
|
|
|
};
|
|
|
|
var APP = window.APP;
|
|
|
|
var APP = window.APP;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var SLIDE_BACKCOLOR_ID = "cryptpad-backcolor";
|
|
|
|
|
|
|
|
var SLIDE_COLOR_ID = "cryptpad-color";
|
|
|
|
Cryptpad.styleAlerts();
|
|
|
|
Cryptpad.styleAlerts();
|
|
|
|
|
|
|
|
|
|
|
|
module.spinner.show();
|
|
|
|
module.spinner.show();
|
|
|
@ -156,6 +158,9 @@ define([
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var textColor;
|
|
|
|
|
|
|
|
var backColor;
|
|
|
|
|
|
|
|
|
|
|
|
var myData = {};
|
|
|
|
var myData = {};
|
|
|
|
var myUserName = ''; // My "pretty name"
|
|
|
|
var myUserName = ''; // My "pretty name"
|
|
|
|
var myID; // My server ID
|
|
|
|
var myID; // My server ID
|
|
|
@ -187,23 +192,34 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
var initializing = true;
|
|
|
|
var initializing = true;
|
|
|
|
|
|
|
|
|
|
|
|
var onLocal = config.onLocal = function () {
|
|
|
|
var stringifyInner = function (textValue) {
|
|
|
|
if (initializing) { return; }
|
|
|
|
var obj = {
|
|
|
|
if (readOnly) { return; }
|
|
|
|
content: textValue,
|
|
|
|
|
|
|
|
metadata: {
|
|
|
|
editor.save();
|
|
|
|
|
|
|
|
var textValue = canonicalize($textarea.val());
|
|
|
|
|
|
|
|
var obj = {content: textValue};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// append the userlist to the hyperjson structure
|
|
|
|
|
|
|
|
obj.metadata = {
|
|
|
|
|
|
|
|
users: userList
|
|
|
|
users: userList
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
if (!isDefaultTitle()) {
|
|
|
|
if (!isDefaultTitle()) {
|
|
|
|
obj.metadata.title = APP.title;
|
|
|
|
obj.metadata.title = APP.title;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (textColor) {
|
|
|
|
|
|
|
|
obj.metadata.color = textColor;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (backColor) {
|
|
|
|
|
|
|
|
obj.metadata.backColor = backColor;
|
|
|
|
|
|
|
|
}
|
|
|
|
// stringify the json and send it into chainpad
|
|
|
|
// stringify the json and send it into chainpad
|
|
|
|
var shjson = stringify(obj);
|
|
|
|
return stringify(obj);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var onLocal = config.onLocal = function () {
|
|
|
|
|
|
|
|
if (initializing) { return; }
|
|
|
|
|
|
|
|
if (readOnly) { return; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
editor.save();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var textValue = canonicalize($textarea.val());
|
|
|
|
|
|
|
|
var shjson = stringifyInner(textValue);
|
|
|
|
|
|
|
|
|
|
|
|
module.patchText(shjson);
|
|
|
|
module.patchText(shjson);
|
|
|
|
Slide.update(textValue);
|
|
|
|
Slide.update(textValue);
|
|
|
@ -429,7 +445,41 @@ define([
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var configureColors = function () {
|
|
|
|
|
|
|
|
$back = $('<button>', {
|
|
|
|
|
|
|
|
id: SLIDE_BACKCOLOR_ID,
|
|
|
|
|
|
|
|
'class': 'fa fa-square',
|
|
|
|
|
|
|
|
'style': 'font-family: FontAwesome; color: #000;',
|
|
|
|
|
|
|
|
title: Messages.backgroundButton + '\n' + Messages.backgroundButtonTitle
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$text = $('<button>', {
|
|
|
|
|
|
|
|
id: SLIDE_COLOR_ID,
|
|
|
|
|
|
|
|
'class': 'fa fa-i-cursor',
|
|
|
|
|
|
|
|
'style': 'font-family: FontAwesome; font-weight: bold; color: #fff; background: #000;',
|
|
|
|
|
|
|
|
title: Messages.colorButton + '\n' + Messages.colorButtonTitle
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$testColor = $('<input>', { type: 'color' });
|
|
|
|
|
|
|
|
if ($testColor.attr('type') !== "color") {alert('not supported'); return;}
|
|
|
|
|
|
|
|
$back.on('click', function() {
|
|
|
|
|
|
|
|
$('<input>', { type: 'color', value: backColor })
|
|
|
|
|
|
|
|
.on('change', function() {
|
|
|
|
|
|
|
|
updateColors(undefined, this.value);
|
|
|
|
|
|
|
|
onLocal();
|
|
|
|
|
|
|
|
}).click();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$text.on('click', function() {
|
|
|
|
|
|
|
|
$('<input>', { type: 'color', value: textColor })
|
|
|
|
|
|
|
|
.on('change', function() {
|
|
|
|
|
|
|
|
updateColors(this.value, undefined);
|
|
|
|
|
|
|
|
onLocal();
|
|
|
|
|
|
|
|
}).click();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$rightside.append($back).append($text);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
configureTheme();
|
|
|
|
configureTheme();
|
|
|
|
|
|
|
|
configureColors();
|
|
|
|
|
|
|
|
|
|
|
|
if (presentMode) {
|
|
|
|
if (presentMode) {
|
|
|
|
$('#top-bar').hide();
|
|
|
|
$('#top-bar').hide();
|
|
|
@ -474,6 +524,20 @@ define([
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var updateColors = function (text, back) {
|
|
|
|
|
|
|
|
if (text) {
|
|
|
|
|
|
|
|
textColor = text;
|
|
|
|
|
|
|
|
$modal.css('color', text);
|
|
|
|
|
|
|
|
$pad.contents().find('#' + SLIDE_COLOR_ID).css('color', text);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (back) {
|
|
|
|
|
|
|
|
backColor = back;
|
|
|
|
|
|
|
|
$modal.css('background-color', back);
|
|
|
|
|
|
|
|
$pad.contents().find('#' + SLIDE_COLOR_ID).css('background', back);
|
|
|
|
|
|
|
|
$pad.contents().find('#' + SLIDE_BACKCOLOR_ID).css('color', back);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var updateMetadata = function(shjson) {
|
|
|
|
var updateMetadata = function(shjson) {
|
|
|
|
// Extract the user list (metadata) from the hyperjson
|
|
|
|
// Extract the user list (metadata) from the hyperjson
|
|
|
|
var json = (shjson === "") ? "" : JSON.parse(shjson);
|
|
|
|
var json = (shjson === "") ? "" : JSON.parse(shjson);
|
|
|
@ -486,6 +550,7 @@ define([
|
|
|
|
if (json.metadata.title) {
|
|
|
|
if (json.metadata.title) {
|
|
|
|
updateTitle(json.metadata.title);
|
|
|
|
updateTitle(json.metadata.title);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
updateColors(json.metadata.color, json.metadata.backColor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -642,18 +707,8 @@ define([
|
|
|
|
editor.scrollTo(scroll.left, scroll.top);
|
|
|
|
editor.scrollTo(scroll.left, scroll.top);
|
|
|
|
|
|
|
|
|
|
|
|
if (!readOnly) {
|
|
|
|
if (!readOnly) {
|
|
|
|
var localDoc = canonicalize($textarea.val());
|
|
|
|
var textValue = canonicalize($textarea.val());
|
|
|
|
var hjson2 = {
|
|
|
|
var shjson2 = stringifyInner(textValue);
|
|
|
|
content: localDoc,
|
|
|
|
|
|
|
|
metadata: {
|
|
|
|
|
|
|
|
users: userList
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
highlightMode: highlightMode,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
if (!isDefaultTitle()) {
|
|
|
|
|
|
|
|
hjson2.metadata.title = APP.title;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var shjson2 = stringify(hjson2);
|
|
|
|
|
|
|
|
if (shjson2 !== shjson) {
|
|
|
|
if (shjson2 !== shjson) {
|
|
|
|
console.error("shjson2 !== shjson");
|
|
|
|
console.error("shjson2 !== shjson");
|
|
|
|
TextPatcher.log(shjson, TextPatcher.diff(shjson, shjson2));
|
|
|
|
TextPatcher.log(shjson, TextPatcher.diff(shjson, shjson2));
|
|
|
|