-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresults.html
175 lines (133 loc) · 4.23 KB
/
results.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Results</title>
<link rel="stylesheet" type="text/css" href="css/main.css" />
<!-- <link rel="shortcut icon" href="images/icon.png" /> -->
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
</head>
<body>
<div id="container">
<header>
<a href="summary.html"><p>Home</p></a>
</header>
<!--<h1>Dysglrepghia</h1>
<p> this is something</p>-->
<div id="content" style="text-align:center">
<br>
<br>
<p style="font-size:larger">You wrote:</p>
<p id="entered" style="font-size: 200%">Loading . . .</p>
<br>
<p style="font-size:larger">The text was <i>originally</i>:</p>
<p id="actual" style="font-size: 200%">Loading . . .</p>
<br>
<br>
<br>
<p style="font-size:larger">Here are some of the responses that got you to this point:</p>
<p id="previous" style="font-size: 200%">Loading . . .</p>
<p id="previous2" style="font-size: 200%">Loading . . .</p>
<br>
<br>
<br>
<br>
<br>
<br>
<p>Please press this button when you're finished! Or else it breaks, @tutors. Thank you!</p>
<input type="submit" id="submit" value="Continue">
</div>
</div>
<script src="https://www.gstatic.com/firebasejs/5.5.4/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/5.5.4/firebase-database.js"></script>
<script>
// Initialize Firebase
var config = {
apiKey: "AIzaSyB4V0cEMBuSwR05-UvcR437IJNRVMb4TaE",
authDomain: "tbaa-103f3.firebaseapp.com",
databaseURL: "https://tbaa-103f3.firebaseio.com",
projectId: "tbaa-103f3",
storageBucket: "tbaa-103f3.appspot.com",
messagingSenderId: "503354521935"
};
firebase.initializeApp(config);
</script>
<script>
$(document).ready(function(){
var topLvlString = 'empty';
var topRef = firebase.database().ref('butter/priority');
topRef.once('value').then(function(snapshot) {
console.log(snapshot.val().value);
if (snapshot.val().value == 0) {
topLvlString = 'butter';
}
});
var topRef = firebase.database().ref('bear/priority');
topRef.once('value').then(function(snapshot) {
console.log(topLvlString);
if (snapshot.val().value == 0) {
topLvlString = 'bear';
}
});
topRef = firebase.database().ref('myson/priority');
topRef.once('value').then(function(snapshot) {
console.log(topLvlString);
if (snapshot.val().value == 0) {
topLvlString = 'myson';
}
});
document.getElementById("submit").onclick = function() {
firebase.database().ref('butter/priority').set({
value: '1'
});
firebase.database().ref('myson/priority').set({
value: '1'
});
firebase.database().ref('bear/priority').set({
value: '1'
});
$(location).attr('href', "simulation.html");
return false;
};
// method to get the most recent ref ID. replace .ref('1') with .ref(refID) from this method
console.log(topLvlString);
setTimeout(run, 5000);
function run() {
var idList = firebase.database().ref(topLvlString);
var wordId;
var lastWordId;
var lastLastWordId;
var pageLoad = false;
var stringToModify;
var modifiedString = '';
var lastString = '';
var lastStringTwo = '';
var lastLastString = '';
idList.once('value').then(function(snapshot) {
for (var i = 0; i < snapshot.val().wordId.length; i ++) {
wordId = i; // gets the id of the most recent addition
lastWordId = i-1; // gets the new id
lastLastWordId = i-2;
}
var wordRef = firebase.database().ref(topLvlString + '/wordId');
wordRef.once('value').then(function(snapshot) {
modifiedString = snapshot.val()[wordId].word;
lastString = snapshot.val()[lastWordId].word;
lastStringTwo = snapshot.val()[lastLastWordId].word;
lastLastString = snapshot.val()[0].word;
// method to actually modify the string. store it and then change 'im pickle rick' to the modified string.
if (!pageLoad) {
document.getElementById("entered").innerHTML = modifiedString;
document.getElementById("actual").innerHTML = lastLastString;
document.getElementById("previous").innerHTML = lastString;
document.getElementById("previous2").innerHTML = lastStringTwo;
pageLoad = true;
}
});
});
}
});
</script>
</body>
</html>