kpcollier Posted July 6, 2021 Report Share Posted July 6, 2021 Hello, I've been trying to edit this script that can be found on here. Originally, this script is for a Monthly Calendar datapage. I am trying to make it work for a Weekly Calendar datapage. I believe the problem is with the beginning of the script, with the replace method. On a monthly calendar, you can loop through the 'li' tags to get the Month and Year. However, in a weekly calendar, that month is a date range. It goes from 'July 2021' on a monthly calendar to 'July 4th, 2021 - July 10, 2021' on a weekly calendar. Anyone have any ideas? Below is the script that works for Monthly. document.addEventListener('DataPageReady', function (event) { // Add link to New Appointment page var month = ""; var allLiTags = document.getElementsByTagName("li"); for (i = 0; i < allLiTags.length; i++) { if (allLiTags[i].className == "cbResultSetCalendarCaption") { month = allLiTags[i].innerText; } } month = month.replace(/January /gi, "1/Day/"); month = month.replace(/February /gi, "2/Day/"); month = month.replace(/March /gi, "3/Day/"); month = month.replace(/April /gi, "4/Day/"); month = month.replace(/May /gi, "5/Day/"); month = month.replace(/June /gi, "6/Day/"); month = month.replace(/July /gi, "7/Day/"); month = month.replace(/August /gi, "8/Day/"); month = month.replace(/September /gi, "9/Day/"); month = month.replace(/October /gi, "10/Day/"); month = month.replace(/November /gi, "11/Day/"); month = month.replace(/December /gi, "12/Day/"); var allHTMLTags = new Array(); // Create Array of All HTML Tags var allHTMLTags = document.getElementsByTagName("div"); // Loop through all tags using a for loop for (i = 0; i < allHTMLTags.length; i++) { // Get all tags with the specified class name. if (allHTMLTags[i].className == "cbResultSetCalendarField") { var transfer = month.replace(/Day/gi, allHTMLTags[i].innerHTML); // Check if date is not past date var sysDate = '[@cbTimestamp*]'; var dateToday = new Date(sysDate); var dateCalendar = new Date(transfer); if (dateCalendar >= dateToday) { // Begin Add New Link Section allHTMLTags[i].innerHTML = '<a class="truncated float-left" title="New Appointment" style="text-decoration:none;" href="https://c3eku680.caspio.com/dp/e7505000d2bec545bf5441938a387?Date=' + transfer + '"><i class="fa fa-calendar-plus fa-2x"></i></i></a>' + allHTMLTags[i].innerHTML; // End of Add New Link Section } //Again for past dates, different color } } }); Quote Link to comment Share on other sites More sharing options...
GoodBoy Posted July 6, 2021 Report Share Posted July 6, 2021 Hello! This comment is similar to your inquiry and might help you I guess. kpcollier 1 Quote Link to comment Share on other sites More sharing options...
kpcollier Posted July 6, 2021 Author Report Share Posted July 6, 2021 Thanks @GoodBoy. I was searching with the wrong terms. This should work for me. Quote Link to comment Share on other sites More sharing options...
Kurumi Posted May 7, 2022 Report Share Posted May 7, 2022 Hi everyone - Just wanted to share this solution. If you want to save the date in your Calendar or download it as a .ics file. You may use an external JS library called Add-to-Calendar Button:https://jekuer.github.io/add-to-calendar-button/https://github.com/jekuer/add-to-calendar-button Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.