make json toolkit for the web?

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-17 22:23:01 -06:00
parent 841e6252c9
commit bee272651a
2 changed files with 66 additions and 0 deletions

6
go.sum Normal file
View File

@ -0,0 +1,6 @@
go.wit.com/dev/davecgh/spew v1.1.4 h1:C9hj/rjlUpdK+E6aroyLjCbS5MFcyNUOuP1ICLWdNek=
go.wit.com/dev/davecgh/spew v1.1.4/go.mod h1:sihvWmnQ/09FWplnEmozt90CCVqBtGuPXM811tgfhFA=
go.wit.com/gui/widget v1.1.4 h1:dCztWNSuTSSP+/M8h8F3cT7vWtoKdCL3DUQql0qLKdk=
go.wit.com/gui/widget v1.1.4/go.mod h1:A6/FaiFQtAHTjgo7c4FrokXe6bXX1Cowo35b2Lgi31E=
go.wit.com/log v0.5.5 h1:bK3b94uVKgev4jB5wg06FnvCFBEapQICTSH2YW+CWr4=
go.wit.com/log v0.5.5/go.mod h1:BaJBfHFqcJSJLXGQ9RHi3XVhPgsStxSMZRlaRxW4kAo=

60
tree/json.go Normal file
View File

@ -0,0 +1,60 @@
package tree
import (
"fmt"
"go.wit.com/log"
"go.wit.com/gui/widget"
)
// makes a JSON version to pass to the toolkits ?
// probably this should be in gui/toolkits/tree
/*
{"widget": {
"debug": "on",
"window": {
"title": "Sample Konfabulator Widget",
"name": "main_window",
"width": 500,
"height": 500
},
"image": {
"src": "Images/Sun.png",
"name": "sun1",
"hOffset": 250,
"vOffset": 250,
"alignment": "center"
},
"text": {
"data": "Click Here",
"size": 36,
"style": "bold",
"name": "text1",
"hOffset": 250,
"vOffset": 100,
"alignment": "center",
"onMouseUp": "sun1.opacity = (sun1.opacity / 100) * 90;"
}
}}
*/
func (n *Node) Json() []string {
var all []string
switch n.WidgetType {
case widget.Checkbox:
case widget.Button:
case widget.Combobox:
case widget.Dropdown:
case widget.Textbox:
case widget.Spinner:
case widget.Slider:
case widget.Window:
tmp := fmt.Sprint("{ WidgetType :", n.WidgetType, "}")
all = append(all, tmp)
log.Warn(tmp)
return all
default:
log.Info("doUserEvent() type =", n.WidgetType)
}
return all
}