Skip to content

Commit

Permalink
Improve clipboard content
Browse files Browse the repository at this point in the history
Things added:
1. chapter, verse number
2. both text and transliteration
3. url dump
  • Loading branch information
rtshkmr committed Dec 29, 2023
1 parent d25475f commit 69da68f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions assets/js/hooks/share_quote.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,15 @@ ShareQuoteButton = {
};
} else if ("clipboard" in navigator) { // copies to clipboard:
callback = () => {
const verse = JSON.parse(this.el.getAttribute("data-verse"));
navigator.clipboard.writeText(verse.text);
const {
chapter_number: chapterNum,
verse_number: verseNum,
transliteration,
text,
} = JSON.parse(this.el.getAttribute("data-verse"));

const content = `[Gita Chapter ${chapterNum} Verse ${verseNum}] \n${text}\n${transliteration}\nRead more at ${document.URL}`
navigator.clipboard.writeText(content);
};
}

Expand Down

0 comments on commit 69da68f

Please sign in to comment.