Improve compatibility with old browsers #136

Merged
seeseemelk merged 3 commits from improve-compat-with-old-browsers into main 2025-05-29 13:54:53 +02:00
3 changed files with 16 additions and 9 deletions
Showing only changes of commit 8d43f3828a - Show all commits

View File

@ -28,8 +28,13 @@ func loadWebEndpoints(router *gin.Engine) {
}
func redirectToPage(c *gin.Context, page string) {
redirectToPageStatus(c, page, http.StatusSeeOther)
}
func redirectToPageStatus(c *gin.Context, page string, status int) {
scheme := c.Request.URL.Scheme
c.Redirect(http.StatusSeeOther, scheme+domain+page)
target := scheme + domain + page
c.Redirect(status, target)
}
func renderLogin(c *gin.Context) {
@ -75,7 +80,7 @@ func renderCreateTask(c *gin.Context) {
return
}
c.Redirect(http.StatusFound, "/")
redirectToPageStatus(c, "/", http.StatusFound)
}
func renderCompleteTask(c *gin.Context) {
@ -92,7 +97,7 @@ func renderCompleteTask(c *gin.Context) {
return
}
c.Redirect(http.StatusFound, "/")
redirectToPageStatus(c, "/", http.StatusFound)
}
func renderCreateAllowance(c *gin.Context) {
@ -129,7 +134,7 @@ func renderCreateAllowance(c *gin.Context) {
return
}
c.Redirect(http.StatusFound, "/")
redirectToPageStatus(c, "/", http.StatusFound)
}
func renderCompleteAllowance(c *gin.Context) {
@ -151,7 +156,7 @@ func renderCompleteAllowance(c *gin.Context) {
return
}
c.Redirect(http.StatusFound, "/")
redirectToPageStatus(c, "/", http.StatusFound)
}
func getCurrentUser(c *gin.Context) *int {
@ -180,7 +185,7 @@ func getCurrentUser(c *gin.Context) *int {
func unsetUserCookie(c *gin.Context) {
c.SetCookie("user", "", -1, "/", "localhost", false, true)
c.Redirect(http.StatusFound, "/")
redirectToPageStatus(c, "/", http.StatusFound)
}
func renderNoUser(c *gin.Context) {

View File

@ -3,9 +3,11 @@
<head>
<title>Allowance Planner 2000</title>
<style>
<!--
tr:hover {
background-color: #f0f0f0;
}
-->
</style>
</head>
<body>
@ -27,7 +29,7 @@
{{if ne .CurrentUser 0}}
<h2>Allowances</h2>
<form action="/createAllowance" method="post">
<table border="1">
<table border=1>
<thead>
<tr>
<th>Name</th>
@ -43,7 +45,7 @@
<td></td>
<td><label><input type="number" name="target" placeholder="Target"></label></td>
<td><label><input type="number" name="weight" placeholder="Weight"></label></td>
<td><button>Create</button></td>
<td><input type="submit" value="Create"></td>
</tr>
{{range .Allowances}}
{{if eq .ID 0}}
@ -103,7 +105,7 @@
<td><label><input type="text" name="name" placeholder="Name"></label></td>
<td></td>
<td><label><input type="number" name="reward" placeholder="Reward"></label></td>
<td><button>Create</button></td>
<td><input type="submit" value="Create"></td>
</tr>
</tbody>
</table>