From 63f6da832b02b398118af14dde31dfe7fadcc91d Mon Sep 17 00:00:00 2001 From: MrOtherGuy Date: Sat, 15 May 2021 08:40:18 +0300 Subject: [PATCH] make tagbrowser support combining multiple files from search query --- html_resources/selector.js | 24 ++++++++++++++++++++---- index.html | 3 ++- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/html_resources/selector.js b/html_resources/selector.js index 3499e4a..2f6aadb 100644 --- a/html_resources/selector.js +++ b/html_resources/selector.js @@ -436,7 +436,7 @@ const Highlighter = new(function(){ return this })(); -function handleSearchQuery(){ +async function handleSearchQuery(){ let params = (new URL(document.location)).searchParams; let param = params.get("tag"); if(param){ @@ -451,12 +451,27 @@ function handleSearchQuery(){ } param = params.get("file"); if(param){ - if(DB.keys.includes(param)){ - onTargetClicked(param) + let files = param.split(",").filter(a => DB.keys.includes(a)); + + if(files.length === 0 ){ + return + } + + const codeBlock = document.querySelector("pre"); + let composedText = ""; + for(let file of files){ + composedText += await fetchWithType(`chrome/${file}`); + composedText += "\n"; } + Highlighter.parse(codeBlock,composedText) } } +function showUI(){ + document.getElementById("placeholder").remove(); + document.getElementById("ui").classList.remove("hidden"); +} + document.onreadystatechange = (function () { if (document.readyState === "complete") { @@ -479,6 +494,7 @@ document.onreadystatechange = (function () { .then(initDB) .then(createCategories) .then(handleSearchQuery) - .catch(e=>{console.log(e);document.getElementById("ui").textContent = "FAILURE, Database could not be loaded"}); + .then(showUI) + .catch(e => console.log(e)) } }); \ No newline at end of file diff --git a/index.html b/index.html index dcfcc1d..76a9fa0 100644 --- a/index.html +++ b/index.html @@ -9,7 +9,8 @@ -
+
FAILURE, Database could not be loaded
+