define([ '/api/config?cb=' + Math.random().toString(16).substring(2), '/customize/messages.js', '/bower_components/chainpad-netflux/chainpad-netflux.js', '/bower_components/chainpad-crypto/crypto.js', '/bower_components/textpatcher/TextPatcher.amd.js', '/common/cryptpad-common.js', '/slide/slide.js', '/common/notify.js', '/common/visible.js', '/common/clipboard.js', '/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) { var $ = window.jQuery; var saveAs = window.saveAs; /* TODO * patch in changes using DiffDOM * predraw some things in case they use external assets * strip out script tags? * better CSS * use codemirror instead of a text editor * add ability to link to a rendered slide * ui hint for escaping presentation mode */ Cryptpad.styleAlerts(); var secret = Cryptpad.getSecrets(); var APP = window.APP = { TextPatcher: TextPatcher, Slide: Slide, }; var initializing = true; var $textarea = $('textarea'); var suggestName = function () { var title = ''; var patt = /^#\s+(.*)\s*$/; $textarea.val().split("\n").some(function (line) { if (!patt.test(line)) { return; } line.replace(patt, function (a, b) { title = b; }); return true; }); return title; }; var unnotify = function () { if (!(APP.tabNofification && typeof(APP.tabNofification.cancel) === 'function')) { return; } APP.tabNofification.cancel(); }; var notify = function () { if (!(Visible.isSupported() && !Visible.currently())) { return; } unnotify(); APP.tabNofification = Notify.tab(document.title, 1000, 10); }; var $modal = $('#modal'); var $content = $('#content'); Slide.setModal($modal, $content); var config = APP.config = { initialState: '', websocketURL: Config.websocketURL, channel: secret.channel, crypto: Crypto.createEncryptor(secret.key), }; var setEditable = function (bool) { $textarea.attr('disabled', !bool); }; var canonicalize = function (text) { return text.replace(/\r\n/g, '\n'); }; setEditable(false); var onLocal = config.onLocal = function () { if (initializing) { return; } var content = canonicalize($textarea.val()); APP.patchText(content); Slide.update(content); }; var Button = function (opt) { return $('