diff --git a/website/public/js/wasm.js b/website/public/js/wasm.js index f8bc0d5..ca400b3 100644 --- a/website/public/js/wasm.js +++ b/website/public/js/wasm.js @@ -49,13 +49,14 @@ const main = () => { main(); const update = async (fixers, locale, content, resultElt, phpCodeElt, resultContentElt) => { - resultElt.classList.remove('u-d(none)'); - const phpCode = buildPhpCode(fixers, locale, content); - phpCodeElt.textContent = phpCode + const phpCode = buildPhpFixerCode(fixers, locale, content); + const phpHighlighCode = buildPhpHighlighCode(phpCode); + phpCodeElt.innerHTML = await runPhpCode(phpHighlighCode); resultContentElt.textContent = await runPhpCode(phpCode); + resultElt.classList.remove('u-d(none)'); } -const buildPhpCode = (fixers, locale, content) => { +const buildPhpFixerCode = (fixers, locale, content) => { return `setLocale(${JSON.stringify(locale)}); echo $fixer->fix(${JSON.stringify(content)});`; }; +const buildPhpHighlighCode = (phpCode) => { + return ` { FS.unlink('/app/src/index.php') FS.writeFile('/app/src/index.php', phpCode);