Update index.html
Browse files- index.html +14 -4
index.html
CHANGED
|
@@ -619,7 +619,7 @@
|
|
| 619 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><path d="M3 9h18"/><path d="M9 21V9"/></svg>
|
| 620 |
گالری و تاریخچه شما
|
| 621 |
</div>
|
| 622 |
-
|
| 623 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 6h18"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"/><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>
|
| 624 |
<span>پاک کردن همه</span>
|
| 625 |
</button>
|
|
@@ -647,7 +647,7 @@
|
|
| 647 |
</a>
|
| 648 |
</div>
|
| 649 |
</div>
|
| 650 |
-
|
| 651 |
<div id="confirmation-modal">
|
| 652 |
<div class="modal-dialog">
|
| 653 |
<div class="modal-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg></div>
|
|
@@ -1047,13 +1047,21 @@
|
|
| 1047 |
const handleDeleteItem = (index) => showConfirmationModal('آیا از حذف این مورد از تاریخچه مطمئن هستید؟', () => { let history = getHistory(); history.splice(index, 1); saveHistory(history); });
|
| 1048 |
|
| 1049 |
const renderHistory = () => {
|
| 1050 |
-
|
| 1051 |
const sixHoursInMs = 6 * 60 * 60 * 1000;
|
| 1052 |
const currentTime = Date.now();
|
| 1053 |
const validHistory = history.filter(item => (currentTime - item.timestamp) < sixHoursInMs);
|
| 1054 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1055 |
historyGrid.innerHTML = '';
|
| 1056 |
clearHistoryBtn.style.display = validHistory.length > 0 ? 'flex' : 'none';
|
|
|
|
| 1057 |
validHistory.forEach((item, index) => {
|
| 1058 |
const card = document.createElement('div');
|
| 1059 |
card.className = 'history-item';
|
|
@@ -1062,12 +1070,14 @@
|
|
| 1062 |
img.alt = 'تصویر ساخته شده در تاریخچه';
|
| 1063 |
img.addEventListener('click', () => openLightbox(item.url));
|
| 1064 |
card.appendChild(img);
|
|
|
|
| 1065 |
const deleteBtn = document.createElement('button');
|
| 1066 |
deleteBtn.className = 'history-delete-btn';
|
| 1067 |
deleteBtn.title = 'حذف این مورد';
|
| 1068 |
deleteBtn.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 6h18"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"/><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>`;
|
| 1069 |
deleteBtn.onclick = (e) => { e.stopPropagation(); handleDeleteItem(index); };
|
| 1070 |
card.appendChild(deleteBtn);
|
|
|
|
| 1071 |
historyGrid.appendChild(card);
|
| 1072 |
});
|
| 1073 |
};
|
|
|
|
| 619 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><path d="M3 9h18"/><path d="M9 21V9"/></svg>
|
| 620 |
گالری و تاریخچه شما
|
| 621 |
</div>
|
| 622 |
+
<button id="clear-history-btn">
|
| 623 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 6h18"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"/><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>
|
| 624 |
<span>پاک کردن همه</span>
|
| 625 |
</button>
|
|
|
|
| 647 |
</a>
|
| 648 |
</div>
|
| 649 |
</div>
|
| 650 |
+
|
| 651 |
<div id="confirmation-modal">
|
| 652 |
<div class="modal-dialog">
|
| 653 |
<div class="modal-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg></div>
|
|
|
|
| 1047 |
const handleDeleteItem = (index) => showConfirmationModal('آیا از حذف این مورد از تاریخچه مطمئن هستید؟', () => { let history = getHistory(); history.splice(index, 1); saveHistory(history); });
|
| 1048 |
|
| 1049 |
const renderHistory = () => {
|
| 1050 |
+
const history = getHistory();
|
| 1051 |
const sixHoursInMs = 6 * 60 * 60 * 1000;
|
| 1052 |
const currentTime = Date.now();
|
| 1053 |
const validHistory = history.filter(item => (currentTime - item.timestamp) < sixHoursInMs);
|
| 1054 |
+
|
| 1055 |
+
// This is the bug fix: Only update localStorage if items were actually removed.
|
| 1056 |
+
// But it's better to just not write back here at all. The filtering is for display only.
|
| 1057 |
+
// The next page load will naturally filter out expired items again.
|
| 1058 |
+
// if (validHistory.length !== history.length) {
|
| 1059 |
+
// localStorage.setItem('fluxLoraHistory_v2', JSON.stringify(validHistory));
|
| 1060 |
+
// }
|
| 1061 |
+
|
| 1062 |
historyGrid.innerHTML = '';
|
| 1063 |
clearHistoryBtn.style.display = validHistory.length > 0 ? 'flex' : 'none';
|
| 1064 |
+
|
| 1065 |
validHistory.forEach((item, index) => {
|
| 1066 |
const card = document.createElement('div');
|
| 1067 |
card.className = 'history-item';
|
|
|
|
| 1070 |
img.alt = 'تصویر ساخته شده در تاریخچه';
|
| 1071 |
img.addEventListener('click', () => openLightbox(item.url));
|
| 1072 |
card.appendChild(img);
|
| 1073 |
+
|
| 1074 |
const deleteBtn = document.createElement('button');
|
| 1075 |
deleteBtn.className = 'history-delete-btn';
|
| 1076 |
deleteBtn.title = 'حذف این مورد';
|
| 1077 |
deleteBtn.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 6h18"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"/><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>`;
|
| 1078 |
deleteBtn.onclick = (e) => { e.stopPropagation(); handleDeleteItem(index); };
|
| 1079 |
card.appendChild(deleteBtn);
|
| 1080 |
+
|
| 1081 |
historyGrid.appendChild(card);
|
| 1082 |
});
|
| 1083 |
};
|