// 一个发起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()) }
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 + `>`) }
func NewCaret() kmgView.HtmlRenderer { return kmgView.Html(`<span class="caret"></span>`) }
func IncludeCssFile(url string) kmgView.HtmlRenderer { return kmgView.Html(` <link rel="stylesheet" href="` + kmgXss.H(url) + `"> `) }
func IncludeJsFile(url string) kmgView.HtmlRenderer { return kmgView.Html(` <script src="` + kmgXss.H(url) + `"></script> `) }
func Hr(num int) kmgView.HtmlRenderer { return kmgView.Html(strings.Repeat("<hr />", num)) }
func Pre(content string) kmgView.HtmlRenderer { return kmgView.Html(`<pre>` + kmgXss.H(content) + `</pre>`) }
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) + `>`) }
func BlankChinese(num int) kmgView.HtmlRenderer { return kmgView.Html(strings.Repeat(" ", num)) }
func Blank(num int) kmgView.HtmlRenderer { return kmgView.Html(strings.Repeat(" ", num)) }