-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
109 lines (98 loc) · 3.56 KB
/
index.html
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<!DOCTYPE HTML>
<html>
<head>
<title> waiting to serve some twits </title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="/css/bootstrap.min.css" rel="stylesheet">
<link href="/css/style.css" rel="stylesheet">
</head>
<body>
<div class="background" id="instad">
<img class='bg'>
</div>
<div class="col-md-12" id="instaGallery">
<div class="input-group">
<input type="text" class="form-control" id="selection" placeholder="Instasearch">
<span class="input-group-btn">
<button class="btn btn-default" id="instaButton" type="button">Go!</button>
</span>
</div>
</div>
<div id="pictureGallery"></div>
<script type="text/javascript" src="/js/jquery-1.11.2.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
<script src="/socket.io/socket.io.js"></script>
<script>
var textBox,
myTwitterNumber,
myInstaNumber,
tweetNum,
tweetArray,
pictureGallery,
requestObj,
statusList,
$newTweet,
// socket = io.connect('http://localhost:7500'),
socket = io.connect('https://theinstacache.herokuapp.com/', {secure: true}),
myNumber = 5;
socket.on("FreshTweets", function(data) {
statusList = "";
console.log(data);
tweetArray = data;
tweetNum = tweetArray.length;
for (var i = 0; i < tweetNum; i++) {
statusList += "<div class='tweetContainer'><h5>" + tweetArray[i].name + "<img src='" + tweetArray[i].profileimg + "'></h5><p>" + tweetArray[i].status + "</p></div>";
}
$("#tweetd").prepend(statusList);
})
socket.on("tweet", function(data) {
$newTweet = "<div class='tweetContainer'><h5><img src='" + data.profileimg + "'>" + data.name + "<h5><p>" + data.status + "</p></div>";
$($newTweet).prependTo($("#tweetd"));
tweetNum++
if (tweetNum > myNumber) {
$( ".tweetContainer" ).last().remove();
}
});
socket.on("twitPics", function(data) {
console.log(data);
pictureGallery = "";
for (var i = 0; i < data.length; i++) {
pictureGallery += "<div class='imgContainer'><img href='" + data[i].link + "' class='gallery' src='" + data[i].pic + "'></div>";
}
$("#instaGallery").append(pictureGallery);
});
socket.on("instaPics", function(data) {
console.log(data);
pictureGallery = "";
for (var i = 0; i < data.length; i++) {
pictureGallery += "<div class='imgContainer'><img href='" + data[i].link + "' class='gallery' src='" + data[i].pic + "'></div>";
}
$("#instaGallery").append(pictureGallery);
})
socket.on("cachedPics", function(data) {
console.log(data.twArray);
pictureGallery = "";
for (var i = 0; i < data.twArray.length; i++) {
pictureGallery += "<div class='imgContainer'><img href='" + data.twArray[i].link + "' class='gallery' src='" + data.twArray[i].pic + "'></div>";
}
for (var i = 0; i < data.igArray.length; i++) {
pictureGallery += "<div class='imgContainer'><img href='" + data.igArray[i].link + "' class='gallery' src='" + data.igArray[i].pic + "'></div>";
}
$("#instaGallery").append(pictureGallery);
})
socket.on("message", function(data) {
console.log(data);
})
$("#instaButton").on("click", function(){
requestObj = {
textBox: $("#selection").val()
}
console.log(requestObj.textBox);
socket.emit("picsPlease", requestObj);
console.log("request sent")
})
</script>
</body>
</html>