Skip to content

Commit

Permalink
feat: add captive portal info message
Browse files Browse the repository at this point in the history
  • Loading branch information
Tasssadar committed Nov 25, 2023
1 parent 786ab3a commit 3e0d911
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 4 deletions.
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"maintainer": true
}
],
"version": "5.0.0",
"version": "5.1.0",
"frameworks": ["espidf", "arduino"],
"platforms": "espressif32",
"dependencies": [
Expand Down
2 changes: 1 addition & 1 deletion src/gridui_version.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#pragma once

#define RB_GRIDUI_VERSION 0x050000
#define RB_GRIDUI_VERSION 0x050100
30 changes: 28 additions & 2 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
</style>
</head>

<body id="body">
<div id="log" class="log-short"></div>
<div id="main-ui">
<div id="log" class="log-short"></div>

<div id="grid"></div>
</div>

<div id="grid"></div>
<div id="captive-msg">
<h2>Grid UI controls</h2>
<p>The GridUI controls do not work well in this limited captive portal browser.</p>
<div style="margin: 16px">
<a id="captive-link">[ Open in browser ]</a>
</div>
<p><i>If the link above does not work, please open <b id="captive-url"></b> in your normal web browser.</i></p>
<div style="margin-top: 48px">
<a href="javascript:void(0)" onclick="closeCaptivePortalNotice();">Show the controls anyway</a>
</div>
</div>

<script src="combined.js"></script>
</body>
Expand Down
16 changes: 16 additions & 0 deletions web/js/99_footer.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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'
}

0 comments on commit 3e0d911

Please sign in to comment.