dom

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Rendered for js/wasm

Overview

Package dom contains the javascript bindings for the site

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AlertOnPanic

func AlertOnPanic()

AlertOnPanic checks to see if a panic has occurred. This function should be deferred as the first statement for each goroutine.

func Base64Decode added in v1.1.0

func 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 Checked

func Checked(query string) bool

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

func CloneElement

func CloneElement(query string) js.Value

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

func Color

func Color(element js.Value) string

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

func Confirm

func Confirm(message string) bool

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

func FormatTime

func FormatTime(utcSeconds int64) string

FormatTime formats a datetime to HH:MM:SS.

func NewJsEventFunc

func 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 NewJsEventFuncAsync

func 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 NewJsFunc

func NewJsFunc(fn func()) js.Func

NewJsFunc creates a new javascript function from the provided function.

func NewWebSocket

func NewWebSocket(url string) js.Value

NewWebSocket creates a new WebSocket with the specified url.

func NewXHR

func NewXHR() js.Value

NewXHR creates a new XML HTTP Request.

func QuerySelector

func QuerySelector(query string) js.Value

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

func QuerySelectorAll

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

QuerySelectorAll returns an array of the elements returned by the query from the specified document.

func RecoverError

func RecoverError(r interface{}) error

RecoverError converts the recovery interface into a useful error. Panics if the interface is not an error or a string.

func RegisterFuncs

func 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 ReleaseJsFuncsOnDone

func 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 SetButtonDisabled

func SetButtonDisabled(query string, disabled bool)

SetButtonDisabled sets the disable property of the button element.

func SetChecked

func SetChecked(query string, checked bool)

SetChecked sets the checked property of the element.

func SetValue

func SetValue(query, value string)

SetValue sets the value of the input element.

func Value

func Value(query string) string

Value gets the value of the input element.

Types

type Form

type Form struct {
	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(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) Reset

func (f *Form) Reset()

Reset clears the named inputs of the form.

func (*Form) StoreCredentials

func (f *Form) StoreCredentials()

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

Directories

Path Synopsis
Package url replaces the standard net/url package for basic url operations
Package url replaces the standard net/url package for basic url operations

Jump to

Keyboard shortcuts

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