From dd1083663fd14337d7e735d09bd508780ca5010e Mon Sep 17 00:00:00 2001 From: Michael Nolan Date: Sat, 11 Nov 2023 10:20:58 -0600 Subject: [PATCH] Add printable add menu --- BibleServerCli/data/www/chapter/index.html | 20 ++++- BibleServerCli/data/www/printable/index.html | 91 ++++++++++++++++---- 2 files changed, 95 insertions(+), 16 deletions(-) diff --git a/BibleServerCli/data/www/chapter/index.html b/BibleServerCli/data/www/chapter/index.html index 4489767..6be9069 100644 --- a/BibleServerCli/data/www/chapter/index.html +++ b/BibleServerCli/data/www/chapter/index.html @@ -111,8 +111,17 @@ }); }); } + function inIframe () { + try { + return window.self !== window.top ? 1 : 0; + } catch (e) { + return 2; + } + } + function generate_verse_element(element,bible,book,chapter,i) { + const isiniframe = inIframe(); /*

@@ -153,7 +162,7 @@ var card_footer_item = document.createElement('p'); card_footer_item.classList.add('card-footer-item'); var card_footer_link = document.createElement('a'); - card_footer_link.innerText= "Copy Link"; + card_footer_link.innerText= isiniframe === 0 ? "Copy Link" : isiniframe === 1 ? "Add" : "Set"; card_footer_link.classList.add('button'); card_footer_link.classList.add('is-primary'); card_footer_link.classList.add('is_light'); @@ -161,10 +170,19 @@ const myUrl = new URL(window.location.href); myUrl.hash = `#verse-${i}`; card_footer_link.href = myUrl.toString(); + if(isiniframe !== 2) + { card_footer_link.onclick = (e)=>{ + e.preventDefault(); + if(isiniframe ===1) + { + window.addVerse(myUrl.toString()); + }else{ navigator.clipboard.writeText(myUrl.toString()); + } }; + } card_footer_item.appendChild(card_footer_link); card_footer.appendChild(card_footer_item); card.appendChild(card_footer); diff --git a/BibleServerCli/data/www/printable/index.html b/BibleServerCli/data/www/printable/index.html index 80f3aac..71e1725 100644 --- a/BibleServerCli/data/www/printable/index.html +++ b/BibleServerCli/data/www/printable/index.html @@ -9,35 +9,49 @@

- + - + +

NOTE: Print in context menu does not work, use either the Print button on the page, CTRL+P or Command+P

+

\ No newline at end of file