From 46c8f6e77b74c97993414af1c3a3a8a047414baf Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Sun, 3 Jan 2021 12:20:15 -0500 Subject: Add clipboard sharing (#3330) When the discussion #3327 started, I thought that the clipboard share is a good idea. It never occurred to me because I do not use a smartphone. It might need some polishing but it seems pretty usable as-is. See #3327 --- p/scripts/main.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'p/scripts') diff --git a/p/scripts/main.js b/p/scripts/main.js index 1a3b02c2a..f8d20a622 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -946,7 +946,7 @@ function init_stream(stream) { return true; } - el = ev.target.closest('.item.share > a[href="#"]'); + el = ev.target.closest('.item.share > a[data-type="print"]'); if (el) { //Print const tmp_window = window.open(); for (var i = 0; i < document.styleSheets.length; i++) { @@ -960,6 +960,12 @@ function init_stream(stream) { return false; } + el = ev.target.closest('.item.share > a[data-type="clipboard"]'); + if (el && navigator.clipboard) { //Clipboard + navigator.clipboard.writeText(el.href); + return false; + } + el = ev.target.closest('.item.share > a[href="POST"]'); if (el) { //Share by POST const f = el.parentElement.querySelector('form'); -- cgit v1.2.3