Exemplo n.º 1
0
Arquivo: ts.go Projeto: tangseng/yts
func (this *TSController) AjaxGet() {
	hash := this.GetString("hash")
	name := this.User.Name
	tsOption := models.NewTSOption()
	var tss []models.TS
	var nowHash string
	var i int8
	var max int8 = 30
	for {
		if i > max {
			break
		}
		tss, _ = tsOption.Get(name, 0, 1)
		if len(tss) > 0 {
			nowHash = models.MD5(tss[0].Data, "")
		}
		if hash != nowHash {
			break
		}
		time.Sleep(time.Second)
		i++
	}
	if i > max {
		this.OK(map[string]interface{}{
			"hash": hash,
		})
		return
	}
	this.OK(map[string]interface{}{
		"ts":   tss,
		"hash": nowHash,
	})
}
Exemplo n.º 2
0
Arquivo: ts.go Projeto: tangseng/yts
func (this *TSController) More() {
	tss, _ := models.NewTSOption().Get(this.User.Name, 0, 10)
	this.Data["TS"] = tss
	this.Data["Script"] = []string{"jquery.jsonview", "app/app", "app/directives/tip", "app/directives/jsonview", "app/services/time", "app/controllers/tsmore/tsmoreCtrl"}
	this.Data["Css"] = []string{"jquery.jsonview"}
	this.LayoutSections = make(map[string]string)
	this.LayoutSections["Navbar"] = "layout/navbar.html"
	this.TplNames = "tsmore.html"
}
Exemplo n.º 3
0
Arquivo: ts.go Projeto: tangseng/yts
func (this *TSController) Get() {
	tss, _ := models.NewTSOption().Get(this.User.Name, 0, 1)
	var hash string
	if len(tss) > 0 {
		hash = models.MD5(tss[0].Data, "")
	}
	this.Data["User"] = this.OutUser()
	this.Data["Hash"] = hash
	this.Data["TS"] = tss
	this.Data["PHPUrl"] = fmt.Sprintf("http://%s/ts/php?t=%s", this.domain(), this.Token)
	this.Data["JSUrl"] = fmt.Sprintf("http://%s/ts/js?t=%s", this.domain(), this.Token)
	this.Data["Script"] = []string{"jquery.jsonview", "app/app", "app/directives/tip", "app/directives/jsonview", "app/services/time", "app/controllers/ts/tsCtrl"}
	this.Data["Css"] = []string{"jquery.jsonview"}
	this.LayoutSections = make(map[string]string)
	this.LayoutSections["Navbar"] = "layout/navbar.html"
	this.TplNames = "ts.html"
}
Exemplo n.º 4
0
Arquivo: ts.go Projeto: tangseng/yts
func (this *TSController) Post() {
	token := this.GetString("token")
	time := this.GetString("time")
	data := this.GetString("data")
	te := this.GetString("type")
	fmt.Println(data)
	ip := this.Ctx.Input.IP()
	go func(token, time, data, te, ip string) {
		t, err := models.NewTokenOption().Get(token)
		if err != nil {
			return
		}
		tstime, _ := strconv.ParseInt(time, 10, 64)
		ts := models.NewTS(data, te, ip, tstime, 0)
		models.NewTSOption().Insert(t.User.Name, ts)
	}(token, time, data, te, ip)
	this.Ctx.Output.Header("Access-Control-Allow-Origin", "*")
	this.Ctx.WriteString("")
}