From ce1fdb09648e8aa07a635a0c4b5f08bd7906b801 Mon Sep 17 00:00:00 2001 From: Adam Ross <14985050+R055A@users.noreply.github.com> Date: Tue, 3 Oct 2023 22:01:24 +0200 Subject: [PATCH 1/5] Add demo clipboard view toggle between when type is set to JSON and when not when set to JSON, markdown and HTML clipboards not visible and disabled when not set to JSON, JSON clipboard not visible and disabled --- src/demo/index.php | 11 +++++++++++ src/demo/js/script.js | 13 +++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/demo/index.php b/src/demo/index.php index a168c0bf..4da301c3 100644 --- a/src/demo/index.php +++ b/src/demo/index.php @@ -245,6 +245,17 @@ function gtag() { Copy To Clipboard + +
+

JSON

+
+ +
+ + +
diff --git a/src/demo/js/script.js b/src/demo/js/script.js index 903f9d9f..e351bf10 100644 --- a/src/demo/js/script.js +++ b/src/demo/js/script.js @@ -47,17 +47,22 @@ const preview = { document.querySelector(".output img").src = demoImageURL; document.querySelector(".md code").innerText = md; document.querySelector(".html code").innerText = html; + document.querySelector(".copy-md").style.display = "block"; + document.querySelector(".copy-html").style.display = "block"; document.querySelector(".output img").style.display = "block"; document.querySelector(".output .json").style.display = "none"; + document.querySelector(".copy-json").style.display = "none"; } else { - document.querySelector(".output img").style.display = "none"; - document.querySelector(".output .json").style.display = "block"; fetch(demoImageURL) .then((response) => response.json()) .then((data) => (document.querySelector(".output .json pre").innerText = JSON.stringify(data, null, 2))) .catch(console.error); - document.querySelector(".md code").innerText = imageURL; - document.querySelector(".html code").innerText = imageURL; + document.querySelector(".json code").innerText = imageURL; + document.querySelector(".copy-md").style.display = "none"; + document.querySelector(".copy-html").style.display = "none"; + document.querySelector(".output img").style.display = "none"; + document.querySelector(".output .json").style.display = "block"; + document.querySelector(".copy-json").style.display = "block"; } // disable copy button if username is invalid const copyButtons = document.querySelectorAll(".copy-button"); From 2b367e917c40553d7f987808851473c896e0ef54 Mon Sep 17 00:00:00 2001 From: Adam Ross <14985050+R055A@users.noreply.github.com> Date: Tue, 3 Oct 2023 23:05:08 +0200 Subject: [PATCH 2/5] Update src/demo/js/script.js Co-authored-by: Jonah Lawrence --- src/demo/js/script.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/demo/js/script.js b/src/demo/js/script.js index e351bf10..914b9f88 100644 --- a/src/demo/js/script.js +++ b/src/demo/js/script.js @@ -47,8 +47,8 @@ const preview = { document.querySelector(".output img").src = demoImageURL; document.querySelector(".md code").innerText = md; document.querySelector(".html code").innerText = html; - document.querySelector(".copy-md").style.display = "block"; - document.querySelector(".copy-html").style.display = "block"; + document.querySelector(".copy-md").parentElement.style.display = "block"; + document.querySelector(".copy-html").parentElement.style.display = "block"; document.querySelector(".output img").style.display = "block"; document.querySelector(".output .json").style.display = "none"; document.querySelector(".copy-json").style.display = "none"; From 71116d9bfbd9be98e96ab94e3ea69534e6e97284 Mon Sep 17 00:00:00 2001 From: Adam Ross <14985050+R055A@users.noreply.github.com> Date: Tue, 3 Oct 2023 23:05:19 +0200 Subject: [PATCH 3/5] Update src/demo/js/script.js Co-authored-by: Jonah Lawrence --- src/demo/js/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/demo/js/script.js b/src/demo/js/script.js index 914b9f88..4a8d63ac 100644 --- a/src/demo/js/script.js +++ b/src/demo/js/script.js @@ -51,7 +51,7 @@ const preview = { document.querySelector(".copy-html").parentElement.style.display = "block"; document.querySelector(".output img").style.display = "block"; document.querySelector(".output .json").style.display = "none"; - document.querySelector(".copy-json").style.display = "none"; + document.querySelector(".copy-json").parentElement.style.display = "none"; } else { fetch(demoImageURL) .then((response) => response.json()) From 19d1b33b201ff220019a8523bbc6140389381bc6 Mon Sep 17 00:00:00 2001 From: Adam Ross <14985050+R055A@users.noreply.github.com> Date: Tue, 3 Oct 2023 23:05:30 +0200 Subject: [PATCH 4/5] Update src/demo/js/script.js Co-authored-by: Jonah Lawrence --- src/demo/js/script.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/demo/js/script.js b/src/demo/js/script.js index 4a8d63ac..4733222b 100644 --- a/src/demo/js/script.js +++ b/src/demo/js/script.js @@ -58,11 +58,11 @@ const preview = { .then((data) => (document.querySelector(".output .json pre").innerText = JSON.stringify(data, null, 2))) .catch(console.error); document.querySelector(".json code").innerText = imageURL; - document.querySelector(".copy-md").style.display = "none"; - document.querySelector(".copy-html").style.display = "none"; + document.querySelector(".copy-md").parentElement.style.display = "none"; + document.querySelector(".copy-html").parentElement.style.display = "none"; document.querySelector(".output img").style.display = "none"; document.querySelector(".output .json").style.display = "block"; - document.querySelector(".copy-json").style.display = "block"; + document.querySelector(".copy-json").parentElement.style.display = "block"; } // disable copy button if username is invalid const copyButtons = document.querySelectorAll(".copy-button"); From 94b53055346766d3b8e456b54bb5b130c201cebd Mon Sep 17 00:00:00 2001 From: Adam Ross <14985050+R055A@users.noreply.github.com> Date: Wed, 4 Oct 2023 13:41:25 +0200 Subject: [PATCH 5/5] Fix demo clipboard copy to json --- src/demo/js/script.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/demo/js/script.js b/src/demo/js/script.js index 4733222b..00044a79 100644 --- a/src/demo/js/script.js +++ b/src/demo/js/script.js @@ -393,6 +393,8 @@ const clipboard = { input.value = document.querySelector(".md code").innerText; } else if (el.classList.contains("copy-html")) { input.value = document.querySelector(".html code").innerText; + } else if (el.classList.contains("copy-json")) { + input.value = document.querySelector(".json code").innerText; } document.body.appendChild(input); // select all pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy