Forked from Dalia's Pen Random HarryPotter Quote Generator - Zipline.
Forked from Dalia's Pen Random HarryPotter Quote Generator - Zipline.
A Pen by Captain Anonymous on CodePen.
Forked from Dalia's Pen Random HarryPotter Quote Generator - Zipline.
Forked from Dalia's Pen Random HarryPotter Quote Generator - Zipline.
A Pen by Captain Anonymous on CodePen.
var channel = 'pubnub-twitter'; | |
var pubnubTweet = PUBNUB.init({ | |
subscribe_key: 'sub-c-78806dd4-42a6-11e4-aed8-02ee2ddab7fe', | |
ssl: true | |
}); |
<div class="container"></div> | |
<div class="container"> | |
<div id="selDiv"> | |
<h4 id="bestFans">Which fans are Tweeting more?</h4> | |
</div> | |
<div id="scrollDiv"></div> | |
<div id="scrollDivPic"></div> | |
</div> |
function getStreamData() { | |
pubnubTweet.subscribe({ | |
channel: channel, | |
callback: processData | |
}); | |
} |
function getData() { | |
pubnubTweet.history({ | |
channel: channel, | |
count: 75, | |
callback: function(messages) { | |
pubnubTweet.each(messages[0], processData); | |
getStreamData(); | |
}, | |
error: function(error) { | |
console.log(error); |
var curryWords = [ | |
'stephen curry', 'chef curry', '#stephcurry', '#chefcurry', ‘curry’ | |
] | |
var splashWords = [ | |
'splash brothers', 'splash bros', 'splash' | |
] |
var numCurryWords = 0; | |
var numSplashWords = 0; |
function processData(data) { | |
if (!data) return; | |
if (splashWords.some(function(v) { return data.text.toLowerCase().indexOf(v) !== -1; })) { | |
numSplashWords +=1; | |
totalNumTweets+=1; | |
publish2(); | |
console.log(data); | |
} | |
bestFans(); |
if (splashWords.some(function(v) { return data.text.toLowerCase().indexOf(v) !== -1; })) { | |
numSplashWords += 1; | |
totalNumTweets += 1; | |
publish2(); | |
console.log(data); | |
} |
function bestFans() { | |
var fanElement = document.getElementById('scrollDiv'); | |
var fanStr = document.createTextNode('Warriors fans are Tweeting more'); | |
var notFanStr = document.createTextNode('Cleveland fans are Tweeting more'); | |
var tieFanStr = document.createTextNode('Both teams\' fans are tweeting equally!'); | |
if (numDubsTeamWords == numCavsTeamWords) { | |
fanElement.innerHTML = tieFanStr; | |
fanElement.appendChild(tieFanStr); | |
} //if |