From 082cb322ef3e3bd32bfa0a68e90f28d946e0fd82 Mon Sep 17 00:00:00 2001 From: TekH Date: Tue, 9 Jun 2026 17:05:01 +0200 Subject: [PATCH] Refactor comments for clarity and consistency Replaced non-English comments with English equivalents across `EnvelopeViewer.razor` and `pdf-viewer.js` to improve code readability and maintainability. Updated comments to clarify the purpose of variables, methods, and DOM manipulation logic without altering functionality. These changes ensure the codebase is more accessible to a broader audience. --- .../Pages/EnvelopeViewer.razor | 12 +-- .../wwwroot/js/pdf-viewer.js | 82 ++++++++++--------- 2 files changed, 48 insertions(+), 46 deletions(-) diff --git a/EnvelopeGenerator.ReceiverUI/Pages/EnvelopeViewer.razor b/EnvelopeGenerator.ReceiverUI/Pages/EnvelopeViewer.razor index 78b99f3d..5b47a8e8 100644 --- a/EnvelopeGenerator.ReceiverUI/Pages/EnvelopeViewer.razor +++ b/EnvelopeGenerator.ReceiverUI/Pages/EnvelopeViewer.razor @@ -519,7 +519,7 @@ EnvelopeReceiverDto? _envelopeReceiver; int _totalSignatures = 0; int _signedSignatures = 0; int _unsignedSignatures = 0; -int _currentSignatureIndex = 0; // Şu an hangi imzada (1-based) +int _currentSignatureIndex = 0; // Current signature index (1-based) // Signature state SignatureCaptureDto? _capturedSignature; @@ -817,7 +817,7 @@ const int MaxThumbnailWidth = 400; _totalSignatures = state.Total; _signedSignatures = state.Signed; _unsignedSignatures = state.Unsigned; - _currentSignatureIndex = state.CurrentIndex; // Şu an hangi imzada + _currentSignatureIndex = state.CurrentIndex; // Current signature await InvokeAsync(StateHasChanged); } catch { // Ignore errors during counter update @@ -862,12 +862,12 @@ const int MaxThumbnailWidth = 400; // Signature popup methods void OpenSignaturePopup() { - // Popup'ı mevcut imza ile aç (değiştirme modu) + // Open popup with current signature (edit mode) _activeSignatureTab = SignatureTabDraw; _signaturePopupVisible = true; _popupValidationMessage = null; - // Mevcut imza bilgilerini form field'larına yükle + // Load current signature info into form fields if (_capturedSignature is not null) { _signerFullName = _capturedSignature.FullName; @@ -879,10 +879,10 @@ const int MaxThumbnailWidth = 400; async Task OnPopupShownAsync() { await InitializeActiveSignatureTabAsync(); - // Eğer mevcut imza varsa ve draw tab'deyse, imzayı canvas'a yükle + // If there's an existing signature and we're on draw tab, load it to canvas if (_capturedSignature is not null && _activeSignatureTab == SignatureTabDraw) { - await Task.Delay(100); // Canvas'ın hazır olmasını bekle + await Task.Delay(100); // Wait for canvas to be ready await JSRuntime.InvokeVoidAsync("receiverSignature.loadExistingSignature", DrawCanvasId, _capturedSignature.DataUrl); } } diff --git a/EnvelopeGenerator.ReceiverUI/wwwroot/js/pdf-viewer.js b/EnvelopeGenerator.ReceiverUI/wwwroot/js/pdf-viewer.js index 4a377dec..20998519 100644 --- a/EnvelopeGenerator.ReceiverUI/wwwroot/js/pdf-viewer.js +++ b/EnvelopeGenerator.ReceiverUI/wwwroot/js/pdf-viewer.js @@ -489,7 +489,7 @@ window.pdfViewer = { * @returns {object} { total, signed, unsigned, currentIndex, canGoPrev, canGoNext } */ getSignatureNavState() { - // Global imza listesi yoksa bo? state d�n + // Return empty state if global signature list is empty if (!this._allSignatures || this._allSignatures.length === 0) { return { total: 0, @@ -501,25 +501,26 @@ window.pdfViewer = { }; } - // T�M sayfalardaki imzalar? say (database'den gelen global liste) - const total = this._allSignatures.length; // Global: Toplam imza say?s? - const signed = this.appliedSignatures.length; // ?mzalananlar - const unsigned = total - signed; // Hesaplanan: ?mzalanmayanlar - // Mevcut görüntülenen imzanın sıra numarasını bul + // Count signatures across ALL pages (from database global list) + const total = this._allSignatures.length; // Global: Total signature count + const signed = this.appliedSignatures.length; // Signed signatures + const unsigned = total - signed; // Calculated: Unsigned signatures + + // Find the current viewed signature index let currentIndex = 0; if (this._lastViewedSignatureId) { const index = this._allSignatures.findIndex(s => s.id === this._lastViewedSignatureId); - currentIndex = index !== -1 ? index + 1 : 0; // 1-based index (kullanıcıya göstermek için) + currentIndex = index !== -1 ? index + 1 : 0; // 1-based index (for user display) } return { total: total, signed: signed, unsigned: unsigned, - currentIndex: currentIndex, // Şu an hangi imzada (1-5 arası) - canGoPrev: total > 0, // Her zaman aktif (e?er imza varsa) - canGoNext: total > 0 // Her zaman aktif (e?er imza varsa) + currentIndex: currentIndex, // Current signature index (1-5 range) + canGoPrev: total > 0, // Always active (if signatures exist) + canGoNext: total > 0 // Always active (if signatures exist) }; }, @@ -529,63 +530,64 @@ window.pdfViewer = { * Cross-page navigation: searches ALL pages for next unsigned signature. */ async goToNextSignature(dotNetRef) { - // Global imza listesi yoksa �?k + // Exit if no global signature list if (!this._allSignatures || this._allSignatures.length === 0) { return false; } - // Mevcut g�r�nt�lenen imzan?n index'ini bul + // Find current displayed signature's index let currentIndex = -1; if (this._lastViewedSignatureId) { currentIndex = this._allSignatures.findIndex(s => s.id === this._lastViewedSignatureId); } - // Bir sonraki imzay? al (imzalanm?? olup olmad???na bakmadan) + // Get next signature (regardless of signed status) let nextIndex = currentIndex + 1; - // Sonsuz d�ng�: Son imzadaysa ilk imzaya d�n + // Infinite loop: If at last signature, return to first if (nextIndex >= this._allSignatures.length) { - nextIndex = 0; // ?lk imzaya d�n + nextIndex = 0; // Return to first signature } const nextSignature = this._allSignatures[nextIndex]; - // Farkl? sayfadaysa sayfa de?i?tir + // Change page if signature is on different page if (nextSignature.page !== this.pageNum) { - // Sayfa de?i?tir + // Change page this.pageNum = nextSignature.page; this.queueRenderPage(this.pageNum); - // Render tamamlanana kadar bekle + // Wait until render completes let waitCount = 0; while (this.pageRendering && waitCount < 20) { await new Promise(resolve => setTimeout(resolve, 100)); waitCount++; } - // Blazor'a haber ver - signature butonlar?n? yeniden ?iz + // Notify Blazor - re-render signature buttons if (dotNetRef) { await dotNetRef.invokeMethodAsync('OnPageChangedBySignatureNav', this.pageNum); } - // Butonlar?n DOM'a eklenmesini bekle + // Wait for buttons to be added to DOM await new Promise(resolve => setTimeout(resolve, 150)); } - // Son g�r�nt�lenen imzay? kaydet + + // Save last viewed signature this._lastViewedSignatureId = nextSignature.id; - // ?mza imzalanm?? m? kontrol et + // Check if signature is signed const isApplied = this.appliedSignatures.some(s => s.id === nextSignature.id); if (isApplied) { - // ?mzalanm?? - overlay container'? bul ve scroll yap + // Signed - find overlay container and scroll const container = document.querySelector(`.applied-signature[data-signature-id="${nextSignature.id}"]`); if (container) { this.scrollToElement(container); } } else { - // ?mzalanmam?? - butonu bul ve scroll yap + // Unsigned - find button and scroll const button = this.signatureButtons.find(btn => parseInt(btn.getAttribute('data-signature-id')) === nextSignature.id ); @@ -594,7 +596,7 @@ window.pdfViewer = { } } - // Counter'? g�ncelle (Blazor'a bildir) + // Update counter (notify Blazor) if (dotNetRef) { dotNetRef.invokeMethodAsync('OnSignatureNavChanged'); } @@ -611,58 +613,58 @@ window.pdfViewer = { return false; } - // Mevcut g�r�nt�lenen imzan?n index'ini bul - let currentIndex = this._allSignatures.length; // Varsay?lan: son imzadan sonra + // Find current displayed signature's index + let currentIndex = this._allSignatures.length; // Default: after last signature if (this._lastViewedSignatureId) { currentIndex = this._allSignatures.findIndex(s => s.id === this._lastViewedSignatureId); } - // Bir �nceki imzay? al + // Get previous signature let prevIndex = currentIndex - 1; - // Sonsuz d�ng�: ?lk imzadaysa son imzaya git + // Infinite loop: If at first signature, go to last if (prevIndex < 0) { - prevIndex = this._allSignatures.length - 1; // Son imzaya git + prevIndex = this._allSignatures.length - 1; // Go to last signature } const prevSignature = this._allSignatures[prevIndex]; // Change page if needed if (prevSignature.page !== this.pageNum) { - // Sayfa de?i?tir + // Change page this.pageNum = prevSignature.page; this.queueRenderPage(this.pageNum); - // Render tamamlanana kadar bekle + // Wait until render completes let waitCount = 0; while (this.pageRendering && waitCount < 20) { await new Promise(resolve => setTimeout(resolve, 100)); waitCount++; } - // Blazor'a haber ver - signature butonlar?n? yeniden �iz + // Notify Blazor - re-render signature buttons if (dotNetRef) { await dotNetRef.invokeMethodAsync('OnPageChangedBySignatureNav', this.pageNum); } - // DOM g�ncellenmesini bekle + // Wait for DOM update await new Promise(resolve => setTimeout(resolve, 150)); } - // Son g�r�nt�lenen imzay? kaydet + // Save last viewed signature this._lastViewedSignatureId = prevSignature.id; - // ?mza imzalanm?? m? kontrol et + // Check if signature is signed const isApplied = this.appliedSignatures.some(s => s.id === prevSignature.id); if (isApplied) { - // ?mzalanm?? - overlay container'? bul ve scroll yap + // Signed - find overlay container and scroll const container = document.querySelector(`.applied-signature[data-signature-id="${prevSignature.id}"]`); if (container) { this.scrollToElement(container); } } else { - // ?mzalanmam?? - butonu bul ve scroll yap + // Unsigned - find button and scroll const button = this.signatureButtons.find(btn => parseInt(btn.getAttribute('data-signature-id')) === prevSignature.id ); @@ -1070,8 +1072,8 @@ window.pdfViewer = { // Text information container const infoContainer = document.createElement('div'); - infoContainer.className = 'signature-info-text'; // ✅ Class ekle (querySelector için) - infoContainer.setAttribute('data-base-font-size', '9'); // ✅ Base font size sakla + infoContainer.className = 'signature-info-text'; // ✅ Add class (for querySelector) + infoContainer.setAttribute('data-base-font-size', '9'); // ✅ Store base font size infoContainer.style.fontSize = '9px'; infoContainer.style.lineHeight = '1.4'; infoContainer.style.color = '#495057';