-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIfEmptyDynamicValue.js
More file actions
42 lines (34 loc) · 1.24 KB
/
Copy pathIfEmptyDynamicValue.js
File metadata and controls
42 lines (34 loc) · 1.24 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
// Extensions are implemented as JavaScript classes
var IfEmptyDynamicValue = function () {
this.title = function (context) {
return "IfEmpty";
};
this.text = function (context) {
return this.name;
};
// implement the evaluate() method to generate the dynamic value
this.evaluate = function (context) {
return this._isNull(this.testValue) ? this.isEmpty : this.notEmpty;
};
this._isNull = function ( str ) {
if (!str || str == "" ) return true;
var regu = "^[ ]+$";
var re = new RegExp(regu);
return re.test(str);
};
};
// set the Extension Identifier (must be same as the directory name)
IfEmptyDynamicValue.identifier = "io.chengguo.PawExtensions.IfEmptyDynamicValue";
// give a display name to your Dynamic Value
IfEmptyDynamicValue.title = "If Empty Dynamic Value";
// Link to the Dynamic Value documentation.
IfEmptyDynamicValue.help = "https://github.com/FingerArt/IfEmptyDynamicValue"
// set input fields
IfEmptyDynamicValue.inputs = [
InputField("name", "Name", "String"),
InputField("testValue", "Test Value", "String"),
InputField("isEmpty", "Empty", "String"),
InputField("notEmpty", "Not Empty", "String")
];
// call to register function is required
registerDynamicValueClass(IfEmptyDynamicValue);