blob: 21f431a769748e660b84d153bc5fd0210529e1ae (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
package main
templ headerJS() {
<script src="/static/js/alpine.js" defer></script>
<script src="/static/js/md5.min.js" defer></script>
<script>
document.addEventListener("alpine:init", () => {
Alpine.data("azurda", () => ({
str: "", // The input string
md5: "", // md5 hash of the string
url: "/static/img/azurda.png", // image for user
md5sum() {
return new Promise((resolve) => {
this.md5 = md5(this.str);
this.url = `https://cdn.xeiaso.net/avatar/${this.md5}`;
resolve(this.md5);
});
},
}));
});
</script>
}
templ body() {
<p>Type in some text and get a randomly generated avatar!</p>
<div x-data="azurda">
<input
@input.debounce.500ms="md5sum().then((hash) => console.log(hash))"
type="text"
x-model="str"
/>
<br/>
<img
style="margin-top: 2rem"
x-bind:src="url"
alt="Azurda"
width="256px"
/>
</div>
}
templ footer() {
<p>
From <a href="https://within.website">Within</a> with ❤️ -
<a href="">Source code</a>
</p>
}
|