From 3e0d91137affcc4f10af671cf12930abae6d52e8 Mon Sep 17 00:00:00 2001 From: Vojtech Bocek Date: Sat, 25 Nov 2023 09:59:22 +0100 Subject: [PATCH] feat: add captive portal info message --- library.json | 2 +- src/gridui_version.h | 2 +- web/index.html | 30 ++++++++++++++++++++++++++++-- web/js/99_footer.js | 16 ++++++++++++++++ 4 files changed, 46 insertions(+), 4 deletions(-) diff --git a/library.json b/library.json index 87bfaf66..6178106e 100644 --- a/library.json +++ b/library.json @@ -14,7 +14,7 @@ "maintainer": true } ], - "version": "5.0.0", + "version": "5.1.0", "frameworks": ["espidf", "arduino"], "platforms": "espressif32", "dependencies": [ diff --git a/src/gridui_version.h b/src/gridui_version.h index 128ddf67..86e7c7ea 100644 --- a/src/gridui_version.h +++ b/src/gridui_version.h @@ -1,3 +1,3 @@ #pragma once -#define RB_GRIDUI_VERSION 0x050000 +#define RB_GRIDUI_VERSION 0x050100 diff --git a/web/index.html b/web/index.html index 506e7771..1161693c 100644 --- a/web/index.html +++ b/web/index.html @@ -48,13 +48,39 @@ left: 0px; right: 0px; } + + #captive-msg { + display: none; + margin: auto; + text-align: center; + padding: 16px; + } + + #captive-link { + padding: 5px; + font-size: larger; + } -
+
+
+ +
+
-
+
+

Grid UI controls

+

The GridUI controls do not work well in this limited captive portal browser.

+
+ [ Open in browser ] +
+

If the link above does not work, please open in your normal web browser.

+
+ Show the controls anyway +
+
diff --git a/web/js/99_footer.js b/web/js/99_footer.js index db47cb8f..81f712e1 100644 --- a/web/js/99_footer.js +++ b/web/js/99_footer.js @@ -1,4 +1,15 @@ window.addEventListener('load', function () { + // Detect captive portal and show message + var ua = window.navigator.userAgent; + if(ua.indexOf("; wv)") !== -1 && ua.indexOf("Chrome/") !== -1 && ua.indexOf("Version/") !== -1 && ua.indexOf("Android") !== -1) { + document.getElementById("main-ui").style.display = "none"; + document.getElementById("captive-msg").style.display = "block"; + + document.getElementById("captive-url").innerText = window.location.origin; + document.getElementById("captive-link").href = "intent://" + window.location.hostname + "#Intent;scheme=http;end"; + return; + } + var man = new Manager('log', 'grid') // Detect whether we're running in RBController or just web browser @@ -8,3 +19,8 @@ window.addEventListener('load', function () { man.start('ws://' + window.location.host, true) } }) + +function closeCaptivePortalNotice() { + document.getElementById('main-ui').style.display = "block"; + document.getElementById('captive-msg').style.display = 'none' +}