kelo
/
document.go
69 строк · 1.5 Кб
1package godom
2
3import (
4"gitverse.ru/metalcore/kelo/wrapper"
5)
6
7type DocumentValuer interface {
8NodeValuer
9
10Body() ElementValuer
11Cookie() string
12SetCookie(string)
13Head() ElementValuer
14Location() LocationValuer
15Title() string
16
17GetElementById(string) ElementValuer
18CreateComment(string) NodeValuer
19CreateElement(string) ElementValuer
20CreateTextNode(string) NodeValuer
21}
22
23type Document struct {
24Node
25}
26
27func GetDocument() *Document {
28return &Document{*NewNode(wrapper.JSGlobalValue.Get("document"))}
29}
30
31func (d *Document) Body() ElementValuer {
32return NewElement(d.GetJS().Get("body"))
33}
34
35func (d *Document) Cookie() string {
36return d.GetJS().Get("cookie").String()
37}
38
39func (d *Document) SetCookie(cookie string) {
40d.GetJS().Set("cookie", cookie)
41}
42
43func (d *Document) Head() ElementValuer {
44return NewElement(d.GetJS().Get("head"))
45}
46
47func (d *Document) Location() LocationValuer {
48return NewLocation(d.GetJS().Get("location"))
49}
50
51func (d *Document) Title() string {
52return d.GetJS().Get("title").String()
53}
54
55func (d *Document) GetElementById(id string) ElementValuer {
56return NewElement(d.GetJS().Call("getElementById", id))
57}
58
59func (d *Document) CreateComment(data string) NodeValuer {
60return NewNode(d.GetJS().Call("createComment", data))
61}
62
63func (d *Document) CreateElement(name string) ElementValuer {
64return NewElement(d.GetJS().Call("createElement", name))
65}
66
67func (d *Document) CreateTextNode(text string) NodeValuer {
68return NewElement(d.GetJS().Call("createTextNode", text))
69}
70