mirror of
https://github.com/Matewoo/tablet-web-survey.git
synced 2026-11-18 13:52:47 +01:00
increased timeout from 1 sec to 2.5 sec
This commit is contained in:
+2
-50
@@ -1,51 +1,3 @@
|
|||||||
/* document.querySelectorAll('.emoji').forEach(button => {
|
|
||||||
button.addEventListener('click', () => {
|
|
||||||
const category = button.getAttribute('data-category');
|
|
||||||
if (category === 'Fleischgericht' || category === 'Vegetarisch' || category === 'Tagesgericht' || category === 'Tagessalat') {
|
|
||||||
document.querySelectorAll('.emoji[data-category="Fleischgericht"], .emoji[data-category="Vegetarisch"], .emoji[data-category="Tagesgericht"], .emoji[data-category="Tagessalat"]').forEach(btn => btn.classList.remove('selected'));
|
|
||||||
} else {
|
|
||||||
document.querySelectorAll(`.emoji[data-category="${category}"]`).forEach(btn => btn.classList.remove('selected'));
|
|
||||||
}
|
|
||||||
button.classList.add('selected');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
document.getElementById('submit').addEventListener('click', () => {
|
|
||||||
const results = {};
|
|
||||||
document.querySelectorAll('.emoji.selected').forEach(button => {
|
|
||||||
const category = button.getAttribute('data-category');
|
|
||||||
results[category] = button.id;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (Object.keys(results).length > 0) {
|
|
||||||
fetch('/submit', {
|
|
||||||
method: 'POST',
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json'
|
|
||||||
},
|
|
||||||
body: JSON.stringify(results)
|
|
||||||
})
|
|
||||||
.then(response => response.json())
|
|
||||||
.then(data => {
|
|
||||||
console.log('Success:', data);
|
|
||||||
document.getElementById('thank-you-message').style.display = 'block';
|
|
||||||
setTimeout(() => {
|
|
||||||
document.getElementById('thank-you-message').style.display = 'none';
|
|
||||||
document.querySelectorAll('.emoji').forEach(button => button.classList.remove('selected'));
|
|
||||||
}, 1000);
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
console.error('Error:', error);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const submitButton = document.getElementById('submit');
|
|
||||||
submitButton.disabled = true;
|
|
||||||
setTimeout(() => {
|
|
||||||
submitButton.disabled = false;
|
|
||||||
}, 1000);
|
|
||||||
}); */
|
|
||||||
|
|
||||||
document.querySelectorAll('.emoji').forEach(button => {
|
document.querySelectorAll('.emoji').forEach(button => {
|
||||||
button.addEventListener('click', () => {
|
button.addEventListener('click', () => {
|
||||||
const category = button.getAttribute('data-category');
|
const category = button.getAttribute('data-category');
|
||||||
@@ -68,10 +20,10 @@ document.querySelectorAll('.emoji').forEach(button => {
|
|||||||
document.getElementById('thank-you-message').style.display = 'none';
|
document.getElementById('thank-you-message').style.display = 'none';
|
||||||
document.getElementById('content').style.visibility = 'visible';
|
document.getElementById('content').style.visibility = 'visible';
|
||||||
document.querySelectorAll('.emoji').forEach(button => button.classList.remove('selected'));
|
document.querySelectorAll('.emoji').forEach(button => button.classList.remove('selected'));
|
||||||
}, 1000);
|
}, 2500);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error('Error:', error);
|
console.error('Error:', error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user