-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate_sort (1).html
249 lines (235 loc) · 10.6 KB
/
update_sort (1).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
248
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Password Protection Page</title>
<link rel="stylesheet" href="style2.css">
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
}
.logo-container {
text-align: left;
display: inline-block;
width: 100%;
}
.logo {
display: inline-block;
}
#passwordForm, #newPasswordForm {
margin-top: 50px;
}
input[type="password"], input[type="submit"], button {
padding: 10px;
margin: 10px;
font-size: 16px;
width: 100px;
height: 40px;
display: inline-block;
vertical-align: middle;
text-align: center;
}
#changePasswordBtn {
width: 150px;
height: 40px;
font-size: 14px;
}
#password {
width: 200px;
height: 20px;
font-size: 16px;
}
#newPassword {
width: 200px;
height: 20px;
font-size: 16px;
}
#changePasswordBtnNewPassword {
width: 600px;
height: 40px;
font-size: 14px;
}
#protectedContent {
display: none;
}
</style>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
<header>
<div class="container">
<div class="logo-container">
<a href="#" class="logo">Younger Lab Database</a>
</div>
<nav>
<ul class="nav-menu">
<li><a href="#" id="home-link">Home</a></li>
<li class="dropdown">
<a href="#" class="dropbtn">Forms</a>
<ul class="dropdown-menu">
<li><a href="#" id="passage-form-link">Passage Form</a></li>
<li><a href="#" id="sorting-form-link">Sorting Form</a></li>
<li><a href="#" id="clutch-form-link">Clutch Form</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropbtn">Tables</a>
<ul class="dropdown-menu">
<li><a href="#" id="master-view-link">Master View</a></li>
<li><a href="#" id="sorting-table-link">Sorting Table</a></li>
<li><a href="#" id="passage-table-link">Passage Table</a></li>
</ul>
</li>
<li><a href="#" id="modify-tables-link">Modify Tables</a></li>
<li class="dropdown">
<a href="#" class="dropbtn">Diagnostics</a>
<ul class="dropdown-menu">
<li><a href="#" id="clutch-wellness-link">Clutch Wellness</a></li>
<li><a href="#" id="statistics-link">Statistics</a></li>
</ul>
</li>
<li><a href="#" id="help-link">Help</a></li>
</ul>
</nav>
</div>
</header>
<div id="passwordForm">
<form id="loginForm">
<label for="password">Enter Password:</label><br>
<input type="password" id="password" name="password" required><br>
<input type="submit" value="Submit" id="submitBtn">
<button id="changePasswordBtn" type="button">Change Password</button>
</form>
</div>
<div id="newPasswordForm" style="display: none;">
<form id="changePasswordForm">
<label for="newPassword">New Password:</label><br>
<input type="password" id="newPassword" name="newPassword" required><br>
<input type="submit" value="Change Password" id="changePasswordSubmit">
</form>
</div>
<div id="protectedContent">
<h2>Modify Existing Entries</h2>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Update Sort Data</title>
</head>
<body>
<h2>Update Sort Data</h2>
<form id="updateForm">
<label for="sort_id">Sort ID:</label>
<input type="text" id="sort_id" name="sort_id"><br><br>
<label for="hatch_date">Hatch Date:</label>
<input type="text" id="hatch_date" name="hatch_date"><br><br>
<label for="sort_date">Sort Date:</label>
<input type="text" id="sort_date" name="sort_date"><br><br>
<label for="line_name">Line Name:</label>
<input type="text" id="line_name" name="line_name"><br><br>
<label for="marker_color">Marker Color:</label>
<input type="text" id="marker_color" name="marker_color"><br><br>
<label for="marker_location">Marker Location:</label>
<input type="text" id="marker_location" name="marker_location"><br><br>
<label for="fl_ratio">FL Ratio:</label>
<input type="text" id="fl_ratio" name="fl_ratio"><br><br>
<label for="fl_total">FL Total:</label>
<input type="text" id="fl_total" name="fl_total"><br><br>
<label for="notes">Notes:</label>
<input type="text" id="notes" name="notes"><br><br>
<button type="button" onclick="submitForm()">Submit</button>
</form>
<div id="successMessage" style="display: none; color: green; margin-top: 10px;">Update successful!</div>
<script>
document.getElementById("sort_id").addEventListener("input", function() {
var sort_id = document.getElementById("sort_id").value;
fetch('/cgi-bin/students_24/Team_4/get_sort.py?sort_id=' + encodeURIComponent(sort_id))
.then(response => response.json())
.then(data => {
if (data.error) {
alert("Failed to fetch data: " + data.error);
} else {
document.getElementById("hatch_date").value = data.hatch_date || "";
document.getElementById("sort_date").value = data.sort_date || "";
document.getElementById("line_name").value = data.line_name || "";
document.getElementById("marker_color").value = data.marker_color || "";
document.getElementById("marker_location").value = data.marker_location || "";
document.getElementById("fl_ratio").value = data.fl_ratio || "";
document.getElementById("fl_total").value = data.fl_total || "";
document.getElementById("notes").value = data.notes || "";
}
})
.catch(error => {
console.error("Fetch error:", error);
alert("Failed to fetch data: " + error);
});
});
function submitForm() {
var sort_id = document.getElementById("sort_id").value;
var hatch_date = document.getElementById("hatch_date").value;
var sort_date = document.getElementById("sort_date").value;
var line_name = document.getElementById("line_name").value;
var marker_color = document.getElementById("marker_color").value;
var marker_location = document.getElementById("marker_location").value;
var fl_ratio = document.getElementById("fl_ratio").value;
var fl_total = document.getElementById("fl_total").value;
var notes = document.getElementById("notes").value;
// Send a request to the CGI script to update the database
fetch('/cgi-bin/students_24/Team_4/update_sort.py?sort_id=' + encodeURIComponent(sort_id) + '&hatch_date=' + encodeURIComponent(hatch_date) + '&sort_date=' + encodeURIComponent(sort_date) + '&line_name=' + encodeURIComponent(line_name) + '&marker_color=' + encodeURIComponent(marker_color) + '&marker_location=' + encodeURIComponent(marker_location) + '&fl_ratio=' + encodeURIComponent(fl_ratio) + '&fl_total=' + encodeURIComponent(fl_total) + '¬es=' + encodeURIComponent(notes))
.then(response => response.json())
.then(data => {
if (data.success) {
// Display success message
document.getElementById("successMessage").style.display = "block";
// Clear form fields after successful submission
document.getElementById("sort_id").value = "";
document.getElementById("hatch_date").value = "";
document.getElementById("sort_date").value = "";
document.getElementById("line_name").value = "";
document.getElementById("marker_color").value = "";
document.getElementById("marker_location").value = "";
document.getElementById("fl_ratio").value = "";
document.getElementById("fl_total").value = "";
document.getElementById("notes").value = "";
} else {
// Display error message if update fails
alert("Failed to update database: " + data.error);
}
})
.catch(error => {
console.error("Fetch error:", error);
// Display error message if fetch request fails
alert("Failed to update database: " + error);
});
}
</script>
</body>
</html>
</div>
<script>
$(document).ready(function() {
// Event listener for the login form submission
$('#loginForm').submit(function(e) {
e.preventDefault(); // Prevent the default form submission
authenticate(); // Call the authenticate function
});
});
function authenticate() {
var password = $('#password').val();
// Check if the password is correct
if (password === 'your_password') { // Replace 'your_password' with actual password
// Show the protected content
$('#protectedContent').show();
// Hide the password form
$('#passwordForm').hide();
} else {
// Incorrect password, show an error message
alert('Incorrect password! Please try again.');
}
}
</script>
</body>
</html>