Exemple #1
0
// 一个发起Post请求的按钮
// url: 将把url转化为表单并使用Post方法提交
// title: 按钮上面的字
// 在当前页面打开连接
//不支持一个 key 里塞多个 value 的 url
func NewPostButton(urlStr string, title string) kmgView.HtmlRenderer {
	formAction, err := url.Parse(urlStr)
	kmgErr.PanicIfError(err)
	query, err := url.ParseQuery(formAction.RawQuery)
	kmgErr.PanicIfError(err)
	formAction.RawQuery = ""
	id := kmgRand.MustCryptoRandToReadableAlphaNum(10)
	form := Form{
		Id:        id,
		NoSubmit:  true,
		Url:       formAction.String(),
		InputList: []kmgView.HtmlRenderer{},
		IsHidden:  true,
	}
	for k, v := range query {
		form.InputList = append(form.InputList, InputHidden{
			Name:  k,
			Value: v[0],
		})
	}
	button := Button{
		FormId:  id,
		Type:    ButtonTypeButton,
		Content: kmgView.String(title),
		Size:    ButtonSizeExtraSmall,
		Color:   ButtonColorInfo,
	}
	return kmgView.Html(form.HtmlRender() + button.HtmlRender())
}
Exemple #2
0
func H(index int, content kmgView.HtmlRenderer) kmgView.HtmlRenderer {
	if content == nil {
		return kmgView.String("")
	}
	if index == 0 {
		index = 1
	}
	iStr := strconv.Itoa(index)
	return kmgView.Html(`<h` + iStr + `>` + content.HtmlRender() + `</h` + iStr + `>`)
}
Exemple #3
0
func NewCaret() kmgView.HtmlRenderer {
	return kmgView.Html(`<span class="caret"></span>`)
}
Exemple #4
0
func IncludeCssFile(url string) kmgView.HtmlRenderer {
	return kmgView.Html(`
	<link rel="stylesheet" href="` + kmgXss.H(url) + `">
	`)
}
Exemple #5
0
func IncludeJsFile(url string) kmgView.HtmlRenderer {
	return kmgView.Html(`
	<script src="` + kmgXss.H(url) + `"></script>
	`)
}
Exemple #6
0
func Hr(num int) kmgView.HtmlRenderer {
	return kmgView.Html(strings.Repeat("<hr />", num))
}
Exemple #7
0
func Pre(content string) kmgView.HtmlRenderer {
	return kmgView.Html(`<pre>` + kmgXss.H(content) + `</pre>`)
}
Exemple #8
0
func HString(index int, content string) kmgView.HtmlRenderer {
	if index == 0 {
		index = 1
	}
	return kmgView.Html(`<h` + strconv.Itoa(index) + `>` + kmgXss.H(content) + `</h` + strconv.Itoa(index) + `>`)
}
Exemple #9
0
func BlankChinese(num int) kmgView.HtmlRenderer {
	return kmgView.Html(strings.Repeat("&#12288;", num))
}
Exemple #10
0
func Blank(num int) kmgView.HtmlRenderer {
	return kmgView.Html(strings.Repeat("&nbsp;", num))
}