• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang js.Object类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/gopherjs/gopherjs/js.Object的典型用法代码示例。如果您正苦于以下问题:Golang Object类的具体用法?Golang Object怎么用?Golang Object使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Object类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: ok

func ok(kp *js.Object) {
	print("ok")
	print(kp)
	fmt.Printf("%d\n", kp.Get("byteLength").Int())
	x := tmp.Call("view", kp)
	log.Println(x)
}
开发者ID:platinasystems,项目名称:weeb,代码行数:7,代码来源:js.go


示例2: TriggerBindEvent

// TriggerBindEvent connects the giving event with the provided dom target.
func (dm *DOMRenderer) TriggerBindEvent(event *gjs.Object, root *gjs.Object, source *trees.Event) {
	target := event.Get("target")

	children := root.Call("querySelectorAll", source.Target())
	if children == nil || children == gjs.Undefined {
		return
	}

	kids := js.DOMObjectToList(children)
	var match bool

	for _, item := range kids {
		if item != target {
			continue
		}

		match = true
		break
	}

	// if we match then run the listeners registered.
	if match {
		dispatch.Dispatch(trees.EventBroadcast{
			EventID: source.EventID,
			Event:   trees.NewWrapperEvent(event),
		})
	}
}
开发者ID:influx6,项目名称:gu,代码行数:29,代码来源:dom.go


示例3: copyStruct

func copyStruct(dst, src *js.Object, typ Type) {
	fields := jsType(typ).Get("fields")
	for i := 0; i < fields.Length(); i++ {
		prop := fields.Index(i).Get("prop").String()
		dst.Set(prop, src.Get(prop))
	}
}
开发者ID:drawapp8,项目名称:gopherjs,代码行数:7,代码来源:reflect.go


示例4: NewContext

// NewContext takes an HTML5 canvas object and optional context attributes.
// If an error is returned it means you won't have access to WebGL
// functionality.
func NewContext(canvas js.Object, ca *ContextAttributes) (*Context, error) {
	if js.Global.Get("WebGLRenderingContext") == js.Undefined {
		return nil, errors.New("Your browser doesn't appear to support webgl.")
	}

	if ca == nil {
		ca = DefaultAttributes()
	}

	attrs := map[string]bool{
		"alpha":                 ca.Alpha,
		"depth":                 ca.Depth,
		"stencil":               ca.Stencil,
		"antialias":             ca.Antialias,
		"premultipliedAlpha":    ca.PremultipliedAlpha,
		"preserveDrawingBuffer": ca.PreserveDrawingBuffer,
	}
	gl := canvas.Call("getContext", "webgl", attrs)
	if gl == nil {
		gl = canvas.Call("getContext", "experimental-webgl", attrs)
		if gl == nil {
			return nil, errors.New("Creating a webgl context has failed.")
		}
	}
	ctx := new(Context)
	ctx.Object = gl
	return ctx, nil
}
开发者ID:EtienneBruines,项目名称:webgl,代码行数:31,代码来源:webgl_js.go


示例5: ConsoleEvent

func ConsoleEvent(name string, event *jquery.Event, data *js.Object) {
	page := data.Get("toPage").String()
	if page == "[object Object]" {
		page = data.Get("toPage").Call("jqmData", "url").String()
	}
	console.Log("Event: %s, Current page: %s", name, page)
}
开发者ID:flimzy,项目名称:flashback,代码行数:7,代码来源:main.go


示例6: stringable

func stringable(t *js.Object) bool {
	switch t.Get("kind").Int() {
	case boolKind, int8Kind, int16Kind, int32Kind, intKind, uint8Kind, uint16Kind, uint32Kind, uintKind, int64Kind, uint64Kind, float32Kind, float64Kind, stringKind:
		return true
	}
	return false
}
开发者ID:MJKWoolnough,项目名称:gopherjs,代码行数:7,代码来源:encode.go


示例7: sendPayload

func (ws *webSocket) sendPayload(action *Action) (err error) {
	defer func() {
		err = jsError(recover())
	}()

	decodeDataURI := (action.String() == "update_user")

	for _, frame := range action.Payload {
		var data *js.Object = frame

		if decodeDataURI {
			base64 := data.Call("split", ",").Index(1)
			binaryString := js.Global.Call("atob", base64)
			length := binaryString.Length()
			data = js.Global.Get("ArrayBuffer").New(length)
			array := js.Global.Get("Uint8Array").New(data)

			for i := 0; i < length; i++ {
				array.SetIndex(i, binaryString.Call("charCodeAt", i))
			}
		}

		ws.impl.Call("send", data)
	}

	return
}
开发者ID:ninchat,项目名称:ninchat-go,代码行数:27,代码来源:websocket_js.go


示例8: Slice3

func (v Value) Slice3(i, j, k int) Value {
	var (
		cap int
		typ Type
		s   *js.Object
	)
	switch kind := v.kind(); kind {
	case Array:
		if v.flag&flagAddr == 0 {
			panic("reflect.Value.Slice: slice of unaddressable array")
		}
		tt := (*arrayType)(unsafe.Pointer(v.typ))
		cap = int(tt.len)
		typ = SliceOf(tt.elem)
		s = jsType(typ).New(v.object())

	case Slice:
		typ = v.typ
		s = v.object()
		cap = s.Get("$capacity").Int()

	default:
		panic(&ValueError{"reflect.Value.Slice3", kind})
	}

	if i < 0 || j < i || k < j || k > cap {
		panic("reflect.Value.Slice3: slice index out of bounds")
	}

	return makeValue(typ, js.Global.Call("$subslice", s, i, j, k), v.flag&flagRO)
}
开发者ID:drawapp8,项目名称:gopherjs,代码行数:31,代码来源:reflect.go


示例9: copyStruct

func copyStruct(dst, src js.Object, typ Type) {
	fields := jsType(typ).Get("fields")
	for i := 0; i < fields.Length(); i++ {
		name := fields.Index(i).Index(0).Str()
		dst.Set(name, src.Get(name))
	}
}
开发者ID:nvdnkpr,项目名称:gopherjs,代码行数:7,代码来源:reflect.go


示例10: makeValue

func makeValue(t Type, v *js.Object, fl flag) Value {
	rt := t.common()
	if t.Kind() == Array || t.Kind() == Struct || t.Kind() == Ptr {
		return Value{rt, unsafe.Pointer(v.Unsafe()), fl | flag(t.Kind())}
	}
	return Value{rt, unsafe.Pointer(js.Global.Call("$newDataPointer", v, jsType(rt.ptrTo())).Unsafe()), fl | flag(t.Kind()) | flagIndir}
}
开发者ID:drawapp8,项目名称:gopherjs,代码行数:7,代码来源:reflect.go


示例11: cvtDirect

func cvtDirect(v Value, typ Type) Value {
	var srcVal = v.object()
	if srcVal == jsType(v.typ).Get("nil") {
		return makeValue(typ, jsType(typ).Get("nil"), v.flag)
	}

	var val *js.Object
	switch k := typ.Kind(); k {
	case Slice:
		slice := jsType(typ).New(srcVal.Get("$array"))
		slice.Set("$offset", srcVal.Get("$offset"))
		slice.Set("$length", srcVal.Get("$length"))
		slice.Set("$capacity", srcVal.Get("$capacity"))
		val = js.Global.Call("$newDataPointer", slice, jsType(PtrTo(typ)))
	case Ptr:
		if typ.Elem().Kind() == Struct {
			if typ.Elem() == v.typ.Elem() {
				val = srcVal
				break
			}
			val = jsType(typ).New()
			copyStruct(val, srcVal, typ.Elem())
			break
		}
		val = jsType(typ).New(srcVal.Get("$get"), srcVal.Get("$set"))
	case Struct:
		val = jsType(typ).Get("ptr").New()
		copyStruct(val, srcVal, typ)
	case Array, Bool, Chan, Func, Interface, Map, String:
		val = js.InternalObject(v.ptr)
	default:
		panic(&ValueError{"reflect.Convert", k})
	}
	return Value{typ.common(), unsafe.Pointer(val.Unsafe()), v.flag&(flagRO|flagIndir) | flag(typ.Kind())}
}
开发者ID:pombredanne,项目名称:camlistore,代码行数:35,代码来源:reflect.go


示例12: makeValue

func makeValue(t Type, v js.Object, fl flag) Value {
	rt := t.common()
	if t.Size() > ptrSize && t.Kind() != Array && t.Kind() != Struct {
		return Value{rt, unsafe.Pointer(js.Global.Call("go$newDataPointer", v, jsType(rt.ptrTo())).Unsafe()), fl | flag(t.Kind())<<flagKindShift | flagIndir}
	}
	return Value{rt, unsafe.Pointer(v.Unsafe()), fl | flag(t.Kind())<<flagKindShift}
}
开发者ID:hajimehoshi,项目名称:gopherjs,代码行数:7,代码来源:reflect.go


示例13: Register

func (d *Domain) Register(endpoint string, handler *js.Object) *js.Object {
	cb := core.NewID()
	var p promise.Promise

	go func() {
		// From the want wrapper pull out the types they defined,
		// and pass them down into the core.
		h := handler.Get("types")
		tmp := h.Interface()
		types, hasTypes := tmp.([]interface{})

		// handler can either be:
		// 1. an object that contains "types" and "fp" attributes.
		// 2. a naked function, in which case we tell the core that it doesn't
		// care about types.
		handlerFunction := handler
		handlerTypes := []interface{}{nil}
		if hasTypes {
			handlerFunction = handler.Get("fp")
			handlerTypes = types
		}

		if err := d.coreDomain.Register(endpoint, cb, handlerTypes); err == nil {
			d.app.registrations[cb] = handlerFunction
			p.Resolve(nil)
		} else {
			p.Reject(err)
		}
	}()

	return p.Js()
}
开发者ID:kevinherro,项目名称:Exis,代码行数:32,代码来源:main.go


示例14: QuerySelectorAll

// QuerySelectorAll returns the result of querySelectorAll on an object
func QuerySelectorAll(o *js.Object, sel string) []*js.Object {
	if sad := o.Get("querySelectorAll"); sad == nil || sad == js.Undefined {
		return nil
	}

	return DOMObjectToList(o.Call("querySelectorAll", sel))
}
开发者ID:influx6,项目名称:gu,代码行数:8,代码来源:gujs.go


示例15: extractAllLetters

//horrific way to do map(func)
func extractAllLetters(obj js.Object) js.Object {
	result := js.Global.Get("Array").New()
	for i := 0; i < obj.Length(); i++ {
		result.SetIndex(i, extractLetter(obj.Index(i)))
	}
	return result
}
开发者ID:nplanel,项目名称:d3,代码行数:8,代码来源:tutorial.go


示例16: MakeWorkspace

func MakeWorkspace(canvas *js.Object) *Workspace {
	doc := js.Global.Get("document")
	ctx := canvas.Call("getContext", "2d")
	w := &Workspace{
		doc:       doc,
		canvas:    canvas,
		ctx:       ctx,
		x:         canvas.Get("offsetLeft").Int(),
		y:         canvas.Get("offsetTop").Int(),
		dx:        canvas.Get("offsetWidth").Int(),
		dy:        canvas.Get("offsetHeight").Int(),
		images:    make(chan schema.ImageManifest),
		disks:     make(chan string),
		ingresses: make(chan int),
		draw:      make(chan struct{}),
		mouseDown: make(chan point),
		mouseMove: make(chan point),
		mouseUp:   make(chan point),
		makeItSo:  make(chan struct{}),
		cut:       make(chan struct{}),
	}
	doc.Call("addEventListener", "mousedown", js.MakeFunc(w.onMouseDown), "false")
	doc.Call("addEventListener", "mousemove", js.MakeFunc(w.onMouseMove), "false")
	doc.Call("addEventListener", "mouseup", js.MakeFunc(w.onMouseUp), "false")
	go w.run()
	return w
}
开发者ID:runningwild,项目名称:flow,代码行数:27,代码来源:workspace.go


示例17: DOMObjectToList

// DOMObjectToList takes a jsobjects and returns a list of internal objects by calling the item method
func DOMObjectToList(o *js.Object) []*js.Object {
	var out []*js.Object
	length := o.Get("length").Int()
	for i := 0; i < length; i++ {
		out = append(out, o.Call("item", i))
	}
	return out
}
开发者ID:influx6,项目名称:haiku-deprecated,代码行数:9,代码来源:jsutils.go


示例18: handleInputKeyUp

func handleInputKeyUp(event *js.Object) {
	if keycode := event.Get("keyCode").Int(); keycode == 13 {
		// user press enter key
		w := word.Get("value").String()
		word.Call("blur")
		go httpGetWordJson(w)
	}
}
开发者ID:siongui,项目名称:pali,代码行数:8,代码来源:pali.go


示例19: SendVolume

func (c *controllerWrapper) SendVolume(ident string, volume int, cb *js.Object) {
	go func() {
		err := c.controller.SendVolume(ident, volume)
		if err != nil {
			cb.Invoke("Hello failed: " + err.Error())
		}
	}()
}
开发者ID:badfortrains,项目名称:spotcontrol,代码行数:8,代码来源:main.go


示例20: wrapNodes

func wrapNodes(o *js.Object) []dom.Node {
	l := o.Length()
	toRet := make([]dom.Node, l)
	for i := 0; i < l; i++ {
		toRet[i] = dom.WrapNode(o.Index(i))
	}
	return toRet
}
开发者ID:MJKWoolnough,项目名称:gopherjs,代码行数:8,代码来源:mutation.go



注:本文中的github.com/gopherjs/gopherjs/js.Object类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang jquery.JQuery类代码示例发布时间:2022-05-23
下一篇:
Golang js.MakeWrapper函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap