kelo

Форк
0
/
document.go 
69 строк · 1.5 Кб
1
package godom
2

3
import (
4
	"gitverse.ru/metalcore/kelo/wrapper"
5
)
6

7
type DocumentValuer interface {
8
	NodeValuer
9

10
	Body() ElementValuer
11
	Cookie() string
12
	SetCookie(string)
13
	Head() ElementValuer
14
	Location() LocationValuer
15
	Title() string
16

17
	GetElementById(string) ElementValuer
18
	CreateComment(string) NodeValuer
19
	CreateElement(string) ElementValuer
20
	CreateTextNode(string) NodeValuer
21
}
22

23
type Document struct {
24
	Node
25
}
26

27
func GetDocument() *Document {
28
	return &Document{*NewNode(wrapper.JSGlobalValue.Get("document"))}
29
}
30

31
func (d *Document) Body() ElementValuer {
32
	return NewElement(d.GetJS().Get("body"))
33
}
34

35
func (d *Document) Cookie() string {
36
	return d.GetJS().Get("cookie").String()
37
}
38

39
func (d *Document) SetCookie(cookie string) {
40
	d.GetJS().Set("cookie", cookie)
41
}
42

43
func (d *Document) Head() ElementValuer {
44
	return NewElement(d.GetJS().Get("head"))
45
}
46

47
func (d *Document) Location() LocationValuer {
48
	return NewLocation(d.GetJS().Get("location"))
49
}
50

51
func (d *Document) Title() string {
52
	return d.GetJS().Get("title").String()
53
}
54

55
func (d *Document) GetElementById(id string) ElementValuer {
56
	return NewElement(d.GetJS().Call("getElementById", id))
57
}
58

59
func (d *Document) CreateComment(data string) NodeValuer {
60
	return NewNode(d.GetJS().Call("createComment", data))
61
}
62

63
func (d *Document) CreateElement(name string) ElementValuer {
64
	return NewElement(d.GetJS().Call("createElement", name))
65
}
66

67
func (d *Document) CreateTextNode(text string) NodeValuer {
68
	return NewElement(d.GetJS().Call("createTextNode", text))
69
}
70

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.