-
Notifications
You must be signed in to change notification settings - Fork 0
/
embed.php
163 lines (147 loc) · 4.13 KB
/
embed.php
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
<?php
require 'include/env.php';
////////////////////////////////
// START OF FLASHCARD QUERIES //
////////////////////////////////
// query for all flashcards
$sql = 'select flashcards.*
from flashcard_groups
join flashcards on flashcards.id = flashcard_groups.flashcard_id
where flashcard_groups.group_id = 1';
$result = $db->query($sql);
$group_name = "Sample Group";
// Get group from $_GET
$group = $_GET['group'];
if(!empty($group))
{
$sql = "select name
from groups
where id = $group";
$name_result = $db->query($sql);
$group_name = $name_result->fetch_assoc()['name'];
if(empty($group_name))
{
$group_name = "Sample Group";
}
else
{
$sql = "select flashcards.*
from flashcard_groups
join flashcards on flashcards.id = flashcard_groups.flashcard_id
where flashcard_groups.group_id = $group";
$result = $db->query($sql);
}
}
//////////////////////////////
// END OF FLASHCARD QUERIES //
//////////////////////////////
// HTML Page Header
$header = <<<EOF
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8'>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Flashcards</title>
<link rel='stylesheet' href='style.css' />
<link rel='stylesheet' href='toggle.css' />
</head>
<body>
EOF;
echo $header;
// Admin Menu
if($admin) include 'include/menu.php';
// Application Container Open
$app_container = <<<EOF
<div class="app-container">
<div class="title-bar">
<h2>$group_name</h2>
</div>
<div class="app-body">
EOF;
echo $app_container;
// Flashcards
if($result->num_rows > 0)
{
$notFirst = false;
$hidden = '';
while($row = $result->fetch_assoc())
{
// Hide the following cards that are generated (only showing the first)
if($notFirst)
{
$hidden = ' hidden';
}
$card = "
<div class='card-container $hidden'>
<div class='card-front'>
<p class='hint-box hidden'>" . substr($row['definition'], 0, 20) . "...</p>
<p class='term'>" . $row['term'] . "</p>
</div>
<div class='card-back hidden'>
<p class='term-box'>" . $row['term'] . "</p>
<p class='definition'>" . $row['definition'] . "</p>
<p class='question hidden'>" . $row['question'] . "</p>
</div>
</div>
";
echo $card;
$notFirst = true;
}
}
// Next/Previous Button Bar
echo "
<div class='bar'>
<button class='button previous-button' id='previous'>Previous</button>
<button class='button next-button' id='next'>Next</button>
</div>
";
// Status Bar
$status_bar = <<<EOF
<div class='status-bar'>
<div class='progress-group'>
<progress value="1" max="1" id="progress-bar"></progress>
<p>
Progress:
<span id='position'>
1
</span>
/
<span id='total'>
1
</span>
</p>
</div>
<div class='toggle-group'>
<p class='help'>Toggle between Term and Definition</p>
<label class="switch">
<input type="checkbox" id="toggleTerm">
<span class="slider round"></span>
</label>
<!-- Show notes feature to come later
<br/>
<p class='help'>Show Notes</p>
<label class="switch">
<input type="checkbox" id="toggleNotes">
<span class="slider round"></span>
</label>
<br/>
-->
</div>
</div>
EOF;
echo $status_bar;
// Application Container Close
$app_container = <<<EOF
</div><!-- end app-body -->
</div><!-- end app-container -->
EOF;
echo $app_container;
// HTML Footers
$footer = <<<EOF
<script type='text/javascript' src='script.js'></script>
</body>
</html>
EOF;
echo $footer;
require 'include/end.php';