-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmaster.php
More file actions
209 lines (190 loc) · 8.81 KB
/
master.php
File metadata and controls
209 lines (190 loc) · 8.81 KB
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
<?php
include_once 'includes/db_connect.php';
include_once 'includes/functions.php';
sec_session_start();
checkSessionTimeExpiry($mysqli);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>REP Crossword Master Page</title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/jumbotron.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="css/js/bootstrap.min.js"></script>
<script src="css/js/ie10-viewport-bug-workaround.js"></script>
<script>
$(function () {
var availCrosswordResult = $('#availCrosswordResult');
var crosswordOptions = $('#crosswordOptions');
var dangerSelections = [];
var storedSelections = [];
crosswordOptions.find("td").hover(
function() {
$(this).addClass("active");
},
function() {
$(this).removeClass("active");
});
crosswordOptions.find("td").click(function () {
if(this.id === "addCrosswords") {
window.location.href="./crosswords/crosswordAddition.php";
} else if (this.id === "CRUD") {
if (storedSelections.length == 0) {
alert('Please select a crossword!');
} else {
var url = "./crosswords/crosswordView.php?crosswordId="+storedSelections[0];
window.location.href=url;
}
} else if (this.id === "sessionCreate") {
if (storedSelections.length == 0) {
alert('Please select a crossword!');
} else {
$('#groupOptions').slideToggle("fast");
}
} else if (this.id === "copyShare") {
console.log('ccce');
}
});
availCrosswordResult.find("tr").click(function () {
var selection = $(this);
var selectionId = selection.attr("id");
var rowSelection = $("[id=" + selectionId + "]");
if (storedSelections.length == 0) {
storedSelections.push(selection.attr("id"));
rowSelection.addClass("info");
rowSelection.prop("title", "Selected crossword.");
dangerRemoval(rowSelection, selectionId);
} else {
var index = storedSelections.indexOf(String(selectionId));
if (index > -1) {
storedSelections.splice(index, 1);
rowSelection.removeClass("info");
rowSelection.prop("title", "Crossword is fully assigned.");
dangerAdd(selectionId);
} else {
var removeSelection = storedSelections.pop();
$("[id=" + removeSelection + "]").removeClass("info");
dangerAdd(removeSelection);
dangerRemoval(rowSelection, selectionId);
storedSelections.push(selection.attr("id"));
rowSelection.addClass("info");
rowSelection.prop("title", "Selected crossword.");
}
}
});
function dangerRemoval(rowSelection, selectionId) {
if (rowSelection.hasClass("danger")) {
dangerSelections.push(selectionId);
rowSelection.removeClass("danger");
}
}
function dangerAdd(removeSelection) {
var dangerKey = dangerSelections[0];
if(dangerKey == removeSelection) {
$("[id=" + removeSelection + "]").addClass("danger");
dangerSelections.pop();
$("[id=" + removeSelection + "]").prop("title", "Crossword is not fully assigned.");
}
}
$('#sessionForm').submit(function() {
$('input#crosswordOption').val(storedSelections [0]);
return true;
});
});
</script>
</head>
<body>
<!-- Only for admins and super users -->
<?php if ((login_check($mysqli) == true) && role_check($mysqli) != 0) : ?>
<nav role="navigation" class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" data-target="#navbarCollapse" data-toggle="collapse" class="navbar-toggle">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="../master.php" style="color:white;">REP Crossword Master Page</a>
</div>
<!-- Collection of nav links, forms, and other content for toggling -->
<div id="navbarCollapse" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li><a href="./sessions/sessionView.php" style="color:white;">Sessions</a></li>
<li><a href="./reviews/reviews.php" style="color:white;">Performance</a></li>
<li><a href="./users/users.php" style="color:white;">Users</a></li>
</ul>
<div id="navbar" class="navbar-collapse collapse">
<div class="navbar-right navbar-form" style="color:white;">
<?php loginNavBarAction($mysqli);?>
<a class="btn btn-success" href="includes/logout.php" role="button">Log out</a>
</div>
</div>
</div>
</div>
</nav>
<div class="jumbotron">
<div class="container">
<div class="row">
<div class="col-xs-12 col-md-8 col-md-offset-2">
<table class="table table-bordered table-responsive" id="crosswordOptions">
<caption style="font-size:30px;" class="text-center">My Crosswords</caption>
<tr style="cursor: pointer;">
<td id="addCrosswords">Add Crosswords</td>
<td id="CRUD">View/Edit/Delete</td>
<td id="sessionCreate">Create Sessions</td>
<td id="copyShare">Share/Copy</td>
</tr>
</table>
<div id="groupOptions" style="display:none">
<form id="sessionForm" action="./sessions/includes/sessionCreate.php" method="POST">
<select name="groupOptions" form="sessionForm" id="sessionOptions">
<?php groupCheckD($mysqli); ?>
</select>
<input type="hidden" name="crosswordOption" id="crosswordOption">
<input type="submit" class="btn btn-primary btn-sm" value="Create Session">
</form>
</div>
<table id="crosswordList" class="table table-striped table-hover">
<thead>
<tr>
<th>Crossword ID</th>
<th>Crossword Name</th>
<th>Crossword Description</th>
<th>Time Created</th>
</tr>
</thead>
<tbody style="cursor: pointer;" id="availCrosswordResult">
<?php listOfCrosswordAvail($mysqli); ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-xs-12 col-md-8 col-md-offset-2">
<hr><p>© 2016 Product of REP</p>
</div>
</div>
</div>
<!--**********************************************************************-->
<!-- For the case of wrong login -->
<?php
elseif ((login_check($mysqli) == true) && (role_check($mysqli) == 1 || role_check($mysqli) == 0)) :
echo '<script>';
echo 'window.location.href="./user.php";';
echo '</script>';
else :
echo '<script>';
echo 'window.location.href="./index.php";';
echo '</script>';
endif;
?>
</body>
</html>