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.
This commit is contained in:
2026-06-09 17:05:01 +02:00
parent cd077aa1bd
commit 082cb322ef
2 changed files with 48 additions and 46 deletions

View File

@@ -519,7 +519,7 @@ EnvelopeReceiverDto? _envelopeReceiver;
int _totalSignatures = 0; int _totalSignatures = 0;
int _signedSignatures = 0; int _signedSignatures = 0;
int _unsignedSignatures = 0; int _unsignedSignatures = 0;
int _currentSignatureIndex = 0; // Şu an hangi imzada (1-based) int _currentSignatureIndex = 0; // Current signature index (1-based)
// Signature state // Signature state
SignatureCaptureDto? _capturedSignature; SignatureCaptureDto? _capturedSignature;
@@ -817,7 +817,7 @@ const int MaxThumbnailWidth = 400;
_totalSignatures = state.Total; _totalSignatures = state.Total;
_signedSignatures = state.Signed; _signedSignatures = state.Signed;
_unsignedSignatures = state.Unsigned; _unsignedSignatures = state.Unsigned;
_currentSignatureIndex = state.CurrentIndex; // Şu an hangi imzada _currentSignatureIndex = state.CurrentIndex; // Current signature
await InvokeAsync(StateHasChanged); await InvokeAsync(StateHasChanged);
} catch { } catch {
// Ignore errors during counter update // Ignore errors during counter update
@@ -862,12 +862,12 @@ const int MaxThumbnailWidth = 400;
// Signature popup methods // Signature popup methods
void OpenSignaturePopup() { void OpenSignaturePopup() {
// Popup'ı mevcut imza ile aç (değiştirme modu) // Open popup with current signature (edit mode)
_activeSignatureTab = SignatureTabDraw; _activeSignatureTab = SignatureTabDraw;
_signaturePopupVisible = true; _signaturePopupVisible = true;
_popupValidationMessage = null; _popupValidationMessage = null;
// Mevcut imza bilgilerini form field'larına yükle // Load current signature info into form fields
if (_capturedSignature is not null) if (_capturedSignature is not null)
{ {
_signerFullName = _capturedSignature.FullName; _signerFullName = _capturedSignature.FullName;
@@ -879,10 +879,10 @@ const int MaxThumbnailWidth = 400;
async Task OnPopupShownAsync() { async Task OnPopupShownAsync() {
await InitializeActiveSignatureTabAsync(); 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) 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); await JSRuntime.InvokeVoidAsync("receiverSignature.loadExistingSignature", DrawCanvasId, _capturedSignature.DataUrl);
} }
} }

View File

@@ -489,7 +489,7 @@ window.pdfViewer = {
* @returns {object} { total, signed, unsigned, currentIndex, canGoPrev, canGoNext } * @returns {object} { total, signed, unsigned, currentIndex, canGoPrev, canGoNext }
*/ */
getSignatureNavState() { 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) { if (!this._allSignatures || this._allSignatures.length === 0) {
return { return {
total: 0, 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; let currentIndex = 0;
if (this._lastViewedSignatureId) { if (this._lastViewedSignatureId) {
const index = this._allSignatures.findIndex(s => s.id === 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 { return {
total: total, total: total,
signed: signed, signed: signed,
unsigned: unsigned, unsigned: unsigned,
currentIndex: currentIndex, // Şu an hangi imzada (1-5 arası) currentIndex: currentIndex, // Current signature index (1-5 range)
canGoPrev: total > 0, // Her zaman aktif (e?er imza varsa) canGoPrev: total > 0, // Always active (if signatures exist)
canGoNext: total > 0 // Her zaman aktif (e?er imza varsa) canGoNext: total > 0 // Always active (if signatures exist)
}; };
}, },
@@ -529,63 +530,64 @@ window.pdfViewer = {
* Cross-page navigation: searches ALL pages for next unsigned signature. * Cross-page navigation: searches ALL pages for next unsigned signature.
*/ */
async goToNextSignature(dotNetRef) { async goToNextSignature(dotNetRef) {
// Global imza listesi yoksa <20>?k // Exit if no global signature list
if (!this._allSignatures || this._allSignatures.length === 0) { if (!this._allSignatures || this._allSignatures.length === 0) {
return false; return false;
} }
// Mevcut g<>r<EFBFBD>nt<6E>lenen imzan?n index'ini bul // Find current displayed signature's index
let currentIndex = -1; let currentIndex = -1;
if (this._lastViewedSignatureId) { if (this._lastViewedSignatureId) {
currentIndex = this._allSignatures.findIndex(s => s.id === 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; let nextIndex = currentIndex + 1;
// Sonsuz d<>ng<6E>: Son imzadaysa ilk imzaya d<>n // Infinite loop: If at last signature, return to first
if (nextIndex >= this._allSignatures.length) { if (nextIndex >= this._allSignatures.length) {
nextIndex = 0; // ?lk imzaya d<>n nextIndex = 0; // Return to first signature
} }
const nextSignature = this._allSignatures[nextIndex]; const nextSignature = this._allSignatures[nextIndex];
// Farkl? sayfadaysa sayfa de?i?tir // Change page if signature is on different page
if (nextSignature.page !== this.pageNum) { if (nextSignature.page !== this.pageNum) {
// Sayfa de?i?tir // Change page
this.pageNum = nextSignature.page; this.pageNum = nextSignature.page;
this.queueRenderPage(this.pageNum); this.queueRenderPage(this.pageNum);
// Render tamamlanana kadar bekle // Wait until render completes
let waitCount = 0; let waitCount = 0;
while (this.pageRendering && waitCount < 20) { while (this.pageRendering && waitCount < 20) {
await new Promise(resolve => setTimeout(resolve, 100)); await new Promise(resolve => setTimeout(resolve, 100));
waitCount++; waitCount++;
} }
// Blazor'a haber ver - signature butonlar?n? yeniden ?iz // Notify Blazor - re-render signature buttons
if (dotNetRef) { if (dotNetRef) {
await dotNetRef.invokeMethodAsync('OnPageChangedBySignatureNav', this.pageNum); 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)); await new Promise(resolve => setTimeout(resolve, 150));
} }
// Son g<>r<EFBFBD>nt<6E>lenen imzay? kaydet
// Save last viewed signature
this._lastViewedSignatureId = nextSignature.id; this._lastViewedSignatureId = nextSignature.id;
// ?mza imzalanm?? m? kontrol et // Check if signature is signed
const isApplied = this.appliedSignatures.some(s => s.id === nextSignature.id); const isApplied = this.appliedSignatures.some(s => s.id === nextSignature.id);
if (isApplied) { 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}"]`); const container = document.querySelector(`.applied-signature[data-signature-id="${nextSignature.id}"]`);
if (container) { if (container) {
this.scrollToElement(container); this.scrollToElement(container);
} }
} else { } else {
// ?mzalanmam?? - butonu bul ve scroll yap // Unsigned - find button and scroll
const button = this.signatureButtons.find(btn => const button = this.signatureButtons.find(btn =>
parseInt(btn.getAttribute('data-signature-id')) === nextSignature.id 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) { if (dotNetRef) {
dotNetRef.invokeMethodAsync('OnSignatureNavChanged'); dotNetRef.invokeMethodAsync('OnSignatureNavChanged');
} }
@@ -611,58 +613,58 @@ window.pdfViewer = {
return false; return false;
} }
// Mevcut g<>r<EFBFBD>nt<6E>lenen imzan?n index'ini bul // Find current displayed signature's index
let currentIndex = this._allSignatures.length; // Varsay?lan: son imzadan sonra let currentIndex = this._allSignatures.length; // Default: after last signature
if (this._lastViewedSignatureId) { if (this._lastViewedSignatureId) {
currentIndex = this._allSignatures.findIndex(s => s.id === this._lastViewedSignatureId); currentIndex = this._allSignatures.findIndex(s => s.id === this._lastViewedSignatureId);
} }
// Bir <20>nceki imzay? al // Get previous signature
let prevIndex = currentIndex - 1; let prevIndex = currentIndex - 1;
// Sonsuz d<>ng<6E>: ?lk imzadaysa son imzaya git // Infinite loop: If at first signature, go to last
if (prevIndex < 0) { 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]; const prevSignature = this._allSignatures[prevIndex];
// Change page if needed // Change page if needed
if (prevSignature.page !== this.pageNum) { if (prevSignature.page !== this.pageNum) {
// Sayfa de?i?tir // Change page
this.pageNum = prevSignature.page; this.pageNum = prevSignature.page;
this.queueRenderPage(this.pageNum); this.queueRenderPage(this.pageNum);
// Render tamamlanana kadar bekle // Wait until render completes
let waitCount = 0; let waitCount = 0;
while (this.pageRendering && waitCount < 20) { while (this.pageRendering && waitCount < 20) {
await new Promise(resolve => setTimeout(resolve, 100)); await new Promise(resolve => setTimeout(resolve, 100));
waitCount++; waitCount++;
} }
// Blazor'a haber ver - signature butonlar?n? yeniden <20>iz // Notify Blazor - re-render signature buttons
if (dotNetRef) { if (dotNetRef) {
await dotNetRef.invokeMethodAsync('OnPageChangedBySignatureNav', this.pageNum); await dotNetRef.invokeMethodAsync('OnPageChangedBySignatureNav', this.pageNum);
} }
// DOM g<>ncellenmesini bekle // Wait for DOM update
await new Promise(resolve => setTimeout(resolve, 150)); await new Promise(resolve => setTimeout(resolve, 150));
} }
// Son g<>r<EFBFBD>nt<6E>lenen imzay? kaydet // Save last viewed signature
this._lastViewedSignatureId = prevSignature.id; this._lastViewedSignatureId = prevSignature.id;
// ?mza imzalanm?? m? kontrol et // Check if signature is signed
const isApplied = this.appliedSignatures.some(s => s.id === prevSignature.id); const isApplied = this.appliedSignatures.some(s => s.id === prevSignature.id);
if (isApplied) { 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}"]`); const container = document.querySelector(`.applied-signature[data-signature-id="${prevSignature.id}"]`);
if (container) { if (container) {
this.scrollToElement(container); this.scrollToElement(container);
} }
} else { } else {
// ?mzalanmam?? - butonu bul ve scroll yap // Unsigned - find button and scroll
const button = this.signatureButtons.find(btn => const button = this.signatureButtons.find(btn =>
parseInt(btn.getAttribute('data-signature-id')) === prevSignature.id parseInt(btn.getAttribute('data-signature-id')) === prevSignature.id
); );
@@ -1070,8 +1072,8 @@ window.pdfViewer = {
// Text information container // Text information container
const infoContainer = document.createElement('div'); const infoContainer = document.createElement('div');
infoContainer.className = 'signature-info-text'; // ✅ Class ekle (querySelector için) infoContainer.className = 'signature-info-text'; // ✅ Add class (for querySelector)
infoContainer.setAttribute('data-base-font-size', '9'); // ✅ Base font size sakla infoContainer.setAttribute('data-base-font-size', '9'); // ✅ Store base font size
infoContainer.style.fontSize = '9px'; infoContainer.style.fontSize = '9px';
infoContainer.style.lineHeight = '1.4'; infoContainer.style.lineHeight = '1.4';
infoContainer.style.color = '#495057'; infoContainer.style.color = '#495057';