31 lines
No EOL
918 B
Text
31 lines
No EOL
918 B
Text
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.setDateValue($.NSDate.dateWithTimeIntervalSince1970({{.Date}}))
|
|
date.setFrameSize(date.fittingSize)
|
|
|
|
var alert = $.NSAlert.alloc.init
|
|
alert.setAccessoryView(date)
|
|
alert.setMessageText({{json .Text}})
|
|
{{- if .Info}}alert.setInformativeText({{json .Info}}){{- end}}
|
|
{{- range .Buttons}}alert.addButtonWithTitle([{{json .}}]){{end}}
|
|
|
|
var res = alert.runModal
|
|
switch (res) {
|
|
case $.NSAlertThirdButtonReturn:
|
|
$.puts({{json .Buttons}}[2])
|
|
case $.NSAlertSecondButtonReturn:
|
|
$.exit(1)
|
|
}
|
|
|
|
var fmt = $.NSDateFormatter.alloc.init
|
|
fmt.dateFormat = {{json .Format}}
|
|
fmt.stringFromDate(date.dateValue) |