ymd78329 commited on
Commit
b7dd4c3
·
verified ·
1 Parent(s): 3d9354b

When I click on 'ইতিহাস' in the hamburger menu, show my reset history & time duration. - Follow Up Deployment

Browse files
Files changed (1) hide show
  1. index.html +75 -5
index.html CHANGED
@@ -106,7 +106,7 @@
106
  <i class="fas fa-question-circle mr-3 text-blue-500"></i>
107
  <span>ইসলামিক কুইজ</span>
108
  </div>
109
- <div class="menu-item p-4 border-b border-gray-200 flex items-center">
110
  <i class="fas fa-history mr-3 text-blue-500"></i>
111
  <span>ইতিহাস</span>
112
  </div>
@@ -274,6 +274,18 @@
274
  </button>
275
  </div>
276
 
 
 
 
 
 
 
 
 
 
 
 
 
277
  <div id="islamicQuizPage" class="hidden">
278
  <h2 class="text-2xl font-bold mb-4">ইসলামিক কুইজ</h2>
279
  <div class="prose">
@@ -571,6 +583,7 @@
571
  }
572
 
573
  // Timer Logic
 
574
  const timer = document.getElementById('timer');
575
  const startBtn = document.getElementById('startBtn');
576
  const resetBtn = document.getElementById('resetBtn');
@@ -669,10 +682,27 @@
669
  resetBtn.addEventListener('click', () => {
670
  clearInterval(timerInterval);
671
 
672
- // Update highest streak if current is higher
673
- if (currentStreakTime > highestStreakTime) {
674
- highestStreakTime = currentStreakTime;
675
- localStorage.setItem('highestStreakTime', highestStreakTime);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
676
  }
677
 
678
  // Reset timer
@@ -692,11 +722,51 @@
692
  updateStreakDisplay();
693
  });
694
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
695
  // Initialize from localStorage
696
  if (localStorage.getItem('highestStreakTime')) {
697
  highestStreakTime = parseInt(localStorage.getItem('highestStreakTime'));
698
  updateStreakDisplay();
699
  }
 
 
 
700
  </script>
701
  <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=ymd78329/tracker" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
702
  </html>
 
106
  <i class="fas fa-question-circle mr-3 text-blue-500"></i>
107
  <span>ইসলামিক কুইজ</span>
108
  </div>
109
+ <div class="menu-item p-4 border-b border-gray-200 flex items-center" onclick="showContentPage('historyPage')">
110
  <i class="fas fa-history mr-3 text-blue-500"></i>
111
  <span>ইতিহাস</span>
112
  </div>
 
274
  </button>
275
  </div>
276
 
277
+ <div id="historyPage" class="hidden">
278
+ <h2 class="text-2xl font-bold mb-4">আপনার রিসেট ইতিহাস</h2>
279
+ <div class="prose">
280
+ <div id="resetHistory" class="space-y-4">
281
+ <!-- History items will be added here dynamically -->
282
+ </div>
283
+ </div>
284
+ <button onclick="hideContentPage()" class="mt-6 bg-blue-500 text-white py-2 px-4 rounded-md">
285
+ <i class="fas fa-arrow-left mr-2"></i> ফিরে যান
286
+ </button>
287
+ </div>
288
+
289
  <div id="islamicQuizPage" class="hidden">
290
  <h2 class="text-2xl font-bold mb-4">ইসলামিক কুইজ</h2>
291
  <div class="prose">
 
583
  }
584
 
585
  // Timer Logic
586
+ let resetHistory = JSON.parse(localStorage.getItem('resetHistory')) || [];
587
  const timer = document.getElementById('timer');
588
  const startBtn = document.getElementById('startBtn');
589
  const resetBtn = document.getElementById('resetBtn');
 
682
  resetBtn.addEventListener('click', () => {
683
  clearInterval(timerInterval);
684
 
685
+ // Record reset history
686
+ if (currentStreakTime > 0) {
687
+ const now = new Date();
688
+ const historyItem = {
689
+ date: now.toLocaleString(),
690
+ duration: formatDuration(currentStreakTime),
691
+ seconds: currentStreakTime
692
+ };
693
+ resetHistory.unshift(historyItem);
694
+ localStorage.setItem('resetHistory', JSON.stringify(resetHistory));
695
+
696
+ // Update highest streak if current is higher
697
+ if (currentStreakTime > highestStreakTime) {
698
+ highestStreakTime = currentStreakTime;
699
+ localStorage.setItem('highestStreakTime', highestStreakTime);
700
+ }
701
+
702
+ // Update history display if visible
703
+ if (!document.getElementById('historyPage').classList.contains('hidden')) {
704
+ displayResetHistory();
705
+ }
706
  }
707
 
708
  // Reset timer
 
722
  updateStreakDisplay();
723
  });
724
 
725
+ function formatDuration(totalSeconds) {
726
+ const days = Math.floor(totalSeconds / 86400);
727
+ const hours = Math.floor((totalSeconds % 86400) / 3600);
728
+ const minutes = Math.floor((totalSeconds % 3600) / 60);
729
+ const seconds = totalSeconds % 60;
730
+
731
+ let parts = [];
732
+ if (days > 0) parts.push(`${days} দিন`);
733
+ if (hours > 0) parts.push(`${hours} ঘণ্টা`);
734
+ if (minutes > 0) parts.push(`${minutes} মিনিট`);
735
+ if (seconds > 0 || parts.length === 0) parts.push(`${seconds} সেকেন্ড`);
736
+
737
+ return parts.join(' ');
738
+ }
739
+
740
+ function displayResetHistory() {
741
+ const historyContainer = document.getElementById('resetHistory');
742
+ historyContainer.innerHTML = '';
743
+
744
+ if (resetHistory.length === 0) {
745
+ historyContainer.innerHTML = '<p class="text-gray-500">কোন রিসেট ইতিহাস পাওয়া যায়নি</p>';
746
+ return;
747
+ }
748
+
749
+ resetHistory.forEach(item => {
750
+ const historyItem = document.createElement('div');
751
+ historyItem.className = 'bg-white p-4 rounded-lg shadow-sm border border-gray-200';
752
+ historyItem.innerHTML = `
753
+ <div class="flex justify-between items-center">
754
+ <span class="font-medium">${item.date}</span>
755
+ <span class="bg-blue-100 text-blue-800 px-3 py-1 rounded-full text-sm">${item.duration}</span>
756
+ </div>
757
+ `;
758
+ historyContainer.appendChild(historyItem);
759
+ });
760
+ }
761
+
762
  // Initialize from localStorage
763
  if (localStorage.getItem('highestStreakTime')) {
764
  highestStreakTime = parseInt(localStorage.getItem('highestStreakTime'));
765
  updateStreakDisplay();
766
  }
767
+
768
+ // Update history page display when shown
769
+ document.getElementById('historyPage').addEventListener('show', displayResetHistory);
770
  </script>
771
  <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=ymd78329/tracker" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
772
  </html>