Guest User

Pastebin for Calendar and Instructions

a guest
Jul 1st, 2025
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.98 KB | None | 0 0
  1. Be sure the calendar things are within a folder in this structure, or prepare to rewrite the link refs.
  2. Or you can download all files as a zip here: https://files.catbox.moe/ef67y1.zip and open with liveserver in VSCode to see
  3.  
  4.  
  5. [public]
  6. [calendar]
  7. [stickers]
  8. golden lotus.png
  9. pink lotus.png
  10. ...
  11. calendar.html
  12. calendar.css
  13. calendar.js
  14. stickers.js
  15. index.html
  16. --------------------------------------------------------------------
  17. calendar.css: https://pastebin.com/y8tXzdta
  18. This ensures the days and weeks line up and the grid area scales to maximalize the space given to it, you can change the colors with :root's variables and change the height/width of things.
  19. --------------------------------------------------------------------
  20. calendar.html: https://pastebin.com/9vFt9LDq
  21. This is the framework for the calendar to add to your page.
  22. --------------------------------------------------------------------
  23. index.html: https://pastebin.com/E0psSkBm
  24.  
  25. You only need to add about 5 lines of code to wherever you want your calendar to be.
  26. Add this in your header:
  27. <link href="calendar/calendar.css" rel="stylesheet" type="text/css" media="all">
  28.  
  29. Add the <div id= "content-body"></div> to where you want to put the calendar in your body.
  30.  
  31. Add this below the body (Must be after the body so that all the html is loaded and it can search for div class = "content-body")
  32. <script type="module">
  33. import { ShowCalendar } from '../calendar/calendar.js';
  34. ShowCalendar(); // auto-load calendar on page load
  35. </script>
  36. ShowCalendar will search for the class ".content-body" to write calendar.html in it, but you can replace it with whatever id you want
  37.  
  38. --------------------------------------------------------------------
  39. stickers.js: https://pastebin.com/2QTHhGCc
  40.  
  41. - LoadMyHabits: reads async from the sheets (meaning it will wait until the sheet is read before running the code)
  42. - GetStickers takes the date, reads the corresponding row for that date
  43. For You:
  44. Feel free to change the logic for the sticker (eg. create stickers representing 2.5k, 5k, 7.5k, 10k steps)
  45. Feel free to change the types of stickers
  46. In the future, you/I can update LoadMyHabits to read from different Google sheets and tabs by changing the logic in the string and making either an array or json object to store different links to different sheets
  47.  
  48. --------------------------------------------------------------------
  49. calendar.js: https://pastebin.com/KcQ4TyZU
  50.  
  51. Simple logic to update the calendar per current day.
  52. For You:
  53. important thing to note is this section of the for loop, you can change it depending on how you want to add the stickers.
  54. await means wait for the GetStickers function to return, because it may be waiting to finish reading the Google sheets.
  55.  
  56. datedivs += '<div class = "date">';
  57. const stickerHTML = await GetSticker(i + 1); // +1 because your sheet uses 1-based days
  58. datedivs += stickerHTML;
  59. --------------------------------------------------------------------
  60.  
Add Comment
Please, Sign In to add comment