var d = []; var app = angular.module('TrainingSearchModule', ['angular.filter']); app.controller('TrainingSearchControler', function ($scope, $http) { var url = window.location.pathname.toLowerCase() + '' + window.location.search.toLowerCase(); if (url == "/en-ca/sites/microsoft-training-days/home/search?eventtitle=&index=0&recordcount=12&orderby=date&wt.mc_id=" || url == "/en-ca/sites/microsoft-training-days/home/search") { var newPath = window.location.protocol + "//" + window.location.host + '' + "/en-ca/sites/microsoft-training-days/Home/Search?SearchText=&index=0&RecordCount=12&OrderBy=date&wt.mc_id=" window.history.pushState({ path: newPath }, '', newPath); } //$scope.ModalVisible = false; //$("#loaderDiv").fadeOut(); $scope.filtersVisible = false; $scope.UrlHasFilters = false; $scope.RecordCount = 12; $scope.loggedInUser = ""; $scope.SelectedSol = ""; $scope.SolutionStatements = function (selectedSolution) { $http.get("/en-ca/sites/microsoft-training-days/api/SolutionStatementsAPI") .then(function (response) { $scope.SolutionStatementData = response.data; $scope.SelectedSol = selectedSolution; }); }; $scope.loadFilters = function () { //$("#loaderDiv").fadeIn(); $http.get("/en-ca/sites/microsoft-training-days/api/Default/GetValues") .then(function (response) { //debugger; $scope.filterData = response.data; $scope.applyUrlFilter(); setTimeout(function () { if ($scope.UrlHasFilters === false) { $scope.search("LoadPage"); $scope.UrlHasFilters = false; } else { $scope.search("LoadPageWithUrlFilter"); } }, 101); //$("#loaderDiv").fadeOut(); }); let usr = $("#loggedInUser"); if (typeof $(usr).val() !== typeof undefined) { if ($("#loggedInUser").val() !== "") $scope.loggedInUser = $(usr).val(); } else { $scope.loggedInUser = ""; } }; $scope.applyUrlFilter = function () { /*debugger;*/ var urlPar = window.location.href.split('?'); setTimeout(function () { //debugger /*******making checkbox checed in case of page load and All Product Category selection*******/ if (window.location.search.indexOf("ProductCategory") < 0) { $("#productcategory").find(":checkbox").each(function () { $(this).attr("checked", "checked"); $(this).prop("checked", true); $(this).attr("aria-checked", "true"); }); } /***********end****** */ /*******making all checkbox disabled*******/ //$("#productcategory").find(":checkbox").each(function () { // $(this).attr("disabled", true); //}); /***********end****** */ if (typeof urlPar[1] !== typeof undefined) { $scope.UrlHasFilters = true; let dHre = urlPar[1]; let dHreArr = dHre.split('&'); // Split Multiple filter areas for (i = 0; i < dHreArr.length; i++) { let d = dHreArr[i].split('='); // Split for the key value pairs for (j = 0; j < d.length; j++) { if (d[0].toLowerCase() === "solutionstatement") { $scope.SolutionStatements(d[1].split('+').join(' ')); } if (d[0].toLowerCase() == "eventtitle") { $("[name='EventTitle']").val(d[1]) } var PCFilter = ""; let ssl = d[1].split('_'); // Split for the multiple items /*******making Product Category Pivot tab active in case of page load *******/ //if (d[0].toLowerCase() == "productcategory" || d[0].toLowerCase() === "countries") { if (d[0].toLowerCase() == "productcategory") { if (ssl.length == 1) { PCFilter = ssl[0].split('+').join(' '); $('div.tab-window tab-group').find('a:first-child').attr('class', ""); $('div.tab-window tab-group').find('a').each(function () { if (PCFilter == $(this).text()) { $(this).attr('class', 'active'); } }); } } /***********end****** */ for (o = 0; o < ssl.length; o++) { if (typeof ssl[o] !== typeof undefined) { //console.log(ssl[o].replace('+', ' ').toLowerCase()) $('li[id="' + d[0].toLowerCase() + '"]').find('[data-val="' + ssl[o].split('+').join(' ').toLowerCase() + '"]').attr("checked", "checked"); $('li[id="' + d[0].toLowerCase() + '"]').find('[data-val="' + ssl[o].split('+').join(' ').toLowerCase() + '"]').prop("checked", true); $('li[id="' + d[0].toLowerCase() + '"]').find('[data-val="' + ssl[o].split('+').join(' ').toLowerCase() + '"]').attr("aria-checked", "true"); } } } } } $scope.CreateTag(); if ($scope.UrlHasFilters) { $("[name='search']").click(); } }, 100); }; $scope.nextPageIndex = 0; $scope.smoothScroll = function () { // $('html, body').animate({ // scrollTop: $("#solutionStatementSection").offset().top // }, 500); // $("#solutionStatementSection").focus(); } $scope.NextPage = function (ind, e) { e.preventDefault(); console.log(ind) if (typeof ind !== typeof undefined) { if (ind === (-1)) {//Clicked Next if (parseInt($scope.nextPageIndex) == 0) { $scope.nextPageIndex = parseInt($scope.nextPageIndex) + parseInt($scope.RecordCount) + 1; } else { $scope.nextPageIndex = parseInt($scope.nextPageIndex) + parseInt($scope.RecordCount); } } else if (ind === (-99)) {//Clicked Previous console.log($scope.nextPageIndex); if (parseInt($scope.nextPageIndex) == 10) { $scope.nextPageIndex = ($scope.nextPageIndex - $scope.RecordCount - 1) < 0 ? 0 : ($scope.nextPageIndex - $scope.RecordCount - 1); } else { $scope.nextPageIndex = ($scope.nextPageIndex - $scope.RecordCount - 1) < 0 ? 0 : ($scope.nextPageIndex - $scope.RecordCount); } } else if (ind === (1)) {//Clicked first index $scope.nextPageIndex = 0; } else {//CLicked on valued index $scope.nextPageIndex = (($scope.RecordCount * ind) - ($scope.RecordCount - 1)); } $scope.search("Pagination"); //$('#EventTitle').focus(); /*$("#examplePivot1Target1 > div > div:nth-child(2) > div > div > div > div:nth-child(1) > div > div > div > a").focus();*/ } }; $scope.search = function (ActionType) { var result = findCampaignParameter(); $('#pagclick').val('false'); if (ActionType.toLowerCase() == "userclick") { $scope.IsSelectedSolution = ""; } else if (ActionType.toLowerCase() == "pagination") { $('#pagclick').val('true'); } function urldecode(str) { return decodeURIComponent((str + '').replace(/\+/g, '%20')); } $("#loaderDiv").fadeIn(); $scope.FilteredEvents = []; //EVENTSAPI = '/en-ca/sites/microsoft-training-days/api/EventListingSearch/'; EVENTSAPINew = '/en-ca/sites/microsoft-training-days/api/EventListingSearch/'; let solutions = $('[data-category="Solutions"]:checked'); //let locations = $('[data-category="Locations"]:checked'); let industry = $('[data-category="IndustryType"]:checked'); let jobroles = $('[data-category="JobRoles"]:checked'); let classlevels = $('[data-category="ClassLevels"]:checked'); let eventtitle = urldecode($("[name='EventTitle']").val()); //new filters let eventformat = $('[data-category="eventformat"]:checked'); let eventtypes = $('[data-category="eventtypes"]:checked'); let skilllevel = $('[data-category="skilllevel"]:checked'); let productcategory = $('[data-category="productcategory"]:checked'); let productsandsolutions = $('[data-category="productsandsolutions"]:checked'); let jobrole = $('[data-category="jobrole"]:checked'); let countries = $('[data-category="countries"]:checked'); console.log(eventtitle); //While changing the ordering, make sure to change the order of "TrackSearch" function too //let categories = [solutions, industry, jobroles, classlevels]; let categoriesNew = [eventformat, eventtypes, skilllevel, productcategory, productsandsolutions, jobrole, countries]; let params = [[], [], [], [], []]; let paramsNew = [[], [], [], [], [], [], []]; let urlParams = ''; let urlParamsNew = ''; let amp = ''; let ampNew = ''; //categories.forEach(function (item, j) { // for (var i = 0; i < item.length; i++) { // params[j].push(item[i].name); // } //}); categoriesNew.forEach(function (item, j) { for (var i = 0; i < item.length; i++) { paramsNew[j].push(item[i].name); } }); let sortBy = ""; sortBy = $("#sortOrderdrop").val(); //if ($("#hidValClickSort").val() === "1") { // sortBy = "Date"; //} //else { // if (window.location.search.toLowerCase().indexOf("orderby") < 0) { // sortBy = "Date"; // } else { // var d = getUrlParameter("orderby"); // sortBy = d; // } //} var wt = ""; if (window.location.search.toLowerCase().indexOf("wt.mc_id") > 0) { wt = getUrlParameter("wt.mc_id"); } $("#hidValClickSort").val(""); //if (params[0].length > 0) { // urlParams = '&Solutions=' + params[0].join('_'); //} //if (params[1].length > 0) { // urlParams += '&IndustryType=' + params[1].join('_'); //} //if (params[2].length > 0) { // urlParams += '&JobRoles=' + params[2].join('_'); //} //if (params[3].length > 0) { // urlParams += '&ClassLevels=' + params[3].join('_'); //} if (paramsNew[0].length > 0) { urlParamsNew = '&EventFormat=' + paramsNew[0].join('_'); } if (paramsNew[1].length > 0) { urlParamsNew += '&EventTypesNew=' + paramsNew[1].join('_'); } if (paramsNew[2].length > 0) { urlParamsNew += '&SkillLevel=' + paramsNew[2].join('_'); } if (paramsNew[3].length > 0) { urlParamsNew += '&ProductCategory=' + paramsNew[3].join('_'); } if (paramsNew[4].length > 0) { urlParamsNew += '&ProductsAndSolutions=' + paramsNew[4].join('_'); } if (paramsNew[5].length > 0) { urlParamsNew += '&JobRole=' + paramsNew[5].join('_'); } if (paramsNew[6].length > 0) { urlParamsNew += '&Countries=' + paramsNew[6].join('_'); } //$('#productcategory-3').prop('checked', true); //if (urlParams.length > 0) { // amp = '&'; //} if (urlParamsNew.length > 0) { ampNew = '&'; $('.tab-window > [role="tablist"] > [role="tab"]').removeClass('active'); if (urlParamsNew.indexOf('_') != -1) { $('#pc').addClass('active'); } else if (urlParamsNew.indexOf('Azure') != -1) { $('#az').addClass('active'); } else if (urlParamsNew.indexOf('Dynamics 365') != -1) { $('#d365').addClass('active'); } else if (urlParamsNew.indexOf('Microsoft 365') != -1) { $('#m365').addClass('active'); } else if (urlParamsNew.indexOf('Power Platform') != -1) { $('#pp').addClass('active'); } else if (urlParamsNew.indexOf('Security') != -1) { $('#sc').addClass('active'); } else { $('#pc').addClass('active'); } } //if (sortBy === null) { // sortBy = "Date"; //} var campaignUrl = ''; if (typeof result != 'undefined' && result) { campaignUrl = '&campaign=' + result; } if (ActionType.toLowerCase() == "userclick") { $scope.nextPageIndex = "0"; } let urlQueryStringPart = '?EventTitle=' + eventtitle + '&index=' + $scope.nextPageIndex + '&RecordCount=' + $scope.RecordCount + '&OrderBy=' + sortBy + urlParams.replace(/\s/g, '+') + campaignUrl; let urlQueryStringPartNew = '?EventTitle=' + eventtitle + '&index=' + $scope.nextPageIndex + '&RecordCount=' + $scope.RecordCount + '&OrderBy=' + sortBy + urlParamsNew.replace(/\s/g, '+') + campaignUrl; var ispreviewUrl = getUrlParameter("state"); console.log(ispreviewUrl); var eventId = ""; if (ispreviewUrl == "preview") { var url_string = window.location.href; var url = new URL(url_string); var c = url.searchParams.get("EventID"); //urlQueryStringPart = urlQueryStringPart + '&state=' + 'preview'; urlQueryStringPartNew = urlQueryStringPartNew + '&state=' + 'preview'; //urlQueryStringPart = urlQueryStringPart + '&EventID=' + c; urlQueryStringPartNew = urlQueryStringPartNew + '&EventID=' + c; $('#sort').hide(); $('filter-button').hide(); } else { $('#sort').show(); $('filter-button').show(); } //EVENTSAPI = EVENTSAPI + urlQueryStringPart; EVENTSAPINew = EVENTSAPINew + urlQueryStringPartNew; //$http.get(EVENTSAPI) // .then(function (response) { // $scope.FilteredEvents = response.data; // $("#loaderDiv").fadeOut(); // //$scope.smoothScroll(); // }); $http.get(EVENTSAPINew) .then(function (response) { //debugger; $scope.FilteredEvents = response.data; $('#nextValid').val(''); $('#prevValid').val(''); if (response.data.PageIndexes.length === response.data.CurrentPageIndex) { $('#nextValid').val('disabled'); //document.getElementById('nextValid').value = 'disabled'; } else if (response.data.CurrentPageIndex === 1) { $('#prevValid').val('disabled'); //document.getElementById('prevValid').value = 'disabled'; } $("#loaderDiv").fadeOut(); //$scope.smoothScroll(); }); $scope.CreateTag(); // $scope.TrackSearch(params, ActionType); var newurl = window.location.protocol + "//" + window.location.host + window.location.pathname + urlQueryStringPartNew + '&wt.mc_id=' + wt; window.history.pushState({ path: newurl }, '', newurl); // bindCTA(); }; $scope.SetFocus = function (ele) { var flag = $('#pagclick').val(); var pageValue = new URL(window.location.href).search.split('&'); for (var i = 0; i < pageValue.length; ++i) { var text = pageValue[i]; if (text.contains('index')) { var val = text.split('=')[1]; //if (val != 0) { // $("#examplePivot1Target1 > div > div:nth-child(2) > div > div > div > div:nth-child(1) > div > div > div > a").focus(); //} if (flag === "true") { $("#examplePivot1Target1 #eventsCard").find("a.cta").first().focus(); } break; } } } $scope.SetPaginationStatus = function (ele) { $('#nextpagebtn').removeClass('d-none'); $('#prevpagebtn').removeClass('d-none'); if ($('#nextValid').val() == 'disabled') { $('#nextpagebtn').addClass('d-none'); } else if ($('#prevValid').val() == 'disabled') { $('#prevpagebtn').addClass('d-none'); } } $scope.trimSolution = function (SolutionName) { if (typeof SolutionName !== typeof undefined) { if (SolutionName.indexOf("Microsoft Azure") >= 0) { return "Azure"; } else if (SolutionName.indexOf("Microsoft 365") >= 0) { return "Microsoft 365"; } else if (SolutionName.indexOf("Microsoft Dynamics 365") >= 0) { return "Dynamics 365"; } else if (SolutionName.indexOf("Microsoft Power Platform") >= 0) { return "Power Platform"; } else if (SolutionName.indexOf("Microsoft Security") >= 0) { return "Security"; } } }; $scope.SolutionColor = function (SolutionName) { if (typeof SolutionName !== typeof undefined) { if (SolutionName.indexOf("Azure") >= 0) { return "blue"; } else if (SolutionName.indexOf("Microsoft 365") >= 0) { return "orange"; } else if (SolutionName.indexOf("Dynamics 365") >= 0) { return "purple"; } else if (SolutionName.indexOf("Power Platform") >= 0) { return "dark-purple"; } else if (SolutionName.indexOf("Security") >= 0) { return "orange"; } } }; $scope.clearFilters = function () { $scope.UrlHasFilters = false; $("#filters input:checked").each(function () { $(this).removeAttr("checked"); $(this).prop("checked", false); $(this).attr("aria-checked", false); }); $scope.search("ClearAllFilter"); $scope.IsSelectedSolution = ""; }; $scope.ChangeFilterPC = function (PCFilter, eleid) { //debugger; if (PCFilter == "ProductCategory") $('#examplePivot1Target1').attr("aria-label", "All Product Category data here."); else $('#examplePivot1Target1').attr("aria-label", PCFilter + " data here."); $('.tab-window > [role="tablist"] > [role="tab"]').removeClass('active'); $('#' + eleid).addClass('active') if (PCFilter == "ProductCategory") { $("#productcategory").find(":checkbox").each(function () { if (!$(this).is(":checked")) { $(this).attr("checked", "checked"); $(this).prop("checked", true); $(this).attr("aria-checked", "true"); /*$(this).removeAttr("disabled");*/ } }); } else { $("#productcategory").find(":checkbox").each(function () { $(this).attr("checked", ""); $(this).prop("checked", false); $(this).attr("aria-checked", "false"); /*$(this).attr("disabled", true);*/ }); $('#productcategory').find('[data-val="' + PCFilter.toLowerCase() + '"]').attr("checked", "checked"); $('#productcategory').find('[data-val="' + PCFilter.toLowerCase() + '"]').prop("checked", true); $('#productcategory').find('[data-val="' + PCFilter.toLowerCase() + '"]').attr("aria-checked", "true"); /*$('#productcategory').find('[data-val="' + PCFilter.toLowerCase() + '"]').removeAttr("disabled");*/ } $scope.search("userclick"); } $scope.CreateTag = function () { let vars = $("#filters [type='checkbox']:checked"); $scope.filterValues = []; $(vars).each(function () { let ds = { id: $(this).attr("id"), Title: $(this).attr("name") }; $scope.filterValues.push(ds); }); //console.log($scope.filterValues) }; $scope.clearOneFilter = function (id, e) { e.preventDefault(); var i = $("#" + id); $scope.nextPageIndex = 0; if (typeof i !== typeof undefined) { //$("#loaderDiv").fadeIn(); $("#" + id).removeAttr("checked"); $("#" + id).prop("checked", false); $("#" + id).attr("aria-checked", "false"); $scope.search("ClearOneFilter"); } $scope.IsSelectedSolution = ""; }; $scope.showHideFilter = function () { $scope.filtersVisible = !$scope.filtersVisible; }; $scope.sortFilteredData = function () { $scope.search("Sort"); }; $scope.TrackSearch = function (searchArr, ActionType) { //debugger; let SEARCHAPI = '/en-ca/sites/microsoft-training-days/api/SearchTrack'; if (typeof searchArr !== typeof undefined) { //console.log(searchArr); if (checkAnonCookie()) { let cook = getAnonCookie(cookName); let Solution = searchArr[0].join("|"); let IndustryType = searchArr[1].join("|"); //let EventType = searchArr[1].join("|"); let Location = searchArr[2].join("|"); let JobRole = searchArr[3].join("|"); let ClassLevel = searchArr[4].join("|"); $("#Solution").val(Solution); $("#IndustryType").val(IndustryType); $("#EventType").val(EventType); $("#Location").val(Location); $("#JobRole").val(JobRole); $("#ClassLevel").val(ClassLevel); let orderBy = "Date";//$("#sortControl option:selected").val(); if (orderBy === "undefined" || typeof orderBy === typeof undefined) { orderBy = "Date"; } //Call the JSLL tracking let TS = SEARCHAPI + "?Solution=" + Solution + "&IndustryType=" + IndustryType + "&EventType=" + EventType + "&Location=" + Location + "&JobRole=" + JobRole + "&ClassLevel=" + ClassLevel + "&OrderBy=" + orderBy + "&ActionType=" + ActionType + "&AnonAffinity=" + cook; //Track search $http.get(TS) .then(function (response) { }); } } }; $scope.CollapsibleCntrl = function (event) { //debugger var ariaexpanded = event.target.getAttribute('aria-expanded'); if (ariaexpanded == 'false' && !event.target.classList.contains('collapsed')) { event.target.setAttribute('aria-expanded', 'true'); $(event.currentTarget).addClass('collapsed'); $(event.currentTarget).parent().next('div.collapse').addClass('show'); $(event.currentTarget).parent().click(); } else { event.target.setAttribute('aria-expanded', 'false'); $(event.currentTarget).removeClass('collapsed'); $(event.currentTarget).parent().next('div.collapse').removeClass('show'); $(event.currentTarget).parent().click(); } } }); $(function () { $(document).on("click", "#Expand", function () { $('.btn-collapse').attr("aria-expanded", "true"); $('.collapse').addClass("show"); document.getElementById("Expand").style.display = "none"; document.getElementById("Collapsee").style.display = "inline"; }); $(document).on("click", "#Collapsee", function () { $('.btn-collapse').attr("aria-expanded", "false"); $('.collapse').removeClass("show"); document.getElementById("Expand").style.display = "inline"; document.getElementById("Collapsee").style.display = "none"; }); $(document).on("click", "button.btn-collapse", function () { var totalAcc = $("#accordionExample button.btn-collapse").length; var openAcc = $("#accordionExample button[aria-expanded='true']").length; if (openAcc == totalAcc) { document.getElementById("Expand").style.display = "none"; document.getElementById("Collapsee").style.display = "inline"; } else { document.getElementById("Expand").style.display = "inline"; document.getElementById("Collapsee").style.display = "none"; } }); $(document).on("click", "a.c-refine-item", function () { var a = this; angular.element(document.getElementById('app')).scope().search('userclick'); //let v = $("#sortControl option:selected").val(); //$("#hidValClickSort").val("1"); //document.getElementsByName('search')[0].click(); //$("#hidValClickSort").val(""); }); /*$(document).on("click", "input[data-category='jobrole']", function () {*/ $(document).on("click", "input[type='checkbox']", function () { var a = this; angular.element(document.getElementById('app')).scope().search('userclick'); //let v = $("#sortControl option:selected").val(); //$("#hidValClickSort").val("1"); //document.getElementsByName('search')[0].click(); //$("#hidValClickSort").val(""); }); $(document).on("keydown", "input[type='checkbox']", function (event) { //debugger; if (event.keyCode === 32) { //alert('hi'); /*if ($("#el").is(":checked")) {*/ //if ($('ul').find('[data-val= "' + $(this).attr('data-val') + '"]').is(":checked")) { // $('ul').find('[data-val="' + $(this).attr('data-val') + '"]').attr("checked", ""); // $('ul').find('[data-val="' + $(this).attr('data-val') + '"]').prop("checked", false); // $('ul').find('[data-val="' + $(this).attr('data-val') + '"]').attr("aria-checked", "false"); //} //else { // $('ul').find('[data-val="' + $(this).attr('data-val') + '"]').attr("checked", "checked"); // $('ul').find('[data-val="' + $(this).attr('data-val') + '"]').prop("checked", true); // $('ul').find('[data-val="' + $(this).attr('data-val') + '"]').attr("aria-checked", "true"); //} angular.element(document.getElementById('app')).scope().search('userclick'); //let v = $("#sortControl option:selected").val(); //$("#hidValClickSort").val("1"); //document.getElementsByName('search')[0].click(); //$("#hidValClickSort").val(""); } }); $(document).on("keyup", "[role='tablist'] a", function (event) { var keyCode = event.keyCode || event.which; if (keyCode === 39) { $(this).next('a').focus(); } else if (keyCode === 37) { $(this).prev('a').focus(); } }); $(document).on("change", "#sortOrderdrop", function () { //debugger; angular.element(document.getElementById('app')).scope().search('userclick'); }); $("#clearResetFilters").on("click", function (e) { e.preventDefault(); $("#filters").find(":checkbox").each(function () { $(this).removeAttr("checked"); $(this).prop("checked", false); $(this).attr("aria-checked", "false"); console.log("test"); }); $("[name='search']").click(); document.getElementsByName('search')[0].click(); }); $(".filterSelectAll").on("click", function (e) { e.preventDefault(); if ($(this).attr("data-selected") === "false") { $(this).closest("ul").find(":checkbox").each(function (i, e) { $(this).attr("checked"); $(this).prop("checked", true); $(this).attr("aria-checked", true); }); $(this).attr("data-selected", "true"); $(this).text("Remove selection").attr("aria-label", "Click to remove selection from all " + $(this).attr("data-filter") + " checkboxes"); } else { $(this).closest("ul").find(":checkbox").each(function (i, e) { $(this).removeAttr("checked"); $(this).prop("checked", false); $(this).attr("aria-checked", false); }); $(this).attr("data-selected", "false"); $(this).text("Select all").attr("aria-label", "Click to select all " + $(this).attr("data-filter") + " checkboxes"); } }); $(document).on("click", "input[data-val]", function () { let allLeng = $(this).closest("ul").find("input[type='checkbox']").length; let selLeng = $(this).closest("ul").find("input[type='checkbox']:checked").length; if (allLeng === selLeng) { //All Selected $(this).closest("ul").find(".filterSelectAll").attr("data-selected", "true"); $(this).closest("ul").find(".filterSelectAll").text("Remove selection").attr("aria-label", "Click to remove selection from all " + $(this).closest("ul").find(".filterSelectAll").attr("data-filter") + " checkboxes"); } else if (allLeng > selLeng) { //Some selected $(this).closest("ul").find(".filterSelectAll").attr("data-selected", "false"); $(this).closest("ul").find(".filterSelectAll").text("Select all").attr("aria-label", "Click to select all " + $(this).closest("ul").find(".filterSelectAll").attr("data-filter") + " checkboxes"); } }) }); //Handle Cookie var cookName = "AnonAffinity"; function setAnonCookie(name, value) { var d = new Date(); d.setTime(d.getTime() + (365 * 24 * 60 * 60 * 1000)); var expires = "expires=" + d.toUTCString(); document.cookie = name + "=" + value + ";" + expires + ";path=msaucloudhub"; } function getAnonCookie(cokName) { var name = cokName + "="; var cn = document.cookie.split(';'); for (var i = 0; i < cn.length; i++) { var c = cn[i]; while (c.charAt(0) === ' ') { c = c.substring(1); } if (c.indexOf(name) === 0) { return c.substring(name.length, c.length); } } return ""; } function checkAnonCookie() { let user = getAnonCookie(cookName); if (user === "") { setAnonCookie(cookName, makeUUID()); } return true; } function makeUUID() { let r = ''; let validChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_+^%$&'; let charLength = validChars.length; let length = 25;//Generate string of length 40 for (let i = 0; i < length; i++) { r += validChars.charAt(Math.floor(Math.random() * charLength)); } return r; } $(function () { document.querySelectorAll('.context-jsll-form').forEach(function (el) { new jsllForm(el); }); function jsllForm(formEl) { var form = formEl; var submitBtn = form.querySelectorAll('.search-button')[0]; var whitelist = form.querySelectorAll('.whitelist'); var overrideValues = { behavior: parseInt(submitBtn.getAttribute('data-bi-bhvr')), actionType: "CL", contentTags: { formnm: form.getAttribute('data-bi-formnm'), formid: form.getAttribute('data-bi-formid'), name: submitBtn.getAttribute('data-bi-name'), id: submitBtn.getAttribute('data-bi-id') }, uri: encodeURI(window.location.href) }; var setOverrideValues = function (bool) { for (i = 0; i < whitelist.length; i++) { if (whitelist[i].type === 'radio') { if (whitelist[i].checked) { overrideValues.contentTags[whitelist[i].id] = whitelist[i].value; } } else { overrideValues.contentTags[whitelist[i].id] = whitelist[i].value; } } overrideValues.contentTags.isSuccess = bool ? true : false; }; submitBtn.onclick = function (e) { e.preventDefault(); setOverrideValues(true); awa.ct.captureContentPageAction(overrideValues); return false; }; } }); var getUrlParameter = function getUrlParameter(sParam) { var sPageURL = window.location.search.toLowerCase().substring(1), sURLVariables = sPageURL.split('&'), sParameterName, i; for (i = 0; i < sURLVariables.length; i++) { sParameterName = sURLVariables[i].split('='); if (sParameterName[0] === sParam) { return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]); } } }; //JSLL implementation