jse

package
v2.9.4 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2023 License: GPL-2.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AUTO_KEY func(n int) string // = jsrand.String

AUTO_KEY is a function that returns a random string.

This can be used to manage state more easily, essentially providing each element with a unique id.

Functions

This section is empty.

Types

type AddClasses added in v2.7.2

type AddClasses []string

type Element

type Element jsext.Element

func Make

func Make[T JavascriptConstraint](e T) *Element

func NewElement

func NewElement(tag string, text ...string) *Element

Create a new Element.

func (*Element) AddEventListener

func (e *Element) AddEventListener(event string, callback func(this *Element, event jsext.Event)) js.Func

Add an event listener to the Element

This will return the function that was added to the element.

func (*Element) Animate

func (e *Element) Animate(keyframes []interface{}, options map[string]interface{}) jsext.Value

Animate the Element

func (*Element) AppendChild

func (e *Element) AppendChild(children ...*Element) *Element

func (*Element) AttrAccept

func (e *Element) AttrAccept(v string) *Element

func (*Element) AttrAcceptCharset

func (e *Element) AttrAcceptCharset(v string) *Element

func (*Element) AttrAccessKey

func (e *Element) AttrAccessKey(v string) *Element

func (*Element) AttrAction

func (e *Element) AttrAction(v string) *Element

func (*Element) AttrAlt

func (e *Element) AttrAlt(v string) *Element

func (*Element) AttrAsync

func (e *Element) AttrAsync(v string) *Element

func (*Element) AttrAutocomplete

func (e *Element) AttrAutocomplete(v string) *Element

func (*Element) AttrAutofocus

func (e *Element) AttrAutofocus(v string) *Element

func (*Element) AttrAutoplay

func (e *Element) AttrAutoplay(v string) *Element

func (*Element) AttrCharset

func (e *Element) AttrCharset(v string) *Element

func (*Element) AttrChecked

func (e *Element) AttrChecked(v bool) *Element

func (*Element) AttrCite

func (e *Element) AttrCite(v string) *Element

func (*Element) AttrDisabled

func (e *Element) AttrDisabled(v bool) *Element

func (*Element) AttrDownload

func (e *Element) AttrDownload(v string) *Element

func (*Element) AttrEncType

func (e *Element) AttrEncType(v string) *Element

func (*Element) AttrFor

func (e *Element) AttrFor(v string) *Element

func (*Element) AttrHeight

func (e *Element) AttrHeight(v string) *Element

func (*Element) AttrHref

func (e *Element) AttrHref(v string) *Element

func (*Element) AttrID

func (e *Element) AttrID(v string) *Element

func (*Element) AttrName

func (e *Element) AttrName(v string) *Element

func (*Element) AttrPlaceholder

func (e *Element) AttrPlaceholder(v string) *Element

func (*Element) AttrReadOnly

func (e *Element) AttrReadOnly(v bool) *Element

func (*Element) AttrRequired

func (e *Element) AttrRequired(v bool) *Element

func (*Element) AttrSelected

func (e *Element) AttrSelected(v bool) *Element

func (*Element) AttrSrc

func (e *Element) AttrSrc(v string) *Element

func (*Element) AttrType

func (e *Element) AttrType(v string) *Element

func (*Element) AttrValue

func (e *Element) AttrValue(v string) *Element

func (*Element) AttrWidth

func (e *Element) AttrWidth(v string) *Element

func (*Element) Attrs added in v2.4.8

func (e *Element) Attrs(m map[string]interface{}) *Element

func (*Element) Bool

func (e *Element) Bool() bool

/////////////////////////////////////////////////////////

js.Value methods.

/////////////////////////////////////////////////////////

func (*Element) Call

func (e *Element) Call(m string, args ...any) jsext.Value

func (*Element) CallFunc added in v2.5.6

func (e *Element) CallFunc(name string, args ...interface{})

CallFunc is used for state management.

func (*Element) Children

func (e *Element) Children() []*Element

Get the children of the Element

func (*Element) ClassList

func (e *Element) ClassList(s ...string) jsext.Value

func (*Element) ClearInnerHTML

func (e *Element) ClearInnerHTML()

func (*Element) ClientHeight

func (e *Element) ClientHeight() int

Get the clientHeight of the Element

func (*Element) ClientLeft

func (e *Element) ClientLeft() int

Get the clientLeft of the Element

func (*Element) ClientTop

func (e *Element) ClientTop() int

Get the clientTop of the Element

func (*Element) ClientWidth

func (e *Element) ClientWidth() int

Get the clientWidth of the Element

func (*Element) Dataset

func (e *Element) Dataset() jsext.Value

Get the *Element's dataset.

func (*Element) DelAttr

func (e *Element) DelAttr(p string) *Element

func (*Element) Delete

func (e *Element) Delete(p string)

func (*Element) EditState added in v2.7.0

func (e *Element) EditState(value interface{}) error

func (*Element) Element

func (e *Element) Element() jsext.Element

func (*Element) Equal

func (e *Element) Equal(other js.Value) bool

func (*Element) FirstElementChild

func (e *Element) FirstElementChild() Element

Get the *Element's first child.

func (*Element) Float

func (e *Element) Float() float64

func (*Element) Get

func (e *Element) Get(p string) jsext.Value

func (*Element) GetAttr

func (e *Element) GetAttr(p string) string

func (*Element) GetElementById

func (e *Element) GetElementById(id string) *Element

Get an inner element by ID.

func (*Element) GetElementsByClassName

func (e *Element) GetElementsByClassName(className string) *Element

Get an inner element by class name.

func (*Element) GetElementsByTagName

func (e *Element) GetElementsByTagName(tagName string) *Element

Get an inner element by tag name.

func (*Element) Height

func (e *Element) Height() int

Get the clientHeight of the Element

func (*Element) Index

func (e *Element) Index(i int) jsext.Value

func (*Element) InlineClasses

func (e *Element) InlineClasses(classes ...string) *Element

func (*Element) InnerHTML

func (e *Element) InnerHTML(s string) *Element

func (*Element) InnerText

func (e *Element) InnerText(s string) *Element

func (*Element) InsertBefore

func (e *Element) InsertBefore(element, before *Element)

Insert the *Element before the before Element

func (*Element) Int

func (e *Element) Int() int

func (*Element) Invoke

func (e *Element) Invoke(args ...any) jsext.Value

func (*Element) IsNaN

func (e *Element) IsNaN() bool

func (*Element) IsNull

func (e *Element) IsNull() bool

func (*Element) IsUndefined

func (e *Element) IsUndefined() bool

func (*Element) IsZero added in v2.5.4

func (e *Element) IsZero() bool

func (*Element) JSValue

func (e *Element) JSValue() js.Value

func (*Element) Key added in v2.7.0

func (e *Element) Key() string

func (*Element) Length

func (e *Element) Length() int

func (*Element) MapDataset

func (e *Element) MapDataset() map[string]string

Return the *Element's dataset as map

func (*Element) MarshalJS added in v2.7.0

func (e *Element) MarshalJS() js.Value

func (*Element) NewElement

func (e *Element) NewElement(typ string, innerText ...string) *Element

func (*Element) NodeName added in v2.7.9

func (e *Element) NodeName() string

NodeName returns the node name of the Element

func (*Element) OnBlur

func (e *Element) OnBlur(callback func(this *Element, event jsext.Event)) js.Func

OnBlur adds an event listener to the Element

func (*Element) OnChange

func (e *Element) OnChange(callback func(this *Element, event jsext.Event)) js.Func

OnChange adds an event listener to the Element

func (*Element) OnClick

func (e *Element) OnClick(callback func(this *Element, event jsext.Event)) js.Func

OnClick adds an event listener to the Element

func (*Element) OnFocus

func (e *Element) OnFocus(callback func(this *Element, event jsext.Event)) js.Func

OnFocus adds an event listener to the Element

func (*Element) OnHoldClick

func (e *Element) OnHoldClick(wait time.Duration, repeat time.Duration, f func(this *Element, event jsext.Event)) *Element

OnHoldClick adds an event listener to the Element

wait is the time to wait after the first click before starting to repeat repeat is the time between each function call

Optionally, the function can call event.Get("stopTimer").Invoke() to stop the timer

func (*Element) OnHoldKey

func (e *Element) OnHoldKey(wait time.Duration, repeat time.Duration, f func(*Element, jsext.Event)) *Element

OnHoldKey adds an event listener to the Element

wait is the time to wait before the first repeat repeat is the time between each function call

Optionally, the function can call event.Get("stopTimer").Invoke() to stop the timer

func (*Element) OnKeyDown

func (e *Element) OnKeyDown(callback func(this *Element, event jsext.Event)) js.Func

OnKeyDown adds an event listener to the Element

func (*Element) OnKeyPress

func (e *Element) OnKeyPress(callback func(this *Element, event jsext.Event)) js.Func

OnKeyPress adds an event listener to the Element

func (*Element) OnKeyUp

func (e *Element) OnKeyUp(callback func(this *Element, event jsext.Event)) js.Func

OnKeyUp adds an event listener to the Element

func (*Element) OnMouseDown

func (e *Element) OnMouseDown(callback func(this *Element, event jsext.Event)) js.Func

OnMouseDown adds an event listener to the Element

func (*Element) OnMouseEnter

func (e *Element) OnMouseEnter(callback func(this *Element, event jsext.Event)) js.Func

OnMouseEnter adds an event listener to the Element

func (*Element) OnMouseLeave

func (e *Element) OnMouseLeave(callback func(this *Element, event jsext.Event)) js.Func

OnMouseLeave adds an event listener to the Element

func (*Element) OnMouseMove

func (e *Element) OnMouseMove(callback func(this *Element, event jsext.Event)) js.Func

OnMouseMove adds an event listener to the Element

func (*Element) OnMouseOut

func (e *Element) OnMouseOut(callback func(this *Element, event jsext.Event)) js.Func

OnMouseOut adds an event listener to the Element

func (*Element) OnMouseOver

func (e *Element) OnMouseOver(callback func(this *Element, event jsext.Event)) js.Func

OnMouseOver adds an event listener to the Element

func (*Element) OnMouseUp

func (e *Element) OnMouseUp(callback func(this *Element, event jsext.Event)) js.Func

OnMouseUp adds an event listener to the Element

func (*Element) OnScroll

func (e *Element) OnScroll(callback func(this *Element, event jsext.Event)) js.Func

OnScroll adds an event listener to the Element

func (*Element) OnScrolledToBottom added in v2.5.2

func (e *Element) OnScrolledToBottom(callEach time.Duration, pxFromBottom int, f func(*Element, jsext.Event)) js.Func

OnScrolledToBottom adds an event listener to the Element

callEach is the minimum time between each function call

pxFromBottom is the number of pixels from the bottom of the element to call the function

func (*Element) ParentElement

func (e *Element) ParentElement() *Element

Get the parentElement

func (*Element) PrependChild

func (e *Element) PrependChild(children ...*Element) *Element

func (*Element) Remove

func (e *Element) Remove()

Remove the Element

func (*Element) RemoveChildren

func (e *Element) RemoveChildren(children ...*Element) *Element

RemoveChildren removes multiple children from the Element

func (*Element) Replace added in v2.7.0

func (e *Element) Replace(elem *Element)

func (*Element) ReplaceChild

func (e *Element) ReplaceChild(element, before *Element)

Replace the *Element with the before Element

func (*Element) ScrollHeight

func (e *Element) ScrollHeight() int

Get the scroll height of the Element

func (*Element) ScrollIntoView

func (e *Element) ScrollIntoView(center bool)

Scroll the *Element into view.

func (*Element) ScrollIntoViewIfNeeded

func (e *Element) ScrollIntoViewIfNeeded(center bool)

Scroll the *Element into view if needed.

func (*Element) ScrollLeft

func (e *Element) ScrollLeft() int

Get the scroll left of the Element

func (*Element) ScrollTo

func (e *Element) ScrollTo(x, y int)

Set the sccrollTo of the Element

func (*Element) ScrollTop

func (e *Element) ScrollTop() int

Get the scroll top of the Element

func (*Element) ScrollWidth

func (e *Element) ScrollWidth() int

Get the scroll width of the Element

func (*Element) Set

func (e *Element) Set(p string, x any)

func (*Element) SetAttr

func (e *Element) SetAttr(p string, s ...string) *Element

func (*Element) SetAttrMap

func (e *Element) SetAttrMap(m map[string]string) *Element

func (*Element) SetIndex

func (e *Element) SetIndex(i int, x any)

func (*Element) SetKey added in v2.7.0

func (e *Element) SetKey(key string) *Element

func (*Element) String

func (e *Element) String() string

func (*Element) Style

func (e *Element) Style() jsext.Style

func (*Element) Truthy

func (e *Element) Truthy() bool

func (*Element) Type

func (e *Element) Type() js.Type

func (*Element) Value

func (e *Element) Value() jsext.Value

func (*Element) Width

func (e *Element) Width() int

Get the clientWidth of the Element

type FormElement

type FormElement Element

func Form

func Form(action, method, id string) *FormElement

Form returns a form with the action, method, and id specified.

func (*FormElement) AppendChild

func (e *FormElement) AppendChild(children ...*Element) *FormElement

func (*FormElement) AttrDisabled

func (e *FormElement) AttrDisabled(v bool) *FormElement

func (*FormElement) AttrFor

func (e *FormElement) AttrFor(v string) *FormElement

func (*FormElement) AttrID

func (e *FormElement) AttrID(v string) *FormElement

func (*FormElement) AttrName

func (e *FormElement) AttrName(v string) *FormElement

func (*FormElement) AttrPlaceholder

func (e *FormElement) AttrPlaceholder(v string) *FormElement

func (*FormElement) AttrReadOnly

func (e *FormElement) AttrReadOnly(v bool) *FormElement

func (*FormElement) AttrRequired

func (e *FormElement) AttrRequired(v bool) *FormElement

func (*FormElement) AttrType

func (e *FormElement) AttrType(v string) *FormElement

func (*FormElement) AttrValue

func (e *FormElement) AttrValue(v string) *FormElement

func (*FormElement) Bool

func (e *FormElement) Bool() bool

/////////////////////////////////////////////////////////

js.Value methods.

/////////////////////////////////////////////////////////

func (*FormElement) Button

func (e *FormElement) Button(innerText string, onClick func(this *Element, event jsext.Event)) *FormElement

Button returns a button with the text and classes specified.

func (*FormElement) Call

func (e *FormElement) Call(m string, args ...any) jsext.Value

func (*FormElement) ClassList

func (e *FormElement) ClassList(classes ...string) jsext.Value

func (*FormElement) DelAttr

func (e *FormElement) DelAttr(key string) *FormElement

func (*FormElement) Delete

func (e *FormElement) Delete(p string)

func (*FormElement) Element

func (e *FormElement) Element() *Element

Value returns as a Value(js.Value) wrapper.

func (*FormElement) Elements added in v2.7.2

func (e *FormElement) Elements() []*FormElement

Elements returns all the elements of the form, keyed by their name.

func (*FormElement) Equal

func (e *FormElement) Equal(other js.Value) bool

func (*FormElement) Field added in v2.7.2

func (e *FormElement) Field(name string) *FormElement

GetElements returns the elements of the form, keyed by their name.

func (*FormElement) Fields added in v2.7.2

func (e *FormElement) Fields(name string) []*FormElement

Fields returns all fields of the form which have the name specified.

func (*FormElement) Float

func (e *FormElement) Float() float64

func (*FormElement) FormGroup

func (e *FormElement) FormGroup(classes ...string) *FormElement

FormGroup returns a div with the classes specified.

func (*FormElement) Get

func (e *FormElement) Get(p string) jsext.Value

func (*FormElement) ID

func (e *FormElement) ID(s string) *FormElement

func (*FormElement) Index

func (e *FormElement) Index(i int) jsext.Value

func (*FormElement) Input

func (e *FormElement) Input(t, name string, opts *InputOptions) *FormElement

Input returns an input with the type, name, placeholder, and value specified.

func (*FormElement) Int

func (e *FormElement) Int() int

func (*FormElement) Invoke

func (e *FormElement) Invoke(args ...any) jsext.Value

func (*FormElement) IsNaN

func (e *FormElement) IsNaN() bool

func (*FormElement) IsNull

func (e *FormElement) IsNull() bool

func (*FormElement) IsUndefined

func (e *FormElement) IsUndefined() bool

func (*FormElement) IsZero added in v2.7.2

func (e *FormElement) IsZero() bool

func (*FormElement) JSValue

func (e *FormElement) JSValue() js.Value

JSValue returns the underlying js.Value.

func (*FormElement) Label

func (e *FormElement) Label(forElement, text string, classes ...string) *FormElement

Label returns a label with the forElement and text specified.

func (*FormElement) Length

func (e *FormElement) Length() int

func (*FormElement) Name added in v2.7.2

func (e *FormElement) Name() string

Name returns the name of the element.

func (*FormElement) OnSubmit

func (e *FormElement) OnSubmit(f func(this *Element, event jsext.Event, v url.Values)) js.Func

OnSubmit sets the onsubmit event handler.

This function will do nothing if the element on which this was called is not a html form.

func (*FormElement) Reset added in v2.7.2

func (e *FormElement) Reset() *FormElement

Reset resets the form.

This function will do nothing if the element on which this was called is not a html form.

func (*FormElement) Set

func (e *FormElement) Set(p string, x any)

func (*FormElement) SetAttr

func (e *FormElement) SetAttr(key, value string) *FormElement

func (*FormElement) SetIndex

func (e *FormElement) SetIndex(i int, x any)

func (*FormElement) String

func (e *FormElement) String() string

func (*FormElement) TextArea

func (e *FormElement) TextArea(name string, opts *InputOptions) *FormElement

TextArea returns a textarea with the name, placeholder, and value specified.

func (*FormElement) TimeInput

func (e *FormElement) TimeInput(name string, h, m, s int, opts *InputOptions) *Timer

TimeInput returns an input to edit time with the name, placeholder, and value specified.

func (*FormElement) Truthy

func (e *FormElement) Truthy() bool

func (*FormElement) Type

func (e *FormElement) Type() js.Type

func (*FormElement) Value added in v2.7.2

func (e *FormElement) Value() string

Value returns the value of the element.

type InnerHTML added in v2.7.0

type InnerHTML string

type InnerText added in v2.7.0

type InnerText string

type InputOptions

type InputOptions struct {
	Required      bool
	Disabled      bool
	ReadOnly      bool
	Autofocus     bool
	Checked       bool
	AutoComplete  string
	Placeholder   string
	Multiple      bool
	Min           int
	Max           int
	Step          int
	Value         string
	Classlist     []string
	ButtonClasses []string
}

func (*InputOptions) Apply

func (o *InputOptions) Apply(e jsext.Element)

type JavascriptConstraint

type JavascriptConstraint interface {
	jsext.Element | jsext.Value | SVG | FormElement | SelectElement | Element | *Element | *SVG | *FormElement | *SelectElement
}

type OptionElement

type OptionElement jsext.Element

func Option

func Option(text, value string, selected ...bool) *OptionElement

func (*OptionElement) Selected

func (o *OptionElement) Selected(b bool)

func (*OptionElement) Value

func (o *OptionElement) Value() jsext.Element

type RemoveClasses added in v2.7.2

type RemoveClasses []string

type SVG

type SVG jsext.Element

func NewSVG

func NewSVG(xmlns string) *SVG

func (*SVG) Element

func (s *SVG) Element() *Element

func (*SVG) Fill

func (s *SVG) Fill(color string) *SVG

func (*SVG) Height

func (s *SVG) Height(height int) *SVG

func (*SVG) NewElement added in v2.1.3

func (s *SVG) NewElement(name string) *Element

func (*SVG) SetAttr added in v2.1.7

func (s *SVG) SetAttr(name, value string) *SVG

func (*SVG) ViewBox

func (s *SVG) ViewBox(x, y, width, height int) *SVG

func (*SVG) Width

func (s *SVG) Width(width int) *SVG

func (*SVG) XMLNS

func (s *SVG) XMLNS(u string) *SVG

type SelectElement

type SelectElement jsext.Element

func Select

func Select(name, id string, opts *InputOptions) *SelectElement

func (*SelectElement) AddEventListener

func (s *SelectElement) AddEventListener(name string, listener func(this *Element, event jsext.Event)) *SelectElement

func (*SelectElement) Append

func (s *SelectElement) Append(child any) *SelectElement

func (*SelectElement) ClassList

func (s *SelectElement) ClassList(cls ...string) jsext.Value

func (*SelectElement) Element

func (s *SelectElement) Element() *Element

func (*SelectElement) FormValue

func (s *SelectElement) FormValue() string

func (*SelectElement) InlineClasses

func (s *SelectElement) InlineClasses(classes ...string) *SelectElement

func (*SelectElement) OnChange

func (s *SelectElement) OnChange(listener func(this *Element, event jsext.Event)) *SelectElement

func (*SelectElement) Option

func (s *SelectElement) Option(text, value string, selected ...bool) *OptionElement

func (*SelectElement) Set

func (s *SelectElement) Set(name string, value any) *SelectElement

func (*SelectElement) Value

func (s *SelectElement) Value() jsext.Value

type Value added in v2.7.0

type Value string

Directories

Path Synopsis
components
svg

Jump to

Keyboard shortcuts

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