Fix CSP violation by using event delegation for reply form buttons
This commit is contained in:
@@ -1252,6 +1252,12 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
case 'reply-comment':
|
case 'reply-comment':
|
||||||
showReplyForm(parseInt(target.dataset.commentId), target.dataset.user);
|
showReplyForm(parseInt(target.dataset.commentId), target.dataset.user);
|
||||||
break;
|
break;
|
||||||
|
case 'close-reply':
|
||||||
|
closeReplyForm();
|
||||||
|
break;
|
||||||
|
case 'submit-reply':
|
||||||
|
submitReply(parseInt(target.dataset.parentId));
|
||||||
|
break;
|
||||||
case 'edit-comment':
|
case 'edit-comment':
|
||||||
editComment(parseInt(target.dataset.commentId));
|
editComment(parseInt(target.dataset.commentId));
|
||||||
break;
|
break;
|
||||||
@@ -1471,7 +1477,7 @@ function showReplyForm(commentId, userName) {
|
|||||||
<div class="reply-form-container" data-parent-id="${commentId}">
|
<div class="reply-form-container" data-parent-id="${commentId}">
|
||||||
<div class="reply-header">
|
<div class="reply-header">
|
||||||
<span>Replying to <span class="replying-to">@${userName}</span></span>
|
<span>Replying to <span class="replying-to">@${userName}</span></span>
|
||||||
<button type="button" class="close-reply-btn" onclick="closeReplyForm()">Cancel</button>
|
<button type="button" class="close-reply-btn" data-action="close-reply">Cancel</button>
|
||||||
</div>
|
</div>
|
||||||
<textarea id="replyText" placeholder="Write your reply..."></textarea>
|
<textarea id="replyText" placeholder="Write your reply..."></textarea>
|
||||||
<div class="reply-actions">
|
<div class="reply-actions">
|
||||||
@@ -1480,7 +1486,7 @@ function showReplyForm(commentId, userName) {
|
|||||||
<span>Markdown</span>
|
<span>Markdown</span>
|
||||||
</label>
|
</label>
|
||||||
<div class="reply-buttons">
|
<div class="reply-buttons">
|
||||||
<button type="button" class="btn btn-small" onclick="submitReply(${commentId})">Reply</button>
|
<button type="button" class="btn btn-small" data-action="submit-reply" data-parent-id="${commentId}">Reply</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user