2014-05-18 23:10:00 +02:00
<!--
2014-05-24 17:38:35 +02:00
2014-05-18 23:10:00 +02:00
Copyright 2014 Charalampos Doukas, @BuildingIoT
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
2014-05-19 11:08:15 +02:00
< script type = "text/x-red" data-template-name = "pusher in" >
2014-05-18 23:10:00 +02:00
< div class = "form-row" >
2014-09-03 17:12:26 +02:00
< label for = "node-input-channel" > < i class = "fa fa-random" > < / i > Channel< / label >
2014-05-24 19:29:27 +02:00
< input type = "text" id = "node-input-channel" placeholder = "my_channel" >
2014-05-18 23:10:00 +02:00
< / div >
< div class = "form-row" >
2014-09-03 17:12:26 +02:00
< label for = "node-input-eventname" > < i class = "fa fa-tasks" > < / i > Event< / label >
2014-05-24 19:29:27 +02:00
< input type = "text" id = "node-input-eventname" placeholder = "test_event_name" >
2014-05-18 23:10:00 +02:00
< / div >
< div class = "form-row" >
2014-09-03 17:12:26 +02:00
< label for = "node-input-appkey_sub" > < i class = "fa fa-lock" > < / i > App Key< / label >
2014-05-24 19:29:27 +02:00
< input type = "text" id = "node-input-appkey_sub" placeholder = "key" >
2014-05-18 23:10:00 +02:00
< / div >
2014-05-24 19:29:27 +02:00
2014-05-18 23:10:00 +02:00
< div class = "form-row" >
2014-09-03 17:12:26 +02:00
< label for = "node-input-name" > < i class = "fa fa-tag" > < / i > Name< / label >
2014-05-18 23:10:00 +02:00
< input type = "text" id = "node-input-name" placeholder = "Name" >
< / div >
< / script >
2014-05-24 17:38:35 +02:00
<!-- Next, some simple help text is provided for the node. -->
2014-05-19 11:08:15 +02:00
< script type = "text/x-red" data-help-name = "pusher in" >
2014-05-18 23:10:00 +02:00
< p > Pusher input mode. Use this node to subscribe to a Pusher channel/event. You need a valid Pusher App key.< / p >
< / script >
2014-05-24 17:38:35 +02:00
<!-- Finally, the node type is registered along with all of its properties -->
2014-05-18 23:10:00 +02:00
< script type = "text/javascript" >
2014-05-19 11:08:15 +02:00
RED.nodes.registerType('pusher in',{
2014-05-24 17:38:35 +02:00
category: 'social-input', // the palette category
2014-05-18 23:10:00 +02:00
color:"#A9D0F5",
2014-05-24 17:38:35 +02:00
defaults: { // defines the editable properties of the node
name: {value:""}, // along with default values.
2014-05-18 23:10:00 +02:00
channel: {value:"", required:true},
eventname: {value:"", required:true}
},
2014-05-24 17:38:35 +02:00
inputs:0, // set the number of inputs - only 0 or 1
outputs:1, // set the number of outputs - 0 to n
icon: "pusher.png", // set the icon (held in public/icons)
label: function() { // sets the default label contents
return this.name||"pusher";
2014-05-18 23:10:00 +02:00
},
labelStyle: function() { // sets the class to apply to the label
return this.name?"node_label_italic":"";
},
oneditsave: function() {
var credentials = {};
var newAppKey_sub = $('#node-input-appkey_sub').val();
credentials.pusherappkey_sub = newAppKey_sub;
$.ajax({
url: 'pusher/'+this.id,
type: 'POST',
data: credentials,
success: function(result){}
});
},
2014-05-24 14:31:02 +02:00
oneditprepare: function() {
$.getJSON('pusher/'+this.id,function(data) {
if (data.pusherappkey_sub) {
$('#node-input-appkey_sub').val(data.pusherappkey_sub);
}
});
},
2014-05-18 23:10:00 +02:00
ondelete: function() {
$.ajax({
url: 'pusher/'+this.id,
type: 'DELETE',
success: function(result) {}
});
}
});
< / script >
2014-05-19 11:08:15 +02:00
< script type = "text/x-red" data-template-name = "pusher out" >
2014-05-18 23:10:00 +02:00
< div class = "form-row" >
2014-09-03 17:12:26 +02:00
< label for = "node-input-channel" > < i class = "fa fa-random" > < / i > Channel< / label >
2014-05-24 19:29:27 +02:00
< input type = "text" id = "node-input-channel" placeholder = "my_channel" >
2014-05-18 23:10:00 +02:00
< / div >
< div class = "form-row" >
2014-09-03 17:12:26 +02:00
< label for = "node-input-eventname" > < i class = "fa fa-tasks" > < / i > Event< / label >
2014-05-24 19:29:27 +02:00
< input type = "text" id = "node-input-eventname" placeholder = "test_event_name" >
2014-05-18 23:10:00 +02:00
< / div >
< div class = "form-row" >
2014-09-03 17:12:26 +02:00
< label for = "node-input-appid" > < i class = "fa fa-tag" > < / i > App ID< / label >
2014-05-24 19:29:27 +02:00
< input type = "text" id = "node-input-appid" placeholder = "app_id" >
2014-05-18 23:10:00 +02:00
< / div >
< div class = "form-row" >
2014-09-03 17:12:26 +02:00
< label for = "node-input-appkey" > < i class = "fa fa-lock" > < / i > App Key< / label >
2014-05-24 19:29:27 +02:00
< input type = "text" id = "node-input-appkey" placeholder = "key" >
2014-05-18 23:10:00 +02:00
< / div >
< div class = "form-row" >
2014-09-03 17:12:26 +02:00
< label for = "node-input-topic" > < i class = "fa fa-asterisk" > < / i > App Secret< / label >
2014-05-24 19:29:27 +02:00
< input type = "password" id = "node-input-appsecret" placeholder = "secret" >
2014-05-18 23:10:00 +02:00
< / div >
< div class = "form-row" >
2014-09-03 17:12:26 +02:00
< label for = "node-input-name" > < i class = "fa fa-tag" > < / i > Name< / label >
2014-05-18 23:10:00 +02:00
< input type = "text" id = "node-input-name" placeholder = "Name" >
< / div >
< / script >
2014-05-24 17:38:35 +02:00
<!-- Next, some simple help text is provided for the node. -->
2014-05-19 11:08:15 +02:00
< script type = "text/x-red" data-help-name = "pusher out" >
2014-05-18 23:10:00 +02:00
< p > Pusher output node for sending messages to a specific channel/event. You need an App key, secret and ID of a Pusher app. The node will send the payload of the incoming message.< / p >
< / script >
2014-05-24 17:38:35 +02:00
<!-- Finally, the node type is registered along with all of its properties -->
2014-05-18 23:10:00 +02:00
< script type = "text/javascript" >
2014-05-19 11:08:15 +02:00
RED.nodes.registerType('pusher out',{
2014-05-24 17:38:35 +02:00
category: 'social-output', // the palette category
2014-05-18 23:10:00 +02:00
color:"#A9D0F5",
2014-05-24 17:38:35 +02:00
defaults: { // defines the editable properties of the node
name: {value:""}, // along with default values.
2014-05-18 23:10:00 +02:00
channel: {value:"", required:true},
2014-05-24 17:38:35 +02:00
eventname: {value:"", required:true}
2014-05-18 23:10:00 +02:00
},
2014-05-24 17:38:35 +02:00
inputs:1, // set the number of inputs - only 0 or 1
outputs:0, // set the number of outputs - 0 to n
icon: "pusher.png", // set the icon (held in public/icons)
2014-05-18 23:10:00 +02:00
align: "right",
2014-05-24 17:38:35 +02:00
label: function() { // sets the default label contents
return this.name||"pusher";
2014-05-18 23:10:00 +02:00
},
labelStyle: function() { // sets the class to apply to the label
return this.name?"node_label_italic":"";
},
oneditsave: function() {
var credentials = {};
var newAppID = $('#node-input-appid').val();
var newAppKey = $('#node-input-appkey').val();
var newAppSecret = $('#node-input-appsecret').val();
credentials.pusherappid = newAppID;
credentials.pusherappkey = newAppKey;
credentials.pusherappsecret = newAppSecret;
$.ajax({
url: 'pusher/'+this.id,
type: 'POST',
data: credentials,
success: function(result){}
});
},
2014-05-24 14:31:02 +02:00
oneditprepare: function() {
$.getJSON('pusher/'+this.id,function(data) {
if (data.pusherappid) {
$('#node-input-appid').val(data.pusherappid);
}
if (data.pusherappkey) {
$('#node-input-appkey').val(data.pusherappkey);
2014-05-24 17:38:35 +02:00
}
2014-05-24 14:31:02 +02:00
if (data.pusherappsecret) {
$('#node-input-appsecret').val(data.pusherappsecret);
2014-05-24 17:38:35 +02:00
}
2014-05-24 14:31:02 +02:00
});
},
2014-05-18 23:10:00 +02:00
ondelete: function() {
$.ajax({
url: 'pusher/'+this.id,
type: 'DELETE',
success: function(result) {}
});
}
});
< / script >