Fixed loading message

This commit is contained in:
2023-06-19 13:51:30 +02:00
parent aa5abe41f6
commit 9391a984f9
3 changed files with 17 additions and 6 deletions

View File

@@ -13,6 +13,7 @@
<option value="0">Wird Geladen</option> <option value="0">Wird Geladen</option>
</select> </select>
<button id="export-button" onclick="exportReport()">Exportieren</button> <button id="export-button" onclick="exportReport()">Exportieren</button>
<p id="export-status"></p>
</div> </div>
<div id="calendar-div"> <div id="calendar-div">
<div class="ueberschrift"> <div class="ueberschrift">

View File

@@ -10,6 +10,8 @@ const exportButton = document.getElementById('export-button');
const calendarDiv = document.getElementById('calendar-div'); const calendarDiv = document.getElementById('calendar-div');
const untisDiv = document.getElementById('untis-div'); const untisDiv = document.getElementById('untis-div');
const exportStatus = document.getElementById('export-status');
fetch('/show') fetch('/show')
.then(response => { .then(response => {
if (response.ok) { if (response.ok) {
@@ -72,13 +74,14 @@ function copyToClipboard(button, textarea) {
function loading() { function loading() {
exportButton.disabled = true; exportButton.disabled = true;
calendarTextarea.value = 'Wird geladen'; exportStatus.innerHTML = 'Wird geladen';
calendarTextarea.value = '';
untisTextarea.value = ''; untisTextarea.value = '';
loadingInterval = setInterval(() => { loadingInterval = setInterval(() => {
if (calendarTextarea.value != 'Wird geladen...') { if (exportStatus.innerHTML != 'Wird geladen...') {
calendarTextarea.value += '.'; exportStatus.innerHTML += '.';
} else { } else {
calendarTextarea.value = 'Wird geladen'; exportStatus.innerHTML = 'Wird geladen';
} }
}, 500); }, 500);
} }
@@ -86,7 +89,7 @@ function loading() {
function loaded() { function loaded() {
exportButton.disabled = false; exportButton.disabled = false;
clearInterval(loadingInterval); clearInterval(loadingInterval);
calendarTextarea.value = ''; exportStatus.innerHTML = '';
} }
function exportReport() { function exportReport() {
@@ -99,7 +102,7 @@ function exportReport() {
if (response.ok) { if (response.ok) {
return response.text(); return response.text();
} else { } else {
calendarTextarea.value = 'Error während des Abrufs'; exportStatus.innerHTML = 'Error während des Abrufs';
throw new Error('Error während des Abrufs'); throw new Error('Error während des Abrufs');
} }
}).then(text => { }).then(text => {

View File

@@ -18,6 +18,8 @@ h4 {
.selector { .selector {
margin-bottom: 10px; margin-bottom: 10px;
display: flex;
align-items: center;
} }
select::-webkit-scrollbar { select::-webkit-scrollbar {
@@ -34,6 +36,11 @@ select::-webkit-scrollbar {
overflow-y: scroll; overflow-y: scroll;
} }
.selector p {
margin: 0;
margin-left: 10px;
}
button { button {
font-size: 16px; font-size: 16px;
height: 30px; height: 30px;