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 { func (server *Server) apiV0SearchHandler(w http.ResponseWriter, r *http.Request) error {
// TODO case insensitive
query := r.URL.Query().Get("q") query := r.URL.Query().Get("q")
queries := strings.Split(query, " ") queries := strings.Split(query, " ")
if len(queries) == 0 { 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"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/highlight.js/latest/styles/github.min.css">
<style> <style>
#tree { #tree {
min-width: 60px;
}
#tree summary {
min-width: 180px; min-width: 180px;
} }
#tree details { #tree details {
padding-inline-start: 1em; padding-inline-start: 1em;
} }
#tree summary {
min-width: 60px;
}
details { details {
margin-top: .35em; margin-top: .35em;
margin-bottom: .35em; margin-bottom: .35em;
@ -36,7 +36,7 @@
function init() { function init() {
/* TODO when no drawFile, disable editor or somethin */ /* TODO when no drawFile, disable editor or somethin */
drawTree() drawTree()
setInterval(drawTree, 10000) setInterval(drawTree, 100000)
var queryF = getParameterByName("f") var queryF = getParameterByName("f")
console.log("init query f:", queryF) console.log("init query f:", queryF)
if (!queryF || queryF.length == "") { if (!queryF || queryF.length == "") {
@ -66,6 +66,9 @@
alert("todo") alert("todo")
}, body, headers) }, body, headers)
drawTree() drawTree()
document.getElementById("saveFeedback").innerHTML = "success!"
// todo cancel set timeout on setmde
setTimeout(() => {document.getElementById("saveFeedback").innerHTML = ""}, 5000)
} }
function drawFile(id) { function drawFile(id) {
if (!id || id.length < 1) { if (!id || id.length < 1) {
@ -77,6 +80,7 @@
} }
const title = headers("title") ? headers("title") : "" const title = headers("title") ? headers("title") : ""
setMDE(id, title, body) setMDE(id, title, body)
document.getElementById("saveFeedback").innerHTML = ""
}) })
} }
function drawNewFile(pid) { function drawNewFile(pid) {
@ -105,16 +109,26 @@
} }
function drawTree() { function drawTree() {
function htmlifyBranch(id, branch) { 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) 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 ` return `
<details open> <details open>
<summary> <summary>
<div> <div>${parent}</div>
<input type="button" value="${branch.Leaf.Title.substr(0, 15)}" onclick="drawFile('${id}');"/>
<input type="button" value="+" onclick="drawNewFile('${id}');"/>
</div>
</summary> </summary>
${children} ${children}
</details> </details>
@ -160,6 +174,7 @@
</span> </span>
<span id="title" contenteditable style="flex-grow: 1;"></span> <span id="title" contenteditable style="flex-grow: 1;"></span>
<input type="submit" value="SAVE" onclick="pushFile(); return false;"/> <input type="submit" value="SAVE" onclick="pushFile(); return false;"/>
<span id="saveFeedback"></span>
</h1> </h1>
<textarea id="my-text-area"></textarea> <textarea id="my-text-area"></textarea>
</article> </article>