-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfeedbacks.js
More file actions
103 lines (99 loc) · 2.48 KB
/
Copy pathfeedbacks.js
File metadata and controls
103 lines (99 loc) · 2.48 KB
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
96
97
98
99
100
101
102
103
module.exports = async function (self) {
self.setFeedbackDefinitions({
modifier: {
name: 'Modifier active',
type: 'boolean',
description: 'Shows if a modifier has been set from this control or from any control',
defaultStyle: {
bgcolor: 0x555555,
color: 0x000000,
},
options: [
{
id: 'modifier',
type: 'dropdown',
label: 'Modifier',
choices: [
{ id: 1, label: 'Modifier 1' },
{ id: 2, label: 'Modifier 2' },
{ id: 3, label: 'Modifier 1+2' },
],
default: 1,
},
{
id: 'location',
type: 'dropdown',
label: 'Is set on...',
choices: [
{ id: 'here', label: '...this button' },
{ id: 'anywhere', label: '...any button' },
],
default: 'anywhere',
},
],
callback: ({ options, controlId }) => {
if (options.modifier === 1 || options.modifier === 2) {
if (options.location === 'anywhere') {
return self.modifier[options.modifier].effective
} else if (options.location === 'here') {
return self.modifier[options.modifier].controls.has(controlId)
}
} else if (options.modifier === 3) {
if (options.location === 'anywhere') {
return self.modifier[1].effective && self.modifier[2].effective
} else if (options.location === 'here') {
return self.modifier[1].controls.has(controlId) && self.modifier[2].controls.has(controlId)
}
}
},
},
valid: {
name: 'RegExp Validation',
type: 'boolean',
description: 'Shows if data matches a given Regular expression',
defaultStyle: {
bgcolor: 0x00c000,
color: 0x000000,
},
options: [
{
id: 'data',
type: 'dropdown',
label: 'Data to watch',
choices: [
{ id: 'raw', label: 'Raw data' },
{ id: 'formatted', label: 'Formatted Data' },
{ id: 'raw_last', label: 'last Entry' },
],
default: 'raw',
},
{
id: 'regex',
type: 'textinput',
label: 'Regular Expression',
default: '/.*/',
},
],
callback: ({ options }) => {
let string = ''
switch (options.data) {
case 'raw':
string = self.entry_raw
break
case 'formatted':
string = self.entry_formatted
break
case 'raw_last':
string = self.entry_last
break
}
try {
return self.buildRegex(options.regex).test(string)
} catch (error) {
self.log('error', 'Testing for regular expression in feedback failed, ' + error.message)
return false
}
},
},
})
}