Jump to content

'Add An Appointment' Link Customized For Weekly Calendar


Recommended Posts

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

     }
    }    
  });

 

Link to comment
Share on other sites

  • 10 months later...

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...