"use strict"; $(document).ready(function () { if ($("body").attr("class").match(/\bcontext-course_(.[0-9]*)/)) { //insert course ID into variable var courseID = $("body").attr("class").match(/\bcontext-course_(.[0-9]*)/)[1]; $.getJSON("/api/v1/courses/" + courseID, "include[]=term", function (data) { $("#breadcrumbs").html(data.name); $('#section-tabs-header-subtitle.ellipsis').html(data.term.name + '
' + data.course_code); }); //end get jSON } //end check if it is a course }); //end on document ready window.addEventListener('load', function () { function getUrlVars(url) { var vars = {}; var parts = url.replace(/[?&]+([^=&]+)=([^&]*)/gi, function (m, key, value) { vars[key] = value; }); return vars; } if ((/^\/courses\/\d+(\/pages\/.*)?$/.test(window.location.pathname) || /^\/courses\/\d+(\/wiki)?$/.test(window.location.pathname)) && typeof ENV.WIKI_PAGE !== 'undefined') { var isoDate = function isoDate(ds) { var d = ds.toISOString().split(/\D/); return new Date(d[0], --d[1], d[2]); }, deltaDate = function deltaDate(input, days, months, years) { return new Date( input.getFullYear() + years, input.getMonth() + months, Math.min( input.getDate() + days, new Date(input.getFullYear() + years, input.getMonth() + months + 1, 0).getDate())); }, dateDiff = function dateDiff(a, b) { return Math.round((isoDate(b) - isoDate(a)) / 8.64e7); }, roundDays = function roundDays(adate) { var showstartday = adate.toString().split(/\s/), startday = (showstartday[0]), revert = 0; if (startday == "Tue") revert = -1; if (startday == "Wed") revert = -2; if (startday == "Thu") revert = -3; if (startday == "Fri") revert = -4; if (startday == "Sat") revert = -5; return (deltaDate(adate, revert, 0, 0)); }, setWeek = function setWeek(dst, ds, de, dcalstart) { var realstart, tstart = new Date(dst), tcalstart = new Date(dcalstart), cstart = new Date(ds), end = new Date(de), today = new Date(), day = today.toString().split(/\s/), showtoday = "".concat(day[0], ", ").concat(day[1], " ").concat(day[2], ", ").concat(day[3]); console.log('Term Start: (' + dst + ') ' + tstart); console.log('Course Start: (' + ds + ') ' + cstart); console.log('Term Calendar Start: (' + dcalstart + ') ' + tcalstart); console.log('Course End: (' + de + ') ' + end); realstart = tstart; if (ds != null) realstart = cstart; if (ds == null && dst == null) realstart = tcalstart; console.log('Calculate Week From: ' + realstart); var startmon = roundDays(realstart), temptoday = deltaDate(today, 0, 0, 0), wk = Math.floor(dateDiff(startmon, temptoday) / 7 + 1), term = de != null ? Math.floor(dateDiff(startmon, end) / 7) : 14; var semester = 'fall'; if (realstart.getMonth() < 7) semester = 'spring'; var week; if (semester == 'spring') { week = wk >= 8 ? wk - 1 : wk; } else { week = wk >= 14 ? wk - 1 : wk; } term = realstart.getMonth() < 7 && wk >= 13 ? term - 1 : term; var sb = realstart.getMonth() < 7 && wk == 8 ? 1 : 0, links = document.querySelectorAll('.course-week-links'), cwc = document.getElementById('course-week-count'), st = document.getElementById('showtoday'), toExtract = window.location.href, course, toplink, weeklink, php = 'lecture', pageweek = 1, weekday = 0, navlink = document.getElementById('nav'), args = '&test'; console.log('wk:'+wk); console.log('term:'+term); console.log('week:'+week); console.log('sb:'+sb); if (term >= 14) term = 14; if (term >= 8 && term <= 12) term = 10; if (term <= 7) term = 5; course = toExtract.match('courses/(.*)')[1]; if (toExtract.includes('pages')) course = toExtract.match('courses/(.*)\/pages')[1]; if (toExtract.includes('/wiki')) course = toExtract.match('courses/(.*)\/wiki')[1]; if (toExtract.includes('week')) pageweek = parseInt(toExtract.match('week-(.*)')[1], 10); if (toExtract.includes('weekend') || toExtract.includes('looking')) { php = 'suggested'; weekday = 6; } if (toExtract.includes('objectives')) php = 'objectives'; if (toExtract.includes('suggested')) php = 'suggested'; if (toExtract.includes('monday')) { php = 'suggested'; weekday = 1; } if (toExtract.includes('tuesday')) { php = 'suggested'; weekday = 2; } if (toExtract.includes('wednesday')) { php = 'suggested'; weekday = 3; } if (toExtract.includes('thursday')) { php = 'suggested'; weekday = 4; } if (toExtract.includes('friday')) { php = 'suggested'; weekday = 5; } var regexr = new RegExp('lessons-week-' + pageweek + '-'); var regexr2 = new RegExp('readings-week-' + pageweek + '-'); if (toExtract.includes('lessons') && !regexr.test(toExtract)) php = 'lessons'; if (toExtract.includes('readings') && !regexr2.test(toExtract)) php = 'lessons'; if (toExtract.includes('assignments') || toExtract.includes('activities')) php = 'assignments'; if (navlink !== null) { navlink.src = 'https://etop.landmark.edu/timeline/' + php + '.php?week=' + pageweek + '&course=' + course + '&day=' + weekday + '&term=' + term; navlink.title = 'Navigation'; navlink.removeAttribute("sandbox"); } if (cwc !== null) cwc.textContent = 'Week ' + week; if (sb == 1) { cwc.textContent = 'Spring Break'; } if (cwc !== null && (week > 15 || week < 1)) cwc.textContent = "a week outside of this course's calendar"; if (document.getElementById('top') !== null) { toplink = document.getElementById('top').src; if (toplink.includes('glossary')) args = args + '&glossary'; if (toplink.includes('wiki')) args = args + '&wiki'; if (toplink.includes('master')) args = args + '&master'; if (toplink.includes('syl=')) args = args + '&syl=' + getUrlVars(toplink)["syl"]; if (toplink.includes('calendar')) args = args + '&calendar=' + getUrlVars(toplink)["calendar"]; if (toplink !== null) document.getElementById('top').src = 'https://etop.landmark.edu/syllabi/syllabus.php?week=' + week + '&course=' + course + args; } if (document.getElementById('weeklink') !== null) { weeklink = document.getElementById('weeklink'); weeklink.href = 'https://landmark.instructure.com/courses/' + course + '/pages/objectives-week-' + week; weeklink.dataset.apiEndpoint = 'https://landmark.instructure.com/courses/' + course + '/pages/objectives-week-' + week; cwc.href = weeklink.href; cwc.dataset.apiEndpoint = weeklink.dataset.apiEndpoint; } if (st !== null) st.textContent = showtoday; var regex = new RegExp('Week\\s+' + week + '\\b'); Object.keys(links).forEach(function (i) { if (regex.test(links[i].textContent.replace(/\D+$/g, "")) && sb !== 1) { cwc.style.background = null; links[i].style.background = null; cwc.href = links[i].href; if (cwc.nodeName != "SPAN") cwc.className += " highlight"; return links[i].className += " highlight"; //return links[i].classList.add('active-week'); } }); }; fetch("/api/v1/courses/".concat(ENV.COURSE_ID, "?include%5B%5D=term"), { 'headers': { 'accept': 'application/json', } }).then(function (response) { return response.text(); }).then(function (r) { var url = "/api/v1/accounts/1/terms/" + JSON.parse(r).term.id; fetch(url, { 'headers': { 'accept': 'application/json', } }).then(function (response) { return response.text(); }).then(function (r2) { return setWeek(JSON.parse(r).term.start_at, JSON.parse(r).start_at, JSON.parse(r).end_at, JSON.parse(r2).start_at); }); }); } }, false); var atomicSearchWidgetScript = document.createElement("script"); atomicSearchWidgetScript.src = "https://js.atomicsearchwidget.com/atomic_search_widget.js"; document.getElementsByTagName("head")[0].appendChild(atomicSearchWidgetScript); // GOOGLE TAG MANAGER CODE (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','GTM-583WVLQ'); var googleTagManager = '' + '' + ''; $('body').prepend(googleTagManager);