{% include "header" %}
<div class="page-container">
  <div class="np-hidden-mobile">
    {% include "sub_navigation" %}
  </div>
  <main class="np-main np-subpage-container np-max-width custom-course-page">
    <div class="np-hidden-mobile" id="course-desktop">
      {% include "course_desktop_view" %}
    </div>
    <div class="np-hidden-desktop" id="course-mobile">
      {% include "course_mobile_view" %}
    </div>
  </main>
</div>
{% include "footer" %}
<script>

  $(document).ready(function () {
    setLastViewedCourse();
    addTargetBlankToLinksInCourseDescription();
  });

  function setLastViewedCourse() {
    var data = {
      uuid: '{{current_person.id}}',
      courseName: '{{course.id}}' // course id not name 
    };
    $.ajax({
      type: 'POST',
      url: 'https://www.workato.com/webhooks/rest/bd1a1eb7-7e79-4208-a1db-8e9c7440bcc9/course-viewed', //workato link 
      data: JSON.stringify(data),
      success: function (data) {
        console.log(data);
        //setTimeout(location.reload.bind(location), 700);
      },
      error: function (xhr, status, error) {
        console.log(error)
      }
    });
  }

  function addTargetBlankToLinksInCourseDescription() {
    let rte = document.getElementsByClassName("np-card-text")[0];
    let links;

    if (rte) {
      links = rte.querySelectorAll("a");
      if (links) {
        for (i = 0; i < links.length; i++) {
          links[i].setAttribute("target", "_blank");
        }
      }
    }
  }
</script>

<style>
  .custom-course-page {
    max-width: 1600px !important;
  }

  /* Based on how things are setup, at the course cover page, the footer is entirely blocked due to all of the customizations */
  .np-footer{
    display: none;
  }
</style>