Documentation ¶
Index ¶
- Constants
- Variables
- func BoolData(v bool) *boolData
- func FloatData(v float64) *floatData
- func IntData(v int) *intData
- type E
- type El
- type Page
- func (d *Page) Attr(id string, k string, v interface{})
- func (d *Page) Button(id string, value interface{}, extra ...string) string
- func (d *Page) Checkbox(id, text string, value bool, extra ...string) string
- func (d *Page) CliBox(id string, value interface{}, extra ...string) string
- func (d *Page) Console(id string, rows, cols int, value interface{}, extra ...string) string
- func (t *Page) Data() interface{}
- func (d *Page) Element(id, typ, attr string, value interface{}, extra ...string) string
- func (t *Page) ErrorBox() string
- func (d *Page) Img(id string, value interface{}, extra ...string) string
- func (d *Page) JS() string
- func (d *Page) Meter(id string, min, max, value int, extra ...string) string
- func (d *Page) Number(id string, min, max, value int, extra ...string) string
- func (d *Page) OnAnyEvent(handler func())
- func (d *Page) OnEvent(id string, handler func())
- func (d *Page) OnUpdate(f func())
- func (d *Page) Progress(id string, max, value int, extra ...string) string
- func (d *Page) Range(id string, min, max, value int, extra ...string) string
- func (d *Page) Select(id string, value string, options ...string) string
- func (d *Page) SelectArray(id string, value string, options []string) string
- func (d *Page) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (d *Page) Set(id string, v interface{})
- func (d *Page) Span(id string, value interface{}, extra ...string) string
- func (d *Page) StringValue(id string) string
- func (d *Page) TextBox(id string, value interface{}, extra ...string) string
- func (t *Page) UpdateBox(text string) string
- func (t *Page) UpdateButton(text string) string
- func (d *Page) Value(id string) interface{}
Constants ¶
const JS = `` /* 4415-byte string literal not displayed */
Variables ¶
var Debug = false
Functions ¶
Types ¶
type E ¶
type E struct {
// contains filtered or unexported fields
}
wraps a GUI element (button, textbox, ...), stores the dirty flag, extra attributes, lock event handler, ...
type El ¶
type El interface {
// contains filtered or unexported methods
}
Underlying html element like Span, TextBox, etc.
type Page ¶
type Page struct {
// contains filtered or unexported fields
}
Page holds the state to serve a single GUI page to the browser
func NewPage ¶
NewPage constructs a Page based on an HTML template containing element tags like {{.Button}}, {{.Textbox}}, etc. data is fed to the template as additional arbitrary data, available as {{.Data}}.
func (*Page) Data ¶
func (t *Page) Data() interface{}
{{.Data}} returns the extra data that was passed to NewPage
func (*Page) ErrorBox ¶
{{.ErrorBox}} should be embedded in the template where errors are to be shown. CSS rules for class ErrorBox may be set, e.g., to render errors in red.
func (*Page) JS ¶
{{.JS}} should always be embedded in the template <head>. Expands to needed JavaScript code.
func (*Page) OnAnyEvent ¶
func (d *Page) OnAnyEvent(handler func())
OnEvent sets a handler to be called when an event happens to any of the page's HTML elements.
func (*Page) OnEvent ¶
OnEvent sets a handler to be called when an event happens to the HTML element with given id. The event depends on the element type: click for Button, change for TextBox, etc...
func (*Page) OnUpdate ¶
func (d *Page) OnUpdate(f func())
Set func to be executed each time javascript polls for updates
func (*Page) SelectArray ¶
func (*Page) ServeHTTP ¶
func (d *Page) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements http.Handler.
func (*Page) StringValue ¶
StringValue is like Value but returns the value as string, converting if necessary.
func (*Page) UpdateButton ¶
{{.UpdateButton}} adds a page Update button