master
bel 2022-02-09 23:03:43 -07:00
parent e0ead8f3c6
commit 9fa5dc767a
1 changed files with 35 additions and 25 deletions

View File

@ -42,10 +42,10 @@
function init() {
drawTree()
setInterval(drawTree, 100000)
navigateToQueryParams()
navigateToQueryParams()
}
function navigateToQueryParams() {
function navigateToQueryParams() {
var queryF = getParameterByName("f")
var queryQ = getParameterByName("q")
console.log("init query f:", queryF, "q:", queryQ)
@ -54,7 +54,7 @@
} else if (queryQ && queryQ.length > 0) {
searchFilesFor(queryQ)
}
}
}
function getParameterByName(name, url = window.location.href) {
name = name.replace(/[\[\]]/g, '\\$&');
@ -103,7 +103,7 @@
if (!results || results.length == 0)
innerHTML = "no results"
disableMDE()
navigateToQuery("q", q)
navigateToQuery("q", q)
document.getElementById("searchResults").innerHTML = innerHTML
})
}
@ -178,30 +178,30 @@
easyMDE.meta = {
id: id,
}
navigateToQuery("f", id)
navigateToQuery("f", id)
}
var lastNavigateToQuery = new Date()
var lastNavigateToQuery = new Date()
function navigateToQuery(k, v) {
if (new Date() - lastNavigateToQuery < .1)
return
lastNavigateToQuery = new Date()
const url = new URL(window.location)
url.searchParams.set(k, v)
var hash = "#?"
const it = url.searchParams.entries()
let result = it.next()
while (!result.done) {
hash = hash + result.value[0] + "=" + result.value[1] + "&"
result = it.next()
}
window.location.hash = hash
}
function navigateToQuery(k, v) {
if (new Date() - lastNavigateToQuery < .1)
return
lastNavigateToQuery = new Date()
const url = new URL(window.location)
url.searchParams.set(k, v)
var hash = "#?"
const it = url.searchParams.entries()
let result = it.next()
while (!result.done) {
hash = hash + result.value[0] + "=" + result.value[1] + "&"
result = it.next()
}
window.location.hash = hash
}
window.onhashchange = () => {
navigateToQueryParams()
}
window.onhashchange = () => {
navigateToQueryParams()
}
function drawTree() {
function htmlifyBranch(id, branch) {
@ -281,7 +281,9 @@
<div id="saveFeedback" style="min-height: 1.2em; text-align: right;">
</div>
<!-- todo: each line no is an anchor -->
<textarea id="my-text-area"></textarea>
<div style="font-family:Consolas,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New, monospace;">
<textarea id="my-text-area"></textarea>
</font>
</article>
</div>
</div>
@ -317,6 +319,14 @@
codeSyntaxHighlighting: true,
},
})
easyMDE.togglePreview()
/* todo */
setTimeout(() => {
var previews = document.getElementsByClassName("preview")
for (var i in previews) {
previews[i].classList.add("active")
}
}, 250)
function logValue() {
console.log(easyMDE.value())