-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathactions.js
95 lines (90 loc) · 2.06 KB
/
actions.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
module.exports = {
getActions : function() {
var self = this
let actions = {}
let ele = []
for(let k of this.config.countdown.split(";")) {
ele.push({label: `${k}`, id: `${k}`})
}
actions['countdown'] = {
label: 'Countdown',
options: [
{
type: 'dropdown',
label: 'Name',
id: 'name',
default: [],
choices: ele,
},{
type: 'textinput',
label: 'Time (h:mm:ss)',
id: 'time',
default: '0:00:00',
regex: '/^(0*[0-9]|1[0-9]|2[0-3]):(0*[0-9]|[1-5][0-9]|60):(0*[0-9]|[1-5][0-9]|60)$/',
},{
type: 'dropdown',
label: 'Function',
id: 'func',
default: '0',
choices: [
{label: 'Start/Pause', id: 0},
{label: 'Start/Pause/Reset', id: 1},
],
},{
type: 'dropdown',
label: 'When finished',
id: 'end',
default: '0',
choices: [
{label: 'Stop', id: 0},
{label: 'Continue', id: 1},
],
}
],
subscribe: (action) => {
self.setVariable(`count_${action.options.name}`, action.options.time)
self.varStatus[`count_${action.options.name}`] = 0
self.continue[`count_${action.options.name}`] = false
self.feedbacks
},
unsubscribe: (action) => {
clearInterval(self.intVal[`count_${action.options.name}`])
},
}
ele = []
for(let k of this.config.stopwatch.split(";")) {
ele.push({label: `${k}`, id: `${k}`})
}
actions['stopwatch'] = {
label: 'Stopwatch',
options: [
{
type: 'dropdown',
label: 'Name',
id: 'name',
default: [],
choices: ele,
},{
type: 'dropdown',
label: 'Function',
id: 'func',
default: '0',
choices: [
{label: 'Start/Pause', id: 0},
{label: 'Start/Pause/Reset', id: 1},
],
}
],
subscribe: (action) => {
self.setVariable(`stop_${action.options.name}`, '0:00:00')
self.varStatus[`stop_${action.options.name}`] = 0
action.options.time = '0:00:00'
self.feedbacks
},
unsubscribe: (action) => {
clearInterval(self.intVal[`stop_${action.options.name}`])
},
}
return actions
},
}