Documentation ¶
Overview ¶
Package ui contains the client for the game. It compiles to webassembly to allow users to play the game in their browsers. Package dom contains the javascript bindings for the site
Index ¶
- type DOM
- func (dom *DOM) AlertOnPanic()
- func (dom DOM) Base64Decode(a string) []byte
- func (dom DOM) Checked(query string) bool
- func (dom DOM) CloneElement(query string) js.Value
- func (dom DOM) Color(element js.Value) string
- func (dom *DOM) Confirm(message string) bool
- func (dom DOM) EncodeURIComponent(str string) string
- func (dom DOM) FormatTime(utcSeconds int64) string
- func (dom *DOM) NewJsEventFunc(fn func(event js.Value)) js.Func
- func (dom *DOM) NewJsEventFuncAsync(fn func(event js.Value), async bool) js.Func
- func (dom *DOM) NewJsFunc(fn func()) js.Func
- func (dom *DOM) NewWebSocket(url string) js.Value
- func (dom *DOM) NewXHR() js.Value
- func (dom DOM) QuerySelector(query string) js.Value
- func (dom DOM) QuerySelectorAll(document js.Value, query string) []js.Value
- func (dom *DOM) RegisterFuncs(ctx context.Context, wg *sync.WaitGroup, parentName string, ...)
- func (dom *DOM) ReleaseJsFuncsOnDone(ctx context.Context, wg *sync.WaitGroup, jsFuncs map[string]js.Func)
- func (dom *DOM) SetButtonDisabled(query string, disabled bool)
- func (dom *DOM) SetChecked(query string, checked bool)
- func (dom *DOM) SetValue(query, value string)
- func (dom *DOM) StoreCredentials(form js.Value)
- func (dom DOM) Value(query string) string
- type Form
- type Querier
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DOM ¶
type DOM struct {
// contains filtered or unexported fields
}
DOM represents common functions on the Document Object Model.
func (*DOM) AlertOnPanic ¶
func (dom *DOM) AlertOnPanic()
AlertOnPanic checks to see if a panic has occurred. This function should be deferred as the first statement for each goroutine.
func (DOM) Base64Decode ¶
Base64Decode decodes the ascii base-64 string to binary (atob). Panics if the encodedData is not a valid url encoded base64 string.
func (DOM) CloneElement ¶
CloneElement creates a close of the element, which should be a template.
func (*DOM) Confirm ¶
Confirm shows a popup asking the user a yes/no question. The true return value implies the "yes" choice.
func (DOM) EncodeURIComponent ¶
EncodeURIComponent escapes special characters for safe use in URIs.
func (DOM) FormatTime ¶
FormatTime formats a datetime to HH:MM:SS.
func (*DOM) NewJsEventFunc ¶
NewJsEventFunc creates a new javascript function from the provided function that processes an event and returns nothing. PreventDefault is called on the event before applying the function
func (*DOM) NewJsEventFuncAsync ¶
NewJsEventFuncAsync performs similarly to NewJsEventFunc, but calls the event-handling function asynchronously if async is true.
func (*DOM) NewWebSocket ¶
NewWebSocket creates a new WebSocket with the specified url.
func (DOM) QuerySelector ¶
QuerySelector returns the first element returned by the query from root of the document.
func (DOM) QuerySelectorAll ¶
QuerySelectorAll returns an array of the elements returned by the query from the specified document.
func (*DOM) RegisterFuncs ¶
func (dom *DOM) RegisterFuncs(ctx context.Context, wg *sync.WaitGroup, parentName string, jsFuncs map[string]js.Func)
RegisterFuncs sets the function as fields on the parent. The parent object is created if it does not exist.
func (*DOM) ReleaseJsFuncsOnDone ¶
func (dom *DOM) ReleaseJsFuncsOnDone(ctx context.Context, wg *sync.WaitGroup, jsFuncs map[string]js.Func)
ReleaseJsFuncsOnDone releases the jsFuncs and decrements the waitgroup when the context is done. This function should be called on a separate goroutine.
func (*DOM) SetButtonDisabled ¶
SetButtonDisabled sets the disable property of the button element.
func (*DOM) SetChecked ¶
SetChecked sets the checked property of the element.
func (*DOM) StoreCredentials ¶
StoreCredentials attempts to save the credentials for the login, if browser wants to.
type Form ¶
type Form struct { Element js.Value Method string URL url.URL Params url.Values // contains filtered or unexported fields }
Form contains the fields needed to make a request to the server.
func NewForm ¶
NewForm creates a form from the target property of the event. An error is returned if the url action is not successfully parsed.
func (Form) NonSubmitInputs ¶
NonSubmitInputs uses the querier to get named inputs on the form that do not have a type of submit.
Directories ¶
Path | Synopsis |
---|---|
Package game has the ui game logic.
|
Package game has the ui game logic. |
canvas
Package canvas contains the logic to draw the game.
|
Package canvas contains the logic to draw the game. |
lobby
Package lobby contains code to view available games and to close the websocket.
|
Package lobby contains code to view available games and to close the websocket. |
socket
Package socket contains the logic to communicate with the server for the game via websocket communication
|
Package socket contains the logic to communicate with the server for the game via websocket communication |
Package http makes XML HTTP Requests using native browser code.
|
Package http makes XML HTTP Requests using native browser code. |
Package log contains shared logging code
|
Package log contains shared logging code |
Package url replaces the standard net/url package for basic url operations
|
Package url replaces the standard net/url package for basic url operations |
Package user contains code to create and edit users that can play games in the lobby.
|
Package user contains code to create and edit users that can play games in the lobby. |