Merge branch 'slides' into merge-slides

This commit is contained in:
ansuz 2016-09-20 16:28:36 +02:00
commit 723df4880e
5 changed files with 54 additions and 22 deletions

View File

@ -426,38 +426,38 @@ div.modal #content pre,
div#modal #content pre,
div.modal #content code,
div#modal #content code {
font-size: 2.5vw;
line-height: 3vw;
font-size: 2.75vw;
line-height: 3.025vw;
}
div.modal #content h1,
div#modal #content h1 {
font-size: 5vw;
line-height: 6vw;
line-height: 5.5vw;
}
div.modal #content h2,
div#modal #content h2 {
font-size: 4.2vw;
line-height: 5.04vw;
line-height: 4.62vw;
}
div.modal #content h3,
div#modal #content h3 {
font-size: 3.6vw;
line-height: 4.32vw;
line-height: 3.96vw;
}
div.modal #content h4,
div#modal #content h4 {
font-size: 3vw;
line-height: 3.6vw;
line-height: 3.3vw;
}
div.modal #content h5,
div#modal #content h5 {
font-size: 2.2vw;
line-height: 2.64vw;
line-height: 2.42vw;
}
div.modal #content h6,
div#modal #content h6 {
font-size: 1.6vw;
line-height: 1.92vw;
line-height: 1.76vw;
}
div.modal #content pre > code,
div#modal #content pre > code {

View File

@ -484,7 +484,7 @@ div.modal, div#modal {
box-sizing: border-box;
.size (@n) {
font-size: @n * 1vw;
line-height: @n * 1.2vw;
line-height: @n * 1.1vw;
}
border: 1px solid white;
@ -504,7 +504,7 @@ div.modal, div#modal {
left:0;right:0; // horizontal center
p, li, pre, code {
.size(2.5);
.size(2.75);
}
h1 { .size(5); }

View File

@ -81,7 +81,12 @@
#content ol {
font-size: 26px;
}
#content img {
position: relative;
max-width: 90%;
max-height: 90%;
margin: auto;
}
</style>
</head>
<body>

View File

@ -1,3 +1,4 @@
require.config({ paths: { 'json.sortify': '/bower_components/json.sortify/dist/JSON.sortify'} });
define([
'/api/config?cb=' + Math.random().toString(16).substring(2),
'/customize/messages.js',
@ -9,10 +10,11 @@ define([
'/common/notify.js',
'/common/visible.js',
'/common/clipboard.js',
'json.sortify',
'/bower_components/file-saver/FileSaver.min.js',
'/bower_components/jquery/dist/jquery.min.js',
'/customize/pad.js'
], function (Config, Messages, Realtime, Crypto, TextPatcher, Cryptpad, Slide, Notify, Visible, Clipboard) {
], function (Config, Messages, Realtime, Crypto, TextPatcher, Cryptpad, Slide, Notify, Visible, Clipboard, JSONSortify) {
var $ = window.jQuery;
var saveAs = window.saveAs;
@ -36,6 +38,8 @@ define([
Slide: Slide,
};
var Stringify = APP.Stringify = JSONSortify;
var initializing = true;
var $textarea = $('textarea');
@ -69,7 +73,7 @@ define([
Slide.setModal($modal, $content);
var config = APP.config = {
initialState: '',
initialState: '{}',
websocketURL: Config.websocketURL,
channel: secret.channel,
crypto: Crypto.createEncryptor(secret.key),
@ -80,11 +84,34 @@ define([
setEditable(false);
var safelyParseContent = function (S, k, first) {
if (!first) { return JSON.parse(S); }
try { return JSON.parse(S); }
catch (err) {
console.log("Migrating text content to object form");
var O = {};
O[k] = S;
return O;
}
};
var getUserObj = function (rt) {
return safelyParseContent(rt.getUserDoc(), 'content');
};
var onLocal = config.onLocal = function () {
if (initializing) { return; }
var content = canonicalize($textarea.val());
var textContent = canonicalize($textarea.val());
var userObj = getUserObj(APP.realtime);
userObj.content = textContent;
var content = Stringify(userObj);
APP.patchText(content);
Slide.update(content);
Slide.update(textContent);
};
var Button = function (opt) {
@ -228,10 +255,11 @@ define([
.append($export)
.append($share);
};
var onRemote = config.onRemote = function (info) {
if (initializing) { return; }
var userDoc = APP.realtime.getUserDoc();
var userObj = getUserObj(APP.realtime);
var userDoc = userObj.content;
var content = canonicalize($textarea.val());
var op = TextPatcher.diff(content, userDoc);
@ -256,7 +284,8 @@ define([
realtime: realtime
});
var content = canonicalize(realtime.getUserDoc());
var userObj = getUserObj(APP.realtime);
var content = canonicalize(userObj.content || '');
$textarea.val(content);

View File

@ -28,15 +28,11 @@ define([
};
var change = function (oldIndex, newIndex) {
if (oldIndex === newIndex) {
return false;
}
if (Slide.changeHandlers.length) {
Slide.changeHandlers.some(function (f, i) {
// HERE
f(oldIndex, newIndex, Slide.content.length);
});
return true;
}
};
@ -132,7 +128,9 @@ define([
Slide.content = content.split(/\n\s*\-\-\-\s*\n/).filter(truthy);
if (old !== Slide.content[Slide.index]) {
draw(Slide.index);
return;
}
change(Slide.lastIndex, Slide.index);
};
var left = Slide.left = function () {