This repository has been archived by the owner on Aug 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_page.html
104 lines (76 loc) · 4.43 KB
/
test_page.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
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>TEST</title>
<!-- You will need those 2 when you try to use our DB stuff -->
<script src='https://cdn.firebase.com/js/client/2.2.1/firebase.js'></script>
<script src="data.js"></script>
<script>
// some random junk for test
function init(){
var db_name = document.getElementById('db_name').value;
data.init(db_name);
}
function create_data(){
// create some fake data for now
var students = [
{name : 'Simon Lemoine',university_name : 'de Montfort university',category_name : 'High Fantasy'},
{name : 'Preacher K',university_name : 'Leicester Uni',category_name : 'High Fantasy'},
{name : 'Katie North',university_name : 'VAGUE',category_name : 'High Fantasy'},
{name : 'Ben Glover',university_name : 'Leicester Uni',category_name : 'Sci Fi'},
{name : 'Tom Lee',university_name : 'VAGUE',category_name : 'Sci Fi'},
{name : 'Jack Cortese',university_name : 'De Montfort University',category_name : 'Sci Fi'}
];
var unis = [{name : 'De Montfort University'},{name : 'Leicester Uni'},{name : 'VAGUE'}];
var categories = [{name : 'High Fantasy'},{name : 'Sci Fi'}];
var winners = [
{category_fk:1, first_student_fk : 2, second_student_fk : 1, third_student_fk : 3},
{category_fk:2, first_student_fk : 5, second_student_fk : 6, third_student_fk : 4}
];
data.save('university', unis);
data.save('category', categories);
data.save('student', students);
data.save('winner', winners);
}
function get_data(type){
var list = data.get_list(type);
document.getElementById('display').innerHTML = JSON.stringify(list, null, 2).replace(/\n/g, '<br>').replace(/ /g, ' ');
}
function add_points_to_uni(){
var uni_fk = Number(document.getElementById('uni_fk').value);
var points = 1;
data.save("score",[{university_fk : uni_fk, point : points}]);
}
function init_uni_total(){
data.init_university_total(change_display_uni);
}
function change_display_uni(uni_details){
document.getElementById('display2').innerHTML = 'uni_fk : '+uni_details.university_fk+'<br>uni_name : '+uni_details.university_name+'<br>total : ' +uni_details.total;
}
</script>
</head>
<body onload="init();">
<table style="width:100%;height:100%;border-collapse:collapse;">
<tr>
<td>
<input type="text" id="db_name" value="nationals_test_simon">
<button onclick="init()">init</button>
<button onclick="create_data()">create_data</button>
<button onclick="get_data('student')">get_students</button>
<button onclick="get_data('university')">get_universities</button>
<button onclick="get_data('category')">get_categories</button>
<button onclick="get_data('winner')">get_winners</button>
<button onclick="get_data('score')">get_score</button>
<div style="border:1px solid black;height:600px;width:1000px;overflow:auto;" id="display"></div>
</td>
<td>
<input type="text" id="uni_fk" value="1">
<button onclick="add_points_to_uni()">add_points_to_uni</button>
<button onclick="init_uni_total()">init_uni_total</button>
<div style="border:1px solid black;height:600px;width:1000px;overflow:auto;" id="display2"></div>
</td>
</tr>
</table>
</body>
</html>