From ea194b4cad05f003b7bad5e7e5f059d745c64995 Mon Sep 17 00:00:00 2001 From: sanine Date: Mon, 18 Sep 2023 05:25:43 +0000 Subject: add link copying --- yarrow-ui.cgi | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'yarrow-ui.cgi') diff --git a/yarrow-ui.cgi b/yarrow-ui.cgi index 9a1d134..fffa653 100755 --- a/yarrow-ui.cgi +++ b/yarrow-ui.cgi @@ -163,6 +163,22 @@ local head = h('head', { h('meta', { name='viewport', content='width=device-width, initial-scale=1' }), h('title', 'yarrow config'), h('link', { rel='stylesheet', href='style.css' }), + h('script', string.format([[ + window.onload = () => { + const link = document.getElementById('permalink'); + const br = document.createElement('br'); + + const button = document.createElement('button'); + button.textContent = 'copy link'; + button.addEventListener('click', () => { + navigator.clipboard.writeText('%s'); + button.textContent = 'copied!'; + setTimeout(() => button.textContent = 'copy link', 1000); + }); + + link.after(br, button); + }; + ]], 'https://sanine.net/utils/yarrow/yarrow.cgi?statistics='..b64.encode(convert(stat))), { type='text/javascript' }), }) -- cgit v1.2.1