diff --git a/src/.vuepress/public/editor.html b/src/.vuepress/public/editor.html index 5388f232a..6f0de15a6 100644 --- a/src/.vuepress/public/editor.html +++ b/src/.vuepress/public/editor.html @@ -421,6 +421,7 @@
Documentation
var module_wat = '(module)\n' var module_wasm = new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0]) var didCompile = false + var compilingTimeout = null require([ 'vs/editor/editor.main', @@ -550,6 +551,24 @@
Documentation
} }, { passive: false }) + function debounce(fn, delay = 1500) { + let timeout + return function (...args) { + clearTimeout(compilingTimeout) + clearTimeout(timeout) + timeout = setTimeout(() => { + fn.call(this, ...args) + }, delay) + } + } + + document.querySelectorAll('input[id][type="checkbox"],input[id][type="radio"]').forEach(input => { + input.addEventListener('change', debounce(e => { + const activePane = document.querySelector('.tab.active') + recompile(activePane.id) + })) + }) + // Make tabs switchable document.querySelectorAll('.tab').forEach(element => { element.addEventListener('click', () => { @@ -558,31 +577,35 @@
Documentation
document.querySelectorAll('.pane').forEach(element => element.classList.remove('active')) const pane = document.getElementById(element.id.substring(0, element.id.length - 3)) pane.classList.add('active') - if (element.id == 'binaryTab') { - binaryEditor.setValue('(module\n 🚀\n)\n') - setTimeout(() => { - compile() - }, 10) - } else if (element.id == 'playTab') { - function serialize() { - return 'data:text/html;base64,' + btoa([ - '