Esempio n. 1
0
File: ts.go Progetto: 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,
	})
}
Esempio n. 2
0
File: ts.go Progetto: 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"
}