2021-03-14 15:10:26 +01:00
|
|
|
<script type="text/html" data-template-name="twitter-credentials">
|
2018-06-07 12:25:25 +02:00
|
|
|
<div class="form-row">
|
|
|
|
<label for="node-config-input-screen_name"><i class="fa fa-twitter"></i> <span data-i18n="twitter.label.twitter-id"></span></label>
|
|
|
|
<i class="fa fa-at"></i> <input type="text" id="node-config-input-screen_name">
|
|
|
|
</div>
|
|
|
|
<div class="form-row">
|
2018-10-24 13:31:14 +02:00
|
|
|
<p style="margin-top: 30px;"><b>1.</b> <span data-i18n="twitter.label.create"></span> <a href="https://developer.twitter.com/en/apps" target="_blank" style="text-decoration:underline;">developer.twitter.com/en/apps</a></p>
|
2018-06-07 12:25:25 +02:00
|
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
|
|
<p style="margin-top: 30px;"><b>2.</b> <span data-i18n="twitter.label.copy-consumer"></span></p>
|
|
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
|
|
<label style="margin-left: 20px;" for="node-config-input-consumer_key"><span data-i18n="twitter.label.consumer_key"></span></label>
|
|
|
|
<input type="password" id="node-config-input-consumer_key">
|
|
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
|
|
<label style="margin-left: 20px;" for="node-config-input-consumer_secret"><span data-i18n="twitter.label.consumer_secret"></span></label>
|
|
|
|
<input type="password" id="node-config-input-consumer_secret">
|
2018-05-25 14:16:34 +02:00
|
|
|
</div>
|
2018-06-07 12:25:25 +02:00
|
|
|
|
|
|
|
<div class="form-row">
|
|
|
|
<p style="margin-top: 30px;"><b>3.</b> <span data-i18n="twitter.label.copy-accessToken"></span></p>
|
|
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
|
|
<label style="margin-left: 20px;" for="node-config-input-access_token"><span data-i18n="twitter.label.access_key"></span></label>
|
|
|
|
<input type="password" id="node-config-input-access_token">
|
|
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
|
|
<label style="margin-left: 20px;" for="node-config-input-access_token_secret"><span data-i18n="twitter.label.access_secret"></span></label>
|
|
|
|
<input type="password" id="node-config-input-access_token_secret">
|
|
|
|
</div>
|
|
|
|
</script>
|
|
|
|
|
2015-06-13 19:46:44 +02:00
|
|
|
<script type="text/javascript">
|
|
|
|
(function() {
|
|
|
|
var twitterConfigNodeId = null;
|
|
|
|
var twitterConfigNodeIntervalId = null;
|
2015-07-15 00:03:46 +02:00
|
|
|
|
2015-06-13 19:46:44 +02:00
|
|
|
RED.nodes.registerType('twitter-credentials',{
|
|
|
|
category: 'config',
|
|
|
|
defaults: {
|
|
|
|
screen_name: {value:""}
|
|
|
|
},
|
|
|
|
credentials: {
|
2018-06-07 12:25:25 +02:00
|
|
|
consumer_key: { type: "password"},
|
|
|
|
consumer_secret: { type: "password" },
|
2015-06-13 19:46:44 +02:00
|
|
|
access_token: {type: "password"},
|
|
|
|
access_token_secret: {type:"password"}
|
|
|
|
},
|
|
|
|
label: function() {
|
2018-06-07 12:25:25 +02:00
|
|
|
if (this.screen_name) {
|
2018-06-08 13:55:19 +02:00
|
|
|
return (this.screen_name[0]!=="@"?"@":"")+this.screen_name
|
2015-06-13 19:46:44 +02:00
|
|
|
} else {
|
2018-06-07 12:25:25 +02:00
|
|
|
return "Twitter: "+this.id
|
2015-06-13 19:46:44 +02:00
|
|
|
}
|
|
|
|
},
|
2018-06-08 13:55:19 +02:00
|
|
|
exportable: false,
|
|
|
|
oneditsave: function() {
|
|
|
|
var trimFields = [
|
|
|
|
"consumer_key",
|
|
|
|
"consumer_secret",
|
|
|
|
"access_token",
|
|
|
|
"access_token_secret"
|
|
|
|
];
|
|
|
|
// Just in case any whitespace has crept in with the copy-paste of the fields
|
|
|
|
trimFields.forEach(function(field) {
|
|
|
|
var v = $("#node-config-input-"+field).val();
|
|
|
|
v = v.trim();
|
|
|
|
$("#node-config-input-"+field).val(v);
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
2015-06-13 19:46:44 +02:00
|
|
|
});
|
|
|
|
})();
|
|
|
|
</script>
|
|
|
|
|
2021-03-14 15:10:26 +01:00
|
|
|
<script type="text/html" data-template-name="twitter in">
|
2015-06-13 19:46:44 +02:00
|
|
|
<div class="form-row">
|
2015-06-16 11:36:19 +02:00
|
|
|
<label for="node-input-twitter"><i class="fa fa-user"></i> <span data-i18n="twitter.label.twitter-id"></span></label>
|
2015-06-13 19:46:44 +02:00
|
|
|
<input type="text" id="node-input-twitter">
|
|
|
|
</div>
|
|
|
|
<div class="form-row">
|
2015-06-16 11:36:19 +02:00
|
|
|
<label for="node-input-user"><i class="fa fa-search"></i> <span data-i18n="twitter.label.search"></span></label>
|
2015-06-13 19:46:44 +02:00
|
|
|
<select type="text" id="node-input-user" style="display: inline-block; vertical-align: middle; width:60%;">
|
2015-06-16 11:36:19 +02:00
|
|
|
<option value="false" data-i18n="twitter.search.public"></option>
|
|
|
|
<option value="true" data-i18n="twitter.search.follow"></option>
|
|
|
|
<option value="user" data-i18n="twitter.search.user"></option>
|
|
|
|
<option value="dm" data-i18n="twitter.search.direct"></option>
|
2015-06-13 19:46:44 +02:00
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
<div class="form-row" id="node-input-tags-row">
|
2015-06-16 11:36:19 +02:00
|
|
|
<label for="node-input-tags"><i class="fa fa-tags"></i> <span id="node-input-tags-label" data-i18n="twitter.label.for"></span></label>
|
|
|
|
<input type="text" id="node-input-tags" data-i18n="[placeholder]twitter.placeholder.for">
|
2015-06-13 19:46:44 +02:00
|
|
|
</div>
|
|
|
|
<div class="form-row">
|
2015-06-16 12:16:29 +02:00
|
|
|
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="node-red:common.label.name"></span></label>
|
|
|
|
<input type="text" id="node-input-name" data-i18n="[placeholder]node-red:common.label.name">
|
2015-06-13 19:46:44 +02:00
|
|
|
</div>
|
2015-06-16 11:36:19 +02:00
|
|
|
<div class="form-tips"><span data-i18n="[html]twitter.tip"></span></div>
|
2015-06-13 19:46:44 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
RED.nodes.registerType('twitter in',{
|
|
|
|
category: 'social-input',
|
|
|
|
color:"#C0DEED",
|
|
|
|
defaults: {
|
|
|
|
twitter: {type:"twitter-credentials",required:true},
|
2016-09-27 18:34:04 +02:00
|
|
|
tags: {value:""},
|
2015-06-13 19:46:44 +02:00
|
|
|
user: {value:"false",required:true},
|
|
|
|
name: {value:""},
|
2016-09-30 21:38:05 +02:00
|
|
|
inputs: {value:0}
|
2015-06-13 19:46:44 +02:00
|
|
|
},
|
2016-09-30 21:38:05 +02:00
|
|
|
inputs: 0,
|
2016-09-27 22:21:28 +02:00
|
|
|
outputs: 1,
|
2015-06-13 19:46:44 +02:00
|
|
|
icon: "twitter.png",
|
|
|
|
label: function() {
|
|
|
|
if (this.name) {
|
|
|
|
return this.name;
|
|
|
|
}
|
2016-09-30 00:30:13 +02:00
|
|
|
var uname = RED.nodes.node(this.twitter);
|
2015-06-13 19:46:44 +02:00
|
|
|
if (this.user == "dm") {
|
2016-09-30 00:30:13 +02:00
|
|
|
return (uname?uname.label()+" ":"")+this._("twitter.label.dmslabel");
|
2016-11-12 12:43:25 +01:00
|
|
|
} else if (this.user == "event") {
|
|
|
|
var user = RED.nodes.node(this.twitter);
|
|
|
|
return (user?user.label()+" ":"")+this._("twitter.label.eventslabel");
|
2015-06-13 19:46:44 +02:00
|
|
|
} else if (this.user == "user") {
|
2015-06-16 11:36:19 +02:00
|
|
|
return this.tags+" "+this._("twitter.label.tweetslabel");
|
2015-06-13 19:46:44 +02:00
|
|
|
}
|
2016-09-27 22:21:28 +02:00
|
|
|
else if (this.user == "true") {
|
2016-09-30 00:30:13 +02:00
|
|
|
return this._("twitter.label.followers") + (uname?(" "+uname.label()):"");
|
2016-09-27 22:21:28 +02:00
|
|
|
}
|
|
|
|
return "twitter";
|
2015-06-13 19:46:44 +02:00
|
|
|
},
|
|
|
|
labelStyle: function() {
|
|
|
|
return this.name?"node_label_italic":"";
|
|
|
|
},
|
|
|
|
oneditprepare: function() {
|
2015-06-16 11:36:19 +02:00
|
|
|
var userlabel = this._("twitter.label.user");
|
|
|
|
var userph = this._("twitter.placeholder.user");
|
|
|
|
var forlabel = this._("twitter.label.for");
|
|
|
|
var forph = this._("twitter.placeholder.for");
|
2015-06-13 19:46:44 +02:00
|
|
|
$("#node-input-user").change(function() {
|
|
|
|
var type = $("#node-input-user option:selected").val();
|
|
|
|
if (type == "user") {
|
|
|
|
$("#node-input-tags-row").show();
|
2015-06-16 11:36:19 +02:00
|
|
|
$("#node-input-tags-label").html(userlabel);
|
|
|
|
$("#node-input-tags").attr("placeholder",userph);
|
2016-11-12 12:43:25 +01:00
|
|
|
} else if ((type == "dm")||(type == "true")||(type == "event")) {
|
2015-06-13 19:46:44 +02:00
|
|
|
$("#node-input-tags-row").hide();
|
|
|
|
} else {
|
|
|
|
$("#node-input-tags-row").show();
|
2015-06-16 11:36:19 +02:00
|
|
|
$("#node-input-tags-label").html(forlabel);
|
|
|
|
$("#node-input-tags").attr("placeholder",forph);
|
2015-06-13 19:46:44 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
$("#node-input-user").change();
|
2016-09-30 21:38:05 +02:00
|
|
|
},
|
|
|
|
oneditsave: function() {
|
|
|
|
if ($('#node-input-tags').val() === '' && $("#node-input-user option:selected").val() === 'false') {
|
|
|
|
this.inputs = 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
//set back the default state of 0 inputs
|
|
|
|
//this.inputs = 0;
|
|
|
|
}
|
|
|
|
}
|
2015-06-13 19:46:44 +02:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2021-03-14 15:10:26 +01:00
|
|
|
<script type="text/html" data-template-name="twitter out">
|
2015-06-13 19:46:44 +02:00
|
|
|
<div class="form-row">
|
2015-06-16 11:36:19 +02:00
|
|
|
<label for="node-input-twitter"><i class="fa fa-user"></i> <span data-i18n="twitter.label.twitter-id"></span></label>
|
2015-06-13 19:46:44 +02:00
|
|
|
<input type="text" id="node-input-twitter">
|
|
|
|
</div>
|
|
|
|
<div class="form-row">
|
2015-06-16 12:16:29 +02:00
|
|
|
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="node-red:common.label.name"></span></label>
|
|
|
|
<input type="text" id="node-input-name" data-i18n="[placeholder]node-red:common.label.name">
|
2015-06-13 19:46:44 +02:00
|
|
|
</div>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
RED.nodes.registerType('twitter out',{
|
|
|
|
category: 'social-output',
|
|
|
|
color:"#C0DEED",
|
|
|
|
defaults: {
|
|
|
|
twitter: {type:"twitter-credentials",required:true},
|
|
|
|
name: {value:"Tweet"}
|
|
|
|
},
|
|
|
|
inputs:1,
|
|
|
|
outputs:0,
|
|
|
|
icon: "twitter.png",
|
|
|
|
align: "right",
|
|
|
|
label: function() {
|
|
|
|
return this.name;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|