Documentation ¶
Overview ¶
Package jaws provides a mechanism to create dynamic webpages using Javascript and WebSockets.
It integrates well with Go's html/template package, but can be used without it. It can be used with any router that supports the standard ServeHTTP interface.
Example ¶
package main import ( "html/template" "log/slog" "net/http" "github.com/linkdata/jaws" ) const indexhtml = ` <html> <head>{{$.HeadHTML}}</head> <body>{{$.Range .Dot}}</body> </html> ` func main() { jw := jaws.New() // create a default JaWS instance defer jw.Close() // ensure we clean up jw.Logger = slog.Default() // optionally set the logger to use // parse our template and inform JaWS about it templates := template.Must(template.New("index").Parse(indexhtml)) jw.AddTemplateLookuper(templates) go jw.Serve() // start the JaWS processing loop http.DefaultServeMux.Handle("/jaws/", jw) // ensure the JaWS routes are handled var f jaws.Float // somewhere to store the slider data http.DefaultServeMux.Handle("/", jw.Handler("index", &f)) slog.Error(http.ListenAndServe("localhost:8080", nil).Error()) }
Output:
Index ¶
- Constants
- Variables
- func AppendID(b []byte) []byte
- func JawsKeyAppend(b []byte, jawsKey uint64) []byte
- func JawsKeyString(jawsKey uint64) string
- func JawsKeyValue(jawsKey string) uint64
- func MakeID() string
- func MustTagExpand(rq *Request, tag any) []any
- func NextID() int64
- func PreloadHTML(urls ...*url.URL) string
- func TagExpand(rq *Request, tag any) ([]any, error)
- func TagString(tag any) string
- func WriteHtmlInner(w io.Writer, jid jid.Jid, htmlTag, typeAttr string, innerHtml template.HTML, ...) (err error)
- func WriteHtmlInput(w io.Writer, jid jid.Jid, typeAttr, valueAttr string, ...) (err error)
- func WriteHtmlSelect(w io.Writer, jid jid.Jid, nba *NamedBoolArray, attrs []template.HTMLAttr) (err error)
- func WriteHtmlTag(w io.Writer, jid jid.Jid, htmlTag, typeAttr, valueAttr string, ...) (err error)
- type AnySetter
- type Binding
- func (bind Binding[T]) Get() (value T)
- func (bind Binding[T]) JawsGet(elem *Element) T
- func (bind Binding[T]) JawsGetBool(e *Element) bool
- func (bind Binding[T]) JawsGetFloat(e *Element) float64
- func (bind Binding[T]) JawsGetString(e *Element) string
- func (bind Binding[T]) JawsGetTag(*Request) any
- func (bind Binding[T]) JawsGetTime(elem *Element) time.Time
- func (bind Binding[T]) JawsSet(elem *Element, value T) error
- func (bind Binding[T]) JawsSetBool(e *Element, val bool) (err error)
- func (bind Binding[T]) JawsSetFloat(e *Element, val float64) (err error)
- func (bind Binding[T]) JawsSetString(e *Element, val string) (err error)
- func (bind Binding[T]) JawsSetTime(elem *Element, value time.Time) error
- func (bind Binding[T]) Set(value T) (err error)
- type Bool
- func (s *Bool) Get() (val bool)
- func (s *Bool) JawsGetBool(*Element) bool
- func (s *Bool) JawsSetBool(e *Element, val bool) error
- func (s *Bool) MarshalJSON() ([]byte, error)
- func (s *Bool) MarshalText() ([]byte, error)
- func (s *Bool) Set(val bool)
- func (s *Bool) String() string
- func (s *Bool) Swap(val bool) (old bool)
- func (s *Bool) UnmarshalJSON(b []byte) (err error)
- func (s *Bool) UnmarshalText(b []byte) (err error)
- type BoolSetter
- type ClickFndeprecated
- type ClickHandler
- type ConnectFn
- type Container
- type Element
- func (e *Element) Append(htmlCode template.HTML)
- func (e *Element) ApplyGetter(getter any) (tag any)
- func (e *Element) ApplyParams(params []any) (retv []template.HTMLAttr)
- func (e *Element) HasTag(tag any) bool
- func (e *Element) JawsRender(w io.Writer, params []any) (err error)
- func (e *Element) JawsUpdate()
- func (e *Element) Jid() jid.Jid
- func (e *Element) JsCall(arg string)
- func (e *Element) JsSet(val string)
- func (e *Element) Order(jidList []jid.Jid)
- func (e *Element) Remove(htmlId string)
- func (e *Element) RemoveAttr(attr string)
- func (e *Element) RemoveClass(cls string)
- func (e *Element) Replace(htmlCode template.HTML)
- func (e *Element) SetAttr(attr, val string)
- func (e *Element) SetClass(cls string)
- func (e *Element) SetInner(innerHtml template.HTML)
- func (e *Element) SetValue(val string)
- func (e *Element) String() string
- func (e *Element) Tag(tags ...any)
- func (e *Element) Ui() UI
- type EventFn
- type EventHandler
- type Float
- func (s *Float) Get() (val float64)
- func (s *Float) JawsGetFloat(*Element) float64
- func (s *Float) JawsSetFloat(e *Element, val float64) error
- func (s *Float) MarshalJSON() ([]byte, error)
- func (s *Float) Set(val float64)
- func (s *Float) String() string
- func (s *Float) Swap(val float64) (old float64)
- func (s *Float) UnmarshalJSON(b []byte) (err error)
- type FloatSetter
- type Getter
- type Handler
- type HtmlGetter
- type InputBoolFndeprecated
- type InputDateFndeprecated
- type InputFloatFndeprecated
- type InputTextFndeprecated
- type IsJsVar
- type Jaws
- func (jw *Jaws) AddTemplateLookuper(tl TemplateLookuper)
- func (jw *Jaws) Alert(lvl, msg string)
- func (jw *Jaws) Append(target any, html template.HTML)
- func (jw *Jaws) Broadcast(msg Message)
- func (jw *Jaws) Close()
- func (jw *Jaws) Delete(target any)
- func (jw *Jaws) Dirty(tags ...any)
- func (jw *Jaws) Done() <-chan struct{}
- func (jw *Jaws) GenerateHeadHTML(extra ...string) (err error)
- func (jw *Jaws) GetSession(hr *http.Request) (sess *Session)
- func (jw *Jaws) Handler(name string, dot any) http.Handler
- func (jw *Jaws) Insert(target any, where, html string)
- func (jw *Jaws) Log(err error) error
- func (jw *Jaws) LookupTemplate(name string) *template.Template
- func (jw *Jaws) MustLog(err error)
- func (jw *Jaws) NewRequest(hr *http.Request) (rq *Request)
- func (jw *Jaws) NewSession(w http.ResponseWriter, hr *http.Request) (sess *Session)
- func (jw *Jaws) Pending() (n int)
- func (jw *Jaws) Redirect(url string)
- func (jw *Jaws) Reload()
- func (jw *Jaws) RemoveAttr(target any, attr string)
- func (jw *Jaws) RemoveClass(target any, cls string)
- func (jw *Jaws) RemoveTemplateLookuper(tl TemplateLookuper)
- func (jw *Jaws) Replace(target any, where, html string)
- func (jw *Jaws) RequestCount() (n int)
- func (jw *Jaws) Serve()
- func (jw *Jaws) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (jw *Jaws) ServeWithTimeout(requestTimeout time.Duration)
- func (jw *Jaws) Session(h http.Handler) http.Handler
- func (jw *Jaws) SessionCount() (n int)
- func (jw *Jaws) Sessions() (sl []*Session)
- func (jw *Jaws) SetAttr(target any, attr, val string)
- func (jw *Jaws) SetClass(target any, cls string)
- func (jw *Jaws) SetInner(target any, innerHtml template.HTML)
- func (jw *Jaws) SetValue(target any, val string)
- func (jw *Jaws) UseRequest(jawsKey uint64, hr *http.Request) (rq *Request)
- type Jid
- type JsFunc
- type JsVar
- func (ui JsVar[T]) AppendJSON(b []byte, e *Element) []byte
- func (ui JsVar[T]) JawsEvent(e *Element, wht what.What, val string) (err error)
- func (ui JsVar[T]) JawsGetTag(rq *Request) any
- func (ui JsVar[T]) JawsIsJsVar()
- func (ui JsVar[T]) JawsRender(e *Element, w io.Writer, params []any) (err error)
- func (ui JsVar[T]) JawsUpdate(e *Element)
- type Message
- type NamedBool
- func (nb *NamedBool) Array() *NamedBoolArray
- func (nb *NamedBool) Checked() (checked bool)
- func (nb *NamedBool) Html() (h template.HTML)
- func (nb *NamedBool) JawsGetBool(*Element) (v bool)
- func (nb *NamedBool) JawsGetHtml(*Element) (h template.HTML)
- func (nb *NamedBool) JawsGetString(*Element) (name string)
- func (nb *NamedBool) JawsSetBool(e *Element, checked bool) (err error)
- func (nb *NamedBool) Name() (s string)
- func (nb *NamedBool) Set(checked bool) (changed bool)
- func (nb *NamedBool) String() string
- type NamedBoolArray
- func (nba *NamedBoolArray) Add(name string, text template.HTML) *NamedBoolArray
- func (nba *NamedBoolArray) Get() (name string)
- func (nba *NamedBoolArray) IsChecked(name string) (state bool)
- func (nba *NamedBoolArray) JawsContains(e *Element) (contents []UI)
- func (nba *NamedBoolArray) JawsGetString(e *Element) string
- func (nba *NamedBoolArray) JawsSetString(e *Element, name string) (err error)
- func (nba *NamedBoolArray) ReadLocked(fn func(nbl []*NamedBool))
- func (nba *NamedBoolArray) Set(name string, state bool) (changed bool)
- func (nba *NamedBoolArray) String() string
- func (nba *NamedBoolArray) WriteLocked(fn func(nbl []*NamedBool) []*NamedBool)
- type RLocker
- type RadioElement
- type Renderer
- type Request
- func (rq *Request) Alert(lvl, msg string)
- func (rq *Request) AlertError(err error)
- func (rq *Request) Context() (ctx context.Context)
- func (rq *Request) Dirty(tags ...any)
- func (rq *Request) Done() (ch <-chan struct{})
- func (rq *Request) Get(key string) any
- func (rq *Request) GetConnectFn() (fn ConnectFn)
- func (rq *Request) GetElements(tagitem any) (elems []*Element)
- func (rq *Request) HasTag(elem *Element, tag any) (yes bool)
- func (rq *Request) HeadHTML(w io.Writer) (err error)
- func (rq *Request) Initial() (r *http.Request)
- func (rq *Request) JawsKeyString() string
- func (rq *Request) NewElement(ui UI) *Element
- func (rq *Request) Redirect(url string)
- func (rq *Request) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (rq *Request) Session() (sess *Session)
- func (rq *Request) Set(key string, val any)
- func (rq *Request) SetConnectFn(fn ConnectFn)
- func (rq *Request) String() string
- func (rq *Request) Tag(elem *Element, tags ...any)
- func (rq *Request) TagsOf(elem *Element) (tags []any)
- func (rq *Request) Writer(w io.Writer) RequestWriter
- type RequestWriter
- func (rq RequestWriter) A(innerHtml any, params ...any) error
- func (rq RequestWriter) Button(innerHtml any, params ...any) error
- func (rq RequestWriter) Checkbox(value any, params ...any) error
- func (rq RequestWriter) Container(outerHtmlTag string, c Container, params ...any) error
- func (rq RequestWriter) Date(value any, params ...any) error
- func (rq RequestWriter) Div(innerHtml any, params ...any) error
- func (rw RequestWriter) Get(key string) (val any)
- func (rw RequestWriter) HeadHTML() error
- func (rq RequestWriter) Img(imageSrc any, params ...any) error
- func (rw RequestWriter) Initial() *http.Request
- func (rq RequestWriter) JsFunc(jsfuncname string, getter any, params ...any) (err error)
- func (rq RequestWriter) JsVar(jsvarname string, setter any, params ...any) (err error)
- func (rq RequestWriter) Label(innerHtml any, params ...any) error
- func (rq RequestWriter) Li(innerHtml any, params ...any) error
- func (rq RequestWriter) Number(value any, params ...any) error
- func (rq RequestWriter) Password(value any, params ...any) error
- func (rq RequestWriter) Radio(value any, params ...any) error
- func (rw RequestWriter) RadioGroup(nba *NamedBoolArray) (rel []RadioElement)
- func (rq RequestWriter) Range(value any, params ...any) error
- func (rq RequestWriter) Register(updater Updater, params ...any) jid.Jid
- func (rw RequestWriter) Request() *Request
- func (rq RequestWriter) Select(sh SelectHandler, params ...any) error
- func (rw RequestWriter) Session() *Session
- func (rw RequestWriter) Set(key string, val any)
- func (rq RequestWriter) Span(innerHtml any, params ...any) error
- func (rq RequestWriter) Tbody(c Container, params ...any) error
- func (rq RequestWriter) Td(innerHtml any, params ...any) error
- func (rq RequestWriter) Template(name string, dot any, params ...any) error
- func (rq RequestWriter) Text(value any, params ...any) error
- func (rq RequestWriter) Textarea(value any, params ...any) error
- func (rq RequestWriter) Tr(innerHtml any, params ...any) error
- func (rw RequestWriter) UI(ui UI, params ...any) error
- func (rw RequestWriter) Write(p []byte) (n int, err error)
- type SelectHandler
- type Session
- func (sess *Session) Broadcast(msg Message)
- func (sess *Session) Clear()
- func (sess *Session) Close() (cookie *http.Cookie)
- func (sess *Session) Cookie() (cookie *http.Cookie)
- func (sess *Session) CookieValue() (s string)
- func (sess *Session) Get(key string) (val any)
- func (sess *Session) ID() (id uint64)
- func (sess *Session) IP() (ip netip.Addr)
- func (sess *Session) Reload()
- func (sess *Session) Requests() (rl []*Request)
- func (sess *Session) Set(key string, val any)
- type Setter
- type String
- func (s *String) Get() (val string)
- func (s *String) JawsGetHtml(*Element) (val template.HTML)
- func (s *String) JawsGetString(*Element) string
- func (s *String) JawsSetString(e *Element, val string) (err error)
- func (s *String) MarshalText() ([]byte, error)
- func (s *String) Set(val string)
- func (s *String) String() string
- func (s *String) Swap(val string) (old string)
- func (s *String) UnmarshalText(b []byte) (err error)
- type StringGetter
- type StringSetter
- type Tag
- type TagGetter
- type Template
- type TemplateLookuper
- type TimeSetter
- type UI
- type Uideprecated
- type UiA
- type UiBool
- type UiButton
- type UiCheckbox
- type UiContainer
- type UiDate
- type UiDiv
- type UiFloat
- type UiHtml
- type UiHtmlInner
- type UiImg
- type UiInput
- type UiInputBool
- type UiInputDate
- type UiInputFloat
- type UiInputText
- type UiLabel
- type UiLi
- type UiNumber
- type UiOption
- type UiPassword
- type UiRadio
- type UiRange
- type UiRegister
- type UiSelect
- type UiSpan
- type UiString
- type UiTbody
- type UiTd
- type UiText
- type UiTextarea
- type UiTr
- type Updater
- type VarMaker
- type With
Examples ¶
Constants ¶
const (
DefaultUpdateInterval = time.Millisecond * 100 // Default browser update interval
)
const ISO8601 = "2006-01-02"
Variables ¶
var DefaultCookieName string
DefaultCookieName holds the default JaWS cookie name. It will be generated from the executable name, or "jaws" if that fails.
var ErrEventUnhandled = errEventUnhandled{}
ErrEventUnhandled returned by JawsEvent() or JawsClick() causes the next available handler to be invoked.
var ErrIllegalTagType errIllegalTagType
ErrIllegalTagType is returned when a UI tag type is disallowed
var ErrJavascriptDisabled = errors.New("javascript is disabled")
var ErrNoWebSocketRequest errNoWebSocketRequest
ErrNoWebSocketRequest is returned when the WebSocket callback was not received within the timeout period. Most common reason is that client is not using Javascript.
var ErrNotComparable errNotComparable
ErrNotComparable is returned when a UI object or tag is not comparable.
var ErrPendingCancelled errPendingCancelled
ErrPendingCancelled indicates a pending Request was cancelled. Use Unwrap() to see the underlying cause.
var ErrRequestAlreadyClaimed = errors.New("request already claimed")
var ErrTooManyTags = errTooManyTags{}
var ErrValueNotSettable = errors.New("value not settable")
var ErrValueUnchanged = errors.New("value unchanged")
ErrValueUnchanged can be returned from JawsSet[Type] functions to indicate that while there was no error, the underlying value was already the desired value.
var JavascriptGZip = makeJavascriptGZip()
JavascriptGZip is the embedded Javascript library GZipped.
var JavascriptPath = makeJavascriptPath()
JavascriptPath is the path for the embedded JaWS Javascript library.
var JavascriptText []byte
JavascriptText is the source code for the client-side JaWS Javascript library.
Functions ¶
func AppendID ¶ added in v0.31.0
AppendID appends the result of NextID() in text form to the given slice.
func JawsKeyAppend ¶ added in v0.52.0
JawsKeyAppend appends the JaWS key as a string to the buffer.
func JawsKeyString ¶
JawsKeyString returns the string to be used for the given JaWS key.
func JawsKeyValue ¶ added in v0.11.0
JawsKeyValue parses a key string (as returned JawsKeyString) into a uint64.
func MakeID ¶ added in v0.24.0
func MakeID() string
MakeID returns a string in the form 'jaws.X' where X is a unique string within lifetime of the program.
func MustTagExpand ¶ added in v0.34.0
func NextID ¶ added in v0.31.0
func NextID() int64
NextID returns a uint64 unique within lifetime of the program.
func PreloadHTML ¶ added in v0.71.0
PreloadHTML returns HTML code to load the given resources efficiently.
func WriteHtmlInner ¶ added in v0.31.0
func WriteHtmlInput ¶ added in v0.31.0
func WriteHtmlSelect ¶ added in v0.31.0
Types ¶
type Binding ¶ added in v0.78.0
type Binding[T comparable] struct { L sync.Locker P *T }
Binding combines a lock with a pointer to a value of type T, and implements Setter[T]. It also implements BoolSetter, FloatSetter, StringSetter and TimeSetter, but will panic if the underlying type T is not correct.
func Bind ¶ added in v0.78.0
func Bind[T comparable](l sync.Locker, p *T) Binding[T]
Bind returns a Binding[T] with the given sync.Locker (or RWLocker) and a pointer to the underlying value of type T. It implements Setter[T]. It also implements BoolSetter, FloatSetter, StringSetter and TimeSetter, but will panic if the underlying type T is not correct. The pointer will be used as the UI tag.
func (Binding[T]) JawsGetBool ¶ added in v0.78.0
func (Binding[T]) JawsGetFloat ¶ added in v0.78.0
func (Binding[T]) JawsGetString ¶ added in v0.78.0
func (Binding[T]) JawsGetTag ¶ added in v0.78.0
func (Binding[T]) JawsGetTime ¶ added in v0.78.0
func (Binding[T]) JawsSetBool ¶ added in v0.78.0
func (Binding[T]) JawsSetFloat ¶ added in v0.78.0
func (Binding[T]) JawsSetString ¶ added in v0.78.0
func (Binding[T]) JawsSetTime ¶ added in v0.78.0
type Bool ¶ added in v0.62.0
type Bool struct { Value bool // contains filtered or unexported fields }
Bool wraps a mutex and a boolean, and implements jaws.BoolSetter.
func (*Bool) JawsGetBool ¶ added in v0.62.0
func (*Bool) MarshalJSON ¶ added in v0.62.0
func (*Bool) MarshalText ¶ added in v0.62.0
func (*Bool) UnmarshalJSON ¶ added in v0.62.0
func (*Bool) UnmarshalText ¶ added in v0.62.0
type BoolSetter ¶ added in v0.31.0
type ClickHandler ¶ added in v0.31.0
type ClickHandler interface { // JawsClick is called when an Element's HTML element or something within it // is clicked in the browser. // // The name parameter is taken from the first 'name' HTML attribute or HTML // 'button' textContent found when traversing the DOM. It may be empty. JawsClick(e *Element, name string) (err error) }
type ConnectFn ¶
ConnectFn can be used to interact with a Request before message processing starts. Returning an error causes the Request to abort, and the WebSocket connection to close.
type Element ¶ added in v0.31.0
type Element struct { *Request // (read-only) the Request the Element belongs to // contains filtered or unexported fields }
An Element is an instance of a *Request, an UI object and a Jid.
func (*Element) Append ¶ added in v0.31.0
Append appends a new HTML element as a child to the current one.
Call this only during JawsRender() or JawsUpdate() processing.
func (*Element) ApplyGetter ¶ added in v0.75.0
ApplyGetter examines getter, and if it's not nil, either adds it as a Tag, or, if it is a TagGetter, adds the result of that as a Tag. If getter is a ClickHandler or an EventHandler, it's added to the list of handlers for the Element.
Returns the Tag added, or nil if getter was nil.
func (*Element) ApplyParams ¶ added in v0.60.0
ApplyParams parses the parameters passed to UI() when creating a new Element, adding UI tags, adding any additional event handlers found.
Returns the list of HTML attributes found, if any.
func (*Element) JawsRender ¶ added in v0.55.0
JawsRender calls Ui().JawsRender() for this Element.
Do not call this yourself unless it's from within another JawsRender implementation.
func (*Element) JawsUpdate ¶ added in v0.55.0
func (e *Element) JawsUpdate()
JawsUpdate calls Ui().JawsUpdate() for this Element.
Do not call this yourself unless it's from within another JawsUpdate implementation.
func (*Element) Jid ¶ added in v0.31.0
Jid returns the JaWS ID for this Element, unique within it's Request.
func (*Element) JsCall ¶ added in v0.75.0
JsCall queues a Javascript function invocation to be sent to the browser. The string 'arg' must be valid JSON.
The browser will respond by setting this Element's value to the function return value (unless there was a Javascript exception).
func (*Element) JsSet ¶ added in v0.75.0
JsSet sends a Javascript variable update to the browser. The string 'val' must be valid JSON.
func (*Element) Order ¶ added in v0.31.0
Order reorders the HTML elements.
Call this only during JawsRender() or JawsUpdate() processing.
func (*Element) Remove ¶ added in v0.31.0
Remove requests that the HTML child with the given HTML ID of this Element is removed from the Request and it's HTML element from the browser.
Call this only during JawsRender() or JawsUpdate() processing.
func (*Element) RemoveAttr ¶ added in v0.31.0
RemoveAttr queues sending a request to remove an attribute to the browser for the Element with the given JaWS ID in this Request.
Call this only during JawsRender() or JawsUpdate() processing.
func (*Element) RemoveClass ¶ added in v0.31.0
RemoveClass queues sending a request to remove a class to the browser for the Element with the given JaWS ID in this Request.
Call this only during JawsRender() or JawsUpdate() processing.
func (*Element) Replace ¶ added in v0.31.0
Replace replaces the elements entire HTML DOM node with new HTML code. If the HTML code doesn't seem to contain correct HTML ID, it panics.
Call this only during JawsRender() or JawsUpdate() processing.
func (*Element) SetAttr ¶ added in v0.31.0
SetAttr queues sending a new attribute value to the browser for the Element with the given JaWS ID in this Request.
Call this only during JawsRender() or JawsUpdate() processing.
func (*Element) SetClass ¶ added in v0.31.0
SetClass a queues sending a class to the browser for the Element with the given JaWS ID in this Request.
Call this only during JawsRender() or JawsUpdate() processing.
func (*Element) SetInner ¶ added in v0.31.0
SetInner queues sending a new inner HTML content to the browser for the Element.
Call this only during JawsRender() or JawsUpdate() processing.
func (*Element) SetValue ¶ added in v0.31.0
SetValue queues sending a new current input value in textual form to the browser for the Element with the given JaWS ID in this Request.
Call this only during JawsRender() or JawsUpdate() processing.
type EventFn ¶
EventFn is the signature of a event handling function to be called when JaWS receives an event message from the Javascript via the WebSocket connection.
type EventHandler ¶ added in v0.31.0
func ParseParams ¶ added in v0.60.0
func ParseParams(params []any) (tags []any, handlers []EventHandler, attrs []string)
ParseParams parses the parameters passed to UI() when creating a new Element, returning UI tags, event handlers and HTML attributes.
type Float ¶ added in v0.67.0
type Float struct { Value float64 // contains filtered or unexported fields }
Float wraps a mutex and a float64, and implements jaws.FloatSetter.
func (*Float) JawsGetFloat ¶ added in v0.67.0
func (*Float) JawsSetFloat ¶ added in v0.67.0
func (*Float) MarshalJSON ¶ added in v0.67.0
func (*Float) UnmarshalJSON ¶ added in v0.67.0
type FloatSetter ¶ added in v0.31.0
type Getter ¶ added in v0.78.0
type Getter[T comparable] interface { JawsGet(elem *Element) (value T) }
type HtmlGetter ¶ added in v0.31.0
type InputBoolFn
deprecated
type InputFloatFn
deprecated
type InputTextFn
deprecated
type IsJsVar ¶ added in v0.78.0
type IsJsVar interface { JawsIsJsVar() EventHandler AppendJSON(b []byte, e *Element) []byte }
type Jaws ¶
type Jaws struct { CookieName string // Name for session cookies, defaults to "jaws" Logger *slog.Logger // Optional logger to use Debug bool // Set to true to enable debug info in generated HTML code // contains filtered or unexported fields }
func New ¶
func New() (jw *Jaws)
New returns a new JaWS object that must be closed using Close(). This is expected to be created once per HTTP server and handles publishing HTML changes across all connections.
func NewWithDone ¶
func NewWithDone(doneCh <-chan struct{}) (jw *Jaws)
NewWithDone returns a new JaWS object using the given completion channel. This is expected to be created once per HTTP server and handles publishing HTML changes across all connections.
func (*Jaws) AddTemplateLookuper ¶ added in v0.45.0
func (jw *Jaws) AddTemplateLookuper(tl TemplateLookuper)
AddTemplateLookuper adds an object that can resolve strings to *template.Template.
func (*Jaws) Alert ¶
Alert sends an alert to all Requests. The lvl argument should be one of Bootstraps alert levels: primary, secondary, success, danger, warning, info, light or dark.
func (*Jaws) Append ¶
Append calls the Javascript 'appendChild()' method on all HTML elements matching target.
func (*Jaws) Close ¶
func (jw *Jaws) Close()
Close frees resources associated with the JaWS object, and closes the completion channel if the JaWS was created with New(). Once the completion channel is closed, broadcasts and sends may be discarded. Subsequent calls to Close() have no effect.
func (*Jaws) Dirty ¶ added in v0.31.0
Dirty marks all Elements that have one or more of the given tags as dirty.
Note that if any of the tags are a TagGetter, it will be called with a nil Request. Prefer using Request.Dirty() which avoids this.
func (*Jaws) GenerateHeadHTML ¶ added in v0.5.0
GenerateHeadHTML (re-)generates the HTML code that goes in the HEAD section, ensuring that the provided URL resources in `extra` are loaded, along with the JaWS javascript.
You only need to call this if you want to add your own scripts and stylesheets.
func (*Jaws) GetSession ¶ added in v0.11.0
GetSession returns the Session associated with the given *http.Request, or nil.
func (*Jaws) Insert ¶
Insert calls the Javascript 'insertBefore()' method on all HTML elements matching target.
The position parameter 'where' may be either a HTML ID, an child index or the text 'null'.
func (*Jaws) Log ¶
Log sends an error to the Logger set in the Jaws. Has no effect if the err is nil or the Logger is nil. Returns err.
func (*Jaws) LookupTemplate ¶ added in v0.66.0
LookupTemplate queries the known TemplateLookupers in the order they were added and returns the first found.
func (*Jaws) MustLog ¶ added in v0.1.1
MustLog sends an error to the Logger set in the Jaws or panics with the given error if no Logger is set. Has no effect if the err is nil.
func (*Jaws) NewRequest ¶
NewRequest returns a new pending JaWS request that times out after 10 seconds.
Call this as soon as you start processing a HTML request, and store the returned Request pointer so it can be used while constructing the HTML response in order to register the JaWS id's you use in the response, and use it's Key attribute when sending the Javascript portion of the reply.
func (*Jaws) NewSession ¶ added in v0.26.0
NewSession creates a new Session.
Any pre-existing Session will be cleared and closed.
Subsequent Requests created with `NewRequest()` that have the cookie set and originates from the same IP will be able to access the Session.
func (*Jaws) Reload ¶
func (jw *Jaws) Reload()
Reload requests all Requests to reload their current page.
func (*Jaws) RemoveAttr ¶
RemoveAttr sends a request to remove the given attribute from all HTML elements matching target.
func (*Jaws) RemoveClass ¶ added in v0.31.0
RemoveClass sends a request to remove the given class from all HTML elements matching target.
func (*Jaws) RemoveTemplateLookuper ¶ added in v0.45.0
func (jw *Jaws) RemoveTemplateLookuper(tl TemplateLookuper)
RemoveTemplateLookuper removes the given object from the list of TemplateLookupers.
func (*Jaws) Replace ¶
Replace replaces the HTML content on all HTML elements matching target.
The position parameter 'where' may be either a HTML ID or an index.
func (*Jaws) RequestCount ¶ added in v0.25.0
RequestCount returns the number of Requests.
The count includes all Requests, including those being rendered, those waiting for the WebSocket callback and those active.
func (*Jaws) ServeHTTP ¶ added in v0.19.0
func (jw *Jaws) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP can handle the required JaWS endpoints, which all start with "/jaws/".
func (*Jaws) ServeWithTimeout ¶
ServeWithTimeout begins processing requests with the given timeout. It is intended to run on it's own goroutine. It returns when the completion channel is closed.
func (*Jaws) Session ¶ added in v0.77.0
Session returns a http.Handler that ensures a JaWS Session exists before invoking h.
func (*Jaws) SessionCount ¶ added in v0.11.0
SessionCount returns the number of active sessions.
func (*Jaws) Sessions ¶ added in v0.11.0
Sessions returns a list of all active sessions, which may be nil.
func (*Jaws) SetAttr ¶
SetAttr sends a request to replace the given attribute value in all HTML elements matching target.
func (*Jaws) SetClass ¶ added in v0.31.0
SetClass sends a request to set the given class in all HTML elements matching target.
func (*Jaws) SetInner ¶
SetInner sends a request to replace the inner HTML of all HTML elements matching target.
func (*Jaws) SetValue ¶
SetValue sends a request to set the HTML "value" attribute of all HTML elements matching target.
func (*Jaws) UseRequest ¶
UseRequest extracts the JaWS request with the given key from the request map if it exists and the HTTP request remote IP matches.
Call it when receiving the WebSocket connection on '/jaws/:key' to get the associated Request, and then call it's ServeHTTP method to process the WebSocket messages.
Returns nil if the key was not found or the IP doesn't match, in which case you should return a HTTP "404 Not Found" status.
type JsFunc ¶ added in v0.78.0
func (JsFunc) JawsRender ¶ added in v0.78.0
func (JsFunc) JawsUpdate ¶ added in v0.78.0
type JsVar ¶ added in v0.78.0
type JsVar[T comparable] struct { Setter[T] // typed generic Setter }
func NewJsVar ¶ added in v0.78.0
func NewJsVar[T comparable](setter Setter[T]) (v JsVar[T])
func (JsVar[T]) AppendJSON ¶ added in v0.78.0
func (JsVar[T]) JawsGetTag ¶ added in v0.78.0
func (JsVar[T]) JawsIsJsVar ¶ added in v0.78.0
func (ui JsVar[T]) JawsIsJsVar()
func (JsVar[T]) JawsRender ¶ added in v0.78.0
func (JsVar[T]) JawsUpdate ¶ added in v0.78.0
type Message ¶
type Message struct { Dest any // destination (tag, html ID or *Element) What what.What // what to change or do Data string // data (e.g. inner HTML content or slice of tags) }
Message contains the elements of a message to be sent to Requests.
type NamedBool ¶
type NamedBool struct {
// contains filtered or unexported fields
}
NamedBool stores a named boolen value with a HTML representation.
func NewNamedBool ¶ added in v0.31.0
func (*NamedBool) Array ¶ added in v0.31.0
func (nb *NamedBool) Array() *NamedBoolArray
func (*NamedBool) JawsGetBool ¶ added in v0.31.0
func (*NamedBool) JawsGetHtml ¶ added in v0.31.0
func (*NamedBool) JawsGetString ¶ added in v0.31.0
func (*NamedBool) JawsSetBool ¶ added in v0.31.0
type NamedBoolArray ¶
type NamedBoolArray struct { Multi bool // allow multiple NamedBools to be true // contains filtered or unexported fields }
NamedBoolArray stores the data required to support HTML 'select' elements and sets of HTML radio buttons. It it safe to use from multiple goroutines concurrently.
func NewNamedBoolArray ¶
func NewNamedBoolArray() *NamedBoolArray
NewNamedBoolArray creates a new object to track a related set of named booleans.
The JaWS ID string 'jid' is used as the ID for <select> elements and the value for the 'name' attribute for radio buttons. If left empty, MakeID() will be used to assign a unique ID.
func (*NamedBoolArray) Add ¶
func (nba *NamedBoolArray) Add(name string, text template.HTML) *NamedBoolArray
Add adds a NamedBool with the given name and the given text. Returns itself.
Note that while it's legal to have multiple NamedBool with the same name since it's allowed in HTML, it's probably not a good idea.
func (*NamedBoolArray) Get ¶ added in v0.24.0
func (nba *NamedBoolArray) Get() (name string)
Get returns the name of first NamedBool in the group that has it's Checked value set to true. Returns an empty string if none are true.
In case you can have more than one selected or you need to distinguish between a blank name and the fact that none are set to true, use ReadLocked() to inspect the data directly.
func (*NamedBoolArray) IsChecked ¶ added in v0.24.0
func (nba *NamedBoolArray) IsChecked(name string) (state bool)
IsChecked returns true if any of the NamedBool in the set that have the given name are Checked. Returns false if the name is not found.
func (*NamedBoolArray) JawsContains ¶ added in v0.31.0
func (nba *NamedBoolArray) JawsContains(e *Element) (contents []UI)
func (*NamedBoolArray) JawsGetString ¶ added in v0.31.0
func (nba *NamedBoolArray) JawsGetString(e *Element) string
func (*NamedBoolArray) JawsSetString ¶ added in v0.31.0
func (nba *NamedBoolArray) JawsSetString(e *Element, name string) (err error)
func (*NamedBoolArray) ReadLocked ¶ added in v0.24.0
func (nba *NamedBoolArray) ReadLocked(fn func(nbl []*NamedBool))
ReadLocked calls the given function with the NamedBoolArray locked for reading.
func (*NamedBoolArray) Set ¶
func (nba *NamedBoolArray) Set(name string, state bool) (changed bool)
Set sets the Checked state for the NamedBool(s) with the given name.
func (*NamedBoolArray) String ¶
func (nba *NamedBoolArray) String() string
String returns a string representation of the NamedBoolArray suitable for debugging.
func (*NamedBoolArray) WriteLocked ¶ added in v0.24.0
func (nba *NamedBoolArray) WriteLocked(fn func(nbl []*NamedBool) []*NamedBool)
WriteLocked calls the given function with the NamedBoolArray locked for writing and replaces the internal []*NamedBool slice with the return value.
type RadioElement ¶ added in v0.31.0
type RadioElement struct {
// contains filtered or unexported fields
}
type Request ¶
type Request struct { Jaws *Jaws // (read-only) the JaWS instance the Request belongs to JawsKey uint64 // (read-only) a random number used in the WebSocket URI to identify this Request // contains filtered or unexported fields }
Request maintains the state for a JaWS WebSocket connection, and handles processing of events and broadcasts.
Note that we have to store the context inside the struct because there is no call chain between the Request being created and it being used once the WebSocket is created.
func (*Request) Alert ¶
Alert attempts to show an alert message on the current request webpage if it has an HTML element with the id 'jaws-alert'. The lvl argument should be one of Bootstraps alert levels: primary, secondary, success, danger, warning, info, light or dark.
The default JaWS javascript only supports Bootstrap.js dismissable alerts.
func (*Request) AlertError ¶
AlertError calls Alert if the given error is not nil.
func (*Request) Context ¶
Context returns the Request's Context, which is derived from the WebSocket's HTTP requests Context.
func (*Request) Dirty ¶ added in v0.31.0
Dirty marks all Elements that have one or more of the given tags as dirty.
func (*Request) Done ¶ added in v0.31.0
func (rq *Request) Done() (ch <-chan struct{})
Done returns the Request completion channel.
func (*Request) Get ¶ added in v0.11.0
Get is shorthand for `Session().Get()` and returns the session value associated with the key, or nil. It no session is associated with the Request, returns nil.
func (*Request) GetConnectFn ¶ added in v0.7.0
GetConnectFn returns the currently set ConnectFn. That function will be called before starting the WebSocket tunnel if not nil.
func (*Request) GetElements ¶ added in v0.31.0
GetElements returns a list of the UI elements in the Request that have the given tag(s).
func (*Request) Initial ¶ added in v0.8.0
Initial returns the Request's initial HTTP request, or nil.
func (*Request) JawsKeyString ¶
func (*Request) NewElement ¶ added in v0.31.0
NewElement creates a new Element using the given UI object.
Panics if the build tag "debug" is set and the UI object doesn't satisfy all requirements.
func (*Request) ServeHTTP ¶
func (rq *Request) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements http.HanderFunc.
Requires UseRequest() have been successfully called for the Request.
func (*Request) Set ¶ added in v0.11.0
Set is shorthand for `Session().Set()` and sets a session value to be associated with the key. If value is nil, the key is removed from the session. Does nothing if there is no session is associated with the Request.
func (*Request) SetConnectFn ¶ added in v0.7.0
SetConnectFn sets ConnectFn. That function will be called before starting the WebSocket tunnel if not nil.
type RequestWriter ¶ added in v0.39.0
func (RequestWriter) A ¶ added in v0.39.0
func (rq RequestWriter) A(innerHtml any, params ...any) error
func (RequestWriter) Button ¶ added in v0.39.0
func (rq RequestWriter) Button(innerHtml any, params ...any) error
func (RequestWriter) Checkbox ¶ added in v0.39.0
func (rq RequestWriter) Checkbox(value any, params ...any) error
func (RequestWriter) Container ¶ added in v0.39.0
func (rq RequestWriter) Container(outerHtmlTag string, c Container, params ...any) error
func (RequestWriter) Date ¶ added in v0.39.0
func (rq RequestWriter) Date(value any, params ...any) error
func (RequestWriter) Div ¶ added in v0.39.0
func (rq RequestWriter) Div(innerHtml any, params ...any) error
func (RequestWriter) Get ¶ added in v0.40.0
func (rw RequestWriter) Get(key string) (val any)
Get calls Request().Get()
func (RequestWriter) HeadHTML ¶ added in v0.40.0
func (rw RequestWriter) HeadHTML() error
HeadHTML outputs the HTML code needed in the HEAD section.
func (RequestWriter) Img ¶ added in v0.39.0
func (rq RequestWriter) Img(imageSrc any, params ...any) error
func (RequestWriter) Initial ¶ added in v0.40.0
func (rw RequestWriter) Initial() *http.Request
Initial returns the initial http.Request.
func (RequestWriter) JsFunc ¶ added in v0.78.0
func (rq RequestWriter) JsFunc(jsfuncname string, getter any, params ...any) (err error)
func (RequestWriter) JsVar ¶ added in v0.78.0
func (rq RequestWriter) JsVar(jsvarname string, setter any, params ...any) (err error)
JsVar binds a Setter[T] to a named Javascript variable.
Alternatively you may also pass a VarMaker that returns an object that implements Setter[T] and UI.
func (RequestWriter) Label ¶ added in v0.39.0
func (rq RequestWriter) Label(innerHtml any, params ...any) error
func (RequestWriter) Li ¶ added in v0.39.0
func (rq RequestWriter) Li(innerHtml any, params ...any) error
func (RequestWriter) Number ¶ added in v0.39.0
func (rq RequestWriter) Number(value any, params ...any) error
func (RequestWriter) Password ¶ added in v0.39.0
func (rq RequestWriter) Password(value any, params ...any) error
func (RequestWriter) Radio ¶ added in v0.39.0
func (rq RequestWriter) Radio(value any, params ...any) error
func (RequestWriter) RadioGroup ¶ added in v0.40.0
func (rw RequestWriter) RadioGroup(nba *NamedBoolArray) (rel []RadioElement)
func (RequestWriter) Range ¶ added in v0.39.0
func (rq RequestWriter) Range(value any, params ...any) error
func (RequestWriter) Register ¶ added in v0.78.0
func (rq RequestWriter) Register(updater Updater, params ...any) jid.Jid
Register creates a new Element with the given Updater as a tag for dynamic updates. Additional tags may be provided in params. The updaters JawsUpdate method will be called immediately to ensure the initial rendering is correct.
Returns a Jid, suitable for including as a HTML "id" attribute:
<div id="{{$.Register .MyUpdater}}">...</div>
func (RequestWriter) Request ¶ added in v0.40.0
func (rw RequestWriter) Request() *Request
Request returns the current jaws.Request.
func (RequestWriter) Select ¶ added in v0.39.0
func (rq RequestWriter) Select(sh SelectHandler, params ...any) error
func (RequestWriter) Session ¶ added in v0.40.0
func (rw RequestWriter) Session() *Session
Session returns the Requests's Session, or nil.
func (RequestWriter) Set ¶ added in v0.40.0
func (rw RequestWriter) Set(key string, val any)
Set calls Request().Set()
func (RequestWriter) Span ¶ added in v0.39.0
func (rq RequestWriter) Span(innerHtml any, params ...any) error
func (RequestWriter) Tbody ¶ added in v0.39.0
func (rq RequestWriter) Tbody(c Container, params ...any) error
func (RequestWriter) Td ¶ added in v0.39.0
func (rq RequestWriter) Td(innerHtml any, params ...any) error
func (RequestWriter) Template ¶ added in v0.39.0
func (rq RequestWriter) Template(name string, dot any, params ...any) error
Template renders the given template using jaws.With{Dot: dot} as data.
The name argument is a string to be resolved to a *template.Template using Jaws.LookupTemplate().
func (RequestWriter) Text ¶ added in v0.39.0
func (rq RequestWriter) Text(value any, params ...any) error
func (RequestWriter) Textarea ¶ added in v0.39.0
func (rq RequestWriter) Textarea(value any, params ...any) error
type SelectHandler ¶ added in v0.31.0
type SelectHandler interface { Container StringSetter }
type Session ¶ added in v0.11.0
type Session struct {
// contains filtered or unexported fields
}
func (*Session) Broadcast ¶ added in v0.26.0
Broadcast attempts to send a message to all Requests using this session. It is safe to call on a nil Session.
func (*Session) Clear ¶ added in v0.16.0
func (sess *Session) Clear()
Clear removes all key/value pairs from the session. It is safe to call on a nil Session.
func (*Session) Close ¶ added in v0.17.0
Close invalidates and expires the Session. Future Requests won't be able to associate with it, and Cookie() will return a deletion cookie.
Existing Requests already associated with the Session will ask the browser to reload the pages. Key/value pairs in the Session are left unmodified, you can use `Session.Clear()` to remove all of them.
Returns a cookie to be sent to the client browser that will delete the browser cookie. Returns nil if the session was not found or is already closed. It is safe to call on a nil Session.
func (*Session) Cookie ¶ added in v0.11.0
Cookie returns a cookie for the Session. Returns a delete cookie if the Session is expired. It is safe to call on a nil Session, in which case it returns nil.
func (*Session) CookieValue ¶ added in v0.11.0
CookieValue returns the session cookie value. It is safe to call on a nil Session, in which case it returns an empty string.
func (*Session) Get ¶ added in v0.11.0
Get returns the value associated with the key, or nil. It is safe to call on a nil Session.
func (*Session) ID ¶ added in v0.11.0
ID returns the session ID, a 64-bit random value. It is safe to call on a nil Session, in which case it returns zero.
func (*Session) IP ¶ added in v0.11.0
IP returns the remote IP the session is bound to (which may be nil). It is safe to call on a nil Session, in which case it returns nil.
func (*Session) Reload ¶ added in v0.17.0
func (sess *Session) Reload()
Reload calls Broadcast with a message asking browsers to reload the page.
type Setter ¶ added in v0.78.0
type Setter[T comparable] interface { Getter[T] // JawsSet may return ErrValueUnchanged to indicate value was already set. JawsSet(elem *Element, value T) (err error) }
type String ¶ added in v0.44.0
type String struct { Value string // contains filtered or unexported fields }
String wraps a mutex and a string, and implements jaws.StringSetter and jaws.HtmlGetter. String.JawsGetHtml() will escape the string before returning it.
func (*String) JawsGetHtml ¶ added in v0.44.0
func (*String) JawsGetString ¶ added in v0.44.0
func (*String) JawsSetString ¶ added in v0.44.0
func (*String) MarshalText ¶ added in v0.62.0
func (*String) UnmarshalText ¶ added in v0.62.0
type StringGetter ¶ added in v0.31.0
type StringSetter ¶ added in v0.31.0
type StringSetter interface { StringGetter // JawsSetString may return ErrValueUnchanged to indicate value was already set. JawsSetString(e *Element, v string) (err error) }
type Template ¶ added in v0.31.0
type Template struct { Name string // Template name to be looked up using jaws.LookupTemplate() Dot any // Dot value to place in With structure }
func NewTemplate ¶ added in v0.66.0
NewTemplate simply returns a Template{} with the members set.
Provided as convenience so as to not have to name the structure members.
func (Template) JawsRender ¶ added in v0.31.0
func (Template) JawsUpdate ¶ added in v0.31.0
type TemplateLookuper ¶ added in v0.45.0
TemplateLookuper resolves a name to a *template.Template.
type TimeSetter ¶ added in v0.31.0
type UI ¶ added in v0.31.0
UI defines the required methods on JaWS UI objects. In addition, all UI objects must be comparable so they can be used as map keys.
type UiA ¶ added in v0.31.0
type UiA struct {
UiHtmlInner
}
func NewUiA ¶ added in v0.31.0
func NewUiA(innerHtml HtmlGetter) *UiA
type UiBool ¶ added in v0.63.0
UiBool implements BoolSetter given a sync.Locker (or RLocker) and a bool pointer.
func (UiBool) JawsGetBool ¶ added in v0.63.0
type UiButton ¶ added in v0.31.0
type UiButton struct {
UiHtmlInner
}
func NewUiButton ¶ added in v0.31.0
func NewUiButton(innerHtml HtmlGetter) *UiButton
type UiCheckbox ¶ added in v0.31.0
type UiCheckbox struct {
UiInputBool
}
func NewUiCheckbox ¶ added in v0.31.0
func NewUiCheckbox(g BoolSetter) *UiCheckbox
func (*UiCheckbox) JawsRender ¶ added in v0.31.0
type UiContainer ¶ added in v0.31.0
type UiContainer struct { OuterHtmlTag string // contains filtered or unexported fields }
func NewUiContainer ¶ added in v0.31.0
func NewUiContainer(outerHtmlTag string, c Container) *UiContainer
func (*UiContainer) JawsRender ¶ added in v0.31.0
func (*UiContainer) JawsUpdate ¶ added in v0.31.0
func (ui *UiContainer) JawsUpdate(e *Element)
type UiDate ¶ added in v0.31.0
type UiDate struct {
UiInputDate
}
func NewUiDate ¶ added in v0.31.0
func NewUiDate(g TimeSetter) *UiDate
type UiDiv ¶ added in v0.31.0
type UiDiv struct {
UiHtmlInner
}
func NewUiDiv ¶ added in v0.31.0
func NewUiDiv(innerHtml HtmlGetter) *UiDiv
type UiFloat ¶ added in v0.63.0
UiFloat implements FloatSetter given a sync.Locker (or RLocker) and a float64 pointer.
func (UiFloat) JawsGetFloat ¶ added in v0.63.0
type UiHtmlInner ¶ added in v0.31.0
type UiHtmlInner struct { UiHtml HtmlGetter }
func (*UiHtmlInner) JawsUpdate ¶ added in v0.31.0
func (ui *UiHtmlInner) JawsUpdate(e *Element)
type UiImg ¶ added in v0.31.0
type UiImg struct { UiHtml StringGetter }
func NewUiImg ¶ added in v0.31.0
func NewUiImg(g StringGetter) *UiImg
func (*UiImg) JawsRender ¶ added in v0.31.0
func (*UiImg) JawsUpdate ¶ added in v0.31.0
type UiInputBool ¶ added in v0.31.0
type UiInputBool struct { UiInput BoolSetter }
func (*UiInputBool) JawsUpdate ¶ added in v0.31.0
func (ui *UiInputBool) JawsUpdate(e *Element)
type UiInputDate ¶ added in v0.31.0
type UiInputDate struct { UiInput TimeSetter }
func (*UiInputDate) JawsUpdate ¶ added in v0.31.0
func (ui *UiInputDate) JawsUpdate(e *Element)
type UiInputFloat ¶ added in v0.31.0
type UiInputFloat struct { UiInput FloatSetter }
func (*UiInputFloat) JawsUpdate ¶ added in v0.31.0
func (ui *UiInputFloat) JawsUpdate(e *Element)
type UiInputText ¶ added in v0.31.0
type UiInputText struct { UiInput StringSetter }
func (*UiInputText) JawsUpdate ¶ added in v0.31.0
func (ui *UiInputText) JawsUpdate(e *Element)
type UiLabel ¶ added in v0.31.0
type UiLabel struct {
UiHtmlInner
}
func NewUiLabel ¶ added in v0.31.0
func NewUiLabel(innerHtml HtmlGetter) *UiLabel
type UiLi ¶ added in v0.31.0
type UiLi struct {
UiHtmlInner
}
func NewUiLi ¶ added in v0.31.0
func NewUiLi(innerHtml HtmlGetter) *UiLi
type UiNumber ¶ added in v0.31.0
type UiNumber struct {
UiInputFloat
}
func NewUiNumber ¶ added in v0.31.0
func NewUiNumber(g FloatSetter) *UiNumber
type UiOption ¶ added in v0.31.0
type UiOption struct{ *NamedBool }
func (UiOption) JawsRender ¶ added in v0.31.0
func (UiOption) JawsUpdate ¶ added in v0.31.0
type UiPassword ¶ added in v0.31.0
type UiPassword struct {
UiInputText
}
func NewUiPassword ¶ added in v0.31.0
func NewUiPassword(g StringSetter) *UiPassword
func (*UiPassword) JawsRender ¶ added in v0.31.0
type UiRadio ¶ added in v0.31.0
type UiRadio struct {
UiInputBool
}
func NewUiRadio ¶ added in v0.31.0
func NewUiRadio(vp BoolSetter) *UiRadio
type UiRange ¶ added in v0.31.0
type UiRange struct {
UiInputFloat
}
func NewUiRange ¶ added in v0.31.0
func NewUiRange(g FloatSetter) *UiRange
type UiRegister ¶ added in v0.78.0
type UiRegister struct {
Updater
}
func (UiRegister) JawsRender ¶ added in v0.78.0
type UiSelect ¶ added in v0.31.0
type UiSelect struct {
// contains filtered or unexported fields
}
func NewUiSelect ¶ added in v0.31.0
func NewUiSelect(sh SelectHandler) *UiSelect
func (*UiSelect) JawsRender ¶ added in v0.31.0
func (*UiSelect) JawsUpdate ¶ added in v0.31.0
type UiSpan ¶ added in v0.31.0
type UiSpan struct {
UiHtmlInner
}
func NewUiSpan ¶ added in v0.31.0
func NewUiSpan(innerHtml HtmlGetter) *UiSpan
type UiString ¶ added in v0.63.0
UiString implements StringSetter and HtmlGetter given a sync.Locker (or RLocker) and a string pointer.
func (UiString) JawsGetHtml ¶ added in v0.63.0
func (UiString) JawsGetString ¶ added in v0.63.0
type UiTbody ¶ added in v0.31.0
type UiTbody struct {
// contains filtered or unexported fields
}
func NewUiTbody ¶ added in v0.31.0
func (*UiTbody) JawsRender ¶ added in v0.31.0
func (*UiTbody) JawsUpdate ¶ added in v0.31.0
func (ui *UiTbody) JawsUpdate(e *Element)
type UiTd ¶ added in v0.31.0
type UiTd struct {
UiHtmlInner
}
func NewUiTd ¶ added in v0.31.0
func NewUiTd(innerHtml HtmlGetter) *UiTd
type UiText ¶ added in v0.31.0
type UiText struct {
UiInputText
}
func NewUiText ¶ added in v0.31.0
func NewUiText(vp StringSetter) (ui *UiText)
type UiTextarea ¶ added in v0.31.0
type UiTextarea struct {
UiInputText
}
func NewUiTextarea ¶ added in v0.31.0
func NewUiTextarea(g StringSetter) (ui *UiTextarea)
func (*UiTextarea) JawsRender ¶ added in v0.31.0
func (*UiTextarea) JawsUpdate ¶ added in v0.31.0
func (ui *UiTextarea) JawsUpdate(e *Element)
type UiTr ¶ added in v0.31.0
type UiTr struct {
UiHtmlInner
}
func NewUiTr ¶ added in v0.31.0
func NewUiTr(innerHtml HtmlGetter) *UiTr
type Updater ¶ added in v0.60.0
type Updater interface { // JawsUpdate is called for an Element that has been marked dirty to update it's HTML. // Do not call this yourself unless it's from within another JawsUpdate implementation. JawsUpdate(e *Element) }
type With ¶ added in v0.31.0
type With struct { *Element // the Element being rendered using a template. RequestWriter // the RequestWriter Dot any // user data parameter Attrs template.HTMLAttr // HTML attributes string }
With is passed as the data parameter when using RequestWriter.Template(), populated with all members set.
Source Files ¶
- anysetter.go
- atomicsetter.go
- bind.go
- bool.go
- boolsetter.go
- clickhandler.go
- container.go
- defaultcookiename.go
- element.go
- errillegaltagtype.go
- errnotcomparable.go
- errnowebsocketrequest.go
- errpendingcancelled.go
- errvalueunchanged.go
- eventhandler.go
- float.go
- floatsetter.go
- handler.go
- html.go
- htmlgetter.go
- jaws.go
- js.go
- jsfunc.go
- jsvar.go
- legacy.go
- message.go
- namedbool.go
- namedboolarray.go
- parseparams.go
- renderer.go
- request.go
- requestwriter.go
- rlocker.go
- selecthandler.go
- servehttp.go
- session.go
- sessioner.go
- setter.go
- string.go
- stringgetter.go
- stringsetter.go
- subscription.go
- tag.go
- taggetter.go
- template.go
- templatelookuper.go
- timesetter.go
- ui.go
- uia.go
- uibool.go
- uibutton.go
- uicheckbox.go
- uicontainer.go
- uidate.go
- uidiv.go
- uifloat.go
- uihtml.go
- uihtmlinner.go
- uiimg.go
- uiinput.go
- uiinputbool.go
- uiinputdate.go
- uiinputfloat.go
- uiinputtext.go
- uilabel.go
- uili.go
- uinumber.go
- uioption.go
- uipassword.go
- uiradio.go
- uiradiogroup.go
- uirange.go
- uiregister.go
- uiselect.go
- uispan.go
- uistring.go
- uitbody.go
- uitd.go
- uitext.go
- uitextarea.go
- uitr.go
- uiwrapcontainer.go
- updater.go
- with.go
- ws.go
- wsmsg.go