Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using named cookies to get a correct redirect #1492

Merged
merged 4 commits into from
Dec 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions sd-card/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,22 @@
el.style.visibility = 'visible';
});
}

function getCookie(cname) {
let name = cname + "=";
let decodedCookie = decodeURIComponent(document.cookie);
let ca = decodedCookie.split(';');
for(let i = 0; i <ca.length; i++) {
let c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
</script>

</head>
Expand Down Expand Up @@ -88,11 +104,11 @@ <h2>An ESP32 all inclusive neural network recognition system for meter digitaliz
LoadFwVersion();
LoadWebUiVersion();

if (document.cookie == "" || document.cookie == "reboot_page.html") {
document.cookie = "overview.html";
if (getCookie("page") == "" || getCookie("page") == "reboot_page.html") {
document.cookie = "page=overview.html";
}
console.log("Loading page: " + document.cookie);
document.getElementById('maincontent').src = document.cookie;
console.log("Loading page: " + getCookie("page"));
document.getElementById('maincontent').src = getCookie("page");
</script>

</div>
Expand Down
2 changes: 1 addition & 1 deletion sd-card/html/ota_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ <h3><span id="status">Status: idle</span> <span id="progress"></span></h3>
document.getElementById("status").innerText = "Status: Update completed!";
document.getElementById("doUpdate").disabled = true;
document.getElementById("newfile").disabled = false;
document.cookie = "overview.html"; // Make sure after the reboot we go to the overview page
document.cookie = "page=overview.html"; // Make sure after the reboot we go to the overview page

if (xhttp.responseText.startsWith("reboot"))
{
Expand Down