save feedback

master
Bel LaPointe 2022-02-09 15:29:05 -07:00
parent 1d4c826ade
commit aeea7f4855
2 changed files with 26 additions and 10 deletions

View File

@ -325,6 +325,7 @@ func (server *Server) apiV0FilesIDPutHandler(w http.ResponseWriter, r *http.Requ
}
func (server *Server) apiV0SearchHandler(w http.ResponseWriter, r *http.Request) error {
// TODO case insensitive
query := r.URL.Query().Get("q")
queries := strings.Split(query, " ")
if len(queries) == 0 {

View File

@ -7,14 +7,14 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/highlight.js/latest/styles/github.min.css">
<style>
#tree {
min-width: 60px;
}
#tree summary {
min-width: 180px;
}
#tree details {
padding-inline-start: 1em;
}
#tree summary {
min-width: 60px;
}
details {
margin-top: .35em;
margin-bottom: .35em;
@ -36,7 +36,7 @@
function init() {
/* TODO when no drawFile, disable editor or somethin */
drawTree()
setInterval(drawTree, 10000)
setInterval(drawTree, 100000)
var queryF = getParameterByName("f")
console.log("init query f:", queryF)
if (!queryF || queryF.length == "") {
@ -66,6 +66,9 @@
alert("todo")
}, body, headers)
drawTree()
document.getElementById("saveFeedback").innerHTML = "success!"
// todo cancel set timeout on setmde
setTimeout(() => {document.getElementById("saveFeedback").innerHTML = ""}, 5000)
}
function drawFile(id) {
if (!id || id.length < 1) {
@ -77,6 +80,7 @@
}
const title = headers("title") ? headers("title") : ""
setMDE(id, title, body)
document.getElementById("saveFeedback").innerHTML = ""
})
}
function drawNewFile(pid) {
@ -105,16 +109,26 @@
}
function drawTree() {
function htmlifyBranch(id, branch) {
var children = ""
var parent = `
<input type="button" value="${branch.Leaf.Title.substr(0, 15)}" onclick="drawFile('${id}');"/>
<input type="button" value="+" onclick="drawNewFile('${id}');"/>
`
if (id == "") {
parent = `
<span style="flex-grow:1"></span>
<input type="button" value="+" onclick="drawNewFile('${id}');"/>
`
}
var children = []
for (var child in branch.Branches)
children += "\n" + htmlifyBranch(id + "/" + child, branch.Branches[child])
children.push({title: branch.Branches[child].Leaf.Title, content: htmlifyBranch(id + "/" + child, branch.Branches[child])})
children = children.map((e) => `<!--${e.title}-->${e.content}`)
children.sort();
children = children.join("\n")
return `
<details open>
<summary>
<div>
<input type="button" value="${branch.Leaf.Title.substr(0, 15)}" onclick="drawFile('${id}');"/>
<input type="button" value="+" onclick="drawNewFile('${id}');"/>
</div>
<div>${parent}</div>
</summary>
${children}
</details>
@ -160,6 +174,7 @@
</span>
<span id="title" contenteditable style="flex-grow: 1;"></span>
<input type="submit" value="SAVE" onclick="pushFile(); return false;"/>
<span id="saveFeedback"></span>
</h1>
<textarea id="my-text-area"></textarea>
</article>