$(document).ready(footercollapse); $(window).resize(footercollapse); function footercollapse() { if ((window.innerWidth || document.body.offsetWidth) < 992) { $('#dice-sites').removeClass('in').addClass('collapse'); $('#dice-services').removeClass('in').addClass('collapse'); $('#learn-about-dice').removeClass('in').addClass('collapse'); } else { $('#dice-sites').addClass('in').removeClass('collapse').removeAttr('style'); $('#dice-services').addClass('in').removeClass('collapse').removeAttr('style'); $('#learn-about-dice').addClass('in').removeClass('collapse').removeAttr('style'); } } var tlocale = '${pageContext.response.locale}'; $('.nbt').unbind('click'); $('.nbt').click(function () { var navbars = $('.navbar-collapse'); var navtoggle = $(this).attr('data-target'); for (var i = 0; i < navbars.length; i++) { if (navtoggle != '#' + $(navbars[i]).attr('id') && $(navbars[i]).hasClass('slideUp')) { $(navbars[i]).slideUp(); $(navbars[i]).removeClass('slideUp'); } } if ($(navtoggle).length > 0) { if ($(navtoggle).hasClass('hidden-xs')) { $(navtoggle).removeClass('hidden-xs hidden-sm'); $(navtoggle).css('display', 'none'); } if ($(navtoggle).hasClass('slideUp')) { $(navtoggle).slideUp(); $(navtoggle).removeClass('slideUp'); } else { $(navtoggle).slideDown(); $(navtoggle).addClass('slideUp'); } } else { window.location.href = '/jobs'; } }); $('.smartMenu').unbind('click'); $('.smartMenu').click(function () { var navtoggle = $(this).attr('data-target'); var peopleId = $('#pid').val(), isNotificarion = false; var searchableProfile = getCookie('searchableProfileId'); if (this.id === 'smart-notification-toggle-link' || this.id === 'msmart-notification-toggle-link') { if (peopleId !== undefined || peopleId !== "" || peopleId !== null) { var notificationCookie = getCookie('notificationViewed' + peopleId); if (notificationCookie === null || notificationCookie === "" || notificationCookie === "null" || notificationCookie === undefined) { generateCookie('notificationViewed' + peopleId, false, 24 * 60 * 60 * 1, '/'); } } isNotificarion = true; } if (!isNotificarion) { navToggleWin(this); } }); function navToggleWin(obj) { var navtoggle = $(obj).attr('data-target'); $(obj).find('.icon-arrow-67').hide(); $(obj).find('.icon-arrow-68').hide(); if ($(navtoggle).length > 0) { if ($(navtoggle).hasClass('slideUp')) { $(obj).find('.icon-arrow-67').show(); $(navtoggle).slideUp(200); $(navtoggle).removeClass('slideUp'); } else { $(obj).find('.icon-arrow-68').show(); $(navtoggle).slideDown(200); $(navtoggle).addClass('slideUp'); isPopupSpecificClose(obj); } } } $(document).on('click touchstart', 'html', function (e) { var target = (e && e.target) || (event && event.srcElement); if (isPopupClose(target)) { if ((window.innerWidth || document.body.offsetWidth) >= 992) { $('.smartMenu').find('.icon-arrow-68').hide(); $('.smartMenu').find('.icon-arrow-67').show(); $('#smart-toggle').slideUp(200); $('#smart-toggle').removeClass('slideUp'); $('#smart-notification').slideUp(200); $('#smart-notification').removeClass('slideUp'); $('#msmart-notification').slideUp(200); $('#msmart-notification').removeClass('slideUp'); $('#smart-toggle1').slideUp(200); $('#smart-toggle1').removeClass('slideUp'); $('#smart-toggle2').slideUp(200); $('#smart-toggle2').removeClass('slideUp'); $('#smart-toggle3').slideUp(200); $('#smart-toggle3').removeClass('slideUp'); $('#smart-toggle4').slideUp(200); $('#smart-toggle4').removeClass('slideUp'); $('#smart-toggle5').slideUp(200); $('#smart-toggle5').removeClass('slideUp'); $('#msmart-toggle5').slideUp(200); $('#msmart-toggle5').removeClass('slideUp'); $('#menu_4').slideUp(200); $('#menu_4').removeClass('slideUp'); } } }); function setCookie(sKey, sValue, vEnd, sPath, sDomain, bSecure) { if (!sKey || /^(?:expires|max\-age|path|domain|secure)$/i.test(sKey)) { return false; } var sExpires = ''; if (vEnd) { console.log("vEnd =" + vEnd); switch (vEnd.constructor) { case Number: sExpires = vEnd === Infinity ? '; expires=Fri, 31 Dec 9999 23:59:59 GMT' : '; max-age=' + vEnd; break; case String: sExpires = '; expires=' + vEnd; break; case Date: sExpires = '; expires=' + vEnd.toUTCString(); break; } } document.cookie = encodeURIComponent(sKey) + '=' + encodeURIComponent(sValue) + sExpires + (sDomain ? '; domain=' + sDomain : '') + (sPath ? '; path=' + sPath : '') + (bSecure ? '; secure' : ''); return true; } if ($("#careerPathFlagN").val() == "true") { $('.careerPath_notification').on("click touchstart", careerpathnotification); } function careerpathnotification() { setCookie('careerPathCookie' + $('#pid').val(), 1, 30 * 24 * 60 * 60 * 1, '/'); if (tlocale != 'en_GB') { var newWin = window.open('', '_blank'); newWin.location = 'http://www.dice.com/mobile'; } } function isPopupClose(currentTarget) { var isClose = true, current_element = currentTarget, smartToggle = document.getElementById('smart-toggle'), smartToggleLink = document.getElementById('smart-toggle-link'), smartToggleCareer = document.getElementById('smart-toggle-Career'), smartToggleCareer3 = document.getElementById('smart-toggle-Career3'), smarttoggleCareerExplorer = document.getElementById('smart-toggle-Career-Explorer'), smarttoggleCareerExplorer4 = document.getElementById('smart-toggle-Career-Explorer4'), smartNotificationToggleLink = document.getElementById('smart-notification-toggle-link'), msmartNotificationToggleLink = document.getElementById('msmart-notification-toggle-link'), smarttoggleForEmployer = document.getElementById('smart-toggle-for-employer'), msmarttoggleForEmployer = document.getElementById('msmart-toggle-for-employer'), login_1 = document.getElementById('Login_1'); while (current_element && current_element != document.body) { if (current_element === smartToggle || current_element === smartToggleLink || current_element === smartToggleCareer || current_element === smartToggleCareer3 || current_element === smarttoggleCareerExplorer || current_element === smarttoggleCareerExplorer4 || current_element === smartNotificationToggleLink || current_element === msmartNotificationToggleLink || current_element === login_1 || current_element === smarttoggleForEmployer || current_element === msmarttoggleForEmployer) { isClose = false; break; } current_element = current_element.parentNode; } return isClose; } function isPopupSpecificClose(currentTarget) { var isClose = true, current_element = currentTarget, smartToggle = document.getElementById('smart-toggle'), smartToggleLink = document.getElementById('smart-toggle-link'), smartToggleCareer = document.getElementById('smart-toggle-Career'), smartToggleCareer3 = document.getElementById('smart-toggle-Career3'), smarttoggleCareerExplorer = document.getElementById('smart-toggle-Career-Explorer'), smarttoggleCareerExplorer4 = document.getElementById('smart-toggle-Career-Explorer4'), smartNotificationToggleLink = document.getElementById('smart-notification-toggle-link'), msmartNotificationToggleLink = document.getElementById('msmart-notification-toggle-link'), smarttoggleForEmployer = document.getElementById('smart-toggle-for-employer'), msmarttoggleForEmployer = document.getElementById('msmart-toggle-for-employer'), login_1 = document.getElementById('Login_1'); var ele; while (current_element && current_element != document.body) { if (current_element === smartToggle || current_element === smartToggleLink || current_element === smartToggleCareer || current_element === smartToggleCareer3 || current_element === smarttoggleCareerExplorer || current_element === smarttoggleCareerExplorer4 || current_element === smartNotificationToggleLink || current_element === msmartNotificationToggleLink || current_element === login_1 || current_element === smarttoggleForEmployer || current_element === msmarttoggleForEmployer) { isClose = false; ele = current_element; break; } current_element = current_element.parentNode; } var aar = ['#smart-toggle', '#smart-notification', '#msmart-notification', '#smart-toggle1', '#smart-toggle2', '#smart-toggle3', '#smart-toggle4', '#menu_4', '#smart-toggle5', "#msmart-toggle5"]; var navtoggle = $(ele).attr('data-target'); for (var i = 0; i < aar.length; i++) { if (aar[i] !== navtoggle) { if ((window.innerWidth || document.body.offsetWidth) >= 992) { $(aar[i]).slideUp(200); $(aar[i]).removeClass('slideUp'); $(aar[i]).siblings('a').find('.icon-arrow-67').show(); $(aar[i]).siblings('a').find('.icon-arrow-68').hide(); } } } return isClose; } function getIdentityJson() { const token = localStorage.getItem('identityToken'); if (token !== null && token !== undefined) { const splitToken = token.split('.'); if (splitToken.length > 1) { const atob1 = atob(splitToken[1]); if (atob1 !== null && atob1 !== undefined) { return JSON.parse(atob1); } } } return null; } window.addEventListener('DOMContentLoaded', (event) => { if (localStorage.getItem("snowplowOutQueue_snowplow_co_post2")) { localStorage.removeItem('snowplowOutQueue_snowplow_co_post2') } const accessToken = $('#accessToken').val(); const accessTokenExp = $('#accessTokenExp').val(); const refreshToken = $('#refreshToken').val(); const identityToken = $('#identityToken').val(); const refreshedIdentityToken = $('#refreshedIdentityToken').val(); const refreshedAccessTokenExp = $('#refreshedAccessTokenExp').val(); const refreshedAccessToken = $('#refreshedAccessToken').val(); if (refreshedAccessTokenExp && refreshedAccessToken) { localStorage.setItem('accessToken', refreshedAccessToken); localStorage.setItem('identityToken', refreshedIdentityToken); const unixTime = parseInt(refreshedAccessTokenExp); const date = new Date(unixTime); setCookie('access', refreshedAccessToken, date, '/'); } else if (accessToken) { localStorage.setItem('accessToken', accessToken); localStorage.setItem('refreshToken', refreshToken); localStorage.setItem('identityToken', identityToken); this.jwtValue = getIdentityJson(); const unixTime = parseInt(accessTokenExp); const date = new Date(unixTime); if (jwtValue === null) { //Check for candidate id from the JSP which would be there if the user was being emulated const candidateId = $('#candidateId').val(); setCookie('candidate_id', candidateId, date, '/'); } setCookie('access', accessToken, date, '/'); } const candidateToken = getCookie('CMS_Cookie'); const jwtVal = localStorage.getItem('identityToken'); if (candidateToken && jwtVal) { let currentMessageCount = getCookie('CurrentUnReadMessageCount'); let closeMessageBannerClicked = getCookie('closeMessageBannerClicked'); $.ajax({ url: $('#messageCenterUrl').val(), headers: { 'Authorization': 'Bearer ' + candidateToken, 'x-dhi-candidate-guid': this.jwtValue.candidate_id, 'Content-Type': 'application/json' }, method: 'GET', dataType: 'json', success: function (data) { this.unreadMessage = JSON.stringify(data.data['unreadMessagesCount']); if (this.unreadMessage > 0) { $('.bubbleCountMessage').html(this.unreadMessage); $('.bubbleCountMessage').css({ display: 'block', fontSize: '14px', lineHeight: '1', fontWeight: 'normal' }); if (currentMessageCount === null && this.unreadMessage > 0) { setCookie('CurrentUnReadMessageCount', this.unreadMessage, 24 * 60 * 60, '/'); $('#MessageCenterBanner').css('display', 'block'); $('#homeFeedMessageCount').html(this.unreadMessage); } else if (Number(currentMessageCount) < this.unreadMessage) { $('#MessageCenterBanner').css('display', 'block'); $('#homeFeedMessageCount').html(this.unreadMessage); setCookie('CurrentUnReadMessageCount', this.unreadMessage, 24 * 60 * 60, '/'); setCookie('closeMessageBannerClicked', true, 24 * 60 * 60, '/'); } else if (closeMessageBannerClicked === null || closeMessageBannerClicked === "false" && this.unreadMessage > 0) { $('#MessageCenterBanner').css('display', 'block'); $('#homeFeedMessageCount').html(this.unreadMessage); } if (this.unreadMessage > 1) { $('#letterSdisplay').css('display', 'inline'); } if (this.unreadMessage > 9) { $('.bubbleCountMessage').css('width', '24px'); } } } }); const baseUrl = $('#messageCenterUserStatus').val(); const userId = this.jwtValue.candidate_id; fetch(`${baseUrl}status/user/${userId}`, { method: 'POST', cache: 'no-cache', headers: { 'Content-Type': 'application/json' }, body: '{"status":"Online"}' }); setInterval(() => { fetch(`${baseUrl}status/user/${userId}`, { method: 'POST', cache: 'no-cache', headers: { 'Content-Type': 'application/json' }, body: '{"status":"Online"}' }); }, 30000) } }); function updateThirdPartySession(updateVal) { var domain = $('#localDomain').val(); $.get(window.location.protocol + "//" + domain + "/refresh/thirdpartysession/" + updateVal + "/"); } function updateEmailVerifiedSession(email, verified) { var domain = $('#localDomain').val(); $.get(window.location.protocol + "//" + domain + "/refresh/emailverifiedsession/" + email + "/" + verified); } function trackNotification(type) { if (type == "marketValue_notification") { jQuery('#smart-notification li.mvClass.marketValue_notification alink, #msmart-notification li.mvClass.marketValue_notification a').attr('data-navTrackLink', 'Alert Bell: MarketValue Link'); } else if (type == "notifi_skillopen") { jQuery('#smart-notification li.notifi_skillopen a, #msmart-notification li.notifi_skillopen a').attr('data-navTrackLink', 'Alert Bell: Jobs Matched Skills Link'); } else if (type == "notifi_makeprofile") { jQuery('#smart-notification li.notifi_makeprofile a, #msmart-notification li.notifi_makeprofile a').attr('data-navTrackLink', 'Alert Bell: Make Profile Link'); } else if (type == "notifi_createprofile") { jQuery('#smart-notification li.notifi_createprofile a, #msmart-notification li.notifi_createprofile a').attr('data-navTrackLink', 'Alert Bell: Create Profile Link'); } else if (type == "notifi_nonotification") { jQuery('#smart-notification li.notifi_nonotification a, #msmart-notification li.notifi_nonotification a').attr('data-navTrackLink', 'Alert Bell: No Notification Link'); } else if (type == "smartMenu") { jQuery('.dropdown.smart-notification').attr('data-navTrackRegion', 'navbar-header:alert bell'); } }