dixitramjendra commited on
Commit
01d413c
Β·
1 Parent(s): 24da28d

Add PWA install counter badge in header

Browse files
Files changed (1) hide show
  1. forex_macd_dashboard.html +44 -0
forex_macd_dashboard.html CHANGED
@@ -1315,6 +1315,11 @@
1315
  aria-label="Toggle sound alerts">
1316
  <span id="soundIcon">πŸ””</span> <span id="soundText">Alerts On</span>
1317
  </button>
 
 
 
 
 
1318
 
1319
  </header>
1320
 
@@ -1857,8 +1862,47 @@
1857
  window.addEventListener('appinstalled', () => {
1858
  console.log('πŸŽ‰ BiasBuster installed successfully!');
1859
  deferredInstallPrompt = null;
 
 
1860
  });
1861
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1862
  // ========== SOUND ALERTS & BROWSER NOTIFICATIONS ==========
1863
  let soundAlertsEnabled = localStorage.getItem('soundAlerts') !== 'false'; // Default: enabled
1864
  let previousSignals = new Set(); // Track known signals to detect new ones
 
1315
  aria-label="Toggle sound alerts">
1316
  <span id="soundIcon">πŸ””</span> <span id="soundText">Alerts On</span>
1317
  </button>
1318
+ <!-- PWA Install Count Badge -->
1319
+ <span id="pwaInstallBadge"
1320
+ style="display: none; margin-top: 0.75rem; margin-left: 0.5rem; padding: 0.4rem 0.8rem; background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%); border-radius: 1rem; color: white; font-size: 0.85rem; font-weight: 600; align-items: center; gap: 0.3rem;">
1321
+ πŸ“² <span id="pwaInstallCount">0</span> installs
1322
+ </span>
1323
 
1324
  </header>
1325
 
 
1862
  window.addEventListener('appinstalled', () => {
1863
  console.log('πŸŽ‰ BiasBuster installed successfully!');
1864
  deferredInstallPrompt = null;
1865
+ // Record install on server
1866
+ recordPWAInstall();
1867
  });
1868
 
1869
+ // Record PWA install on server
1870
+ async function recordPWAInstall() {
1871
+ try {
1872
+ const res = await fetch('/api/pwa-install', { method: 'POST' });
1873
+ const data = await res.json();
1874
+ if (data.success) {
1875
+ console.log(`πŸ“² Install recorded! Total: ${data.count}`);
1876
+ updatePWAInstallCount(data.count);
1877
+ }
1878
+ } catch (e) {
1879
+ console.log('Could not record install:', e);
1880
+ }
1881
+ }
1882
+
1883
+ // Load and display PWA install count
1884
+ async function loadPWAInstallCount() {
1885
+ try {
1886
+ const res = await fetch('/api/pwa-installs');
1887
+ const data = await res.json();
1888
+ updatePWAInstallCount(data.count);
1889
+ } catch (e) {
1890
+ // Silently fail - not critical
1891
+ }
1892
+ }
1893
+
1894
+ // Update PWA install count display
1895
+ function updatePWAInstallCount(count) {
1896
+ const countEl = document.getElementById('pwaInstallCount');
1897
+ if (countEl) {
1898
+ countEl.textContent = count;
1899
+ countEl.parentElement.style.display = count > 0 ? 'inline-flex' : 'none';
1900
+ }
1901
+ }
1902
+
1903
+ // Load count on page load
1904
+ document.addEventListener('DOMContentLoaded', loadPWAInstallCount);
1905
+
1906
  // ========== SOUND ALERTS & BROWSER NOTIFICATIONS ==========
1907
  let soundAlertsEnabled = localStorage.getItem('soundAlerts') !== 'false'; // Default: enabled
1908
  let previousSignals = new Set(); // Track known signals to detect new ones