-
Notifications
You must be signed in to change notification settings - Fork 1
/
Windows Close EN.js
57 lines (48 loc) · 1.52 KB
/
Windows Close EN.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// The english version of the Window Widget for ventilating a room by iOS Reminders
// Script by Robin Stecher
let minutes = 5
manageInfoWidget()
if(!config.runsInWidget) {
manageReminder()
}
Script.setWidget(await manageHomeWidget())
Script.complete()
async function manageInfoWidget() {
let widget = new ListWidget()
widget.backgroundColor = Color.blue()
let title = widget.addText("⚗️ Close".toUpperCase())
title.font = Font.boldRoundedSystemFont(22)
title.textColor = Color.white()
widget.addSpacer()
let description = widget.addText("✅ Created reminder")
description.font = Font.mediumSystemFont(14)
description.textColor = Color.white()
widget.presentSmall()
}
async function manageHomeWidget() {
let widget = new ListWidget()
widget.backgroundColor = Color.blue()
let title = widget.addText("🚪 Close".toUpperCase())
title.font = Font.boldRoundedSystemFont(22)
widget.addSpacer()
let description = widget.addText("Remind me on closing the window")
description.font = Font.mediumSystemFont(14)
title.textColor = Color.white()
description.textColor = Color.white()
return widget
}
async function manageReminder() {
let reminder = new Reminder()
reminder.calendar = await getCalendar()
reminder.title = "Close the window"
reminder.dueDate = await getReminderDate()
reminder.save()
}
async function getCalendar() {
let c = Calendar.findOrCreateForReminders("Ventilate")
return c
}
async function getReminderDate() {
let d = new Date(Date.now() + (1000 * 60 * minutes))
return d
}