From e9e12f995195d4d1ba6209b109c9bc19a91822ce Mon Sep 17 00:00:00 2001 From: Robin5605 Date: Tue, 13 Jun 2023 22:44:55 -0500 Subject: [PATCH] Add copy URL button to view paste page --- src/asset/pinnwand.scss | 6 ++++-- src/pinnwand/static/pinnwand.css | 6 ++++-- src/pinnwand/static/pinnwand.js | 6 ++++++ src/pinnwand/template/show.html | 1 + 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/asset/pinnwand.scss b/src/asset/pinnwand.scss index a521a4d..ce1e155 100644 --- a/src/asset/pinnwand.scss +++ b/src/asset/pinnwand.scss @@ -151,7 +151,8 @@ section.paste-submit { } div.file-meta button, -section.paste-submit button { +section.paste-submit button, +.copyurl { box-sizing: border-box; border: .0625rem solid var(--color3); padding: .4rem 1.4rem; @@ -164,7 +165,8 @@ section.paste-submit button { } div.file-meta button:hover, -section.paste-submit button:hover { +section.paste-submit button:hover, +.copyurl:hover { color: var(--color3); background: var(--color1); border: .0625rem solid var(--color3); diff --git a/src/pinnwand/static/pinnwand.css b/src/pinnwand/static/pinnwand.css index 555cac3..8d20b13 100644 --- a/src/pinnwand/static/pinnwand.css +++ b/src/pinnwand/static/pinnwand.css @@ -121,7 +121,8 @@ section.paste-submit { padding: .5rem; } div.file-meta button, -section.paste-submit button { +section.paste-submit button, +.copyurl { box-sizing: border-box; border: 0.0625rem solid var(--color3); padding: .4rem 1.4rem; @@ -133,7 +134,8 @@ section.paste-submit button { text-align: center; } div.file-meta button:hover, -section.paste-submit button:hover { +section.paste-submit button:hover, +.copyurl:hover { color: var(--color3); background: var(--color1); border: 0.0625rem solid var(--color3); } diff --git a/src/pinnwand/static/pinnwand.js b/src/pinnwand/static/pinnwand.js index fac5fba..a45fa3b 100644 --- a/src/pinnwand/static/pinnwand.js +++ b/src/pinnwand/static/pinnwand.js @@ -167,6 +167,12 @@ function setupShowPage() { }); }; + let shareButton = document.getElementById("copyurl-btn"); + + shareButton.addEventListener("click", function(event) { + navigator.clipboard.writeText(window.location.href); + }); + return false; } diff --git a/src/pinnwand/template/show.html b/src/pinnwand/template/show.html index 117757a..da9eb11 100644 --- a/src/pinnwand/template/show.html +++ b/src/pinnwand/template/show.html @@ -36,6 +36,7 @@ Report this file. {% end %} + {% end %}