1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Tweak Twitter Properties UI to improve flow

This commit is contained in:
Dave C-J 2013-10-02 21:14:02 +01:00
parent 362bc9a805
commit f6da96e7e1
2 changed files with 23 additions and 21 deletions

View File

@ -30,7 +30,7 @@
}
var callback = encodeURIComponent(location.protocol+"//"+location.hostname+":"+location.port+pathname+"twitter/"+twitterConfigNodeId+"/auth/callback");
$("#node-config-twitter-row").html('Click <a id="node-config-twitter-start" href="/twitter/'+twitterConfigNodeId+'/auth?callback='+callback+'" target="_blank">here</a> to authenticate with Twitter.');
$("#node-config-twitter-row").html('Click <a id="node-config-twitter-start" href="/twitter/'+twitterConfigNodeId+'/auth?callback='+callback+'" target="_blank"><b>here</b></a> to authenticate with Twitter.');
$("#node-config-twitter-start").click(function() {
twitterConfigNodeIntervalId = window.setTimeout(pollTwitterCredentials,2000);
});
@ -103,33 +103,36 @@
<script type="text/x-red" data-template-name="twitter in">
<div class="form-row">
<label for="node-input-twitter"><i class="icon-user"></i> Twitter</label>
<label for="node-input-twitter"><i class="icon-user"></i> User</label>
<input type="text" id="node-input-twitter">
</div>
<div class="form-row">
<label for="node-input-operation"><i class="icon-search"></i> Search</label>
<select type="text" id="node-input-operation" style="display: inline-block; vertical-align: top;">
<option value="words">Tweets</option>
<option value="user">Users</option>
<!--<option value="site">Site</option> -->
</select>
</div>
<div class="form-row">
<label for="node-input-tags"><i class="icon-tag"></i> Tags</label>
<input type="text" id="node-input-tags" placeholder="comma-separated tags">
<label for="node-input-tags"><i class="icon-tags"></i> For</label>
<input type="text" id="node-input-tags" placeholder="comma-separated words, @ids, #tags">
</div>
<div class="form-row">
<label>&nbsp;</label>
<input type="checkbox" id="node-input-user" placeholder="Name" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-input-user" style="width: 70%;">Tick to use user stream<br/>(rather than status/filter)</label>
</div>
<div class="form-row">
<!-- <div class="form-row">
<label for="node-input-topic"><i class="icon-tasks"></i> Topic</label>
<input type="text" id="node-input-topic" placeholder="Topic">
</div>
</div> -->
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-tips">Tip: the Senders name gets appended to the topic heirarchy
</div>
<div class="form-tips">Tip: Use commas without spaces between multiple search terms. Comma = OR, Space = AND.</div>
</script>
<script type="text/x-red" data-help-name="twitter in">
<p>Twitter input node. Watches the public stream for tweets containing the configured search term.</p>
<p>Sets the <b>msg.topic</b> to the configured topic and then appends the senders screen name.</p>
<p>Sets the <b>msg.topic</b> to <i>tweets/</i> and then appends the senders screen name.</p>
<p>Sets <b>msg.location</b> to the tweeters location if known.</p>
</script>
@ -140,7 +143,7 @@
defaults: {
twitter: {type:"twitter-credentials",required:true},
tags: {value:"",required:true},
user: {value:false},
operation: {value:"words",required:true},
name: {value:""},
topic: {value:"tweets"}
},

View File

@ -24,11 +24,10 @@ function TwitterNode(n) {
}
RED.nodes.registerType("twitter-credentials",TwitterNode);
function TwitterInNode(n) {
RED.nodes.createNode(this,n);
this.active = true;
this.user = n.user;
this.oper = n.operation;
this.tags = n.tags.replace(/ /g,'');
this.twitter = n.twitter;
this.topic = n.topic;
@ -47,11 +46,13 @@ function TwitterInNode(n) {
if (this.tags !== "") {
try {
var thing = 'statuses/filter';
if (this.user) { thing = 'user'; }
if (this.oper === "user") { thing = 'user'; }
if (this.oper === "site") { thing = 'site'; }
function setupStream() {
if (node.active) {
twit.stream(thing, { track: [node.tags] }, function(stream) {
//twit.stream('user', { track: [node.tags] }, function(stream) {
//twit.stream('site', { track: [node.tags] }, function(stream) {
//twit.stream('statuses/filter', { track: [node.tags] }, function(stream) {
node.stream = stream;
stream.on('data', function(tweet) {
@ -101,8 +102,6 @@ TwitterInNode.prototype.close = function() {
}
}
function TwitterOutNode(n) {
RED.nodes.createNode(this,n);
this.topic = n.topic;