-- Reusable Hyperscript behaviours and helper functions for the site. -- Loaded from base.html before the Hyperscript runtime, so every behaviour -- defined here can be applied with _="install Name(...)" on any page. -- See HYPERSCRIPT_CONVENTIONS.md, section 4, before adding to this file. -- Copies text to the clipboard on click and confirms in a status element. behavior CopyToClipboard(text, status, doneLabel, resetAfter) init default text to my @data-copy default status to me default doneLabel to "Copied" default resetAfter to 2.4s set :idleLabel to the textContent of status end on click queue none set the clipboard to text put doneLabel into status add .is-done to me wait resetAfter put :idleLabel into status remove .is-done from me end on exception(error) put "Copy failed" into status end end -- Scales a fixed-width frame to fit its box by setting the ratio the CSS reads. def ui.fitFrame(box) set frame to the first