Tweet button under Gita shlok generator does not paste correct text on Twitter
Closes: #1545
Description
The initial problem was that when the page renders and the first shlok shows up, upon clicking the tweet button, we'd be redirected to Twitter but the quote and author would be empty.
Upon going through the code, I saw we're using inner HTML actions such as onclick directly within the necessary tags. In the tweet button, we're calling the tweetQuote function but when the javascript file is loaded, we've initialized the quote and author to be empty. This is why when we want to tweet the first quote, the initial quote is empty on thw twitter prompt.
The fix for this was to simply initialize the quote and author with the same as the one being loaded in the HTML initially. Along with this, I also added a check in the genQuote function to prevent repeating of the same quote. One thing to note is that some quotes are repeated in the array itself. Other than that, the same quote shouldn't render.
Screenshots
1. First quote:
2. After pressing the tweet button:
Checklist
[x] My code adheres to the established style guidelines of the project.
[x] I have included comments in areas that may be difficult to understand.
[x] My changes have not introduced any new warnings.
Tweet button under Gita shlok generator does not paste correct text on Twitter
Closes: #1545
Description
The initial problem was that when the page renders and the first shlok shows up, upon clicking the tweet button, we'd be redirected to Twitter but the quote and author would be empty.
Upon going through the code, I saw we're using inner HTML actions such as onclick directly within the necessary tags. In the tweet button, we're calling the tweetQuote function but when the javascript file is loaded, we've initialized the quote and author to be empty. This is why when we want to tweet the first quote, the initial quote is empty on thw twitter prompt.
The fix for this was to simply initialize the quote and author with the same as the one being loaded in the HTML initially. Along with this, I also added a check in the genQuote function to prevent repeating of the same quote. One thing to note is that some quotes are repeated in the array itself. Other than that, the same quote shouldn't render.
Screenshots
1. First quote:
2. After pressing the tweet button:
Checklist