js

package
v0.13.66 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2025 License: BSD-3-Clause, BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const FALSE = _bool(false)
View Source
const NULL = expr("null")
View Source
const RETURN = Raw("return")
View Source
const TRUE = _bool(true)
View Source
const UNDEFINED = expr("undefined")

Variables

View Source
var AjaxResponse = ajaxResponse{}
View Source
var THIS = Raw("this")

Functions

func And

func And(c ...Condition) _and

func FloaterToStr

func FloaterToStr(n any) string

func GreaterThan

func GreaterThan(left, right Expression) _Gt

func GreaterThanEquals

func GreaterThanEquals(left, right Expression) _Gte

func IF

func IF(cond Condition, statements ...Statement) *_if

func InterToStr

func InterToStr(n any) string

func Is

func Is(left, right Expression) equals

func IsEmptyString added in v0.13.66

func IsEmptyString(expr Expression) equals

func IsNot

func IsNot(left, right Expression) notEquals

func JS

func JS(jser ...Statement) string

func LessThan

func LessThan(left, right Expression) _Lt

func LessThanEquals

func LessThanEquals(left, right Expression) _Lte

func New

func New(jser ...Statement) *_JS

func Not

func Not(c Condition) not

func ObjecterToStr

func ObjecterToStr(n any) string

func Or

func Or(c ...Condition) _or

func SWITCH

func SWITCH(exp Expression) *_switch

func StringerToStr

func StringerToStr(n any) string

Types

type Any

type Any interface {
	Statement
	Expression
}

type Array

type Array []Expression

func NewArray

func NewArray() Array

func (Array) JsValue

func (a Array) JsValue() string

type Block

type Block []Statement

func (Block) JsStatement

func (me Block) JsStatement() string

type Callback

type Callback struct {
	Params     []string
	Statements []Statement
}

func NewCallback

func NewCallback(params []string, stmts ...Statement) *Callback

func (*Callback) Body

func (c *Callback) Body() string

func (*Callback) JsStatement

func (c *Callback) JsStatement() string

func (*Callback) JsValue

func (c *Callback) JsValue() string

type Condition

type Condition interface {
	Cond() string
}

func Exists

func Exists(x Expression) Condition

func HasAttr

func HasAttr[O Objecter, A Stringer](elm O, attr A) Condition

func HasClass

func HasClass[O Objecter, T Stringer](elm O, classStr T) Condition

func HasKey

func HasKey[O Objecter, S Stringer](obj O, key S) Condition

func IsEmpty

func IsEmpty[O Objecter](obj O) Condition

func IsFalse

func IsFalse(x Expression) Condition

func IsNotNull

func IsNotNull(x Expression) Condition

func IsNull

func IsNull(x Expression) Condition

func IsTrue

func IsTrue(x Expression) Condition

func NotExists

func NotExists(x Expression) Condition

func NotHasKey

func NotHasKey[O Objecter, S Stringer](obj O, key S) Condition

type Expression

type Expression interface {
	JsValue() string
}

type Float

type Float float64

func (Float) JsValue

func (me Float) JsValue() string

type Floater

type Floater interface {
	Float | *Variable[Float] | *Variable[Raw] | Raw | float64 | float32
}

type Func

type Func string

func (Func) Call

func (f Func) Call(expr ...Expression) Raw

func (Func) Definition

func (f Func) Definition(params []string, stmts ...Statement) Statement

func (Func) JsValue

func (f Func) JsValue() string

func (Func) Name

func (f Func) Name() string

type Int

type Int int

func (Int) JsValue

func (me Int) JsValue() string

type Inter

type Inter interface {
	Int | *Variable[Int] | *Variable[Raw] | Raw | int
}

type Label

type Label string

func (Label) JsValue

func (l Label) JsValue() string

type LogMap

type LogMap map[string]Expression

func (LogMap) JsStatement

func (m LogMap) JsStatement() string

type Object

type Object map[string]Expression

func NewObject

func NewObject() Object

func (Object) JsValue

func (me Object) JsValue() string

type Objecter

type Objecter interface {
	Object | *Variable[Object] | *Variable[Raw] | map[string]string | map[string]Raw | Raw
}

type Raw

type Raw string

func Anonymous added in v0.13.66

func Anonymous(stmts ...Statement) Raw

func AppendChild added in v0.13.66

func AppendChild[O Objecter, C Objecter](elm O, child C) Raw

func AppendHTML added in v0.13.66

func AppendHTML[O Objecter, S Stringer](elm O, html S) Raw

func Child

func Child[O Objecter, I Inter](elm O, idx I) Raw

func Children

func Children[O Objecter](elm O) Raw

func CreateNodeFromHTML added in v0.13.66

func CreateNodeFromHTML[S Stringer](html S) Raw

func FirstChild

func FirstChild[O Objecter](elm O) Raw

func GetAttr

func GetAttr[O Objecter, T Stringer](elm O, attrStr T) Raw

func GetElementByID

func GetElementByID(s Expression) Raw

func GetHTML

func GetHTML[O Objecter](elm O) Raw

func GetText

func GetText[O Objecter](elm O) Raw

func GetVal

func GetVal[O Objecter](elm O) Raw

func JSONparse

func JSONparse(str Expression) Raw

func JSONtoString

func JSONtoString(obj Expression) Raw

func LastChild

func LastChild[O Objecter](elm O) Raw

func Length

func Length(arr Expression) Raw

func Literal

func Literal(format string, expr ...Expression) Raw

func LocalStorageGet

func LocalStorageGet[S Stringer](keystr S) Raw

func Method

func Method(x Expression, methodName string, expr ...Expression) Raw

func Nth

func Nth[T Inter](arr Expression, n T) Raw

func PropertyOf

func PropertyOf[O Objecter](x O, prop string) Raw

func Query

func Query[S Stringer](selector S) Raw

func QueryAll

func QueryAll[S Stringer](selector S) Raw

func RemoveChildren

func RemoveChildren[O Objecter](elm O) Raw

func SetTimeout added in v0.13.66

func SetTimeout[I Inter](t I, stmts ...Statement) Raw

func SetValOf

func SetValOf[O Objecter, S Stringer](x O, key S, v Expression) Raw

func ValOf

func ValOf[O Objecter, S Stringer](x O, key S) Raw

func (Raw) Cond

func (me Raw) Cond() string

func (Raw) JsStatement

func (l Raw) JsStatement() string

func (Raw) JsValue

func (l Raw) JsValue() string

func (Raw) Statements

func (l Raw) Statements() []Any

type Statement

type Statement interface {
	JsStatement() string
}
var BREAK Statement = Raw("break")
var CONTINUE Statement = Raw("continue")

func AddClass

func AddClass[O Objecter, T Stringer](elm O, classStr T) Statement

func Append

func Append[O Objecter, I Objecter](elmOuter, elm Expression) Statement

func Break

func Break(l Label) Statement

func ClipBoardWriteText

func ClipBoardWriteText[T Stringer](str T) Statement

func Continue

func Continue(l Label) Statement

func DO_WHILE

func DO_WHILE(cond Condition, stmts ...Statement) Statement

func DeleteKey

func DeleteKey[O Objecter, S Stringer](x O, key S) Statement

func Each

func Each(varval string, obj Expression, stmts ...Statement) Statement

Each ranges over iterables, just by value

func EachPair

func EachPair(varidx, varval string, obj Expression, stmts ...Statement) Statement

EachPair ranges over iterables by key/index and value

func EachProperty

func EachProperty(varprop string, obj Expression, stmts ...Statement) Statement

EachProperty ranges over the properties of an object

func FOR

func FOR(initSt Raw, cond Condition, postSt Raw, stmts ...Statement) Statement

initSt and postSt might be empty strings

func LocalStorageSet

func LocalStorageSet[S Stringer](keystr S, valstr Expression) Statement

func Log

func Log(expr ...Expression) Statement

func LogExpressions

func LogExpressions(expr ...Expression) Statement

func Prepend

func Prepend[O Objecter, I Objecter](elmOuter O, elm I) Statement

func Push

func Push(arr Expression, item Expression) Statement

func RemoveClass

func RemoveClass[O Objecter, T Stringer](elm O, classStr T) Statement

func RemoveElement

func RemoveElement[O Objecter](elm O) Statement

func Set

func SetAttr

func SetAttr[O Objecter, S Stringer, V Stringer](elm O, attrStr S, val V) Statement

func SetHTML

func SetHTML[O Objecter, V Stringer](elm O, val V) Statement

func SetPropertyIfNotExists added in v0.13.66

func SetPropertyIfNotExists[O Objecter](x O, prop string, val Expression) Statement

func SetPropertyOf

func SetPropertyOf[O Objecter](x O, prop string, val Expression) Statement

func SetText

func SetText[O Objecter, V Stringer](elm O, val V) Statement

func SetVal

func SetVal[O Objecter, V Stringer](elm O, val V) Statement

func WHILE

func WHILE(cond Condition, stmts ...Statement) Statement

type String

type String string

func (String) JsValue

func (me String) JsValue() string

type Stringer

type Stringer interface {
	String | *Variable[String] | *Variable[Raw] | Raw | string
}

type Variable

type Variable[T Expression] struct {
	Name string
	Val  T
	// contains filtered or unexported fields
}

func Const

func Const[T Expression](name string, val T) *Variable[T]

func Let

func Let[T Expression](name string, val T) *Variable[T]

func TypeOf

func TypeOf(varname string, v Expression) Variable[String]

func Var

func Var[T Expression](name string, val T) *Variable[T]

func (*Variable[T]) JsStatement

func (me *Variable[T]) JsStatement() string

func (Variable[T]) JsValue

func (me Variable[T]) JsValue() string

func (*Variable[T]) Set

func (me *Variable[T]) Set(x Expression) Statement

func (*Variable[T]) SetIfNotNull added in v0.13.66

func (me *Variable[T]) SetIfNotNull(x Expression) Statement

func (Variable[T]) Type

func (me Variable[T]) Type() string

type XMLHttpRequest

type XMLHttpRequest struct {
	// contains filtered or unexported fields
}

func AjaxDELETE

func AjaxDELETE[S Stringer](url S) *XMLHttpRequest

func AjaxGET

func AjaxGET[S Stringer](url S) *XMLHttpRequest

func AjaxHEAD

func AjaxHEAD[S Stringer](url S) *XMLHttpRequest

func AjaxPATCH

func AjaxPATCH[S Stringer](url S) *XMLHttpRequest

func AjaxPOST

func AjaxPOST[S Stringer](url S) *XMLHttpRequest

func AjaxPUT

func AjaxPUT[S Stringer](url S) *XMLHttpRequest

func (*XMLHttpRequest) OnError

func (me *XMLHttpRequest) OnError(stmts ...Statement) *XMLHttpRequest

func (*XMLHttpRequest) OnSuccess

func (me *XMLHttpRequest) OnSuccess(stmts ...Statement) *XMLHttpRequest

func (*XMLHttpRequest) Send

func (me *XMLHttpRequest) Send() Statement

func (*XMLHttpRequest) WithData

func (me *XMLHttpRequest) WithData(s Expression) *XMLHttpRequest

func (*XMLHttpRequest) WithDataJSON

func (me *XMLHttpRequest) WithDataJSON(s Expression) *XMLHttpRequest

func (*XMLHttpRequest) WithHeader

func (me *XMLHttpRequest) WithHeader(key string, value Expression) *XMLHttpRequest

func (*XMLHttpRequest) WithResponseJSON

func (me *XMLHttpRequest) WithResponseJSON() *XMLHttpRequest

func (*XMLHttpRequest) WithResponseType

func (me *XMLHttpRequest) WithResponseType(s string) *XMLHttpRequest

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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