2023-10-07 17:12:47 +01:00
|
|
|
package server
|
|
|
|
|
|
|
|
import "html/template"
|
|
|
|
|
|
|
|
var home = template.Must(template.New("home").Parse(`
|
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
2024-05-04 14:01:35 +01:00
|
|
|
<link rel="stylesheet" href="https://cdn.simplecss.org/simple.min.css">
|
|
|
|
<script src="https://unpkg.com/htmx.org@1.9.12"></script>
|
|
|
|
<style>
|
|
|
|
div.center {
|
|
|
|
text-align: center;
|
|
|
|
}
|
|
|
|
|
|
|
|
div#results {
|
|
|
|
height: 60dvh;
|
|
|
|
}
|
|
|
|
|
|
|
|
div#results > ul {
|
|
|
|
list-style-type: none;
|
|
|
|
overflow-y: auto;
|
|
|
|
height: 100%;
|
|
|
|
}
|
|
|
|
</style>
|
2023-10-07 17:12:47 +01:00
|
|
|
<title>Anagram and Word Search</title>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<header>
|
|
|
|
<h1>Anagram and Word Search</h1>
|
|
|
|
</header>
|
|
|
|
|
|
|
|
<main>
|
2024-05-04 14:01:35 +01:00
|
|
|
<form action="/search" method="post" hx-boost="true" hx-target="#results" hx-push-url="false">
|
2023-10-07 17:12:47 +01:00
|
|
|
<div class="center">
|
2024-04-20 16:04:32 +01:00
|
|
|
<input id="pattern" type="text" name="pattern" required autofocus></input>
|
2023-10-07 17:12:47 +01:00
|
|
|
<button name="mode" value="match">Match</button>
|
|
|
|
<button name="mode" value="anagrams">Anagrams</button>
|
2024-04-20 16:04:32 +01:00
|
|
|
<button type="reset" onclick="getfocus()">Clear</button>
|
2023-10-07 17:12:47 +01:00
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
<div id="results">
|
|
|
|
</div>
|
|
|
|
</main>
|
|
|
|
|
|
|
|
</body>
|
2024-04-20 16:04:32 +01:00
|
|
|
<script>
|
|
|
|
function getfocus() {
|
|
|
|
document.getElementById("pattern").focus();
|
|
|
|
}
|
|
|
|
</script>
|
2023-10-07 17:12:47 +01:00
|
|
|
</html>
|
|
|
|
`))
|
|
|
|
|
2023-10-07 18:05:05 +01:00
|
|
|
type ResultParams struct {
|
|
|
|
Preamble string
|
|
|
|
Results []string
|
|
|
|
}
|
|
|
|
|
2023-10-07 17:12:47 +01:00
|
|
|
var results = template.Must(template.New("results").Parse(`
|
|
|
|
{{ with .Preamble }}
|
|
|
|
<p>{{ . }}</p>
|
|
|
|
{{ end }}
|
|
|
|
<ul>
|
|
|
|
{{ range .Results }}
|
2024-05-04 14:01:35 +01:00
|
|
|
<li>
|
|
|
|
<a href="https://dicoweb.gnu.org.ua/?q={{.}}&db=gcide&define=1" target="defn">{{.}}</a>
|
2024-04-20 14:40:00 +01:00
|
|
|
</li>
|
2023-10-07 17:12:47 +01:00
|
|
|
{{ end }}
|
|
|
|
</ul>
|
|
|
|
`))
|