Edoruin commited on
Commit
df68a62
·
1 Parent(s): f9d26ad

sustitude flet by flask

Browse files
Files changed (1) hide show
  1. app/templates/base.html +20 -6
app/templates/base.html CHANGED
@@ -78,10 +78,15 @@
78
  notif.innerHTML = `<i class="fas fa-info-circle"></i> <span>${text}</span>`;
79
  container.appendChild(notif);
80
 
 
81
  if ("Notification" in window && Notification.permission === "granted") {
82
- new Notification("MAKER SPACE", {
83
- body: text,
84
- icon: "/static/assets/icon192x192.png"
 
 
 
 
85
  });
86
  }
87
 
@@ -91,10 +96,19 @@
91
  }, 5000);
92
  }
93
 
94
- // Notification Permission
95
- document.getElementById('notif-btn').addEventListener('click', () => {
 
96
  if ("Notification" in window) {
97
- Notification.requestPermission();
 
 
 
 
 
 
 
 
98
  }
99
  });
100
 
 
78
  notif.innerHTML = `<i class="fas fa-info-circle"></i> <span>${text}</span>`;
79
  container.appendChild(notif);
80
 
81
+ // System Notification (more reliable via Service Worker)
82
  if ("Notification" in window && Notification.permission === "granted") {
83
+ navigator.serviceWorker.ready.then(registration => {
84
+ registration.showNotification("MAKER SPACE", {
85
+ body: text,
86
+ icon: "/static/assets/icon192x192.png",
87
+ vibrate: [200, 100, 200],
88
+ badge: "/static/assets/favicon.png"
89
+ });
90
  });
91
  }
92
 
 
96
  }, 5000);
97
  }
98
 
99
+ // Notification Permission with feedback
100
+ const notifBtn = document.getElementById('notif-btn');
101
+ notifBtn.addEventListener('click', () => {
102
  if ("Notification" in window) {
103
+ Notification.requestPermission().then(permission => {
104
+ if (permission === 'granted') {
105
+ notifBtn.style.color = '#10b981';
106
+ showNotification("Notificaciones activadas", "green");
107
+ } else if (permission === 'denied') {
108
+ notifBtn.style.color = '#ef4444';
109
+ alert("Has bloqueado las notificaciones. Actívalas en la configuración de tu navegador.");
110
+ }
111
+ });
112
  }
113
  });
114