Move 'vdom' to the main 'pad'.
Hide the right-hand panel (can de bisplayed with a 'debug' button) Hide the IDs of users if they don't change their name
This commit is contained in:
58
www/_pad/main.js
Normal file
58
www/_pad/main.js
Normal file
@@ -0,0 +1,58 @@
|
||||
define([
|
||||
'/api/config?cb=' + Math.random().toString(16).substring(2),
|
||||
'/pad/realtime-wysiwyg.js',
|
||||
'/common/messages.js',
|
||||
'/common/crypto.js',
|
||||
'/bower_components/jquery/dist/jquery.min.js',
|
||||
'/customize/pad.js'
|
||||
], function (Config, RTWysiwyg, Messages, Crypto) {
|
||||
var $ = window.jQuery;
|
||||
var ifrw = $('#pad-iframe')[0].contentWindow;
|
||||
var Ckeditor = ifrw.CKEDITOR;
|
||||
|
||||
var andThen = function (Ckeditor) {
|
||||
$(window).on('hashchange', function() {
|
||||
window.location.reload();
|
||||
});
|
||||
if (window.location.href.indexOf('#') === -1) {
|
||||
window.location.href = window.location.href + '#' + Crypto.genKey();
|
||||
return;
|
||||
}
|
||||
var key = Crypto.parseKey(window.location.hash.substring(1));
|
||||
var editor = Ckeditor.replace('editor1', {
|
||||
removeButtons: 'Source,Maximize',
|
||||
// magicline plugin inserts html crap into the document which is not part of the
|
||||
// document itself and causes problems when it's sent across the wire and reflected back
|
||||
removePlugins: 'magicline,resize'
|
||||
});
|
||||
editor.on('instanceReady', function () {
|
||||
editor.execCommand('maximize');
|
||||
|
||||
// (contenteditable) iframe in an iframe
|
||||
ifrw.$('iframe')[0].contentDocument.body.innerHTML = Messages.initialState;
|
||||
|
||||
var rtw =
|
||||
RTWysiwyg.start(ifrw, // window
|
||||
Config.websocketURL, // websocketUrl
|
||||
Crypto.rand64(8), // userName
|
||||
key.channel, // channel
|
||||
key.cryptKey); // cryptKey
|
||||
editor.on('change', function () { rtw.onEvent(); });
|
||||
});
|
||||
window.editor = editor;
|
||||
window.RTWysiwyg = RTWysiwyg;
|
||||
};
|
||||
|
||||
var interval = 100;
|
||||
var first = function () {
|
||||
Ckeditor = ifrw.CKEDITOR;
|
||||
if (Ckeditor) {
|
||||
andThen(Ckeditor);
|
||||
} else {
|
||||
console.log("Ckeditor was not defined. Trying again in %sms",interval);
|
||||
setTimeout(first, interval);
|
||||
}
|
||||
};
|
||||
|
||||
$(first);
|
||||
});
|
||||
Reference in New Issue
Block a user