pwa: remove floating install-app button

- drop beforeinstallprompt handler + .mu-install-btn markup from ui/pwa.js
- remove .mu-install-btn styles from _shared.css
- drop unused pwa.install i18n key (th/en)
- SW registration/auto-update untouched; VERSION 2026.09.27.107
This commit is contained in:
Bkk1234 committed 2026-11-03 00:20:30 +07:00
1 parent 4acb43ff45
commit 449afb923a
6 files changed
+8 -73

No files matched your search

+2 -40
View File
@@ -12,46 +12,8 @@
var CHECK_INTERVAL_MS = 30 * 60 * 1000; // ตรวจอัปเดตทุก 30 นาที
/* ---- ปุ่มติดตั้งแอป (ก่อน install prompt) ---- */
var deferredPrompt = null;
var installBtn = null;
function makeInstallBtn() {
var btn = document.createElement("button");
btn.type = "button";
btn.className = "mu-install-btn";
btn.innerHTML = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><path d="m7 10 5 5 5-5"/><path d="M12 15V3"/></svg> ' + ((window.I18N && I18N.t) ? I18N.t('pwa.install') : 'ติดตั้งแอป');
btn.addEventListener("click", function () {
if (!deferredPrompt) return;
deferredPrompt.prompt();
deferredPrompt.userChoice.then(function () {
deferredPrompt = null;
if (installBtn) installBtn.style.display = "none";
});
});
document.body.appendChild(btn);
/* เปลี่ยนภาษาแล้ว → อัปเดตข้อความบนปุ่ม */
window.addEventListener('langchange', function () {
if (!installBtn) return;
var svg = installBtn.querySelector('svg');
installBtn.textContent = '';
if (svg) installBtn.appendChild(svg);
installBtn.appendChild(document.createTextNode(
(window.I18N && I18N.t) ? I18N.t('pwa.install') : 'ติดตั้งแอป'));
});
return btn;
}
window.addEventListener("beforeinstallprompt", function (e) {
e.preventDefault();
deferredPrompt = e;
if (!installBtn) installBtn = makeInstallBtn();
installBtn.style.display = "inline-flex";
});
window.addEventListener("appinstalled", function () {
if (installBtn) installBtn.style.display = "none";
});
/* หมายเหตุ: ไม่มีปุ่ม "ติดตั้งแอป" ลอยมุมขวาล่างแล้ว
(ตั้งใจเอาออก — Chrome จะโชว์ไอคอนติดตั้งของเบราว์เซอร์เองตามปกติ) */
window.addEventListener("load", function () {
navigator.serviceWorker