2014-10-31 16:42:58 +01:00
|
|
|
define([
|
2015-01-29 17:55:18 +01:00
|
|
|
'/api/config?cb=' + Math.random().toString(16).substring(2),
|
|
|
|
|
'/pad/realtime-wysiwyg.js',
|
|
|
|
|
'/common/messages.js',
|
2015-01-30 16:52:23 +01:00
|
|
|
'/common/crypto.js',
|
2015-01-29 17:55:18 +01:00
|
|
|
'/bower_components/jquery/dist/jquery.min.js',
|
|
|
|
|
'/bower_components/ckeditor/ckeditor.js',
|
2015-01-30 16:52:23 +01:00
|
|
|
], function (Config, RTWysiwyg, Messages, Crypto) {
|
2014-10-31 16:42:58 +01:00
|
|
|
var Ckeditor = window.CKEDITOR;
|
2015-01-30 16:52:23 +01:00
|
|
|
var $ = window.jQuery;
|
2014-10-31 16:42:58 +01:00
|
|
|
|
|
|
|
|
$(function () {
|
|
|
|
|
$(window).on('hashchange', function() {
|
|
|
|
|
window.location.reload();
|
|
|
|
|
});
|
2015-01-28 17:58:55 +01:00
|
|
|
if (window.location.href.indexOf('#') === -1) {
|
2015-01-30 16:52:23 +01:00
|
|
|
window.location.href = window.location.href + '#' + Crypto.genKey();
|
2015-01-28 17:58:55 +01:00
|
|
|
return;
|
|
|
|
|
}
|
2015-01-30 16:52:23 +01:00
|
|
|
var key = Crypto.parseKey(window.location.hash.substring(1));
|
2014-10-31 16:42:58 +01:00
|
|
|
var editor = Ckeditor.replace('editor1', {
|
|
|
|
|
removeButtons: 'Source,Maximize',
|
2014-11-04 10:52:15 +01:00
|
|
|
// This 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.
|
2014-11-04 10:53:49 +01:00
|
|
|
removePlugins: 'magicline'
|
2014-10-31 16:42:58 +01:00
|
|
|
});
|
|
|
|
|
editor.on('instanceReady', function () {
|
2014-10-31 17:05:09 +01:00
|
|
|
editor.execCommand('maximize');
|
2014-10-31 16:42:58 +01:00
|
|
|
var ifr = window.ifr = $('iframe')[0];
|
2014-11-03 16:07:39 +01:00
|
|
|
ifr.contentDocument.body.innerHTML = Messages.initialState;
|
2014-10-31 16:42:58 +01:00
|
|
|
|
|
|
|
|
var rtw =
|
2014-11-03 11:13:41 +01:00
|
|
|
RTWysiwyg.start(Config.websocketURL,
|
2015-01-30 16:52:23 +01:00
|
|
|
Crypto.rand64(8),
|
|
|
|
|
key.channel,
|
2014-10-31 16:42:58 +01:00
|
|
|
key.cryptKey);
|
|
|
|
|
editor.on('change', function () { rtw.onEvent(); });
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|