ui

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 15, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Rendered for js/wasm

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

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 NewDOM

func NewDOM(global js.Value) *DOM

NewDOM creates a new DOM that is backed by the 'global' value.

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

func (dom DOM) Base64Decode(a string) []byte

Base64Decode decodes the ascii base-64 string to binary (atob). Panics if the encodedData is not a valid url encoded base64 string.

func (DOM) Checked

func (dom DOM) Checked(query string) bool

Checked returns whether the element has a checked value of true.

func (DOM) CloneElement

func (dom DOM) CloneElement(query string) js.Value

CloneElement creates a close of the element, which should be a template.

func (DOM) Color

func (dom DOM) Color(element js.Value) string

Color returns the text color of the element after css has been applied.

func (*DOM) Confirm

func (dom *DOM) Confirm(message string) bool

Confirm shows a popup asking the user a yes/no question. The true return value implies the "yes" choice.

func (DOM) EncodeURIComponent

func (dom DOM) EncodeURIComponent(str string) string

EncodeURIComponent escapes special characters for safe use in URIs.

func (DOM) FormatTime

func (dom DOM) FormatTime(utcSeconds int64) string

FormatTime formats a datetime to HH:MM:SS.

func (*DOM) NewJsEventFunc

func (dom *DOM) NewJsEventFunc(fn func(event js.Value)) js.Func

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

func (dom *DOM) NewJsEventFuncAsync(fn func(event js.Value), async bool) js.Func

NewJsEventFuncAsync performs similarly to NewJsEventFunc, but calls the event-handling function asynchronously if async is true.

func (*DOM) NewJsFunc

func (dom *DOM) NewJsFunc(fn func()) js.Func

NewJsFunc creates a new javascript function from the provided function.

func (*DOM) NewWebSocket

func (dom *DOM) NewWebSocket(url string) js.Value

NewWebSocket creates a new WebSocket with the specified url.

func (*DOM) NewXHR

func (dom *DOM) NewXHR() js.Value

NewXHR creates a new XML HTTP Request.

func (DOM) QuerySelector

func (dom DOM) QuerySelector(query string) js.Value

QuerySelector returns the first element returned by the query from root of the document.

func (DOM) QuerySelectorAll

func (dom DOM) QuerySelectorAll(document js.Value, query string) []js.Value

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

func (dom *DOM) SetButtonDisabled(query string, disabled bool)

SetButtonDisabled sets the disable property of the button element.

func (*DOM) SetChecked

func (dom *DOM) SetChecked(query string, checked bool)

SetChecked sets the checked property of the element.

func (*DOM) SetValue

func (dom *DOM) SetValue(query, value string)

SetValue sets the value of the input element.

func (*DOM) StoreCredentials

func (dom *DOM) StoreCredentials(form js.Value)

StoreCredentials attempts to save the credentials for the login, if browser wants to.

func (DOM) Value

func (dom DOM) Value(query string) string

Value gets the value of the input element.

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

func NewForm(querier Querier, event js.Value) (*Form, error)

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

func (f Form) NonSubmitInputs() []js.Value

NonSubmitInputs uses the querier to get named inputs on the form that do not have a type of submit.

func (*Form) Reset

func (f *Form) Reset()

Reset clears the named inputs of the form.

type Querier

type Querier func(form js.Value, query string) []js.Value

Querier selects on the form.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL