@JoshDaBosh/

jeopoopy

HTML, CSS, JS

No description

fork
loading
Files
  • index.html
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
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
<html>

<head>
	<title>Jeopardy | Joshua Wang</title>
	<meta charset="utf-8" />
	
	<style>
		body, html{
			padding: 0;
			margin: 0;
			
			color: blue;
		}
		
		#group > * {
			margin: 0 10px;
		}
		
		#m_table {
			text-align: center;
		}

    #correct {
      text-align: center;
    }

	</style>
	
	<script>
	
		var popup;
		
		var questions_python = ['What does the following output?\n\nprint("Hello" * 5)', 'Keyword used to import modules.', 'Function used to write a class constructor.', 'Keyword in order to declare an anonymous function.', 'Keyword to apply a function to an array of elements in a single line.'];
		var questions_java = ['Outputs to stdout.', 'Converts a string to an integer.', 'Method to compare two variables of type String.', 'Method to compare two variables of primitive type int.', '<h1>Double Jeopardy!</h1>The first line of the constructor for the class "Coordinate" that takes in primitive ints x and y.'];
		var questions_cpp = ['Outputs to stdout.', 'Takes input from stdin.', 'Used to load code from another file.', 'General command used to compile C++ code on a Linux machine.', '<h1>Double Jeopardy!</h1>Character used to reference the memory location of a variable.'];
		var questions_math = ['4 people stand in a line, but two people want to stay together. How many ways can you order these 4 people?','What is log(0!)?', 'What is the maximum number of intersection points of a square and a circle?','<h1>Double Jeopardy!</h1>What are the last two digits of the number 2^100?','Who is the IMO coach?'];
		
		var answers_python = ["What is HelloHelloHelloHelloHello.", "What is import.", "What is __init__.", "What is lambda.", "What is map()."]
		var answers_java = ["What is System.out.println();", "What is Integer.parseInt();", "What is .equals();", "What is ==", "What is public Coordinate(int x, int y)"];
		var answers_cpp = ["What is cout << ", "What is cin >> ", "What is #include<>", "What is gcc.", "What is &."];
		var answers_math = ['What is 12.','What is 0.','What is 8.','What is 76.', 'Who is Po-Shen Loh.'];
	



    var d_jeopardy_count = 3;
    
    var used = [];


	
		function init(){
			var headers = ["python", "java", "cpp", "math"];
			var table = document.getElementById("m_table");
			
			for(var i = 0; i < table.children.length; i++){
				var row = table.children[i];
				
				if(row.id != "headers"){
					for(var a = 0; a < row.children.length; a++){
            if(i==5 && a==1 || i==5 && a==2 || i==4 && a==3){
              var id = (headers[a]+"_"+(i * 100))
						  row.children[a].innerHTML = '<input type="button" onclick=showQuestion("' + id + '") data-double="1" id="' + id + '" value="' + 100 * (i) + '">';
            }
            else{
              var id = (headers[a]+"_"+(i * 100))
						  row.children[a].innerHTML = '<input type="button" onclick=showQuestion("' + id + '") data-double="0" id="' + id + '" value="' + 100 * (i) + '">';
            }
					}
				}
			}
			
    }

    var answer;
    var number;
    var answerid;
    
    function showQuestion(id){
      var question
      splittedid = id.split('_')
      splittedid[1] = parseInt(splittedid[1])/100
      category = splittedid[0]
      number = splittedid[1] - 1

      if (used.includes(id)){
        return;
      }

      if (category == 'python'){
        question = questions_python[number] 
      }
      if (category == 'java'){
        question = questions_java[number] 
      }
      if (category == 'cpp'){
        question = questions_cpp[number] 
      }
      if (category == 'math'){
        question = questions_math[number] 
      }

      popup = window.open('', 'question', 'channelmode = 1, height = 400, width = 400 top = 300 left = 400')
      
      popup.document.write(question)
      popup.document.close()
      closer = setTimeout("popup.close()", 10000)

      used.push(id);

      answerid = splittedid;

      document.getElementById(id).value = "USED";
      
    }


    function showAnswer(){
      if (category == 'python'){
        answer = answers_python[number] 
      }
      if (category == 'java'){
        answer = answers_java[number] 
      }
      if (category == 'cpp'){
        answer = answers_cpp[number] 
      }
      if (category == 'math'){
        answer = answers_math[number] 
      }
      popup = window.open('', 'answer', 'channelmode = 1, height = 400, width = 400 top = 300 left = 400')
      
      popup.document.write(answer)
      closer = setTimeout("popup.close()", 10000)
      

    }


    function getGroup(){
      groups = document.getElementById("group").children;

      for (var i = 0; i < groups.length; i++){
        if (groups[i].checked){
          return groups[i].value
        }
      }
    }

    
    function checkDouble(id, score){
      id = id.join("_") + "00";
      var thing = document.getElementById(id);

      var check = thing.getAttribute("data-double");

      if (check == "1"){
        return score * 2
      }
      return score
    }


    function addScore(){
      score = checkDouble(answerid, (number+1)*100);

      var active = getGroup();

      document.getElementById("group_"+active).value = (parseInt(document.getElementById("group_"+active).value)) + score;
      
    }


    function removeScore(){
      score = checkDouble(answerid, (number+1)*100);

      var active = getGroup();

      document.getElementById("group_"+active).value = (parseInt(document.getElementById("group_"+active).value)) - score;
      
    }
	</script>

</head>

<body onload="init();">

	<center>
		<img src="http://cenblog.org/iyc-2011/files/2011/06/JE2010_HeroHR_RGB-21-300x168.jpg" height="300" width="500">
    <h2 style="color: yellow; position: absolute; left: 50%; top: 0;">CS / MATH</h2>
		<br />
		<br />
		<form class="group" id="group">
		Group:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			G1<input type="radio" name="group" value="1" checked>
			G2<input type="radio" name="group" value="2">
			G3<input type="radio" name="group" value="3">
			G4<input type="radio" name="group" value="4">
			G5<input type="radio" name="group" value="5">
			G6<input type="radio" name="group" value="6">
		</form>
		
		<table width="400px;" border=1>
			<tbody id="m_table">
				<tr id="headers">
					<td>Python</td><td>Java</td><td>C++</td><td>Math</td>
				</tr>
				<tr><td></td><td></td><td></td><td></td></tr>
				<tr><td></td><td></td><td></td><td></td></tr>
				<tr><td></td><td></td><td></td><td></td></tr>
				<tr><td></td><td></td><td></td><td></td></tr>
				<tr><td></td><td></td><td></td><td></td></tr>
			</tbody>
		</table>

    <br />
    <br />

    <table width="400px" id="correct">
      <tr>
        <td><input type="button" value="Correct" onclick = "addScore()"></td>
        <td><p>Scores:</p></td>
        <td><input type="button" value="Wrong" onclick="removeScore()"></td>
      </tr>
    </table>

    <br />
    <br />

    <form class="group" id="group">
			G1:<input type="text" id="group_1" value="0" name="group" size="5" readonly checked>
			G2:<input type="text" id="group_2" value="0" name="group" size="5" readonly>
			G3:<input type="text" id="group_3" value="0" name="group" size="5" readonly>
			G4:<input type="text" id="group_4" value="0" name="group" size="5" readonly>
			G5:<input type="text" id="group_5" value="0" name="group" size="5" readonly>
			G6:<input type="text" id="group_6" value="0" name="group" size="5" readonly>
		</form>

    <form class="answer">
      <input type="button" value="Answer" onclick="showAnswer()">
    </form>
		
	</center>

</body>

</html>
result
console