" + "" + "\n" + "\n" + "
\n" + "\n" + (data.courseTitle !== '' ? "

" + data.courseTitle + "

\n" : "") + "
\n" + (data.qualType !== '' ? "" + data.qualType + "\n" : "") + "
" + "
\n" + (data.courseCode !== '' ? "

Course Code" + data.courseCode + "

\n" : "" ) + (data.typeOfLearning !=='' ? "

Type of Learning" + data.typeOfLearning + "

\n" : "") + (data.studyMode !=='' ? "

Study Mode" + data.studyMode + "

\n" : "") + (data.courseOccurences.length > 1 && data.typeOfLearning == 'Adult Learning' ? selectList + "
" : "") + "\n\n"; $('#shortlist--wrapper').append(shortListItem); counter++; $('#counter').html(counter); const intersection = tribalCodes.filter(element => UIOIdCodes.includes(element)); const intersection2 = intersection.toString(); if (selectList.indexOf(intersection2) >= 0) { const intersection3 = parseInt(intersection2); $("#select-box-dates-"+x).val(intersection3); } x++; let UIOIdDeleteNal = data.uiO_ID; $('#' + id).on('click', function(){ $('#shortlist-delete').show(); $('#course-to-delete').html(id.trim()); if(data.courseOccurences.length > 1 && data.typeOfLearning == 'Adult Learning') { let UIOIdDelete = $(this).next().next().find("select"); setCookie("UIOIdDelete", UIOIdDelete.val() , 365); } else { setCookie("UIOIdDelete", UIOIdDeleteNal , 365); } }); if((data.uiO_ID != '' && data.typeOfLearning != 'Adult Learning') || (data.courseOccurences.length == 1 && data.typeOfLearning == 'Adult Learning')) { if(applyAllUrl.endsWith('=')){ applyAllUrl += data.uiO_ID } else{ applyAllUrl += ',' + data.uiO_ID } } else if (data.courseOccurences.length > 1 && data.typeOfLearning == 'Adult Learning') { if(applyAllUrl.endsWith('=')){ applyAllUrl += $(`#select-box-dates-${z}`).val(); } else{ applyAllUrl += ',' + $(`#select-box-dates-${z}`).val(); } } z++; $('#apply-all1').attr('href', applyAllUrl); $('#apply-all2').attr('href', applyAllUrl); $('#apply-all1').show(); $('#apply-all2').show(); console.log(applyAllUrl); } }); } }); }; $(document).on('change', '.select-box-dates', function() { selectValues = "" $("option", this).each(function() { selectValues += ($(this).val()+","); }) let selectValuesArr = selectValues.split(',') selectValuesArr.pop(); console.log("Values in select dropdown: " + selectValuesArr) let activeCourseCodes = applyAllUrl.substring(applyAllUrl.indexOf('=') + 1); let activeCourseCodesArr = activeCourseCodes.split(',') console.log("Current active codes in URL: " + activeCourseCodesArr) let codeToRemove = selectValuesArr.filter(element => activeCourseCodesArr.includes(element)); console.log("Code value to be removed: " + codeToRemove) index = activeCourseCodesArr.indexOf(codeToRemove[0]); activeCourseCodesArr.splice(index, 1); console.log("Codes with value now removed: " + activeCourseCodesArr) let newCourseCode = $(this).val(); console.log("Code value to be added: " + newCourseCode); activeCourseCodesArr.push(newCourseCode) console.log("Codes with value now added: " + activeCourseCodesArr) let newactiveCourseCodes = activeCourseCodesArr.join(',') console.log("Codes with value now added (string format): " + newactiveCourseCodes) applyAllUrl=applyAllUrl.substring(0, (applyAllUrl.indexOf('=')+1)); applyAllUrl+=newactiveCourseCodes; console.log("New Apply Now URL: " + applyAllUrl); $('#apply-all1').attr('href', applyAllUrl); $('#apply-all2').attr('href', applyAllUrl); setCookie("UIOIds", newactiveCourseCodes+',', 365); }); $(document).on('click', '.select-box-dates', function(e) { e.stopPropagation(); if ($(this).hasClass('dates-active')) { $(this).removeClass('dates-active'); } else { $(this).addClass('dates-active'); } }); $(document).on('click', function () { $('.select-box-dates').removeClass('dates-active'); }); function getCookie(cname) { var name = cname + "="; var ca = document.cookie.split(';'); for(var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') { c = c.substring(1); } if (c.indexOf(name) == 0) { return c.substring(name.length, c.length); } } return ""; } function setCookie(cname, cvalue, exdays) { var d = new Date(); d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); var expires = "expires="+d.toUTCString(); document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; } function removeCourseFromShortlist1() { alert('Here'); var code = $(this).attr('class').text(); console.log('Removing: ' + code); } $('#shortlist-delete-popup-close,#no-thanks').on('click', function(){ $('#shortlist-delete').hide(); $('#course-to-delete').html(''); }); $('#remove-course').on('click', function() { $('#shortlist-delete').hide(); var courseCode = $('#course-to-delete').html(); var courses = getCookie('courses'); courses = courses.replace(courseCode + ',',''); setCookie("courses", courses, 365); var UIOIdDelete = getCookie('UIOIdDelete'); var UIOIds = getCookie('UIOIds'); UIOIds = UIOIds.replace(UIOIdDelete + ',',''); setCookie("UIOIds", UIOIds, 365); setCookie("UIOIdDelete", '', 365); loadCookies(); });