Merge branch 'slides' into merge-slides

pull/1/head
ansuz 8 years ago
commit 723df4880e

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

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

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

@ -1,3 +1,4 @@
require.config({ paths: { 'json.sortify': '/bower_components/json.sortify/dist/JSON.sortify'} });
define([ define([
'/api/config?cb=' + Math.random().toString(16).substring(2), '/api/config?cb=' + Math.random().toString(16).substring(2),
'/customize/messages.js', '/customize/messages.js',
@ -9,10 +10,11 @@ define([
'/common/notify.js', '/common/notify.js',
'/common/visible.js', '/common/visible.js',
'/common/clipboard.js', '/common/clipboard.js',
'json.sortify',
'/bower_components/file-saver/FileSaver.min.js', '/bower_components/file-saver/FileSaver.min.js',
'/bower_components/jquery/dist/jquery.min.js', '/bower_components/jquery/dist/jquery.min.js',
'/customize/pad.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 $ = window.jQuery;
var saveAs = window.saveAs; var saveAs = window.saveAs;
@ -36,6 +38,8 @@ define([
Slide: Slide, Slide: Slide,
}; };
var Stringify = APP.Stringify = JSONSortify;
var initializing = true; var initializing = true;
var $textarea = $('textarea'); var $textarea = $('textarea');
@ -69,7 +73,7 @@ define([
Slide.setModal($modal, $content); Slide.setModal($modal, $content);
var config = APP.config = { var config = APP.config = {
initialState: '', initialState: '{}',
websocketURL: Config.websocketURL, websocketURL: Config.websocketURL,
channel: secret.channel, channel: secret.channel,
crypto: Crypto.createEncryptor(secret.key), crypto: Crypto.createEncryptor(secret.key),
@ -80,11 +84,34 @@ define([
setEditable(false); 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 () { var onLocal = config.onLocal = function () {
if (initializing) { return; } 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); APP.patchText(content);
Slide.update(content); Slide.update(textContent);
}; };
var Button = function (opt) { var Button = function (opt) {
@ -228,10 +255,11 @@ define([
.append($export) .append($export)
.append($share); .append($share);
}; };
var onRemote = config.onRemote = function (info) { var onRemote = config.onRemote = function (info) {
if (initializing) { return; } if (initializing) { return; }
var userDoc = APP.realtime.getUserDoc(); var userObj = getUserObj(APP.realtime);
var userDoc = userObj.content;
var content = canonicalize($textarea.val()); var content = canonicalize($textarea.val());
var op = TextPatcher.diff(content, userDoc); var op = TextPatcher.diff(content, userDoc);
@ -256,7 +284,8 @@ define([
realtime: realtime realtime: realtime
}); });
var content = canonicalize(realtime.getUserDoc()); var userObj = getUserObj(APP.realtime);
var content = canonicalize(userObj.content || '');
$textarea.val(content); $textarea.val(content);

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

Loading…
Cancel
Save