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', '/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) { 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 module = 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 $modal = $('#modal'); var $content = $('#content'); Slide.setModal($modal, $content); var config = module.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()); module.patchText(content); Slide.update(content); }; var Button = function (opt) { return $('