From ac8a7cf3d4039c825b3484fa3c6ab44fc9838e16 Mon Sep 17 00:00:00 2001 From: baxiry Date: Thu, 12 Sep 2024 17:09:46 +0300 Subject: [PATCH] fix web shell show output data bug --- engine/store.go | 6 ++---- main.go | 14 ++++++-------- static/shell.js | 6 +++++- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/engine/store.go b/engine/store.go index 98a9c93..0c7b9c7 100644 --- a/engine/store.go +++ b/engine/store.go @@ -5,8 +5,6 @@ import ( "fmt" "strings" - //_ "github.com/mattn/go-sqlite3" - _ "modernc.org/sqlite" ) @@ -20,7 +18,7 @@ var db *DB func NewDB(dbName string) *DB { - newdb, err := sql.Open("sqlite", dbName) // sqlite3 whith mattn lib + newdb, err := sql.Open("sqlite", dbName) if err != nil { panic(err) } @@ -46,7 +44,7 @@ func NewDB(dbName string) *DB { db.lastid[tableName] = lid - fmt.Println("Table Name:", tableName) + //fmt.Println("Table Name:", tableName) } return db } diff --git a/main.go b/main.go index 6c402fb..7cd1624 100644 --- a/main.go +++ b/main.go @@ -24,11 +24,10 @@ func main() { http.Handle("/static/", http.FileServer(http.FS(content))) - http.HandleFunc("/shell", shell) - - // not importent - http.HandleFunc("/dev", dev) + http.HandleFunc("/", index) + http.HandleFunc("/index", shell) + http.HandleFunc("/shell", shell) // standard endpoint http.HandleFunc("/ws", engine.Ws) @@ -36,20 +35,19 @@ func main() { http.HandleFunc("/query", engine.Request) http.HandleFunc("/result", engine.Response) + // for pages under development + http.HandleFunc("/dev", dev) + log.Println(http.ListenAndServe(":1111", nil)) } // redirect to shell page temporary func dev(w http.ResponseWriter, r *http.Request) { - // TODO create index page - //http.Redirect(w, r, "http://localhost:1111/shell", http.StatusSeeOther) f, err := content.ReadFile("static/dev.html") - if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } - fmt.Fprint(w, string(f)) } diff --git a/static/shell.js b/static/shell.js index 30085a9..b68accf 100644 --- a/static/shell.js +++ b/static/shell.js @@ -112,7 +112,11 @@ function calcHeight(value) { let textarea = document.querySelector("textarea"); textarea.addEventListener("keyup", (e) => { - textarea.style.height = calcHeight(textarea.value) + "px"; + let hi = calcHeight(textarea.value) + "px" + textarea.style.height = hi; + + $("#output").css("height", "calc(100vh - "+hi+")" ) + //css height: calc(100vh - 100px); //console.log("event : ", e) });