diff --git a/lang/en_US.ini b/lang/en_US.ini
index d2e0e55..78a857e 100644
--- a/lang/en_US.ini
+++ b/lang/en_US.ini
@@ -394,8 +394,12 @@ notify_new_comments = "Notify me of new comments in this thread"
post_reply = "Post Reply"
post_comment = "Post Comment"
reply = "Reply"
-comment_submitted_success = "Your comment has been posted successfully!"
-comment_submitted_moderation = "Your comment has been submitted and is awaiting moderation."
+comment_submission_success = "Your comment has been posted successfully!"
+comment_submission_moderation = "Your comment has been submitted and is awaiting moderation."
comment_submission_error = "There was an error submitting your comment. Please try again."
+comment_submission_error_shortname = "Name is required and must be at least 2 characters."
+comment_submission_error_email = "Valid email is required."
+comment_submission_error_short = "Comment is required and must be at least 3 characters."
+comment_submission_error_spam = "SPAM detected!"
pending_comments = "Pending Comments"
level = "Level"
\ No newline at end of file
diff --git a/system/htmly.php b/system/htmly.php
index 400e1c3..92f56bd 100644
--- a/system/htmly.php
+++ b/system/htmly.php
@@ -6065,14 +6065,13 @@ post('/comments/submit', function () {
$result = commentInsert($postId, $data);
+ // Kept separate for future use
if ($result['success']) {
// Redirect back to post with success anchor
- $redir = site_url() . $postId . '#comment-success';
- // $redir = site_url() . $postId . '#comment-' . $result['comment_id'];
+ $redir = site_url() . $postId . '#comment-status+' . $result['message'];
} else {
// Redirect back to post with error
- $redir = site_url() . $postId . '#comment-error';
- // $redir = site_url() . $postId . '#comment-error?' . $result['message'];
+ $redir = site_url() . $postId . '#comment-status+' . $result['message'][0];
}
header("location: $redir");
diff --git a/system/includes/comments-frontend.php b/system/includes/comments-frontend.php
index 5ff2841..f8f1695 100644
--- a/system/includes/comments-frontend.php
+++ b/system/includes/comments-frontend.php
@@ -167,26 +167,8 @@ function displayCommentsSection($postId)
--->
-
-
-
-
+
-
-
-
-
-
@@ -256,6 +238,66 @@ function displayCommentsSection($postId)
container.innerHTML = '';
}
}
+
+ function handleCommentStatus() {
+ // Setting messages
+ const messages = {
+ comment_submission_success: "",
+ comment_submission_moderation: "",
+ comment_submission_error: "",
+ comment_submission_error_shortname: "",
+ comment_submission_error_email: "",
+ comment_submission_error_short: "",
+ comment_submission_error_spam: ""
+ };
+
+ // Get the hash in the URL
+ const hash = window.location.hash;
+
+ // Check if there's #comment-status
+ if (hash.startsWith('#comment-status')) {
+ // Get the part after +
+ const parts = hash.split('+');
+
+ if (parts.length > 1) {
+ const statusKey = parts[1];
+ const alertDiv = document.querySelector('.comment-alert-status');
+
+ if (alertDiv && messages[statusKey]) {
+ // Set message to display
+ alertDiv.textContent = messages[statusKey];
+
+ // Set div colors (classes) based on message type
+ if (statusKey.includes('error')) {
+ alertDiv.className = 'comment-alert-status comment-alert-status-error'
+ } else if (statusKey.includes('success')) {
+ alertDiv.className = 'comment-alert-status comment-alert-status-success'
+ } else if (statusKey.includes('moderation')) {
+ alertDiv.className = 'comment-alert-status comment-alert-status-warning'
+ }
+
+ // Showing status message div
+ alertDiv.style.display = 'block';
+
+ // Scroll to status message
+ document.getElementById('comments').scrollIntoView({
+ behavior: 'smooth',
+ block: 'start'
+ });
+
+ }
+ }
+ }
+ }
+
+
+
+ // Esegui la funzione quando il DOM รจ caricato
+ document.addEventListener('DOMContentLoaded', handleCommentStatus);
+
+ // Esegui anche quando l'hash cambia (se navighi sulla stessa pagina)
+ window.addEventListener('hashchange', handleCommentStatus);
+
false,
- 'message' => 'Failed to save comment'
+ 'message' => 'comment_submission_error'
);
}
@@ -329,7 +329,7 @@ function commentInsert($postId, $data)
return array(
'success' => true,
'comment_id' => $commentId,
- 'message' => $comment['published'] ? 'Comment published successfully' : 'Comment submitted for moderation'
+ 'message' => $comment['published'] ? 'comment_submission_success' : 'comment_submission_moderation'
);
}