예제 #1
0
func NewProxy(proxyObj *js.Object) *Proxy {
	p := new(Proxy)
	p.o = proxyObj
	if proxyObj.String() != "undefined" {
		p.Settings = proxyObj.Get("settings")
	}
	return p
}
예제 #2
0
func NewExtension(extensionObj *js.Object) *Extension {
	e := new(Extension)
	e.o = extensionObj
	if extensionObj.String() != "undefined" {
		e.LastError = e.o.Get("lastError")
		e.InIncognitoContext = e.o.Get("inIncognitoContext").Bool()
	}
	return e
}
예제 #3
0
func getFrameData(obj *js.Object) []byte {
	// Check if it's an array buffer. If so, convert it to a Go byte slice.
	if constructor := obj.Get("constructor"); constructor == js.Global.Get("ArrayBuffer") {
		int8Array := js.Global.Get("Uint8Array").New(obj)
		return int8Array.Interface().([]byte)
	}

	return []byte(obj.String())
}
예제 #4
0
func NewPrivacy(privacyObj *js.Object) *Privacy {
	p := new(Privacy)
	if privacyObj.String() != "undefined" {
		p.Services = privacyObj.Get("services")
		p.Network = privacyObj.Get("network")
		p.Websites = privacyObj.Get("websites")
	}
	return p
}
예제 #5
0
func paramToInt(value *js.Object) int32 {
	result := int32(value.Int())

	if value.String() == "true" {
		result = 1
	}

	return result
}
예제 #6
0
파일: canvas.go 프로젝트: theclapp/js
// canvas.toDataURL("image/jpeg") or canvas.toDataURL()
func (c *Canvas) ToDataUrl(mimeType ...string) string {
	var o *js.Object
	if len(mimeType) == 0 {
		o = c.Call("toDataURL")
	} else {
		o = c.Call("toDataURL", mimeType)
	}
	return o.String()
}
예제 #7
0
func NewSystem(systemObj *js.Object) *System {
	s := new(System)
	s.o = systemObj
	if systemObj.String() != "undefined" {
		s.Cpu = &Cpu{o: systemObj.Get("cpu")}
		s.Memory = &Memory{o: systemObj.Get("memory")}
		s.Storage = &SysStorage{o: systemObj.Get("storage")}
	}
	return s
}
예제 #8
0
파일: dom.go 프로젝트: influx6/govfx
// Position returns the current position of the dom.Element.
func Position(elem dom.Element) (float64, float64) {
	parent := OffsetParent(elem)

	var parentTop, parentLeft float64
	var marginTop, marginLeft float64
	var pBorderTop, pBorderLeft float64
	var pBorderTopObject *js.Object
	var pBorderLeftObject *js.Object

	nodeNameObject, err := GetProp(parent, "nodeName")
	if err == nil && !rootName.MatchString(strings.ToLower(nodeNameObject.String())) {
		parentElem := dom.WrapElement(parent)
		parentTop, parentLeft = Offset(parentElem)
	}

	if parent.Get("style") != nil {

		pBorderTopObject, err = GetProp(parent, "style.borderTopWidth")
		if err == nil {
			pBorderTop = ParseFloat(pBorderTopObject.String())
		}

		pBorderLeftObject, err = GetProp(parent, "style.borderLeftWidth")
		if err == nil {
			pBorderLeft = ParseFloat(pBorderLeftObject.String())
		}

		parentTop += pBorderTop
		parentLeft += pBorderLeft
	}

	css, _ := GetComputedStyle(elem, "")

	marginTopObject, err := GetComputedStyleValueWith(css, "margin-top")
	if err == nil {
		marginTop = ParseFloat(marginTopObject.String())
	}

	marginLeftObject, err := GetComputedStyleValueWith(css, "margin-left")
	if err == nil {
		marginLeft = ParseFloat(marginLeftObject.String())
	}

	elemTop, elemLeft := Offset(elem)

	elemTop -= marginTop
	elemLeft -= marginLeft

	return elemTop - parentTop, elemLeft - parentLeft
}
예제 #9
0
func getJSONTag(tag *js.Object) string {
	strLen := tag.Length()
	var val *js.Object
	for i := 0; i < strLen; i++ {
		start := i
		for i < strLen && tag.Call("charCodeAt", i).Int() == ' ' {
			i++
		}
		var char int
		for ; i < strLen; i++ {
			char = tag.Call("charCodeAt", i).Int()
			if char <= ' ' || char == ':' || char == '"' {
				break
			}
		}
		if i+1 >= strLen || char != ':' || tag.Call("charCodeAt", i+1).Int() != '"' {
			break
		}
		name := tag.Call("substring", start, i)
		i += 2
		start = i
		for ; i < strLen; i++ {
			char = tag.Call("charCodeAt", i).Int()
			if char == '\\' {
				i++
			} else if char == '"' {
				break
			}
		}
		if name.String() == "json" {
			val = tag.Call("substring", start, i)
			break
		}
	}
	if val == nil {
		return ""
	}
	return val.String()
}
예제 #10
0
파일: main.go 프로젝트: kevinherro/Exis
func (c Conn) OnClose(msg *js.Object) {
	c.app.Close(msg.String())
}
예제 #11
0
파일: main.go 프로젝트: kevinherro/Exis
func (c Conn) OnMessage(msg *js.Object) {
	c.app.ReceiveBytes([]byte(msg.String()))
}
예제 #12
0
func undefOrEmptyString(o *js.Object) bool {
	return o == js.Undefined || o.String() == ""
}
예제 #13
0
func dataString(x *js.Object) string {
	return x.String()
}
예제 #14
0
파일: main.go 프로젝트: newgogo/Exis
func (c Conn) OnMessage(msg *js.Object) {
	c.app.ReceiveString(msg.String())
}