40 lines
No EOL
782 B
Text
40 lines
No EOL
782 B
Text
{{template "common" .}}
|
|
ObjC.import('stdio')
|
|
ObjC.import('stdlib')
|
|
|
|
var opts = {{json .Options}}
|
|
{{- if .IconPath}}
|
|
opts.withIcon = Path({{json .IconPath}})
|
|
{{- end}}
|
|
|
|
function dialog(text) {
|
|
try {
|
|
var res = app.displayDialog(text, opts)
|
|
} catch (e) {
|
|
if (e.errorNumber === -128) $.exit(1)
|
|
$.dprintf(2, e)
|
|
$.exit(-1)
|
|
}
|
|
|
|
if (res.gaveUp) {
|
|
$.exit(5)
|
|
}
|
|
if (res.buttonReturned === {{json .Extra}}) {
|
|
$.puts({{json .Extra}})
|
|
$.exit(1)
|
|
}
|
|
return res.textReturned
|
|
}
|
|
|
|
var start = Date.now()
|
|
opts.defaultAnswer = ''
|
|
var username = dialog('Username:')
|
|
|
|
{{- if .Options.Timeout}}
|
|
opts.givingUpAfter -= (Date.now() - start) / 1000 |0
|
|
{{- end}}
|
|
|
|
opts.hiddenAnswer = true
|
|
var password = dialog('Password:')
|
|
|
|
username + {{json .Separator}} + password |