oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1(function () {
2 "use strict";
3 var key = "equipo.chat.focus";
4 function place(raw) {
5 if (!raw) return null;
6 var url = new URL(raw, location.href);
7 return url.origin + url.pathname + url.search;
8 }
9 function skip(event, from, to) {
10 if (event.viewTransition && from && to && place(from) === place(to)) event.viewTransition.skipTransition();
11 }
12 window.addEventListener("pageswap", function (event) {
13 var activation = event.activation;
14 skip(event, location.href, activation && activation.entry && activation.entry.url);
15 });
16 window.addEventListener("pagereveal", function (event) {
17 var activation = window.navigation && navigation.activation;
18 skip(event, activation && activation.from && activation.from.url, location.href);
19 });
20 function focus() {
21 var input = document.getElementById("chat-body");
22 if (input) input.focus({ preventScroll: true });
23 }
24 try {
25 var destination = sessionStorage.getItem(key);
26 sessionStorage.removeItem(key);
27 if (destination === place(location.href)) window.addEventListener("pageshow", focus, { once: true });
28 } catch (_) { /* Focus still works for live submissions without storage. */ }
29 document.addEventListener("submit", function (event) {
30 if (!event.target.matches("[data-chat-submit]")) return;
31 try { sessionStorage.setItem(key, place(location.href)); } catch (_) { /* Storage may be disabled. */ }
32 focus();
33 }, true);
34})();
35