From 9fba57f1e66adea8adc820b0b3dbc5afedbd647a Mon Sep 17 00:00:00 2001
From: IM23a-bachmannj2
Date: Tue, 17 Sep 2024 14:22:41 +0200
Subject: [PATCH] Added Suggestion page cooldown and design.
---
static/style.css | 87 +++++++++++++++++++++++++++++++++++
static/suggestion.js | 96 +++++++++++++++++++++++++++++++++++++++
templates/about_us.html | 2 +-
templates/suggestion.html | 31 ++-----------
4 files changed, 188 insertions(+), 28 deletions(-)
create mode 100644 static/suggestion.js
diff --git a/static/style.css b/static/style.css
index 050a752..0b1bfff 100644
--- a/static/style.css
+++ b/static/style.css
@@ -229,3 +229,90 @@ nav {
.button1 {
background-color: black;
}
+
+/* Suggestion Form Enhancements */
+main h1 {
+ font-size: 2.5em;
+ color: black;
+ text-align: center;
+ margin-bottom: 20px;
+}
+
+.suggestion-title {
+ font-size: 1.5em;
+ color: black;
+ text-align: center;
+ margin-bottom: 30px;
+}
+
+article label {
+ font-weight: bold;
+ font-size: 1.1em;
+ color: #333;
+ margin-bottom: 10px;
+ display: block;
+}
+
+input[type="text"], input[type="number"], textarea {
+ width: 95%;
+ padding: 12px;
+ font-size: 1em;
+ border: 1px solid #ccc;
+ border-radius: 8px;
+ margin-bottom: 20px;
+ background-color: #f9f9f9;
+ transition: border-color 0.3s, box-shadow 0.3s;
+}
+
+/* Focus effect to highlight the active input field */
+input[type="text"]:focus, input[type="number"]:focus, textarea:focus {
+ border-color: black;
+ box-shadow: 0 0 5px darkred;
+ background-color: #fff;
+ outline: none;
+}
+
+textarea {
+ resize: none;
+ height: 150px;
+}
+
+/* Submit button improvements */
+.button1 {
+ background-color: darkred;
+ color: white;
+ font-size: 1.2em;
+ padding: 12px 24px;
+ border: none;
+ border-radius: 8px;
+ cursor: pointer;
+ display: block;
+ margin: 0 auto;
+ transition: background-color 0.3s ease, transform 0.3s ease;
+}
+
+/* Button hover effect */
+.button1:hover {
+ background-color: #45a049;
+ transform: scale(1.05);
+}
+
+/* Success message styling */
+#successMessage {
+ font-size: 1.1em;
+ color: green;
+ text-align: center;
+ margin-top: 20px;
+}
+
+/* Adjustments for mobile responsiveness */
+@media screen and (max-width: 600px) {
+ input[type="text"], input[type="number"], textarea {
+ width: 80%;
+ font-size: 0.95em;
+ }
+
+ .suggestion-title {
+ font-size: 1.2em;
+ }
+}
diff --git a/static/suggestion.js b/static/suggestion.js
new file mode 100644
index 0000000..e527439
--- /dev/null
+++ b/static/suggestion.js
@@ -0,0 +1,96 @@
+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']
+; // Example word filtering
+
+// Function to get the last submission time from localStorage
+function getLastSubmissionTime() {
+ const storedTime = localStorage.getItem('lastSubmissionTime');
+ return storedTime ? parseInt(storedTime, 10) : 0;
+}
+
+// Function to save the last submission time to localStorage
+function setLastSubmissionTime(time) {
+ localStorage.setItem('lastSubmissionTime', time.toString());
+}
+
+function sendMessage() {
+ // Get the current time
+ const currentTime = Date.now();
+
+ // Retrieve the last submission time from localStorage
+ const lastSubmissionTime = getLastSubmissionTime();
+
+ // Cooldown logic to prevent spamming
+ if (currentTime - lastSubmissionTime < cooldownDuration) {
+ alert(`Please wait for ${cooldownDuration / 1000} seconds between submissions.`);
+ return;
+ }
+
+ // Get the values from the input fields
+ const pseudoname = document.getElementById("name").value || "Anonymous";
+ const rating = parseInt(document.getElementById("rate").value, 10);
+ const comment = document.getElementById("text").value.trim();
+
+ // Validation: Rating should be between 1 and 10
+ if (isNaN(rating) || rating < 1 || rating > 10) {
+ alert("Rating must be a number between 1 and 10.");
+ return;
+ }
+
+ // Validation: Comment length (min 5, max 500) and simple prohibited word check
+ if (comment.length < 5 || comment.length > 500) {
+ alert("Comment must be between 5 and 500 characters.");
+ return;
+ }
+
+ // Check for prohibited words (basic check)
+ for (const word of prohibitedWords) {
+ if (comment.toLowerCase().includes(word)) {
+ alert("Your comment contains inappropriate content.");
+ return;
+ }
+ }
+
+ // If all checks pass, send the message to the Discord webhook
+ const request = new XMLHttpRequest();
+ request.open("POST", "https://discord.com/api/webhooks/1284936894890901649/Zi-2ZV12L1v1OSBoM-DluE1V1LECXilrNNRZYJcxelnwO7rGgXNH47dxvfFEOK7Fe9_J");
+ request.setRequestHeader('Content-type', 'application/json');
+
+ // Create the content to send to the Discord webhook
+ const content = `**Rating:** ${rating}\n**Comment:**\n${comment}`;
+
+ // Debugging information
+ console.log('Sending message with content:', content);
+
+ // Send the message payload to the Discord webhook
+ const params = {
+ username: pseudoname, // Pseudoname will appear as the username
+ content: content // The combined content (pseudoname, rating, and comment)
+ };
+
+ request.send(JSON.stringify(params));
+
+ // Update the last submission time to the current time
+ setLastSubmissionTime(currentTime);
+
+ // Optionally, you can reset the form after sending
+ document.getElementById("name").value = "";
+ document.getElementById("rate").value = "";
+ document.getElementById("text").value = "";
+
+ // Display the success message
+ const successMessage = document.getElementById("successMessage");
+ successMessage.textContent = "Successfully sent the message!";
+ successMessage.style.display = "block"; // Ensure the message is visible
+
+ // Optionally hide the message after a few seconds
+ setTimeout(() => {
+ successMessage.style.display = "none"; // Hide message after 3 seconds
+ }, 3000);
+}
diff --git a/templates/about_us.html b/templates/about_us.html
index d31efde..837e593 100644
--- a/templates/about_us.html
+++ b/templates/about_us.html
@@ -57,7 +57,7 @@
TRL Community with an easy go-to way to calculate DPS and DPM values to help players make informed decisions
about their gameplay. Whether you're fine-tuning your new Deathwish Strategy or simply curious about firearm
performance, we’ve got you covered. If you have suggestions, feedback, or want to contribute new stats or
- features, we’d love to hear from you, just contact us on Discord!
+ features, we’d love to hear from you, just contact us on Discord or on the Suggestion Page!
Our Story
diff --git a/templates/suggestion.html b/templates/suggestion.html
index 554eb30..66fd282 100644
--- a/templates/suggestion.html
+++ b/templates/suggestion.html
@@ -63,34 +63,11 @@
+
+
+
-
+