infinite scroll fix
This commit is contained in:
@@ -62,7 +62,7 @@
|
||||
window.appState = {
|
||||
currentSymbol: '{{ current_symbol }}',
|
||||
currentTimeframes: {{ timeframes | tojson }},
|
||||
annotations: {{ annotations | tojson }},
|
||||
annotations: { { annotations | tojson } },
|
||||
pendingAnnotation: null,
|
||||
chartManager: null,
|
||||
annotationManager: null,
|
||||
@@ -299,24 +299,44 @@
|
||||
toast.addEventListener('hidden.bs.toast', () => toast.remove());
|
||||
}
|
||||
|
||||
function showWarning(message) {
|
||||
const toast = document.createElement('div');
|
||||
toast.className = 'toast align-items-center text-white bg-warning border-0';
|
||||
toast.setAttribute('role', 'alert');
|
||||
toast.innerHTML = `
|
||||
<div class="d-flex">
|
||||
<div class="toast-body">
|
||||
<i class="fas fa-exclamation-triangle"></i>
|
||||
${message}
|
||||
</div>
|
||||
<button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast"></button>
|
||||
</div>
|
||||
`;
|
||||
|
||||
document.body.appendChild(toast);
|
||||
const bsToast = new bootstrap.Toast(toast);
|
||||
bsToast.show();
|
||||
toast.addEventListener('hidden.bs.toast', () => toast.remove());
|
||||
}
|
||||
|
||||
function deleteAnnotation(annotationId) {
|
||||
console.log('=== deleteAnnotation called ===');
|
||||
console.log('Annotation ID:', annotationId);
|
||||
console.log('window.appState:', window.appState);
|
||||
console.log('window.appState.annotations:', window.appState?.annotations);
|
||||
|
||||
|
||||
if (!annotationId) {
|
||||
console.error('No annotation ID provided');
|
||||
showError('No annotation ID provided');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!window.appState || !window.appState.annotations) {
|
||||
console.error('appState not initialized');
|
||||
showError('Application state not initialized. Please refresh the page.');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Check if annotation exists
|
||||
const annotation = window.appState.annotations.find(a => a.annotation_id === annotationId);
|
||||
if (!annotation) {
|
||||
@@ -324,7 +344,7 @@
|
||||
showError('Annotation not found');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
console.log('Found annotation:', annotation);
|
||||
console.log('Current annotations count:', window.appState.annotations.length);
|
||||
|
||||
@@ -351,7 +371,7 @@
|
||||
|
||||
if (data.success) {
|
||||
console.log('Delete successful, updating UI...');
|
||||
|
||||
|
||||
// Remove from app state
|
||||
const originalCount = window.appState.annotations.length;
|
||||
window.appState.annotations = window.appState.annotations.filter(
|
||||
@@ -404,10 +424,12 @@
|
||||
console.log('renderAnnotationsList function exists:', typeof renderAnnotationsList);
|
||||
console.log('showError function exists:', typeof showError);
|
||||
console.log('showSuccess function exists:', typeof showSuccess);
|
||||
|
||||
console.log('showWarning function exists:', typeof showWarning);
|
||||
|
||||
// Make functions globally available
|
||||
window.showError = showError;
|
||||
window.showSuccess = showSuccess;
|
||||
window.showWarning = showWarning;
|
||||
window.renderAnnotationsList = renderAnnotationsList;
|
||||
window.deleteAnnotation = deleteAnnotation;
|
||||
window.highlightAnnotation = highlightAnnotation;
|
||||
@@ -418,8 +440,9 @@
|
||||
console.log(' - window.renderAnnotationsList:', typeof window.renderAnnotationsList);
|
||||
console.log(' - window.showError:', typeof window.showError);
|
||||
console.log(' - window.showSuccess:', typeof window.showSuccess);
|
||||
console.log(' - window.showWarning:', typeof window.showWarning);
|
||||
console.log(' - window.highlightAnnotation:', typeof window.highlightAnnotation);
|
||||
|
||||
|
||||
// Test call
|
||||
console.log('Testing window.deleteAnnotation availability...');
|
||||
if (typeof window.deleteAnnotation === 'function') {
|
||||
@@ -427,10 +450,10 @@
|
||||
} else {
|
||||
console.error('✗ window.deleteAnnotation is NOT a function!');
|
||||
}
|
||||
|
||||
|
||||
// Add a test button to verify functionality (temporary)
|
||||
console.log('Adding test delete function to window for debugging...');
|
||||
window.testDeleteFunction = function() {
|
||||
window.testDeleteFunction = function () {
|
||||
console.log('Test delete function called');
|
||||
console.log('window.deleteAnnotation type:', typeof window.deleteAnnotation);
|
||||
if (typeof window.deleteAnnotation === 'function') {
|
||||
@@ -446,7 +469,7 @@
|
||||
console.error('window.deleteAnnotation is NOT available');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Add test button to page (temporary debugging)
|
||||
const testButton = document.createElement('button');
|
||||
testButton.textContent = 'Test Delete Function';
|
||||
@@ -455,7 +478,7 @@
|
||||
testButton.style.top = '10px';
|
||||
testButton.style.right = '10px';
|
||||
testButton.style.zIndex = '9999';
|
||||
testButton.onclick = function() {
|
||||
testButton.onclick = function () {
|
||||
console.log('Test button clicked');
|
||||
window.testDeleteFunction();
|
||||
};
|
||||
@@ -493,23 +516,23 @@
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
|
||||
// Add event listeners
|
||||
item.querySelector('.highlight-btn').addEventListener('click', function(e) {
|
||||
item.querySelector('.highlight-btn').addEventListener('click', function (e) {
|
||||
e.stopPropagation();
|
||||
console.log('Highlight button clicked for:', annotation.annotation_id);
|
||||
if (typeof window.highlightAnnotation === 'function') {
|
||||
window.highlightAnnotation(annotation.annotation_id);
|
||||
}
|
||||
});
|
||||
|
||||
item.querySelector('.delete-btn').addEventListener('click', function(e) {
|
||||
|
||||
item.querySelector('.delete-btn').addEventListener('click', function (e) {
|
||||
e.stopPropagation();
|
||||
console.log('=== Delete button clicked ===');
|
||||
console.log('Annotation ID:', annotation.annotation_id);
|
||||
console.log('window.deleteAnnotation type:', typeof window.deleteAnnotation);
|
||||
console.log('window object keys containing delete:', Object.keys(window).filter(k => k.includes('delete')));
|
||||
|
||||
|
||||
if (typeof window.deleteAnnotation === 'function') {
|
||||
console.log('Calling window.deleteAnnotation...');
|
||||
try {
|
||||
@@ -524,7 +547,7 @@
|
||||
showError('Delete function not available. Please refresh the page.');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
listElement.appendChild(item);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user