Skip to content

Commit 6a0d248

Browse files
committed
Move nodes over from main repo
1 parent 5002542 commit 6a0d248

19 files changed

Lines changed: 1073 additions & 0 deletions

File tree

analysis/wordpos/72-wordpos.html

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<!--
2+
Copyright 2013 IBM Corp.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
17+
<script type="text/x-red" data-template-name="wordpos">
18+
<div class="form-row">
19+
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
20+
<input type="text" id="node-input-name" placeholder="Name">
21+
</div>
22+
<div class="form-tips">Adds <b>msg.pos</b> as the anaylsis result.
23+
</div>
24+
</script>
25+
26+
<script type="text/x-red" data-help-name="wordpos">
27+
<p>Analyses <b>msg.payload</b> and classifies the part-of-speech of each word.</p>
28+
<p>The resulting message has <b>msg.pos</b> added with the results:</p>
29+
<pre>{
30+
nouns:[],
31+
verbs:[],
32+
adjectives:[],
33+
adverbs:[],
34+
rest:[]
35+
}</pre>
36+
<p>Note: a word may appear in multiple POS (eg, 'great' is both a noun and an adjective)</p>
37+
</script>
38+
39+
<script type="text/javascript">
40+
RED.nodes.registerType('wordpos',{
41+
category: 'analysis-function',
42+
color:"#E6E0F8",
43+
defaults: {
44+
name: {value:""},
45+
},
46+
inputs:1,
47+
outputs:1,
48+
icon: "arrow-in.png",
49+
label: function() {
50+
return this.name||"wordpos";
51+
},
52+
labelStyle: function() {
53+
return this.name?"node_label_italic":"";
54+
}
55+
});
56+
57+
</script>

analysis/wordpos/72-wordpos.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* Copyright 2013 IBM Corp.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
**/
16+
17+
var RED = require("../../red/red");
18+
var util = require("util");
19+
var WordPos = require('wordpos');
20+
21+
var wordpos = new WordPos();
22+
23+
function WordPOSNode(n) {
24+
RED.nodes.createNode(this,n);
25+
this.on("input", function(msg) {
26+
var node = this;
27+
wordpos.getPOS(msg.payload, function (result) {
28+
msg.pos = result;
29+
node.send(msg);
30+
});
31+
});
32+
}
33+
34+
RED.nodes.registerType("wordpos",WordPOSNode);

hardware/blink/76-blinkstick.html

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<!--
2+
Copyright 2013 IBM Corp.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
17+
<script type="text/x-red" data-template-name="blinkstick">
18+
<div class="form-row">
19+
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
20+
<input type="text" id="node-input-name" placeholder="Name">
21+
</div>
22+
<div class="form-tips">Expects a msg.payload with either hex #rrggbb or decimal red,green,blue.</div>
23+
</script>
24+
25+
<script type="text/x-red" data-help-name="blinkstick">
26+
<p>BlinkStick output node. Expects a <b>msg.payload</b> with either a hex string #rrggbb triple or red,green,blue as three 0-255 values.
27+
It can also accept <i><a href="http://www.w3schools.com/html/html_colornames.asp" target="_new">standard HTML colour</a></i> names</p>
28+
<p><b>NOTE:</b> currently only works with a single BlinkStick. (As it uses the findFirst() function to attach).</p>
29+
<p>For more info see the <i><a href="http://blinkstick.com/" target="_new">BlinkStick website</a></i> or the <i><a href="https://github.com/arvydas/blinkstick-node" target="_new">node module</a></i> documentation.</p>
30+
</script>
31+
32+
<script type="text/javascript">
33+
RED.nodes.registerType('blinkstick',{
34+
category: 'output',
35+
color:"GoldenRod",
36+
defaults: {
37+
name: {value:""}
38+
},
39+
inputs:1,
40+
outputs:0,
41+
icon: "light.png",
42+
align: "right",
43+
label: function() {
44+
return this.name||"blinkstick";
45+
},
46+
labelStyle: function() {
47+
return this.name?"node_label_italic":"";
48+
}
49+
});
50+
</script>

hardware/blink/76-blinkstick.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/**
2+
* Copyright 2013 IBM Corp.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
**/
16+
17+
var RED = require("../../red/red");
18+
var blinkstick = require("blinkstick");
19+
20+
Object.size = function(obj) {
21+
var size = 0, key;
22+
for (key in obj) { if (obj.hasOwnProperty(key)) size++; }
23+
return size;
24+
};
25+
26+
function BlinkStick(n) {
27+
RED.nodes.createNode(this,n);
28+
var p1 = /^\#[A-Fa-f0-9]{6}$/
29+
var p2 = /[0-9]+,[0-9]+,[0-9]+/
30+
this.led = blinkstick.findFirst(); // maybe try findAll() (one day)
31+
var node = this;
32+
33+
this.on("input", function(msg) {
34+
if (msg != null) {
35+
if (Object.size(node.led) !== 0) {
36+
try {
37+
if (p2.test(msg.payload)) {
38+
var rgb = msg.payload.split(",");
39+
node.led.setColor(parseInt(rgb[0])&255, parseInt(rgb[1])&255, parseInt(rgb[2])&255);
40+
}
41+
else {
42+
node.led.setColor(msg.payload.toLowerCase().replace(/\s+/g,''));
43+
}
44+
}
45+
catch (err) {
46+
node.warn("BlinkStick missing ?");
47+
node.led = blinkstick.findFirst();
48+
}
49+
}
50+
else {
51+
//node.warn("No BlinkStick found");
52+
node.led = blinkstick.findFirst();
53+
}
54+
}
55+
});
56+
if (Object.size(node.led) === 0) {
57+
node.error("No BlinkStick found");
58+
}
59+
60+
}
61+
62+
RED.nodes.registerType("blinkstick",BlinkStick);

hardware/blink/77-blink1.html

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<!--
2+
Copyright 2013 IBM Corp.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
17+
<script type="text/x-red" data-template-name="blink1">
18+
<div class="form-row">
19+
<label for="node-input-fade"><i class="icon-signal"></i> Fade (mS)</label>
20+
<input type="text" id="node-input-fade" placeholder="0">
21+
</div>
22+
<div class="form-row">
23+
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
24+
<input type="text" id="node-input-name" placeholder="Name">
25+
</div>
26+
<div class="form-tips">Expects a msg.payload with three part csv string of r,g,b.</div>
27+
</script>
28+
29+
<script type="text/x-red" data-help-name="blink1">
30+
<p>Thingm Blink1 output node. Expects a msg.payload with a three part csv string of r,g,b.</p>
31+
</script>
32+
33+
<script type="text/javascript">
34+
RED.nodes.registerType('blink1',{
35+
category: 'output',
36+
color:"GoldenRod",
37+
defaults: {
38+
fade: {value:"0",required:true,validate:RED.validators.number()},
39+
name: {value:""}
40+
},
41+
inputs:1,
42+
outputs:0,
43+
icon: "light.png",
44+
align: "right",
45+
label: function() {
46+
return this.name||"blink1";
47+
},
48+
labelStyle: function() {
49+
return (this.name||!this.topic)?"node_label_italic":"";
50+
}
51+
});
52+
</script>

hardware/blink/77-blink1.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/**
2+
* Copyright 2013 IBM Corp.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
**/
16+
17+
var RED = require("../../red/red");
18+
var Blink1 = require("node-blink1");
19+
20+
function Blink1Node(n) {
21+
RED.nodes.createNode(this,n);
22+
this.fade = n.fade||0;
23+
var node = this;
24+
25+
try {
26+
var p1 = /^\#[A-Fa-f0-9]{6}$/
27+
var p2 = /[0-9]+,[0-9]+,[0-9]+/
28+
this.on("input", function(msg) {
29+
if (blink1) {
30+
if (p1.test(msg.payload)) {
31+
// if it is a hex colour string
32+
var r = parseInt(msg.payload.slice(1,3),16);
33+
var g = parseInt(msg.payload.slice(3,5),16);
34+
var b = parseInt(msg.payload.slice(5),16);
35+
if (node.fade == 0) { blink1.setRGB( r, g, b ); }
36+
else { blink1.fadeToRGB(node.fade, r, g, b ); }
37+
}
38+
else if (p2.test(msg.payload)) {
39+
// if it is a r,g,b triple
40+
var rgb = msg.payload.split(',');
41+
if (node.fade == 0) { blink1.setRGB(parseInt(rgb[0])&255, parseInt(rgb[1])&255, parseInt(rgb[2])&255); }
42+
else { blink1.fadeToRGB(node.fade, parseInt(rgb[0])&255, parseInt(rgb[1])&255, parseInt(rgb[2])&255); }
43+
}
44+
else {
45+
// you can do fancy colours by name here if you want...
46+
node.warn("Blink1 : invalid msg : "+msg.payload);
47+
}
48+
}
49+
else {
50+
node.warn("No Blink1 found");
51+
}
52+
});
53+
var blink1 = new Blink1.Blink1();
54+
}
55+
catch(e) {
56+
node.error("No Blink1 found");
57+
}
58+
}
59+
60+
RED.nodes.registerType("blink1",Blink1Node);

social/notify/57-notify.html

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<!--
2+
Copyright 2013 IBM Corp.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
17+
<script type="text/x-red" data-template-name="notify">
18+
<div class="form-row">
19+
<label for="node-input-title"><i class="icon-flag"></i> Title</label>
20+
<input type="text" id="node-input-title" placeholder="Node-RED">
21+
</div>
22+
<div class="form-row">
23+
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
24+
<input type="text" id="node-input-name" placeholder="Name">
25+
</div>
26+
</script>
27+
28+
<script type="text/x-red" data-help-name="notify">
29+
<p>Uses Growl to provide a desktop popup containing the <b>msg.payload</b>. Only useful on the local machine.</p>
30+
<p>Optionally uses <b>msg.topic</b> as the title.</p>
31+
<p>Uses Growl so should work cross platform but will need pre-reqs installed... see <i><a href="https://npmjs.org/package/growl" target="_new">this link.</a></i></p>
32+
<p>If installing on Windows you MUST read the install instructions ... especially the bit about adding growlnotify to your path... or it WON'T work.</p>
33+
</script>
34+
35+
<script type="text/javascript">
36+
RED.nodes.registerType('notify',{
37+
category: 'output',
38+
defaults: {
39+
title: {value:""},
40+
name: {value:""}
41+
},
42+
color:"#a7c9a0",
43+
inputs:1,
44+
outputs:0,
45+
icon: "alert.png",
46+
align: "right",
47+
label: function() {
48+
return this.name||this.title||"notify";
49+
},
50+
labelStyle: function() {
51+
return this.name?"node_label_italic":"";
52+
}
53+
});
54+
55+
</script>

0 commit comments

Comments
 (0)