Spaces:
Sleeping
Sleeping
several improvements
Browse files- index.html +24 -6
index.html
CHANGED
@@ -32,7 +32,21 @@
|
|
32 |
|
33 |
<script>
|
34 |
// Load groups when the page loads
|
35 |
-
window.onload =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
function loadGroups() {
|
38 |
fetch('/groups')
|
@@ -112,9 +126,10 @@
|
|
112 |
.then(response => response.json())
|
113 |
.then(result => {
|
114 |
if (result === 0) {
|
115 |
-
setMessage(
|
116 |
} else {
|
117 |
-
setMessage(
|
|
|
118 |
}
|
119 |
});
|
120 |
}
|
@@ -131,11 +146,14 @@
|
|
131 |
fetch(`/borrow/${bookId}/${studentId}`)
|
132 |
.then(response => response.json())
|
133 |
.then(result => {
|
134 |
-
if (result.
|
135 |
-
setMessage(
|
|
|
136 |
} else {
|
137 |
-
setMessage('Fehler beim Ausleihen des Buches: ' +
|
138 |
}
|
|
|
|
|
139 |
});
|
140 |
}
|
141 |
|
|
|
32 |
|
33 |
<script>
|
34 |
// Load groups when the page loads
|
35 |
+
window.onload = function() {
|
36 |
+
loadGroups();
|
37 |
+
|
38 |
+
document.getElementById('returnBookId').addEventListener('keyup', function(event) {
|
39 |
+
if (event.key === 'Enter') {
|
40 |
+
returnBook();
|
41 |
+
}
|
42 |
+
});
|
43 |
+
|
44 |
+
document.getElementById('borrowBookId').addEventListener('keyup', function(event) {
|
45 |
+
if (event.key === 'Enter') {
|
46 |
+
borrowBook();
|
47 |
+
}
|
48 |
+
});
|
49 |
+
};
|
50 |
|
51 |
function loadGroups() {
|
52 |
fetch('/groups')
|
|
|
126 |
.then(response => response.json())
|
127 |
.then(result => {
|
128 |
if (result === 0) {
|
129 |
+
setMessage(`Buch (Nummer: ${bookId}) nicht gefunden oder bereits zurückgegeben`);
|
130 |
} else {
|
131 |
+
setMessage(`Buch (Nummer: ${bookId}) erfolgreich zurückgegeben`);
|
132 |
+
document.getElementById('returnBookId').value = ''; // Clear input field
|
133 |
}
|
134 |
});
|
135 |
}
|
|
|
146 |
fetch(`/borrow/${bookId}/${studentId}`)
|
147 |
.then(response => response.json())
|
148 |
.then(result => {
|
149 |
+
if (result.success) {
|
150 |
+
setMessage(`Buch (Nummer: ${bookId}) erfolgreich ausgeliehen`);
|
151 |
+
document.getElementById('borrowBookId').value = ''; // Clear input field
|
152 |
} else {
|
153 |
+
setMessage('Fehler beim Ausleihen des Buches: ' + result.message);
|
154 |
}
|
155 |
+
// Refresh the outstanding books list
|
156 |
+
loadOutstandingBooks();
|
157 |
});
|
158 |
}
|
159 |
|