Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 21 additions & 45 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -984,55 +984,25 @@ <h4>πŸ’‘ Quick Templates:</h4>
textarea.setSelectionRange(cursorPos + template.length, cursorPos + template.length);
}

function saveComment() {
const textarea = document.getElementById('commentTextarea');
const comment = textarea.value.trim();

if (comment) {
fileComments[currentCommentFile] = comment;

// Update comment button to show it has a comment
const commentBtn = document.querySelector(`[onclick*="'${currentCommentFile}'"]`);
if (commentBtn) {
commentBtn.classList.add('has-comment');
const indicator = document.getElementById(`comment-indicator-${currentCommentFileId}`);
if (indicator) {
indicator.style.display = 'inline';
}
}

// Add comment display to the file
showCommentInFile(currentCommentFile, currentCommentFileId, comment);
} else {
// Remove comment if empty
delete fileComments[currentCommentFile];
const commentBtn = document.querySelector(`[onclick*="'${currentCommentFile}'"]`);
if (commentBtn) {
commentBtn.classList.remove('has-comment');
const indicator = document.getElementById(`comment-indicator-${currentCommentFileId}`);
if (indicator) {
indicator.style.display = 'none';
}
}
removeCommentFromFile(currentCommentFileId);
}

closeCommentModal();
}

function showCommentInFile(file, fileId, comment) {
// Remove existing comment display
removeCommentFromFile(fileId);

// Add comment display after file header
const fileItem = document.getElementById(`diff-${fileId}`).parentElement;
const diffElem = document.getElementById(`diff-${fileId}`);
if (!diffElem) return;

const fileItem = diffElem.parentElement;
const commentDiv = document.createElement('div');
commentDiv.id = `comment-display-${fileId}`;
commentDiv.className = 'comment-display';
commentDiv.innerHTML = `<strong>πŸ’­ Your Comment:</strong><br>${escapeHtml(comment)}`;

const fileHeader = fileItem.querySelector('.file-header');
fileHeader.parentNode.insertBefore(commentDiv, fileHeader.nextSibling);
if (fileHeader) {
fileHeader.parentNode.insertBefore(commentDiv, fileHeader.nextSibling);
}
}

function removeCommentFromFile(fileId) {
Expand Down Expand Up @@ -1272,13 +1242,13 @@ <h3>No Staged Changes</h3>
<span id="comment-indicator-${escapeHtml(fileId)}" style="display: none;" aria-hidden="true">πŸ’¬</span>
<span aria-hidden="true">πŸ’­</span>
</button>
<div class="file-stats" id="stats-${fileId}">
<div class="file-stats" id="stats-${escapeHtml(fileId)}">
<span>Click to load diff</span>
</div>
<span class="badge ${escapeHtml(badgeClass)}">${escapeHtml(badgeText)}</span>
</div>
</div>
<div class="file-diff" id="diff-${fileId}">
<div class="file-diff" id="diff-${escapeHtml(fileId)}">
<div style="padding: 20px; text-align: center; color: #7d8590;">
<div class="spinner" style="margin: 0 auto 12px;"></div>
Loading diff for ${safeFileName}...
Expand All @@ -1301,6 +1271,8 @@ <h3>No Staged Changes</h3>
const icon = document.getElementById(`icon-${fileId}`);
const fileHeader = diffDiv.previousElementSibling;

if (!diffDiv || !icon) return;

if (diffDiv.classList.contains('active')) {
diffDiv.classList.remove('active');
icon.classList.remove('rotated');
Expand Down Expand Up @@ -1387,7 +1359,8 @@ <h3>No Staged Changes</h3>
fileComments[currentCommentFile] = comment;
console.log(`πŸ’¬ File comment added: ${currentCommentFile}: "${comment.substring(0, 50)}${comment.length > 50 ? '...' : ''}"`);

const commentBtn = document.querySelector(`[onclick*="'${currentCommentFile}'"]`);
// Use data attribute instead of string matching
const commentBtn = document.querySelector(`.comment-btn[data-file="${CSS.escape(currentCommentFile)}"]`);
if (commentBtn) {
commentBtn.classList.add('has-comment');
const indicator = document.getElementById(`comment-indicator-${currentCommentFileId}`);
Expand All @@ -1397,7 +1370,7 @@ <h3>No Staged Changes</h3>
} else {
delete fileComments[currentCommentFile];
console.log(`❌ File comment removed: ${currentCommentFile}`);
const commentBtn = document.querySelector(`[onclick*="'${currentCommentFile}'"]`);
const commentBtn = document.querySelector(`.comment-btn[data-file="${CSS.escape(currentCommentFile)}"]`);
if (commentBtn) {
commentBtn.classList.remove('has-comment');
const indicator = document.getElementById(`comment-indicator-${currentCommentFileId}`);
Expand Down Expand Up @@ -1488,15 +1461,18 @@ <h3>No Staged Changes</h3>
const removed = lines.filter(line => line.startsWith('-') && !line.startsWith('---')).length;

const statsElement = document.getElementById(`stats-${fileId}`);
statsElement.innerHTML = `
<span style="color: #aff5b4;">+${added}</span>
<span style="color: #ffdcd7;">-${removed}</span>
`;
if (statsElement) {
statsElement.innerHTML = `
<span style="color: #aff5b4;">+${added}</span>
<span style="color: #ffdcd7;">-${removed}</span>
`;
}
}

// Toggle file selection for export
function toggleFileSelection(file, fileId) {
const checkbox = document.getElementById(`select-${fileId}`);
if (!checkbox) return;
const fileItem = checkbox.closest('.file-item');

if (checkbox.checked) {
Expand Down
Loading