Download this file
| 1 | // A task's "From your conversation, 18:39" link opens the conversation |
| 2 | // at that message (/conversation?message=<id>#m-<id>): it is scrolled to |
| 3 | // the middle of the feed and highlighted for a moment. The server has |
| 4 | // already loaded the history back to it. |
| 5 | (function () { |
| 6 | "use strict"; |
| 7 | var m = /^#(m|card)-(.+)$/.exec(location.hash); |
| 8 | if (!m) return; |
| 9 | var id = decodeURIComponent(m[2]); |
| 10 | function show() { |
| 11 | var el = [].find.call(document.querySelectorAll(m[1] === "card" ? "[data-card]" : "[data-message]"), function (e) { return e.getAttribute(m[1] === "card" ? "data-card" : "data-message") === id; }); |
| 12 | if (!el) return; |
| 13 | var scroll = el.closest("[equipo-scroll]"); |
| 14 | if (scroll) { |
| 15 | scroll.scrollTop += el.getBoundingClientRect().top - scroll.getBoundingClientRect().top - Math.max(0, (scroll.clientHeight - el.offsetHeight) / 2); |
| 16 | scroll.dispatchEvent(new Event("scroll")); |
| 17 | } else { |
| 18 | el.scrollIntoView({ block: "center" }); |
| 19 | } |
| 20 | el.setAttribute("data-highlight", ""); |
| 21 | setTimeout(function () { el.removeAttribute("data-highlight"); }, 4000); |
| 22 | } |
| 23 | if (document.readyState === "complete") show(); |
| 24 | else window.addEventListener("load", show, { once: true }); |
| 25 | })(); |
| 26 | |