-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
55 lines (46 loc) · 1.15 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package main
import (
"fmt"
"strings"
"syscall/js"
"github.com/turtley12/antigorithm/channelselect"
"github.com/turtley12/antigorithm/view"
"github.com/turtley12/antigorithm/feed"
)
func main() {
c := make(chan struct{}, 0)
pathname := js.Global().Get("window").Get("location").Get("pathname").String()
fmt.Println("pathname: " + pathname)
if strings.Contains(pathname, "/userfeed") {
userFeed()
} else {
home()
}
<-c
}
func userFeed() {
userchannels := getUserChannels()
view.DisplayFeed(feed.GetUserFeed(userchannels))
}
func getUserChannels() []string {
window := js.Global().Get("window")
location := window.Get("location")
search := location.Get("search").String()
if search == "" {
location.Call("replace", location.Get("origin"))
}
params := strings.ReplaceAll(search, "?channels=", "")
userchannels := strings.Split(params, ",")
for _, channel := range userchannels {
fmt.Println(channel)
}
return userchannels
}
func home() {
js.Global().Set("generate", js.FuncOf(generate))
channelselect.CreateButtons()
}
func generate(this js.Value, args []js.Value) interface{} {
channelselect.GetUserSelection()
return js.ValueOf(nil)
}