make tagbrowser support combining multiple files from search query
This commit is contained in:
parent
d13b692ca3
commit
63f6da832b
2 changed files with 22 additions and 5 deletions
|
@ -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))
|
||||
}
|
||||
});
|
|
@ -9,7 +9,8 @@
|
|||
<link rel="icon" href="html_resources/favicon.svg" type="image/svg+xml">
|
||||
</head>
|
||||
<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>
|
||||
<div id="secondaryCategories" class="categoryList">
|
||||
|
|
Loading…
Reference in a new issue