(function() { // eslint-disable-line 'use strict'; // eslint-disable-line /* global monaco, require */ const lessonHelperScriptRE = /'); html = obj.html; const tm = titleRE.exec(html); if (tm) { g.title = tm[1]; } let scripts = ''; html = html.replace(externalScriptRE, function(p0, p1, p2) { p1 = p1 || ''; scripts += '\n' + p1 + ''; return ''; }); let dataScripts = ''; html = html.replace(dataScriptRE, function(p0, p1, p2, p3) { p1 = p1 || ''; dataScripts += '\n' + p1 + ''; return ''; }); htmlParts.html.source += dataScripts; htmlParts.html.source += scripts + '\n'; // add style section if there is non if (html.indexOf('${css}') < 0) { html = html.replace('', '\n'); } // add hackedparams section. // We need a way to pass parameters to a blob. Normally they'd be passed as // query params but that only works in Firefox >:( html = html.replace('', '\n'); let links = ''; html = html.replace(cssLinkRE, function(p0, p1) { if (isCSSLinkRE.test(p1)) { const m = hrefRE.exec(p1); if (m) { links += `@import url("${m[1]}");\n`; } return ''; } else { return p0; } }); htmlParts.css.source = links + htmlParts.css.source; g.html = html; } function cantGetHTML(e) { // eslint-disable-line console.log(e); // eslint-disable-line console.log("TODO: don't run editor if can't get HTML"); // eslint-disable-line } function main() { const query = getQuery(); g.url = getFQUrl(query.url); g.query = getSearch(g.url); getHTML(query.url, function(err, html) { if (err) { console.log(err); // eslint-disable-line return; } parseHTML(query.url, html); setupEditor(query.url); if (query.startPane) { const button = document.querySelector('.button-' + query.startPane); toggleSourcePane(button); } }); } let blobUrl; function getSourceBlob(htmlParts, options) { options = options || {}; if (blobUrl) { URL.revokeObjectURL(blobUrl); } const prefix = dirname(g.url); let source = g.html; source = source.replace('${hackedParams}', JSON.stringify(g.query)); source = source.replace('${html}', htmlParts.html); source = source.replace('${css}', htmlParts.css); source = source.replace('${js}', htmlParts.js); source = source.replace('
', '\n'); source = source.replace('', '\n'); const scriptNdx = source.indexOf('