Skip to content

Commit 3eaa948

Browse files
committed
Refactor
1 parent 9eeb952 commit 3eaa948

File tree

1 file changed

+8
-34
lines changed

1 file changed

+8
-34
lines changed

arduino-cloud.html

Lines changed: 8 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,8 @@
2121
return ret;
2222
}
2323

24-
function getName(nodeName){
25-
var ret;
26-
switch (nodeName){
27-
case 'property in':
28-
case 'property out':
29-
ret='property';
30-
break;
31-
case 'property in hist':
32-
ret='historic';
33-
break;
34-
case 'property in poll':
35-
ret ='periodic';
36-
break;
37-
case 'property in push':
38-
ret = 'inject';
39-
break;
40-
41-
}
42-
return ret;
43-
}
44-
45-
function setupNode(nodeName, ins, outs) {
24+
function setupNode(nodeName, labelName, ins, outs) {
4625
var defaults = getDefaults(nodeName);
47-
var name = getName(nodeName);
4826
RED.nodes.registerType(nodeName, {
4927
category: 'Arduino IoT Cloud',
5028
color: '#00979d',
@@ -53,9 +31,9 @@
5331
outputs: outs,
5432
icon: "arduino.png",
5533
label: function () {
56-
return this.name || name;
34+
return this.name || labelName;
5735
},
58-
paletteLabel: name,
36+
paletteLabel: labelName,
5937
oneditprepare: function () {
6038
if (this.connection && this.connection !== "_ADD_") {
6139
initThings(this.connection, this.thing);
@@ -108,18 +86,14 @@
10886
}
10987
});
11088
},
111-
oneditsave: function () {
112-
console.log("thing_id: " + this.thing);
113-
console.log("property_id: " + this.property);
114-
}
11589
});
11690
}
11791

118-
setupNode("property in", 0, 1);
119-
setupNode("property out", 1, 0);
120-
setupNode("property in hist", 1, 1);//historic
121-
setupNode("property in poll", 0, 1);//periodic
122-
setupNode("property in push", 1, 1);//inject
92+
setupNode("property in", "property", 0, 1);
93+
setupNode("property out", "property", 1, 0);
94+
setupNode("property in hist", "historic", 1, 1);
95+
setupNode("property in poll", "periodic", 0, 1);
96+
setupNode("property in push", "inject", 1, 1);
12397
</script>
12498

12599

0 commit comments

Comments
 (0)