From 3f47e98a7579cfd1196fcd56ab5b5d154a37e289 Mon Sep 17 00:00:00 2001 From: MrOtherGuy Date: Fri, 4 Sep 2020 09:47:44 +0300 Subject: [PATCH] Clear the code-block when switching categories --- html_resources/selector.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/html_resources/selector.js b/html_resources/selector.js index e6b4e89..b963257 100644 --- a/html_resources/selector.js +++ b/html_resources/selector.js @@ -104,8 +104,18 @@ function getSecondaryCategories(list){ return ret } +function clearCodeBlock(){ + const pre = document.getElementById("previewBox"); + for(let el of Array.from(pre.childNodes)){ + pre.remove(el) + } + return +} + async function onCategoryClicked(categoryNode,isSecondary = false){ + clearCodeBlock(); + currentCategory.set(categoryNode,isSecondary); // Using textContent is bad but meh //let names = DB.query(categoryNode.textContent);