Download task_017/environment/code/app.js from Lego-X/UXInteract: direct link, hf CLI and curl.
- Browser
- Download file 840 Bytes
-
https://huggingface.co/datasets/Lego-X/UXInteract/resolve/main/task_017/environment/code/app.js
- Command line
-
hf download hf://datasets/Lego-X/UXInteract/task_017/environment/code/app.js
-
curl -L -o app.js https://huggingface.co/datasets/Lego-X/UXInteract/resolve/main/task_017/environment/code/app.js
840 Bytes
| const editor = document.querySelector('[data-testid="editor"]'); | |
| function openBlock(block) { | |
| if (block.querySelector('textarea')) return; | |
| const value = block.dataset.value || ''; | |
| block.classList.remove('empty'); | |
| block.innerHTML = `<textarea data-testid="active-input">${value}</textarea>`; | |
| block.querySelector('textarea').focus(); | |
| } | |
| function closeBlock(block) { | |
| const input = block.querySelector('textarea'); | |
| if (!input) return; | |
| block.dataset.value = input.value; | |
| block.classList.add('empty'); | |
| block.textContent = ''; | |
| } | |
| editor.addEventListener('click', event => { | |
| const block = event.target.closest('.block'); | |
| if (block) openBlock(block); | |
| }); | |
| document.addEventListener('click', event => { | |
| for (const block of document.querySelectorAll('.block')) { | |
| if (!block.contains(event.target)) closeBlock(block); | |
| } | |
| }); | |