Only auto refresh when at top of page

pull/320/head
Andrew Godwin 2022-12-29 13:23:47 -07:00
rodzic 9c3806a175
commit eb7297d743
3 zmienionych plików z 5 dodań i 10 usunięć

Wyświetl plik

@ -1,8 +0,0 @@
function identicon(t,e=50,i=50){const n=t.split("").reduce(((t,e)=>16777619*((t^e.charCodeAt(0))>>>0)),2166136261);const s=n/16777619%18*20;return[...Array(t?25:0)].reduce(((t,e,i)=>n%(16-i%15)<4?t+`<rect x="${i>14?7-~~(i/5):~~(i/5)}" y="${i%5}" width="1" height="1"/>`:t),`<svg viewBox="-1.5 -1.5 8 8" xmlns="http://www.w3.org/2000/svg" fill="hsl(${s} ${e}% ${i}%)">`)+"</svg>"}
function generate_avatar(handle) {
element.src = URL.createObjectURL(
new Blob([identicon(handle)], {
type: 'image/svg+xml;charset=utf8'
}
));
}

3
static/js/takahe.min.js vendored 100644
Wyświetl plik

@ -0,0 +1,3 @@
function identicon(e,t=50,_=50){let c=e.split("").reduce((e,t)=>16777619*((e^t.charCodeAt(0))>>>0),2166136261);return[...Array(e?25:0)].reduce((e,t,_)=>c%(16-_%15)<4?e+`<rect x="${_>14?7-~~(_/5):~~(_/5)}" y="${_%5}" width="1" height="1"/>`:e,`<svg viewBox="-1.5 -1.5 8 8" xmlns="http://www.w3.org/2000/svg" fill="hsl(${c/16777619%18*20} ${t}% ${_}%)">`)+"</svg>"}
function generate_avatar(e){element.src=URL.createObjectURL(new Blob([identicon(e)],{type:"image/svg+xml;charset=utf8"}))}
function isAtTopOfPage(){return document.documentElement.scrollTop<30}

Wyświetl plik

@ -12,7 +12,7 @@
<link rel="shortcut icon" href="{{ config.site_icon }}">
<script src="{% static "js/hyperscript.min.js" %}"></script>
<script src="{% static "js/htmx.min.js" %}"></script>
<script src="{% static "js/minidenticons.min.js" %}"></script>
<script src="{% static "js/takahe.min.js" %}"></script>
<style>
body {
--color-highlight: {{ config.highlight_color }};
@ -50,7 +50,7 @@
<i class="fa-solid fa-search"></i>
</a>
{% if allows_refresh %}
<a href="." title="Refresh" role="menuitem" hx-get="." hx-select=".left-column" hx-target=".left-column" hx-swap="outerHTML" hx-trigger="click, every 120s">
<a href="." title="Refresh" role="menuitem" hx-get="." hx-select=".left-column" hx-target=".left-column" hx-swap="outerHTML" hx-trigger="click, every 120s[isAtTopOfPage()]">
<i class="fa-solid fa-rotate"></i>
</a>
{% endif %}