-
Notifications
You must be signed in to change notification settings - Fork 2
/
hnt-earnings.js
53 lines (51 loc) · 1.52 KB
/
hnt-earnings.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
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: deep-purple; icon-glyph: hand-holding-usd;
const utils = importModule('hnt-earnings/utils');
const widgets = importModule('hnt-earnings/widgets');
// The hotspot name has to be configured via the widget parameter on the homescreen
const params = args.widgetParameter != null ? JSON.parse(args.widgetParameter) : { name: '', period: 'day' };
// Hotspot name has to be given in the format: word-word-word
const devParams = { name: '', period: 'day' };
if (config.runsInWidget) {
const size = config.widgetFamily;
let widget;
switch (size) {
case 'small':
widget = await widgets.small(params);
break;
case 'medium':
widget = await widgets.medium(params);
break;
case 'large':
widget = await widgets.large(params);
break;
default:
widget = await widgets.small(params);
}
Script.setWidget(widget);
} else {
// Choose any size for debugging
const size = 'small';
//const size = 'medium'
//const size = 'large'
let widget;
switch (size) {
case 'small':
widget = await widgets.small(devParams);
widget.presentSmall();
break;
case 'medium':
widget = await widgets.medium(devParams);
widget.presentMedium();
break;
case 'large':
widget = await widgets.large(devParams);
widget.presentLarge();
break;
default:
widget = await widgets.small(devParams);
widget.presentSmall();
}
}
Script.complete();