-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFCF-DataCollection.html
120 lines (113 loc) · 3.67 KB
/
FCF-DataCollection.html
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<script type="text/javascript">
RED.nodes.registerType('FCF-DataCollection', {
category: 'FCF',
color: '#FDF0C2',
defaults: {
rules: {
value: [{
topic: '',
topic2: ''
}]
},
collect: {
value: 'query'
}
},
inputs: 1,
outputs: 2,
paletteLabel: 'Data Collection',
icon: 'db.png',
label: function () {
return 'Data Collection';
},
oneditsave: function () {
var rules = $('#node-input-rule-container').editableList('items');
var node = this;
node.rules = [];
rules.each(function (i) {
var rule = $(this);
var topic = rule.find('#input1').val();
var topic2 = rule.find('#input2').val();
if (topic != null && topic != '' && topic2 != null && topic2 != '') {
node.rules.push({
topic: topic,
topic2: topic2
});
}
});
//this.outputs = node.rules.length;
},
oneditprepare: function () {
var node = this;
$("#node-input-rule-container").css('min-height', '250px').css('min-width', '450px').editableList({
addItem: function (container, i, opt) {
var rule = opt;
var row = $('<div/>').appendTo(container);
var selectField = $('<input/>', {
style: "width:80%; margin-left: 5px; text-align: left;",
id: "input1"
})
.attr('placeholder', 'Message Content')
.attr('type', 'text')
.appendTo(row);
var selectField2 = $('<input/>', {
style: "width:80%; margin-left: 5px; text-align: left;",
id: "input2"
})
.attr('placeholder', 'Variable Name')
.attr('type', 'text')
.appendTo(row);
if (rule.topic != null) {
selectField.val(rule.topic);
}
if (rule.topic2 != null) {
selectField2.val(rule.topic2);
}
var finalspan = $('<span/>', {
style: "float: right;margin-top: 6px;"
}).appendTo(row);
},
removeItem: function (opt) {
var rules = $('#node-input-rule-container').editableList('items');
rules.each(function (i) {
$(this).find('.node-input-rule-index').html(i + 1);
});
},
sortItems: function () {
var rules = $('#node-input-rule-container').editableList('items');
rules.each(function (i) {
$(this).find('.node-input-rule-index').html(i + 1);
});
},
sortable: true,
removable: true
});
for (var i = 0; i < node.rules.length; i++) {
var rule = this.rules[i];
$('#node-input-rule-container').editableList('addItem', rule);
}
}
});
</script>
<script type="text/x-red" data-template-name="FCF-DataCollection">
<div class="form-row">
<label for="node-input-collect"><i class="fa fa-tasks"></i> Data Type</span></label>
<select type="text" id="node-input-collect" style="width:70%;">
<option value="query">Query</option>
<option value="userData">User Data</option>
</select>
</div>
<div class="form-row">
<label for="node-input-name" style="width:100%;"><i class="fa fa-tag"></i> Message Content and Variable Name:</label>
</div>
<div class="form-row node-input-rule-container-row">
<ol id="node-input-rule-container"></ol>
</div>
<div style="max-width: 460px;font-size: 12px;color: #999999;line-height: 14px;clear:both;margin-top:5px;">
</div>
</script>
<script type="text/x-red" data-help-name="FCF-DataCollection">
<p>
用來收集使用者所輸入的資料
</p>
</script>