make tagbrowser support combining multiple files from search query

This commit is contained in:
MrOtherGuy 2021-05-15 08:40:18 +03:00
parent d13b692ca3
commit 63f6da832b
2 changed files with 22 additions and 5 deletions

View file

@ -436,7 +436,7 @@ const Highlighter = new(function(){
return this return this
})(); })();
function handleSearchQuery(){ async function handleSearchQuery(){
let params = (new URL(document.location)).searchParams; let params = (new URL(document.location)).searchParams;
let param = params.get("tag"); let param = params.get("tag");
if(param){ if(param){
@ -451,10 +451,25 @@ function handleSearchQuery(){
} }
param = params.get("file"); param = params.get("file");
if(param){ if(param){
if(DB.keys.includes(param)){ let files = param.split(",").filter(a => DB.keys.includes(a));
onTargetClicked(param)
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 () { document.onreadystatechange = (function () {
@ -479,6 +494,7 @@ document.onreadystatechange = (function () {
.then(initDB) .then(initDB)
.then(createCategories) .then(createCategories)
.then(handleSearchQuery) .then(handleSearchQuery)
.catch(e=>{console.log(e);document.getElementById("ui").textContent = "FAILURE, Database could not be loaded"}); .then(showUI)
.catch(e => console.log(e))
} }
}); });

View file

@ -9,7 +9,8 @@
<link rel="icon" href="html_resources/favicon.svg" type="image/svg+xml"> <link rel="icon" href="html_resources/favicon.svg" type="image/svg+xml">
</head> </head>
<body> <body>
<div id="ui"> <div id="placeholder">FAILURE, Database could not be loaded</div>
<div id="ui" class="hidden">
<div id="categories" class="categoryList"> <div id="categories" class="categoryList">
</div> </div>
<div id="secondaryCategories" class="categoryList"> <div id="secondaryCategories" class="categoryList">