fixed date in meta copy, clean up some text

This commit is contained in:
Jacob Haddon 2024-03-17 11:30:26 -04:00
parent d5361e391e
commit ccde468e88

View File

@ -36,7 +36,7 @@ this file uses:
<script src="jquery-3.7.1.min.js"></script> <script src="jquery-3.7.1.min.js"></script>
<script src="html2canvas.min.js"></script> <script src="html2canvas.min.js"></script>
<script src="FileSaver.min.js"></script> <script src="FileSaver.min.js"></script>
<script src="test3.js"></script> <script src="test5.js"></script>
<script> <script>
@ -44,11 +44,36 @@ this file uses:
// console.log(book.pages[14][6]); // console.log(book.pages[14][6]);
$(document).ready(function(){ $(document).ready(function(){
// get today and format
const today = new Date(Date.now());
let day = today.getDate();
let formattedday = day.toLocaleString('en-US', {
minimumIntegerDigits: 2,
useGrouping: false
});
let month = today.getMonth() + 1;
let formattedmonth = month.toLocaleString('en-US', {
minimumIntegerDigits: 2,
useGrouping: false
});
let year = today.getFullYear();
// console.log(day);
// console.log(formattedmonth);
// make the date string match the book.json file
let todayString = year + "-" + formattedmonth + "-" + formattedday;
// console.log(todayString);
//
// console.log(book[todayString]);
// Make the header with the book info // Make the header with the book info
$("#poem_header").html("<h2>" + book.title + "</h2>\n\n<h3>" + book.author + "</h3>\n"); $("#poem_header").html("<h2>" + book[todayString].title + "</h2>\n\n<h3>" + book[todayString].author + "</h3>\n");
// Add in the page, change the underscores to italics // Add in the page, change the underscores to italics
$("#spina").html(book.pages[14][6].replace(/(_([a-z0-9]+)_)/ig, "<i>$2</i>")); // $("#spina").html(book.pages[14][6].replace(/(_([a-z0-9]+)_)/ig, "<i>$2</i>"));
$("#spina").html(book[todayString].page.replace(/(_([a-z0-9]+)_)/ig, "<i>$2</i>"));
// format the text with span tags // format the text with span tags
$("#spina p").each(function( index ) { $("#spina p").each(function( index ) {
@ -98,7 +123,7 @@ $(document).ready(function(){
todayFormatted = today.toString(); todayFormatted = today.toString();
// add the byline // add the byline
$("#byline").html("<p>blackout poem inspired by " + book.title + " by " + book.author + "</p><p>composed on: " + todayFormatted) + "</p>"; $("#byline").html("<p>blackout poem inspired by " + book[todayString].title + " by " + book[todayString].author + "</p><p>composed on: " + todayFormatted) + "</p>";
// toggle the text on the button // toggle the text on the button
$(this).text(function(i, text) { $(this).text(function(i, text) {
@ -133,7 +158,7 @@ $(document).ready(function(){
todayFormatted = today.toString(); todayFormatted = today.toString();
// add the meta to the copyed text // add the meta to the copyed text
var poem_meta = "#dailyBlackoutPoetryChallenge\n\n" + $("#poem_list").text() + "\n\n" + book.title + " - " + todayFormatted; var poem_meta = "#dailyBlackoutPoetryChallenge\n\n" + $("#poem_list").text() + "\n\n" + book[todayString].title + " - " + todayFormatted;
navigator.clipboard.writeText(poem_meta); navigator.clipboard.writeText(poem_meta);
}); // copy text w/meta }); // copy text w/meta
@ -162,7 +187,7 @@ $(document).ready(function(){
<header> <header>
<h1>Daily <span class="purple">Blackout</span> Poetry Challenge</h1> <h1>Daily <span class="purple">Blackout</span> Poetry Challenge</h1>
<p>Your daily blackout poetry challenge! Make a poem, save the poem, share the poem! (Tag the poem: #dailyBlackoutPoetryChallenge)</p> <p>Your daily blackout poetry challenge! Make a poem, save the poem, share the poem!</p><p>Tag the poem: #dailyBlackoutPoetryChallenge</p>
<p>Click on a word to select it, click on it again to unselect. When youve found your poem hit Blackout! Get a screen shot and copy the words below!</p> <p>Click on a word to select it, click on it again to unselect. When youve found your poem hit Blackout! Get a screen shot and copy the words below!</p>
</header> </header>