-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
49 lines (41 loc) · 1.63 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
function fetchData(){
function setInterval($.ajax({
url: "http://localhost:5000/tweets",
success: function(data) {
var sl = data.stop.length; //the stop array received from the server
var gl = data.go.length;
var cl = data.continue.length;
// //fetch function -> $.getJSON
// //compare function -> if statment, for loop
var stopArray = [],
goArray = [],
continueArray = []; //the arrays that we are creating and giving to the client so that the visiualations could be rendered
function fetchData(){
function setInterval($.ajax({
url: "http://localhost:8000/stop",
success: function(data) {
var sl = data.stop.length; //the stop array received from the server
var gl = data.go.length;
var cl = data.continue.length;
for(var i = 0; i < sl; i++){
if (stopArray[i].text === undefined) {
stopArray.push(data.stop[i]);
}
stopArray[i].count = data.stop[i].count;
}
for(var i = 0; i < gl; i++){
if (goArray[i].text === undefined) {
goArray.push(data.go[i]);
}
goArray[i].count = data.go[i].count;
}
for(var i = 0; i < cl; i++){
if (continueArray[i].text === undefined) {
continueArray.push(data.continue[i]);
}
continueArray[i].count = data.continue[i].count;
}
d3func(data);
}
}), 3000)
}