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
|
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,12 +451,27 @@ 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 () {
|
||||||
|
|
||||||
if (document.readyState === "complete") {
|
if (document.readyState === "complete") {
|
||||||
|
@ -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))
|
||||||
}
|
}
|
||||||
});
|
});
|
|
@ -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">
|
||||||
|
|
Loading…
Reference in a new issue