Implement overhaul of design, add tooltips to certain attributes, update styling and ARIA support.
This commit is contained in:
+47
-32
@@ -1,12 +1,5 @@
|
||||
const cooldownDuration = 10 * 360000;
|
||||
const prohibitedWords = ['fuck', 'shit', 'asshole', 'bitch', 'bastard', 'damn', 'crap', 'dick', 'piss', 'cunt', 'motherfucker', 'douche',
|
||||
'prick', 'whore', 'slut', 'fag', 'nigger', 'spic', 'retard', 'twat', 'bollocks', 'wanker', 'bugger', 'arse',
|
||||
'shithead', 'dumbass', 'jackass', 'dipshit', 'dildo', 'knobhead', 'ballsack', 'buttfucker', 'cum', 'jizz',
|
||||
'cocksucker', 'fucker', 'skank', 'pussy', 'tits', 'clit', 'schlong', 'dickhead', 'goddamn', 'hell', 'bitchass',
|
||||
'fuckface', 'shitfaced', 'asshat', 'bint', 'chink', 'gook', 'jap', 'negro', 'dyke', 'queer', 'tranny', 'tosser',
|
||||
'spaz', 'mong', 'coon', 'beaner', 'cracker', 'wetback', 'homo', 'fudgepacker', 'tard', 'cocks', 'bollocks',
|
||||
'numbnuts', 'knob', 'muppet', 'git', 'shag', 'minge', 'git', 'bugger', 'tosser', 'nonce', 'plonker', 'pillock']
|
||||
;
|
||||
const cooldownDuration = 60 * 60 * 1000;
|
||||
const prohibitedWords = []
|
||||
|
||||
function getLastSubmissionTime() {
|
||||
const storedTime = localStorage.getItem('lastSubmissionTime');
|
||||
@@ -17,16 +10,21 @@ function setLastSubmissionTime(time) {
|
||||
localStorage.setItem('lastSubmissionTime', time.toString());
|
||||
}
|
||||
|
||||
function sendMessage() {
|
||||
async function sendMessage() {
|
||||
const currentTime = Date.now();
|
||||
const lastSubmissionTime = getLastSubmissionTime();
|
||||
if (currentTime - lastSubmissionTime < cooldownDuration) {
|
||||
alert(`Please wait for ${cooldownDuration / 1000} seconds between submissions.`);
|
||||
alert(`Please wait ${Math.ceil((cooldownDuration - (currentTime - lastSubmissionTime)) / 1000)} seconds between submissions.`);
|
||||
return;
|
||||
}
|
||||
const pseudoname = document.getElementById("name").value || "Anonymous";
|
||||
const rating = parseInt(document.getElementById("rate").value, 10);
|
||||
const comment = document.getElementById("text").value.trim();
|
||||
const successMessage = document.getElementById("successMessage");
|
||||
const errorMessage = document.getElementById("errorMessage");
|
||||
successMessage.style.display = "none";
|
||||
errorMessage.style.display = "none";
|
||||
|
||||
if (isNaN(rating) || rating < 1 || rating > 10) {
|
||||
alert("Rating must be a number between 1 and 10.");
|
||||
return;
|
||||
@@ -41,24 +39,41 @@ function sendMessage() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
const request = new XMLHttpRequest();
|
||||
request.open("POST", "https://discord.com/api/webhooks/1284936894890901649/Zi-2ZV12L1v1OSBoM-DluE1V1LECXilrNNRZYJcxelnwO7rGgXNH47dxvfFEOK7Fe9_J");
|
||||
request.setRequestHeader('Content-type', 'application/json');
|
||||
const content = `**Rating:** ${rating}\n**Comment:**\n${comment}`;
|
||||
console.log('Sending message with content:', content);
|
||||
const params = {
|
||||
username: pseudoname,
|
||||
content: content
|
||||
};
|
||||
request.send(JSON.stringify(params));
|
||||
setLastSubmissionTime(currentTime);
|
||||
document.getElementById("name").value = "";
|
||||
document.getElementById("rate").value = "";
|
||||
document.getElementById("text").value = "";
|
||||
const successMessage = document.getElementById("successMessage");
|
||||
successMessage.textContent = "Successfully sent the message!";
|
||||
successMessage.style.display = "block";
|
||||
setTimeout(() => {
|
||||
successMessage.style.display = "none";
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await fetch("/api/feedback", {
|
||||
method: "POST",
|
||||
headers: {"Content-Type": "application/json"},
|
||||
body: JSON.stringify({
|
||||
name: pseudoname,
|
||||
rating: rating,
|
||||
comment: comment
|
||||
})
|
||||
});
|
||||
|
||||
const json = await res.json().catch(() => ({}));
|
||||
|
||||
if (!res.ok || !json.ok) {
|
||||
const msg = (json && json.error) ? json.error : "Failed to send feedback.";
|
||||
errorMessage.textContent = msg;
|
||||
errorMessage.style.display = "block";
|
||||
return;
|
||||
}
|
||||
|
||||
setLastSubmissionTime(currentTime);
|
||||
document.getElementById("name").value = "";
|
||||
document.getElementById("rate").value = "";
|
||||
document.getElementById("text").value = "";
|
||||
|
||||
successMessage.textContent = "Successfully sent the message!";
|
||||
successMessage.style.display = "block";
|
||||
setTimeout(() => {
|
||||
successMessage.style.display = "none";
|
||||
}, 3000);
|
||||
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
errorMessage.textContent = "Network error: could not send feedback.";
|
||||
errorMessage.style.display = "block";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user