boot.js 1.2 KB

123456789101112131415161718192021222324252627
  1. // Set <html lang> before first paint from the saved choice, so the
  2. // browser does not read the static lang="en" and offer to translate a
  3. // page that is about to render in another language (#666).
  4. (function () {
  5. try {
  6. var l = localStorage.getItem('netpulse-lang')
  7. if (!l || l === 'auto') l = navigator.language || 'en'
  8. l = l.slice(0, 2).toLowerCase()
  9. document.documentElement.lang = l === 'zh' ? 'zh-CN' : l === 'es' ? 'es' : 'en'
  10. } catch (e) {}
  11. })()
  12. // Red de seguridad (bug pantalla negra tras update): si el bundle no
  13. // carga, #root queda vacío (el splash CSS pinta negro). Tras 8 s se
  14. // recarga UNA vez (guard en sessionStorage evita bucles); si vuelve a
  15. // fallar, mensaje en vez de recargar.
  16. window.setTimeout(function () {
  17. var r = document.getElementById('root')
  18. if (!r || r.childElementCount > 0) { sessionStorage.removeItem('np-blank'); return }
  19. if (!sessionStorage.getItem('np-blank')) {
  20. sessionStorage.setItem('np-blank', '1')
  21. location.reload()
  22. } else {
  23. r.textContent = 'La app no pudo cargar (¿actualización en curso?). Recarga la página.'
  24. r.style.cssText = 'padding:2rem;text-align:center;color:#98a2b3;font-family:Inter,system-ui,sans-serif;font-size:14px'
  25. }
  26. }, 8000)