2022-03-24 12:15:11 -04:00
|
|
|
var app = Application.currentApplication()
|
|
|
|
app.includeStandardAdditions = true
|
|
|
|
app.activate()
|
|
|
|
|
|
|
|
ObjC.import('Cocoa')
|
|
|
|
ObjC.import('stdio')
|
|
|
|
ObjC.import('stdlib')
|
|
|
|
|
|
|
|
var date = $.NSDatePicker.alloc.init
|
|
|
|
date.setDatePickerStyle($.NSDatePickerStyleClockAndCalendar)
|
|
|
|
date.setDatePickerElements($.NSDatePickerElementFlagYearMonthDay)
|
|
|
|
date.setFrameSize(date.fittingSize)
|
2022-03-30 10:36:50 -04:00
|
|
|
{{- if .Date}}
|
|
|
|
date.setDateValue($.NSDate.dateWithTimeIntervalSince1970({{.Date}}))
|
|
|
|
{{- end}}
|
2022-03-24 12:15:11 -04:00
|
|
|
|
|
|
|
var alert = $.NSAlert.alloc.init
|
|
|
|
alert.setAccessoryView(date)
|
|
|
|
alert.setMessageText({{json .Text}})
|
2022-03-28 15:22:39 -04:00
|
|
|
alert.addButtonWithTitle({{json .OK}})
|
|
|
|
alert.addButtonWithTitle({{json .Cancel}}).keyEquivalent = '\033'
|
|
|
|
{{- if .Info}}
|
2022-05-06 08:48:31 -04:00
|
|
|
alert.setInformativeText({{json .Info}})
|
2022-03-28 15:22:39 -04:00
|
|
|
{{- end}}
|
|
|
|
{{- if .Extra}}
|
2022-05-06 08:48:31 -04:00
|
|
|
alert.addButtonWithTitle({{json .Extra}})
|
2022-03-28 15:22:39 -04:00
|
|
|
{{- end}}
|
2022-03-24 12:15:11 -04:00
|
|
|
|
|
|
|
var res = alert.runModal
|
|
|
|
switch (res) {
|
|
|
|
case $.NSAlertThirdButtonReturn:
|
2022-05-06 08:48:31 -04:00
|
|
|
$.puts({{json .Extra}})
|
2022-03-24 12:15:11 -04:00
|
|
|
case $.NSAlertSecondButtonReturn:
|
2022-05-06 08:48:31 -04:00
|
|
|
$.exit(1)
|
2022-03-24 12:15:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
var fmt = $.NSDateFormatter.alloc.init
|
2022-05-11 12:49:15 -04:00
|
|
|
fmt.locale = $.NSLocale.localeWithLocaleIdentifier('en_US_POSIX')
|
2022-03-24 12:15:11 -04:00
|
|
|
fmt.dateFormat = {{json .Format}}
|
|
|
|
fmt.stringFromDate(date.dateValue)
|