function getNotification(){$("#loadingPopupImageId").show();$.ajax({method:"get",dataType:"json",url:notificationResourceUrl,success:function(obj){if(obj!=undefined&&obj!=null){$("#loadingPopupImageId").hide();$("#notification_count").html(obj.notificationCount);if(obj.notificationCount==0)$(".no-notification").removeClass("d-none");else{var notification="";var notiList=obj.notificationList;for(var i=0;i<notiList.length;i++){var desc="notificationDesc_"+i;notification+='\x3cinput type\x3d"hidden" id\x3d"'+
desc+'" value\x3d"'+notiList[i].notificationDescp+'"/\x3e';notification+='\x3ca href\x3d"#" class\x3d"noti-anchor" id\x3d"noti-anchor" onclick\x3d"updateNotification(\''+notiList[i].notificationId+"','"+notiList[i].articleId+"','"+notiList[i].solListNotificationId+"');redirectNotification('"+notiList[i].notificationTitle+"','"+notiList[i].redirectURL+"','"+notiList[i].missionId+"','"+notiList[i].rebateReferenceID+"','"+notiList[i].notificationStatus+"','"+notiList[i].notificationType+"','"+obj.notificationPageRedirectUrl+
"','"+obj.lenovoIdDomainUrl+"');setNotificationTrack('"+"notificationDesc_"+i+"')\"\x3e";if(notiList[i].read==0)notification+='\x3cdiv class\x3d"col-12 column read"\x3e';else notification+='\x3cdiv class\x3d"col-12 column"\x3e';if(notiList[i].notificationTitle=="PEP"){notification+='\x3cdiv class\x3d"noti-title"\x3e\x3cdiv class\x3d"col-8 left_align"\x3e'+notiList[i].notificationMsgTitle+"\x3c/div\x3e\x3c/div\x3e";notification+='\x3cdiv class\x3d"row noti-footer"\x3e\x3cdiv class\x3d"col-8" \x3e'+
rebate_program_label+"\x3c/div\x3e"}else if(notiList[i].notificationTitle=="tiering and competence"){notification+='\x3cdiv class\x3d"noti-title"\x3e\x3cdiv class\x3d"col-8 left_align"\x3e'+notiList[i].notificationDescp+"\x3c/div\x3e\x3c/div\x3e";notification+='\x3cdiv class\x3d"row noti-footer"\x3e\x3cdiv class\x3d"col-8" \x3e'+tiering_and_competence+"\x3c/div\x3e"}else{notification+='\x3cdiv class\x3d"noti-title"\x3e\x3cdiv class\x3d"col-8 left_align"\x3e'+notiList[i].notificationDescp+"\x3c/div\x3e\x3c/div\x3e";
notification+='\x3cdiv class\x3d"row noti-footer"\x3e\x3cdiv class\x3d"col-8" \x3e'+notiList[i].notificationTitle+"\x3c/div\x3e"}notification+='\x3cdiv class\x3d"col-4 date-align"\x3e'+notiList[i].createdDate+"\x3c/div\x3e";notification+="\x3c/div\x3e\x3c/div\x3e\x3c/a\x3e"}}$("#notifications").html(notification)}}})}
function updateNotification(notificationid,articleId,solListNotificationId){var notificationId_param=notificationid;var articleId_param=articleId;var solNotifId_param=solListNotificationId;var notificationPostData={};notificationPostData[notificationNamespace+"notificationId"]=notificationId_param;notificationPostData[notificationNamespace+"articleId"]=articleId_param;notificationPostData[notificationNamespace+"solListNotificationId"]=solNotifId_param;$.ajax({method:"post",dataType:"json",url:notificationUpdate,
data:notificationPostData,success:function(obj){console.log("update success")}})}
function redirectNotification(notificationTitle,notificationredirect,missionId,rebateReferenceID,notificationStatus,notificationType,notificationPageRedirectUrl,lenovoIdDomainUrl){if($(this).data("link")!=undefined){if($(".ifw").length<1)$("body").append('\x3ciframe src\x3d"#" class\x3d"invisible ifw" title\x3d"notificationOverlay"\x3e\x3c/iframe\x3e');setTimeout(function(){$(".ifw").attr("src",$(this).data("link"))},10)}if(notificationTitle=="Bid Requests"||notificationTitle=="Deal Registrations")redirectForBidRequest(notificationredirect);
else if(notificationType=="Portal Notification")redirectForPortalNotification(notificationredirect,notificationPageRedirectUrl,lenovoIdDomainUrl);else if(notificationTitle=="Solution List")setTimeout(function(){checkAndReplacePageUrl(lenovoIdDomainUrl+themeDisplay.getPortalURL()+notificationPageRedirectUrl+notificationredirect,userType,lenovoIdDomain,false)},100);else if(notificationTitle=="TCMA"&&notificationredirect==null||notificationredirect=="")redirectURL(notificationTitle,missionId,rebateReferenceID,
notificationStatus);else if(notificationTitle=="TCMA"&&notificationredirect!=null&&notificationredirect!="")redirectURLTcma(notificationredirect);else redirectURL(notificationTitle,missionId,rebateReferenceID,notificationStatus)}var redirectURLTcma=function(notificationredirect){var mainurl=TcmaUrl+"?redirectURL\x3d"+notificationredirect;setTimeout(function(){window.open(mainurl,"_self")},500)};
function redirectURL(notificationTitle,missionId,rebateReferenceID,notificationStatus){var mainurl;switch(notificationTitle){case "My Profile":mainurl=my_profileUrl;setTimeout(function(){window.location.href=mainurl},100);break;case "My Colleagues":mainurl=my_colleaguesUrl;setTimeout(function(){window.location.href=mainurl},100);break;case "Invite Colleague":mainurl="invite-colleague";setTimeout(function(){window.location.href=mainurl},100);break;case "My Company":mainurl=my_companyUrl;setTimeout(function(){window.location.href=
mainurl},100);break;case "StarSeller Missions":mainurl=StarSellerUrl+"?missionId\x3d"+missionId;setTimeout(function(){window.location.href=mainurl},100);break;case "Rebate Programs":mainurl=rebate_programUrl+"?referenceID\x3d"+rebateReferenceID;setTimeout(function(){window.location.href=mainurl},100);break;case "PEP":if(notificationStatus=="Current Level Status"){mainurl=rebate_list_url;setTimeout(function(){window.location.href=mainurl},100)}else{mainurl=PePUrl;setTimeout(function(){window.location.href=
mainurl},100)}break;case "TCMA":mainurl=TcmaUrl;setTimeout(function(){window.location.href=mainurl},100);break;case "tiering and competence":mainurl=competencyUrl;setTimeout(function(){window.location.href=mainurl},100);break}}function redirectForBidRequest(url){if(url!=undefined)window.open(url,"_blank")}
function redirectForPortalNotification(url,notificationPageRedirectUrl,lenovoIdDomainUrl){if(url!=undefined)if(url.indexOf("http")!==-1)window.open(url,"_blank");else if(url.includes("Solution Lists")||url.includes("Solution%20Lists"))setTimeout(function(){checkAndReplacePageUrl(lenovoIdDomainUrl+themeDisplay.getPortalURL()+notificationPageRedirectUrl+url,userType,lenovoIdDomain,false)},100);else setTimeout(function(){window.location.href=notificationPageRedirectUrl+url},100)}
var addShowPopupRecords=function(){$.ajax({method:"post",dataType:"json",url:showPopUpUpdateUrl,success:function(obj){console.log("update success");if(obj!=undefined&&obj!=null)if(obj.showPopupValueUpdated)$("#showPopupDivId").addClass("d-none")}})};
$(document).ready(function(){$(".lnv-search-result-content .search-btn button").click(function(){$(".lnv-loading").modal("show")});if(themeDisplay.isSignedIn()&&typeof notificationFlag!=="undefined"&&notificationFlag>0){$(".lnv-header-reddot").removeClass("d-none");$(".bell-vibrate").removeClass("d-none");$(".bell-static").addClass("d-none");var unreadCount=document.getElementById("count-unread");if(unreadCount!=null)document.getElementById("count-unread").innerHTML=notificationFlag}else{$(".lnv-header-reddot").addClass("d-none");
$(".bell-vibrate").addClass("d-none");$(".bell-static").removeClass("d-none")}if(themeDisplay.isSignedIn()&&typeof popUpFlag!=="undefined"&&popUpFlag=="true"&&welcomeFlag=="true")$("#showPopupDivId").removeClass("d-none");else if(themeDisplay.isSignedIn()&&typeof popUpFlag!=="undefined"&&popUpFlag=="false")$("#showPopupDivId").addClass("d-none");$(".lnv-header-notification").off("click").on("click",function(event){event.stopPropagation();var pos=$(this).offset();if($(window).width()<480)$(".header-noti-wrapper").toggleClass("d-none").removeAttr("style").css({"top":$(".main-lnv-wrapper").outerHeight(),
"left":0});else $(".header-noti-wrapper").toggleClass("d-none").removeAttr("style").css({"top":$(".main-lnv-wrapper").outerHeight(),"left":pos.left-290});$(".lnv-header-reddot").addClass("d-none");$(this).toggleClass("border-underline");callLPPNotificationTrack();getNotification()})});function closeNotificationPopup(){$("#showPopupDivId").addClass("d-none")};
