package gonexapp
import (
_ "embed"
"html"
"html/template"
"net/http"
)
//go:embed dialog.js
var dialogJS string
// DialogHTML is the Dialog markup and script for an ExApp page, in English.
// App navigation includes the same fragment in the UI language and does not
// take a language argument. A page the ExApp renders itself inserts this
// fragment, or Credentials.DialogHTML when that page has a request.
// The page then calls exappDialog.message, exappDialog.confirm,
// or exappDialog.prompt and waits for the user's choice.
func DialogHTML() template.HTML {
return dialogHTML("en")
}
// DialogHTML is the Dialog fragment in the UI language of r.
// A missing Requesting user or a failed read uses English.
// The caller does not pass a language.
func (c Credentials) DialogHTML(r *http.Request) template.HTML {
return dialogHTML(c.UILanguage(r))
}
func dialogHTML(lang string) template.HTML {
cancel := html.EscapeString(chromePhrase(lang, "dialog.cancel", nil))
agree := html.EscapeString(chromePhrase(lang, "dialog.ok", nil))
return template.HTML(dialogStyle + dialogButtons(cancel, agree) + "")
}
func dialogButtons(cancel, agree string) string {
return ``
}
const dialogStyle = ``