-
Notifications
You must be signed in to change notification settings - Fork 0
/
indexkathryn.html
128 lines (96 loc) · 3.79 KB
/
indexkathryn.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<!DOCTYPE html>
<html>
<head>
<title>Twitter Emotion Map</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src='https://cdn.firebase.com/js/client/1.0.15/firebase.js'></script>
<link rel="stylesheet" href="https://code.jquery.com/mobile/1.4.3/jquery.mobile-1.4.3.min.css" />
<script src="https://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="https://www.gstatic.com/firebasejs/3.4.0/firebase.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script>
// Initialize Firebase
var config = {
apiKey: "AIzaSyCxZkuXU1RqMPbUjhOk9b6VIHGhQ3U1BBU",
authDomain: " twitter-emotions.firebaseapp.com",
databaseURL: "https://twitter-emotions.firebaseio.com",
storageBucket: ""
};
firebase.initializeApp(config);
firebase.auth().signOut().then(function() {
// Sign-out successful.
}, function(error) {
// An error happened.
});
// Get a reference to the database service
var database = firebase.database();
// This creates the connection to the database
var toDoDB = new Firebase('https://twitter-emotions.firebaseio.com/');
//reads all values in database, automatically updates when database changes
toDoDB.on('value', showItems);
function showItems(snapshot){
//gets data in database as a list
var data = snapshot.val();
//loops over each identifier in database
for (var identifier in data) {
console.log("ID: " + identifier);
console.log("Timestamp: " + data[identifier].created_at + ", id_str:" + data[identifier].id_str + ", text:" + data[identifier].text);
}
}
function addItem(){
var tweetID = $("#tweetID").val();
var coord = $("#coord").val();
var created_at = $('#created_at').val();
var tweetText = $('#tweetText').val();
var wholetweet = {"coordinates": coord, "created_at": created_at, "id_str": tweetID, "text": tweetText};
toDoDB.push(wholetweet);
alert('done');
}
function addJSON() {
tweets = [
{
"coordinates": null,
"created_at": "Mon Sep 24 03:35:21 +0000 2012",
"id_str": "250075927172759552",
"text": "Aggressive Ponytail #freebandnames",
"geo": null,
},
{
"coordinates": null,
"created_at": "Fri Sep 21 23:40:54 +0000 2012",
"id_str": "249292149810667520",
"text": "Thee Namaste Nerdz. #FreeBandNames",
"geo": null,
},
{
"coordinates": null,
"created_at": "Fri Sep 21 23:30:20 +0000 2012",
"id_str": "249289491129438208",
"text": "Mexican Heaven, Mexican Hell #freebandnames",
"geo": null,
},
{
"coordinates": null,
"created_at": "Fri Sep 21 22:51:18 +0000 2012",
"id_str": "249279667666817024",
"text": "The Foolish Mortals #freebandnames",
"geo": null,
}];
toDoDB.push(tweets);
}
</script>
</head>
<body>
<div data-role="page">
<div data-role="header">
<h1>Twitter Emotions Map</h1>
</div><!-- end of header -->
<input type="text" data-clear-btn="true" id="tweetID" placeholder="ID"/>
<input type="text" data-clear-btn="true" id="coord" placeholder="coord"/>
<input type="text" data-clear-btn="true" id="created_at" placeholder="created_at"/>
<input type="text" data-clear-btn="true" id="tweetText" placeholder="tweetText"/>
<button onclick="addItem()">add to firebase</button>
<button onclick="addJSON()">add hardcoded json to firebase</button>
</div><!-- end of page -->
</body>
</html>