Ra_collection[1].txt

  • Uploaded by: Arisleidy Asprilla
  • 0
  • 0
  • April 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Ra_collection[1].txt as PDF for free.

More details

  • Words: 29,035
  • Pages: 201
// create a test node off the browser screen to calculate high contrast mode var testNode = document.createElement("div"); testNode.className = "highContrastTestNode"; document.body.appendChild(testNode); // look at the computed style for the test node var styles = null; try { styles = document.defaultView.getComputedStyle(testNode, ""); } catch(e) { styles = testNode.currentStyle; } var testImg = styles.backgroundImage; if ((styles.borderTopColor == styles.borderRightColor) || (testImg != null && (testImg == "none" || testImg == "url(invalid-url:)" ))) { document.getElementsByTagName("body")[0].className+=" lotusImagesOff"; } document.body.removeChild(testNode);(function(){ var _1=ibmCfg.portalConfig.contentHandlerURI+ ((ibmCfg.portalConfig.contentHandlerURI.indexOf("?")<0)?"?":"&")+"uri=menu:${id}"; var _2=false; var _3=function(){ return i$.hasClass(document.getElementsByTagName("body")[0],"edit-mode"); }; if(typeof wptheme==="undefined"||!wptheme){ wptheme={}; } i$.mash(wptheme,{getWindowIDFromSkin:function(_4){ while((_4=_4.parentNode)!=null){ if(i$.hasClass(_4,"component-control")){ var m=_4&&(_4.className||"").match(/id-([\S]+)/); return m&&m[1]; } } return null; },getPortletState:function(_5){ var _6=i$.byId("portletState"); if(_6){ if(!_6._cache){ _6._cache=i$.fromJson(_6.innerHTML); _6._cache._defaults={"windowState":"normal","portletMode":"view"}; } if(_6._cache[_5]){ return _6._cache[_5]; }else{ return _6._cache._defaults; } } return {}; },isValidOp:function(_7){ if(_7.visibility===false){ return false; } var _8=_7.metadata||{}; switch(_7.id){ case "ibm.portal.operations.changePortletMode": return wptheme.getPortletState(_8.wid).portletMode!=_8.portletMode; case "ibm.portal.operations.changeWindowState": return wptheme.getPortletState(_8.wid).windowState!=_8.windowState; default:

} return true; },operation:{changeToHelpMode:function(_9){ var _a=window.location.href; if(_9.actionUrl){ if(_9.actionUrl.indexOf("?")==0){ var _b=_a.indexOf("#"); if(_b!=-1){ var _c=_a.substring(0,_b); var _d=_a.substring(_b); _a=_c+(_c.indexOf("?")==-1?"?":"&")+_9.actionUrl.substring(1); _a+=_d; }else{ _a+=(_a.indexOf("?")==-1?"?":"&")+_9.actionUrl.substring(1); } }else{ _a=_9.actionUrl; } } window.open(_a,"","resizable=yes,scrollbars=yes,menubar=no,toolbar=no,status=no,wid th=800,height=600,screenX=10,screenY=10,top=10,left=10"); }},canImpersonate:function(){ return ibmCfg.portalConfig.canImpersonate; },contextMenu:{cache:{},css: {focus:"wpthemeMenuFocus",disabled:"wpthemeMenuDisabled",show:"wpthemeMenuShow",err or:"wpthemeMenuError",menuTemplate:"wpthemeTemplateMenu",submenuTemplate:"wpthemeTe mplateSubmenu",loadingTemplate:"wpthemeTemplateLoading"},init:function(_e,_f,_10){ _e._contextMenu=_e._contextMenu||{}; _e._contextMenu.id=_e._contextMenu.id||Math.round(Math.random()*1000000000); _e.setAttribute("id",_e._contextMenu.id); _e._contextMenu.menuId=_f; _e._contextMenu.jsonQuery=_10; var _11=_e._contextMenu; var _12=function(_13){ if(_13.displayMenu){ i$.fireEvent("wptheme/contextMenu/close/all"); if(!_11._submenu){ i$.fireEvent("wptheme/contextMenu/close/all"); wptheme.contextMenu._updateAbsolutePosition(i$.byId(_11.id)); } var _14=wptheme.contextMenu._adjustScreenPositionStart(); i$.addClass((_11.shadowNode)? _11.shadowNode:i$.byId(_11.id),wptheme.contextMenu.css.show); wptheme.contextMenu._adjustScreenPositionEnd(_14); var _15=i$.byId(_11.id)._firstSelectable; if(_15){ _15.focus(); i$.byId(_11.id)._currentSelected=_15; } i$.addListener("wptheme/contextMenu/close/all",function(){ var _16=i$.byId(_11.id); }); } }; wptheme.contextMenu._initialize(_e).then(_12,_12); _e=null; },initSubmenu:function(_17,_18,_19){ _17._contextMenu=_17._contextMenu||{}; _17._contextMenu._submenu=true;

_17._contextMenu._menuitemTemplate=_19._menuitemTemplate; _17._contextMenu._subMenuTemplate=_19._subMenuTemplate; _17._contextMenu._loadingTemplate=_19._loadingTemplate; wptheme.contextMenu.init(_17,_18,_19.jsonQuery); },_findFocusNode:function(_1a){ var _1b,i,_1c; var _1d=function(_1e,_1f){ var l=_1e.childNodes.length; for(i=0;i=0;i--){ _24=_26.childNodes[i]; if(i$.hasClass(_24,wptheme.contextMenu.css.menuTemplate)){ _21=_24; continue; } if(i$.hasClass(_24,wptheme.contextMenu.css.submenuTemplate)){ _22=_24; continue; } if(i$.hasClass(_24,wptheme.contextMenu.css.loadingTemplate)){ _23=_24; continue; } if(_24.childNodes){ i=_25(_24,i); } } return _27; }; _25(_20); return {"menu":_21,"submenu":_22,"loading":_23}; },_invalidateCallback:function(){ wptheme.contextMenu.cache={}; },_initialize:function(_28){ var _29=true; var _2a=_28._contextMenu; if(wptheme.contextMenu.cache[_2a.id]||_2a._inProgress){

return i$.promise.resolved({displayMenu:_29}); } _2a._inProgress=true; i$.addListener("wptheme/contextMenu/invalidate/all",wptheme.contextMenu._invalidate Callback); var _2b,_2c,tmp=i$.createDom("div"); if(_2a._submenu){ tmp.innerHTML=_2a._subMenuTemplate.replace(/\$\{submenu-id\}/g,_2a.id+"_menu"); _28.appendChild(tmp.firstChild); _2b=i$.byId(_2a.id+"_menu"); _2c=i$.createDom("div"); _2c.innerHTML=_2a._loadingTemplate; }else{ var _2d=wptheme.contextMenu._findNodes((_2a.shadowNode)?_2a.shadowNode:_28); _2b=_2d.menu; if(!_2a._menuitemTemplate){ _2a._menuitemTemplate=i$.trim(_2b.innerHTML); } if(!_2a._loadingTemplate){ _2c=i$.createDom("div"); _2c.appendChild(_2d.loading); _2a._loadingTemplate=i$.trim(_2c.innerHTML); _2c=null; } _2c=i$.createDom("div"); _2c.innerHTML=_2a._loadingTemplate; tmp.appendChild(_2d.submenu.cloneNode(true)); if(!_2a._subMenuTemplate){ _2a._subMenuTemplate=i$.trim(tmp.innerHTML); } } while(_2b.firstChild){ _2b.removeChild(_2b.firstChild); } _2b.appendChild(_2c); var _2e; if(_2a._submenu){ _2e=_2a.shadowNode; }else{ if(_2a.shadowNode){ _2e=_2a.shadowNode; }else{ _2e=wptheme.contextMenu._transformIntoAbsolutePosition(_28); } } i$.addClass((_2e)?_2e:_28,wptheme.contextMenu.css.show); i$.bindDomEvt((_2e)?_2e:_28,"onmouseleave",function(){ if(_2a._inProgress){ _29=false; } var _2f=i$.byId(_2a.id); i$.removeClass((_2a.shadowNode)?_2a.shadowNode:_2f,wptheme.contextMenu.css.show); if(!_2a.activeAction){ var _30=_2f._currentSelected; if(_30){ _30.blur(); } var _31=wptheme.contextMenu._findFocusNode(_2f); ((_31)?_31:_2f).focus();

} }); return wptheme.contextMenu._load(_2a).then(function(_32){ var _33=wptheme.contextMenu._parseData(_32).then(function(_34){ _34=wptheme.contextMenu._filterMenu(_34); if(!_34||_34.length==0){ var tmp=i$.createDom("div"); tmp.innerHTML=wptheme.contextMenu._fromTemplate(_2a._menuitemTemplate,wptheme.conte xtMenu.css.error,wptheme.contextMenu.nls.NO_ITEMS_0); while(_2b.firstChild){ _2b.removeChild(_2b.firstChild); } _2b.appendChild(tmp); }else{ wptheme.contextMenu._buildMenu(_2a,_2b,_34); } _2a._inProgress=false; wptheme.contextMenu.cache[_2a.id]=true; return {displayMenu:_29}; }); return _33; },function(){ var tmp=i$.createDom("div"); tmp.innerHTML=wptheme.contextMenu._fromTemplate(_2a._menuitemTemplate,wptheme.conte xtMenu.css.error,wptheme.contextMenu.nls.ERROR_LOADING_0); while(_2b.firstChild){ _2b.removeChild(_2b.firstChild); } _2b.appendChild(tmp); _2a._inProgress=false; wptheme.contextMenu.cache[_2a.id]=true; return {displayMenu:_29}; }); },_load:function(_35){ var _36=_1.replace(/\$\{id\}/g,_35.menuId); if(_35.jsonQuery){ _36+=(_36.indexOf("?")==-1?"?":"&")+i$.toQuery(_35.jsonQuery); } return i$.xhrGet({url:_36,headers:{"X-IBMXHR":"true"},responseType:"json"}).then(function(_37){ return _37.data; },function(_38){ var _39=_38.xhr.getResponseHeader("Content-Type")||""; if((_39.indexOf("text/html")==0)||(_38.xhr.status==401)){ window.setTimeout(function(){ document.location.reload(); },0); } console.log("Error trying to load the context menu feed for '"+_35.menuId+"': "+_38); return null; }); },_parseData:function(_3a){ var _3b=[]; i$.each(_3a,function(_3c){ var _3d=i$.fromPath("moduleInfo.deferred",false,_3c)? i$.modules.loadDeferred():i$.promise.resolved(true); _3b.push(_3d.then(function(){ var _3e=wptheme.contextMenu._checkFunction(_3c,_3c.visibilityFn,_3c,(typeof

_3c.visibility!="undefined")?_3c.visibility:true); var _3f=wptheme.contextMenu._checkFunction(_3c,_3c.enableFn,_3c,(typeof _3c.enabled!="undefined")?_3c.enabled:true); return i$.whenAll(_3e,_3f).then(function(_40){ _3c._visible=_40[0]; _3c._enabled=_40[1]; return _3c; }); })); }); return i$.whenAll.apply(i$,_3b); },_filterMenu:function(_41){ var _42=[],_43,_44={"type":"Separator"}; for(var i=_41.length-1;i>=0;i--){ _43=_41[i]; if(!_43._visible){ continue; } if(_43.type=="Separator"){ if(_44.type=="Separator"){ continue; } }else{ if(_43.type=="Header"){ if((_44.type=="Separator")||(_44.type=="Header")){ continue; } } } _44=_43; _42.unshift(_43); } while(_42.length>0&&_42[0].type=="Separator"){ _42=_42.slice(1); } return _42; },_buildMenu:function(_45,_46,_47){ var _48=document.createDocumentFragment(),tmp=i$.createDom("div"),_49,_4a,_4b,_4c; for(var i=0,l=_47.length;i
wptheme.contextMenu._stopEventPropagation(evt); wptheme.contextMenu._applyAction(evt); setTimeout(function(){ var _4d=i$.byId(_45.id); i$.removeClass((_45.shadowNode)?_45.shadowNode:_4d,wptheme.contextMenu.css.show); },0); }); i$.bindDomEvt(_4a,"onkeydown",function(evt){ return wptheme.contextMenu._applyKeyAction(evt); }); i$.bindDomEvt(_4a,"onmouseover",function(evt){ return wptheme.contextMenu._applyFocusAction(evt); }); } } if((_49.title)&&(i$.isRTL(_49.title.lang))){ i$.addClass(_4a,"rtl"); _4a.setAttribute("dir","RTL"); } if(_49.markupId){ _4a.setAttribute("id",_49.markupId); } } _48.appendChild(_4a); } } while(_46.firstChild){ _46.removeChild(_46.firstChild); } _46.appendChild(_48); i$.byId(_45.id)._firstSelectable=_4c; i$.byId(_45.id)._currentSelected=null; },_fromTemplate:function(_4e,_4f,_50){ var _51,_52,_53; if(typeof (_4f)=="string"){ _51=_4f; _52=_50; _53=""; }else{ _51="type"+_4f.type; if(_4f.itemClass){ _51+=" "+_4f.itemClass; } if(!_4f._enabled){ _51+=" "+wptheme.contextMenu.css.disabled; } _52=(_4f.title)?_4f.title.value:""; _53=((_4f.description)?_4f.description.value:""); } return _4e.replace(/\$\{title\}/g,_52).replace(/"\$\{css-class\}"/g,"\""+ (_51)+"\"").replace(/\$\{css-class\}/g,"\""+(_51)+"\"").replace(/"\$\ {description\}"/g,"\""+_53+"\"").replace(/\$\{description\}/g,"\""+_53+"\""); },_checkFunction:function(_54,fn,arg,_55){ if(fn){ if(!_54.fromPath){ _54.fromPath={}; } var _56=_54.fromPath[fn]||i$.fromPath(fn); _54.fromPath[fn]=_56;

if(i$.isFunction(_56)){ try{ return _56(arg); } catch(exc){ console.log("error executing function "+fn+" - "+exc); } } } return i$.promise.resolved(_55); },_stopEventPropagation:function(evt){ if(evt){ if(evt.stopPropagation){ evt.stopPropagation(); }else{ evt.cancelBubble=true; } } },_applyKeyAction:function(evt){ var _57=evt.target||evt.srcElement; var _58=_57; var _59=null; while(!_59){ _58=_58.parentNode; if(_58._contextMenu){ _59=_58; } } var _5a=_59._contextMenu; switch(evt.keyCode){ case 13: wptheme.contextMenu._stopEventPropagation(evt); var _5b=i$.byId(_5a.id); i$.removeClass((_5a.shadowNode)?_5a.shadowNode:_5b,wptheme.contextMenu.css.show); var _5c=wptheme.contextMenu._findFocusNode(_5b); window.setTimeout(function(){ ((_5c)?_5c:_59).focus(); window.setTimeout(function(){ wptheme.contextMenu._applyAction(evt); },0); },0); return false; case 9: case 27: var _5b=i$.byId(_5a.id); i$.removeClass((_5a.shadowNode)?_5a.shadowNode:_5b,wptheme.contextMenu.css.show); var _5c=wptheme.contextMenu._findFocusNode(_5b); ((_5c)?_5c:_59).focus(); break; case 40: wptheme.contextMenu._moveFocus(evt,_5a,_57,"next"); return false; case 38: wptheme.contextMenu._moveFocus(evt,_5a,_57,"previous"); return false; } return true; },_moveFocus:function(evt,_5d,_5e,_5f){ var _60=_5e.links[_5f];

if(_60&&(_60._menuitem.type=="Header"||_60._menuitem.type=="Separator")){ var _61=false; var _62=null; while(!_62&&!_61){ _60=_60.links[_5f]; if(!_60){ _61=true; }else{ if(_60._menuitem.type!="Header"&&_60._menuitem.type!="Separator"){ _62=_60; } } } _60=_62; } if(_60){ var _63=i$.byId(_5d.id)._currentSelected; if(_63){ _63.blur(); } i$.byId(_5d.id)._currentSelected=_60; _60.focus(); } if(evt.preventDefault){ evt.preventDefault(); } },_applyFocusAction:function(evt){ var _64=evt.target||evt.srcElement; var _65=_64; var _66=null; var _67=_64._menuitem; while(!_66){ _65=_65.parentNode; if(_65._contextMenu){ _66=_65; } if(!_67){ _64=_64.parentNode; _67=_64._menuitem; } } var _68=_66._contextMenu; var _69=i$.byId(_68.id)._currentSelected; if(_69!=_64){ if(_69){ _69.blur(); i$.byId(_68.id)._currentSelected=null; } if(_67.type!="Header"&&_67.type!="Separator"){ i$.byId(_68.id)._currentSelected=_64; _64.focus(); } } return false; },_applyAction:function(evt){ var _6a=evt.target||evt.srcElement; var _6b=_6a; var _6c=null; var _6d=_6a._menuitem;

while(!_6c){ _6b=_6b.parentNode; if(_6b._contextMenu){ _6c=_6b; } if(!_6d){ _6a=_6a.parentNode; _6d=_6a._menuitem; } } var _6e=_6c._contextMenu; _6e.activeAction=true; var p=wptheme.contextMenu._checkFunction(_6d,_6d.actionFn,_6d,_6d.actionUrl); if(p){ p.then(function(_6f){ if(_6f&&i$.isString(_6f)){ var _70=_6d.actionHttpMethod||"GET"; if(_70!="GET"){ var _71=i$.createDom("form"); _71.setAttribute("action",_6f); _70=_70.toLowerCase(); switch(_70){ case "get": _71.setAttribute("method","GET"); break; case "delete": case "put": var _72=i$.createDom("input",{"type":"hidden","name":"x-methodoverride","value":_70.toUpperCase()}); _71.appendChild(_72); case "post": _71.setAttribute("method","POST"); _71.setAttribute("enctype","multipart/form-data"); break; default: } i$.byId("wpthemeComplementaryContent").appendChild(_71); _71.submit(); }else{ window.location.href=_6f; } } }); } },_applySubmenu:function(evt){ var _73=evt.target||evt.srcElement; if(!_73._jsonData){ _73=_73.parentNode; } if(_73._jsonData){ _73.setAttribute("id",_73._jsonData.id+"_"+_73._menuitem.id); wptheme.contextMenu.initSubmenu(_73,_73._menuitem.id,_73._jsonData); } },_transformIntoAbsolutePosition:function(_74){ var _75=_74.childNodes,_76,i=0,_77=false; while(_76=_75[i++]){ if(i$.hasClass(_76,"wpthemeMenuRight")){ _77=true; break;

}else{ if(i$.hasClass(_76,"wpthemeMenuLeft")){ break; } } } var _78=i$.createDom("div"); _78.className=_74.className; _78.appendChild(_76); i$.byId("wpthemeComplementaryContent").appendChild(_78); _78._contextMenu=_74._contextMenu; _74._contextMenu.shadowNode=_78; _74._contextMenu._menuIsRight=_77; var _79=i$.createDom("span"); _78.appendChild(_79); i$.addClass(_79,"wpthemeMenuOverlay"); _74._contextMenu.overlayNode=_79; _74._contextMenu.menuNode=_76; wptheme.contextMenu._updateAbsolutePosition(_74); return _78; },_updateAbsolutePosition:function(_7a){ var _7b=_7a._contextMenu._menuIsRight; var _7c=_7a._contextMenu.menuNode; var _7d=_7a._contextMenu.overlayNode; var _7e=wptheme.contextMenu._findPos(_7a); var _7f=2; _7d.style.left=(_7e[0]-_7f)+"px"; _7d.style.top=(_7e[1]-_7f)+"px"; _7d.style.width=(_7a.offsetWidth+(2*_7f))+"px"; _7d.style.height=(_7a.offsetHeight+(2*_7f))+"px"; var dir=document.getElementsByTagName("html")[0].getAttribute("dir"); if(dir!=null){ dir=dir.toLowerCase(); }else{ dir=""; } if(!(dir=="rtl")){ _7c.style.left=((_7b)?_7e[0]+_7a.offsetWidth:_7e[0])+"px"; }else{ _7c.style.left=((_7b)?_7e[0]+_7a.offsetWidth-_7a.scrollWidth:_7e[0])+"px"; } _7c.style.top=_7e[1]+"px"; },_adjustScreenPositionStart:function(){ return document.documentElement.scrollHeight; },_adjustScreenPositionEnd:function(_80){ var _81=document.documentElement.scrollHeight; if(_80!=_81){ document.documentElement.scrollTop=document.documentElement.scrollHeight; } },_findPos:function(obj){ var _82=curtop=0; if(obj.offsetParent){ do{ _82+=obj.offsetLeft; curtop+=obj.offsetTop; }while(obj=obj.offsetParent); return [_82,curtop]; } }}});

})(); (function(){ i$.merge({ "NO_ITEMS_0":"No hay elementos que visualizar.", "ERROR_LOADING_0":"Se ha producido un error al cargar el menú." },i$.fromPath("wptheme.contextMenu.nls",true)); })(); (function(){ if(!i$.isIE){ i$.addOnLoad(function(){ var _1=document.getElementsByTagName("SECTION"); for(var i=0;i<_1.length;i++){ if(i$.hasClass(_1[i],"a11yRegionTarget")){ var _2=_1[i]; var _3=null; var _4=_2.getElementsByTagName("SPAN"); for(var j=0;j<_4.length;j++){ if(i$.hasClass(_4[j],"a11yRegionLabel")){ _3=_4[j]; } } if(_3){ var _5=_3; var _6=_2; var _7=null; while((_6=_6.parentNode)!=null){ if(i$.hasClass(_6,"component-control")){ var m=_6&&(_6.className||"").match(/id-([\S]+)/); _7=m&&m[1]; break; } } if(_7){ var _8="wpRegionId"+_7; _5.setAttribute("id",_8); _2.setAttribute("aria-labelledby",_8); } } } } }); } })(); jQuery("document").ready(function() { if ( $( "#showContent" ).length ) { var objappVersion = navigator.appVersion; var objAgent = navigator.userAgent; var objbrowserName = navigator.appName; var objfullVersion = ''+parseFloat(navigator.appVersion); var objBrMajorVersion = parseInt(navigator.appVersion,10); var objOffsetName,objOffsetVersion,ix; // In Chrome if ((objOffsetVersion=objAgent.indexOf("Chrome"))!=-1) { objbrowserName = "Chrome"; objfullVersion = objAgent.substring(objOffsetVersion+7); document.getElementById("showContent").innerHTML="


  • "+$

    ('#ID_pps_lbl_DetectMyDevice_ChromeStep1').val()+"
  • "+$ ('#ID_pps_lbl_DetectMyDevice_ChromeStep2').val()+"
  • "+$ ('#ID_pps_lbl_DetectMyDevice_ChromeStep3').val()+"
"; } // In Microsoft internet explorer else if (!!(navigator.userAgent.match(/Trident/))|| (objOffsetVersion=objAgent.indexOf("MSIE"))!=-1) { objbrowserName = "Microsoft Internet Explorer"; objfullVersion = objAgent.substring(objOffsetVersion+5); if (document.all && document.querySelector && ! document.addEventListener) { document.getElementById("showContent").innerHTML="
  • ('#ID_pps_lbl_DetectMyDevice_IE8Step1').val()+"
  • "+$ ('#ID_pps_lbl_DetectMyDevice_IE8Step2').val()+"
  • "+$ ('#ID_pps_lbl_DetectMyDevice_IE8Step3').val()+"
"; } else{ document.getElementById("showContent").innerHTML="
  • ('#ID_pps_lbl_DetectMyDevice_IEStep1').val()+"
  • "+$ ('#ID_pps_lbl_DetectMyDevice_IEStep2').val()+"
"; } } // In Firefox else if ((objOffsetVersion=objAgent.indexOf("Firefox"))!=-1) { objbrowserName = "Firefox"; document.getElementById("showContent").innerHTML="
  • "+$ ('#ID_pps_lbl_DetectMyDevice_FirefoxStep1').val()+"
  • "+$ ('#ID_pps_lbl_DetectMyDevice_FirefoxStep2').val()+"

  • "+$ ('#ID_pps_lbl_DetectMyDevice_FirefoxStep3').val()+"
  • "+$ ('#ID_pps_lbl_DetectMyDevice_FirefoxStep4').val()+"
"; } // In Safari else if ((objOffsetVersion=objAgent.indexOf("Safari"))!=-1) { objbrowserName = "Safari"; objfullVersion = objAgent.substring(objOffsetVersion+7); if ((objOffsetVersion=objAgent.indexOf("Version"))!=-1) objfullVersion = objAgent.substring(objOffsetVersion+8); } // For other browser "name/version" is at the end of userAgent else if ( (objOffsetName=objAgent.lastIndexOf(' ')+1) < (objOffsetVersion=objAgent.lastIndexOf('/')) ) { objbrowserName = objAgent.substring(objOffsetName,objOffsetVersion); objfullVersion = objAgent.substring(objOffsetVersion+1); if (objbrowserName.toLowerCase()==objbrowserName.toUpperCase()) { objbrowserName = navigator.appName; } } // trimming the fullVersion string at semicolon/space if present if ((ix=objfullVersion.indexOf(";"))!=-1) objfullVersion=objfullVersion.substring(0,ix); if ((ix=objfullVersion.indexOf(" "))!=-1) objfullVersion=objfullVersion.substring(0,ix); objBrMajorVersion = parseInt(''+objfullVersion,10);

"+$

"+$

if (isNaN(objBrMajorVersion)) { objfullVersion = ''+parseFloat(navigator.appVersion); objBrMajorVersion = parseInt(navigator.appVersion,10); } } }); /* Global variable declaration*/ var typeAheadTimeout; // to clear Timeout var currentValue; var ajaxParam = { // to hold paramaters to send to ajax url1 : '', //for 1st IDOL call url2 : '', // for second IDOL call url : '', paramData : {} }; var countEachBind = 0; var KEY = { UP : 38, DOWN : 40, TAB : 9, ENTER : 27 }; var comingFromPFinder = false; var urlCreationFilteredData; $(document).ready(function() { typeAheadInit(); }); function checkValidity(val) { if (typeof val !== "undefined" && val != null) { return true; } return false; } /* Initialise the typeahead and attach event handlers */ function typeAheadInit() { $("input[type='text']").each(function() { if ($(this).hasClass("reqTypeAhead")) { var typeAheadObjClass = $(this).data("predectivecontainer"); handleEvents(typeAheadObjClass, $(this)); });

}

} /* Event handler for keyboard and mouse events */ function handleEvents(typeAheadObjClass, reqTypeaheadBox) { // close typeahead on outside click - start - Richa $(document).click(function(e) { if (e.target.id != "search-input") { $('.predictive-results.search-predictive-results').hide();

} }); // close typeahead on outside click - end - Richa // call the typeahead function on input - insert or delete (reqTypeaheadBox).on("input", function() { if((reqTypeaheadBox.val() != undefined) && (reqTypeaheadBox.val() != (reqTypeaheadBox).attr("ghostText"))){ callTypeAhead(reqTypeaheadBox, typeAheadObjClass); } }); // call the typeahead function on input - IE8 if ($("body").hasClass("ie8")) { (reqTypeaheadBox).on("keydown", function(event) { if ((event.which != KEY.DOWN) && (event.which != KEY.UP) && (currentValue != (reqTypeaheadBox).attr("ghostText"))) { callTypeAhead(reqTypeaheadBox, typeAheadObjClass); } }); (reqTypeaheadBox).on("paste", function(event) { setTimeout(function() { callTypeAhead(reqTypeaheadBox, typeAheadObjClass) }, 1); }); jQuery(document).on("dragend",reqTypeaheadBox, function(event) { callTypeAhead(reqTypeaheadBox, typeAheadObjClass); }); } // handle arrow keys , enter, tab on typeahead box (reqTypeaheadBox).on("keydown", function(event) { if ($("." + typeAheadObjClass).length > 0) { if ((event.which != KEY.DOWN) && (event.which != KEY.UP)) { } else if ((event.which == KEY.DOWN)) { event.stopPropagation(); event.preventDefault(); $("." + typeAheadObjClass + " li a").first().focus(); $("." + typeAheadObjClass + " li a").removeClass("hover"); $("." + typeAheadObjClass + " li a").first().addClass("hover"); (reqTypeaheadBox).val($(document.activeElement).text()); // $(".typeAheadBox").val($(document.activeElement).text()); } /* else if(event.which == KEY.TAB){ var clearIcon = (reqTypeaheadBox).parents(".searchbg").find(".clear-search"); if($(clearIcon).length > 0 ){ $(clearIcon).focus(); } }*/ else if ((event.which == KEY.UP)) event.stopPropagation(); event.preventDefault(); $("." + typeAheadObjClass + " $("." + typeAheadObjClass + " $("." + typeAheadObjClass + "

{ li a").last().focus(); li a").removeClass("hover"); li a").last().addClass("hover");

(reqTypeaheadBox).val($(document.activeElement).text()); // $(".typeAheadBox").val($(document.activeElement).text()); }

}

/* else{ if(event.which == KEY.TAB){ var clearIcon = (reqTypeaheadBox).parents(".searchbg").find(".clear-search"); if($(clearIcon).length > 0 ){ $(clearIcon).focus(); } } }*/ if ((event.which == KEY.ENTER)) { event.preventDefault(); (reqTypeaheadBox).val(""); $("." + typeAheadObjClass).remove();

} });

// handle blur on typeahead box $(reqTypeaheadBox).on("blurTypeahead", function(event) { isHidePrediction(typeAheadObjClass, reqTypeaheadBox); }); $(document).on("blur","." + typeAheadObjClass + " li a", function(event) { isHidePrediction(typeAheadObjClass, reqTypeaheadBox); });

// Click on the predictive results $(document).on("click", "." + typeAheadObjClass + " li a", function(event) { (reqTypeaheadBox).val($(this).text()); // If mobile device then check the type ahead behaviour if(isMobileDevice()){ //Since this is mobile & if the key is not true then we need to stop type ahead if(typeAheadClickBehaviorMobile && typeAheadClickBehaviorMobile != "true"){ $(this).parents(".predictive-results").remove(); (reqTypeaheadBox).focus(); //Also we are force returning the event here to stop the ajax call return; } } else { //Now this is not Mobile //Checking if the in Desktop/Tablet if the type ahead behaviour is disabled. if(typeAheadClickBehaviorDesktop && typeAheadClickBehaviorDesktop != "true"){ //Since it is set to something other than true, we are stoping this action $(this).parents(".predictive-results").remove();

(reqTypeaheadBox).focus(); //Also we are force returning the event here to stop the ajax call

return; }

} (reqTypeaheadBox).data("productid",$(this).data("productid")); $(this).parents(".predictive-results").remove(); (reqTypeaheadBox).focus();

/* 6523 - pFinder( SWD) with typeahead functionality if it is pfinder then navigate to SWD step 2 page series = us-en/drivers/selfservice/hp-deskjet-d2600-printerseries/3742933 model = us-en/drivers/selfservice/hp-deskjet-d2600-printerseries/3742933/model/3742935 nodeDepth = 4 for SKU = 6 for product = 2 for series */ //https://g9t0144.houston.hp.com/apps/Nav?h_client=s-a-r118391&h_product=5436977&h_lang=en&h_cc=us&h_pagetype=s-017 var searchQuery = $("input[name='searchQuery']"); if(searchQuery && reqTypeaheadBox.hasClass("pfinder-search") && comingFromPFinder ) { var prodIdSelectedTypeahead = $(this).data("productid"); var separator = "/"; var url = document.location.origin + separator; var cCode = getCCLC("cc") ; var lCode = getCCLC("lc"); //Checking for special cc lc conditions /*if(cCode == "gb" && lCode == "en"){ cCode = "uk" ; } else{ lCode = localeConversion(cCode,lCode); } */ url += cCode + "-"; url += lCode + separator; var pageIdentifier = $('#pageIdentifier').val().toLowerCase(); var urlIdentifier = document.location.href; //adding url creation code for contact-hp /*if(pageIdentifier == "contact hp - anonymous" || urlIdentifier.indexOf("contact-hp") != -1){ url += "contact-hp/product" + separator; }*/ if(pageIdentifier == "swdselfservice" || urlIdentifier.indexOf("drivers") != -1){ url += "drivers/selfservice" + separator; // has to come from SSC - TBD } /*else if(pageIdentifier == "identifyproduct" || urlIdentifier.indexOf("products") != -1 ){ url += "product" + separator; }*/

var productIDContact; var seriesIDContact; var skuIDContact; console.log(urlCreationFilteredData); if(urlCreationFilteredData) { var title; if(urlCreationFilteredData.length >= 1) { $.each(urlCreationFilteredData, function(index, obj) { var data = urlCreationFilteredData[index]; if(data.id == prodIdSelectedTypeahead) { // looping each prod id from response json to match with prod id of clicked typeahead selection // url for series /*6594 - url creation using seofriendlyname*/ if(data.seoFriendlyName!=undefined) { title = data.seoFriendlyName; } else { title = data.seriesName; title = title.replace(/ /g,"-"); } url += title + separator; url += data.seriesId + separator; seriesIDContact = data.seriesId; if(data.classType == 3 || data.classType == 4) { url += "model" + separator; url += data.productId; productIDContact = data.productId; } if(data.classType == 4) { url += "?sku="; url += data.skuId; skuIDContact = data.skuId; } return false; } }); } else { /*6594 - url creation using seofriendlyname*/ if(urlCreationFilteredData.seoFriendlyName!=undefined) { title = urlCreationFilteredData.seoFriendlyName; } else { title = urlCreationFilteredData.seriesName; title = title.replace(/ /g,"-"); } url += title + separator; url += urlCreationFilteredData.seriesId + separator; seriesIDContact = urlCreationFilteredData.seriesId; if(urlCreationFilteredData.classType == 3 || urlCreationFilteredData.classType == 4) { url += "model" + separator; url += urlCreationFilteredData.productId; productIDContact = urlCreationFilteredData.productId; }

if(urlCreationFilteredData.classType == 4) { url += "&sku="; url += urlCreationFilteredData.skuId; skuIDContact = urlCreationFilteredData.skuId; }

} //adding url creation code for contact-hp //var pageIdentifier = $ ('#pageIdentifier').val().toLowerCase(); //var redirectHubUrl = ''; //var redirectHubUrl = "http://g9t0144.houston.hp.com/apps/Nav?h_client=s-a-r11839-1" ; var redirectHubUrl = hubNavigationBaseUrl ; if(productIDContact != undefined){ //no product oid is returned by Idol redirectHubUrl += "&h_product=" + productIDContact; } else{ redirectHubUrl += "&h_product=" + seriesIDContact; } //Checking for special cc lc conditions if(cCode == "gb" && lCode == "en"){ cCode = "uk" ; } else{ lCode = localeConversion(cCode,lCode); } redirectHubUrl += "&h_lang=" + lCode +"&h_cc=" + cCode ; if(pageIdentifier == "contact hp - anonymous" || urlIdentifier.indexOf("contact-hp")!= -1){ redirectHubUrl += "&h_pagetype=s-017"; if (skuIDContact!= undefined){ redirectHubUrl += "&sku=" + skuIDContact; } console.log(redirectHubUrl); window.location.href = redirectHubUrl; }else if(pageIdentifier == "identifyproduct" // It's not SWD landing but the Products landing || (urlIdentifier.indexOf("products") != -1 && urlIdentifier.indexOf("/drivers/products") == -1) ){ redirectHubUrl += "&h_pagetype=s-001"; if (skuIDContact!= undefined){ redirectHubUrl += "&sku=" + skuIDContact; } console.log(redirectHubUrl); window.location.href = redirectHubUrl; }else{ // if url contains '/' at end, remove it var urlLastIndex = url.length - 1; if(url.charAt(urlLastIndex) == separator) { url = url.substr(0,urlLastIndex); } console.log(url); window.location.href = url; }

} } else { (reqTypeaheadBox).parents("form").submit(); } }); // keyboard events on the predictive results $(document).on("keydown","." + typeAheadObjClass + " li a",function(event) { event.stopPropagation(); event.preventDefault(); if ((event.which == KEY.DOWN)) {

in DOM tree*/

if (!($(document.activeElement).parents("li") .is(':last-child'))) { /*3244 start: stop all handlers from being executed

event.stopImmediatePropagation(); /*3244 end*/ $ (document.activeElement).parents("li").find("a").removeClass("hover"); $ (document.activeElement).parents("li").next().children("a").addClass("hover"); $ (document.activeElement).parents("li").next().children("a").focus(); /*For d-3589 */ $ (document.activeElement).closest(".hasTypeahead").find("input.search-input").val($ (document.activeElement).text()); // $(".typeAheadBox").val($ (document.activeElement).text()); //(reqTypeaheadBox).val($ (document.activeElement).text()); } else { $("." + typeAheadObjClass + " li a").removeClass("hover"); (reqTypeaheadBox).focus(); (reqTypeaheadBox).val(currentValue); // autocomplete(reqTypeaheadBox, // typeAheadObjClass); } } else if(event.which == KEY.TAB){ var clearIcon = (reqTypeaheadBox).parents(".searchbg").find(".clear-search"); if($(clearIcon).length > 0 ){ $(clearIcon).focus(); } $("." + typeAheadObjClass).remove(); } else if ((event.which == KEY.UP)) { if (!($(document.activeElement).parents("li") .is(':first-child'))) { /*3244 start: stop all handlers from being executed

in DOM tree*/

event.stopImmediatePropagation(); /*3244 end*/ $ (document.activeElement).parents("li").find("a").removeClass("hover"); $ (document.activeElement).parents("li").prev().children("a").addClass("hover"); $ (document.activeElement).parents("li").prev().children("a").focus(); /*For d-3589 */ $ (document.activeElement).closest(".hasTypeahead").find("input.search-input").val($ (document.activeElement).text()); // $(".typeAheadBox").val($ (document.activeElement).text()); //(reqTypeaheadBox).val($ (document.activeElement).text()); } else { $("." + typeAheadObjClass + " li a").removeClass("hover"); (reqTypeaheadBox).focus(); (reqTypeaheadBox).val(currentValue); // autocomplete(reqTypeaheadBox, // typeAheadObjClass); } } else if (event.which == 13) { $(document.activeElement).trigger("click"); } });

}

function createQueryParams(val){ val = $.trim(val); if (val!='' || val!=null || val!=undefined) { var words = val.split(' '); lengthOfWordList = words.length; var text = ''; var fieldText = ''; //cn, hk, tw var cc = getCCLC('cc'); var lc = getCCLC('lc'); var addFieldTextData = false; //The "+AND+MATCH{pm_series_value,pm_name_value}:CLASS" was added for story 6921 as part of the RnD to improve the functionality of the type ahead. // This prevents the SKUs from Showing up in the type ahead. By restricting the class to "pm_series_value" & "pm_name_value". var addFieldText = 'MATCH{'+cc+',NoValue}:COUNTRY_CODE+AND+BIASVAL{pm_series_value,'+biasvalValue+'}:C LASS+AND+MATCH{pm_series_value,pm_name_value}:CLASS';

// if the user is on us-en/drivers/printer /laptop etc. var filterId = getFilterIdForDriversPage(); // if we have ID(s) defined in SSC if(filterId){ // add filter criteria addFieldText += "+AND+STRING{"+filterId+"}:NAVIGATIONPATH"; } if((cc=='tw'|| cc=='hk' || cc=='cn') && lc=='zh'){ addFieldTextData = true; } // adding false to override adding field text if(false && lengthOfWordList>1){ //more than one word fieldText = words[lengthOfWordList-1]; fieldText = 'WILD{*'+ fieldText +'*}:DRETitle'; if(addFieldTextData){ fieldText = addFieldText+'+AND+'+fieldText; } words[lengthOfWordList-1] = ''; text = words.join(' '); text = $.trim(text); ajaxParam.paramData['text'] = text; ajaxParam.paramData['fieldText'] = fieldText; console.log('FieldText --->'+ fieldText); console.log('Text --->'+ text); } else{ text = val+'*'; if(addFieldTextData){ //CR13588ALM fieldText = addFieldText; ajaxParam.paramData['fieldText'] = fieldText; } else{ // if we have a filter ID and haven't already added it if(filterId){ ajaxParam.url1 = addFieldTextConditionToURL(ajaxParam.url1, "+AND+STRING{"+filterId+"}:NAVIGATIONPATH", filterId); }else{ ajaxParam.paramData['fieldText'] = ''; if(ajaxParam.url1.indexOf('}:NAVIGATIONPATH') > -1){ ajaxParam.url1 = removeFieldTextCondition(ajaxParam.url1); } }

} console.log("field text");

console.log(ajaxParam.paramData['fieldText']); ajaxParam.paramData['text'] = text; console.log('Text --->'+ text) } }

};

// This function makes the ajax call for typeahead function autocomplete(currentInput, typeAheadObjClass) { $("." + typeAheadObjClass + "").remove(); currentValue = (currentInput).val(); ajaxParam.paramData["cc"] = getCCLC("cc"); ajaxParam.paramData["lc"] = getCCLC("lc"); ajaxParam.paramData["searchContext"] = $( "#search-dropdown .search-category").val() != "" ? $( "#search-dropdown .search-category").val() : "All Support"; var modifiedCurrentValue = currentValue.replace("&","&"); //replace & with & for IDOL to understand //create query params including static params createQueryParams(currentValue); var requestJson = JSON.stringify(ajaxParam.paramData); var successHandlerParams = { 'currentValue':modifiedCurrentValue, 'currentInput':currentInput, 'typeAheadObjClass':typeAheadObjClass }; abortAjaxUtil(); // abort called to abort any previous typeahead ajax call //callAjaxUtil('typeahead',ajaxParam.url,'POST',getMatch,'JSON',requestJson,success HandlerParams,ajaxFailureHandler); //Updated Ajax call to Call IDOL directly: //Create the url here //ajaxParam.url = ajaxParam.url1.replace("QueryPlaceholder",modifiedCurrentValue); var idolUTF8Lc = $('#idolUTF8Lc').val(); //base URL from portal var url1 = ajaxParam.url1; ajaxParam.url = url1; if(ajaxParam.paramData['text']!=null){ ajaxParam.url += '&text='+ajaxParam.paramData['text']; } if(ajaxParam.paramData['fieldText']!=null && ajaxParam.paramData['fieldText']! =''){ ajaxParam.url += '&fieldtext='+ajaxParam.paramData['fieldText']; }

// Make the call here callAjaxUtil('typeahead',ajaxParam.url,'POST',recallIdol,'JSON',null,successHandler Params,ajaxFailureHandler); //callAjaxUtil('typeahead',ajaxParam.url,'GET',nonIdolTypeAhead,'JSON',null,success HandlerParams,ajaxFailureHandler); $(currentInput).parent(".hasTypeahead").find(".searching").show(); } /*This function takes the IDOL JSON response and makes sense out of it.*/ var RELEVANCE_DIFF = 10; //to be externalized var TYPEAHEAD_MAX_LIMIT = 8; //to be externalized /** * * * * * * */ var

This method is used when hp-core-service is utilized for type ahead in search. This method populates type ahead. @since R3.0 @author [email protected] nonIdolTypeAhead = function(data,successHandlerParams){ var extractedData = []; for (var i=0; i
} if(extractedData.length > 0){ createList(extractedData, extractedData.length, successHandlerParams.currentInput, successHandlerParams.currentValue, successHandlerParams.typeAheadObjClass); } } var recallIdol = function(data,successHandlerParams){ var totalResults; var responseDataJSON = data.autnresponse.responsedata.$; if(typeof(responseDataJSON)=='object'){ responseDataJSON = responseDataJSON.join(); } responseDataJSON = $.parseJSON(responseDataJSON); /* responseDataJSON = data; */ if(!(responseDataJSON.autnresponse.responsedata["autn:numhits"] == undefined)){ // if IDOL response is not error totalResults = responseDataJSON.autnresponse.responsedata["autn:numhits"].$; } else{ totalResults = 0; }

var modifiedCurrentValue = successHandlerParams.currentValue; var words = modifiedCurrentValue.split(' '); var lengthOfWordList = words.length; if (totalResults == 0 && lengthOfWordList>1) { // if there are no results //createQueryParams var fieldtext = ""; var addFieldText = 'MATCH{'+cc+',NoValue}:COUNTRY_CODE'; if((cc=='tw'|| cc=='hk' || cc=='cn') && lc=='zh'){ fieldtext = "&fieldtext="+addFieldText; } ajaxParam.url = ajaxParam.url1+'&text='+modifiedCurrentValue+fieldtext; //commenting to cancel the second call to IDOL //callAjaxUtil('typeahead',ajaxParam.url,'POST',callTypeAheadResultConstructor,'JSO N',null,successHandlerParams,ajaxFailureHandler); } else { callTypeAheadResultConstructor(data,successHandlerParams); } } var callTypeAheadResultConstructor = function(rawData, successHandlerParams){ new typeAheadResultConstructor(rawData,successHandlerParams).filter(); } var typeAheadResultConstructor = function(rawData, successHandlerParams) { var rawData = rawData; var relevantDataIntrim = []; var urlCreationTempData = []; //6523 - will store respoonse data to be used for url creation var relevantData = { "topic": { "suggestions": [] }, "product": { "suggestions": [] } }; var totalResults; var responseDataJSON = rawData.autnresponse.responsedata.$; if(typeof(responseDataJSON)=='object'){ responseDataJSON = responseDataJSON.join(); } responseDataJSON = $.parseJSON(responseDataJSON); /* responseDataJSON = rawData; */ if(!(responseDataJSON.autnresponse.responsedata["autn:numhits"] == undefined)){ // if IDOL response is not error totalResults = responseDataJSON.autnresponse.responsedata["autn:numhits"].$; } else{ totalResults = 0; }

var var var var

lowestNodeDepth = 0; lowestNodeDepthCount = 0; maxWeightage = 0.0; typeaheadResultCounter = 0;

var calcNodeDepth = function(clazzType, navPathValue){ switch(clazzType){ case "category_navigation": return 1; case "pm_series_value": return 2; case "pm_name_value": return 3; case "pm_number_value": return 4; default: return 5; } } this.filter = function() { //initialise array to store child node paths (array or arrays) us-6523 var childNodeParentArray=[]; if (totalResults == 0) { // if there are no results getMatch(relevantData,successHandlerParams); } else { rawData = responseDataJSON; //Initialize this function by creating an array of the relevant data from the raw data set by using the filtering logic by VKS var isMultipleResult = (rawData.autnresponse.responsedata["autn:hit"] ! = undefined && rawData.autnresponse.responsedata["autn:hit"].length == undefined) ? false : true; if (isMultipleResult) { //if there are multiple results, autn:hit would be an array otherwise a single object $.each(rawData.autnresponse.responsedata["autn:hit"], function(index, obj) { var tempData = {}; var tempDataforURL = {}; var elemNavPathValue = ((this["autn:content"].DOCUMENT.SHORTESTNAVIGATIONPATH.$).split('|').length) 2; //having a -2 as an empty string is created after the last '|' var elemClazzType = this["autn:content"].DOCUMENT.CLASS.$; var shortestNavPathLength = calcNodeDepth(elemClazzType, elemNavPathValue); //store child nodes if present only us-6523 //if(this["autn:content"].DOCUMENT.CHILDNODES.hasOwnProperty("$")) //{ // var childArray=this["autn:content"].DOCUMENT.CHILDNODES. $.split('|'); // childNodeParentArray.push(childArray); // }

var weightage = this["autn:weight"].$; var nodeDepth = shortestNavPathLength; tempData["title"] = this["autn:content"].DOCUMENT.DRETITLE.$; tempData["nodeDepth"] = nodeDepth; tempData["weightage"] = weightage; tempData["product"] = (checkValidity(this["autn:content"].DOCUMENT.PRODUCTID.$)) ? this["autn:content"].DOCUMENT.PRODUCTID.$ : ""; if (maxWeightage == 0.0) { maxWeightage = weightage; relevantDataIntrim.push(tempData); lowestNodeDepth = nodeDepth; if(this["autn:content"].DOCUMENT.CHILDNODES.hasOwnProperty("$")) { var childArray=this["autn:content"].DOCUMENT.CHILDNODES. $.split('|'); childNodeParentArray.push(childArray); } } else if ((maxWeightage - weightage) < RELEVANCE_DIFF) {

if (nodeDepth <= lowestNodeDepth) { relevantDataIntrim.push(tempData); lowestNodeDepth = nodeDepth; } else if (nodeDepth - lowestNodeDepth == 1) { relevantDataIntrim.push(tempData); } if(this["autn:content"].DOCUMENT.CHILDNODES.hasOwnProperty("$")) { var childArray=this["autn:content"].DOCUMENT.CHILDNODES.$.split('|'); childNodeParentArray.push(childArray); } } /*6523 - in case of pfinder, storing results for forming URL of drivers page (on click of typeahead results)*/ tempDataforURL["seriesName"] = tempData["title"]; tempDataforURL["classType"] = shortestNavPathLength;

undefined){

/*6594 - url creation using seofriendlyname */ if(this["autn:content"].DOCUMENT.SEO_FRIENDLY_NAME ==

tempDataforURL["seoFriendlyName"] = "null"; //If no seoFriendlyName is found, use null } else{ tempDataforURL["seoFriendlyName"] =

this["autn:content"].DOCUMENT.SEO_FRIENDLY_NAME.$; } if(shortestNavPathLength == 2) { tempDataforURL["seriesId"] = tempData["product"]; tempDataforURL["id"] = tempData["product"]; } else if(shortestNavPathLength == 3) { tempDataforURL["productId"] = tempData["product"]; tempDataforURL["id"] = tempDataforURL["productId"]; var seriesId = this["autn:content"].DOCUMENT.SHORTESTNAVIGATIONPATH.$; seriesId = (checkValidity(seriesId)) ? seriesId.split("|") : ""; seriesId == "" ? "" : (seriesId = seriesId[seriesId.length3]); tempDataforURL["seriesId"] = seriesId; } else if(shortestNavPathLength == 4) { tempDataforURL["skuId"] = tempData["title"]; tempDataforURL["productId"] = tempData["product"]; tempDataforURL["id"] = tempDataforURL["productId"]; var seriesId = this["autn:content"].DOCUMENT.SHORTESTNAVIGATIONPATH.$; seriesId = (checkValidity(seriesId)) ? seriesId.split("|") : ""; seriesId == "" ? "" : (seriesId = seriesId[seriesId.length4]); tempDataforURL["seriesId"] = seriesId; var productId = this["autn:content"].DOCUMENT.SHORTESTNAVIGATIONPATH.$; productId = (checkValidity(seriesId)) ? productId.split("|") : ""; productId == "" ? "" : (productId = productId[productId.length-3]); tempDataforURL["productId"] = productId; } urlCreationTempData.push(tempDataforURL); /* 6523 - in case of pfinder, storing results for forming URL of drivers page (on click of typeahead results - End */ });

} else { var tempData = {}; var tempDataforURL = {}; var elemNavPathValue = ((rawData.autnresponse.responsedata["autn:hit"] ["autn:content"].DOCUMENT.SHORTESTNAVIGATIONPATH.$).split('|').length) - 2; //having a -2 as an empty string is created after the last '|' var elemClazzType = rawData.autnresponse.responsedata["autn:hit"] ["autn:content"].DOCUMENT.CLASS.$; var shortestNavPathLength = calcNodeDepth(elemClazzType, elemNavPathValue)

var weightage = rawData.autnresponse.responsedata["autn:hit"] ["autn:weight"].$; tempData["title"] = rawData.autnresponse.responsedata["autn:hit"] ["autn:content"].DOCUMENT.DRETITLE.$; tempData["nodeDepth"] = shortestNavPathLength; tempData["weightage"] = weightage; tempData["product"]= (checkValidity(rawData.autnresponse.responsedata["autn:hit"] ["autn:content"].DOCUMENT.PRODUCTID.$)) ? rawData.autnresponse.responsedata["autn:hit"]["autn:content"].DOCUMENT.PRODUCTID. $ : "" ; lowestNodeDepth = shortestNavPathLength; relevantDataIntrim.push(tempData); tempDataforURL["seriesName"] = tempData["title"]; tempDataforURL["classType"] = shortestNavPathLength; /*6594 - url creation using seofriendlyname*/ tempDataforURL["seoFriendlyName"] = rawData.autnresponse.responsedata["autn:hit"] ["autn:content"].DOCUMENT.SEO_FRIENDLY_NAME.$; if(shortestNavPathLength == 2) { tempDataforURL["seriesId"] = tempData["product"]; } else if(shortestNavPathLength == 3) { tempDataforURL["productId"] = tempData["product"]; var seriesId = rawData.autnresponse.responsedata["autn:hit"] ["autn:content"].DOCUMENT.SHORTESTNAVIGATIONPATH.$; seriesId = (checkValidity(seriesId)) ? seriesId.split("|") : ""; seriesId == "" ? "" : (seriesId = seriesId[seriesId.length-3]); tempDataforURL["seriesId"] = seriesId; tempDataforURL["id"] = tempDataforURL["productId"]; } else if(shortestNavPathLength == 4) { tempDataforURL["skuId"] = tempData["title"]; tempDataforURL["productId"] = tempData["product"]; tempDataforURL["id"] = tempDataforURL["productId"]; var seriesId = rawData.autnresponse.responsedata["autn:hit"] ["autn:content"].DOCUMENT.SHORTESTNAVIGATIONPATH.$; seriesId = (checkValidity(seriesId)) ? seriesId.split("|") : ""; seriesId == "" ? "" : (seriesId = seriesId[seriesId.length4]); tempDataforURL["seriesId"] = seriesId; var productId = rawData.autnresponse.responsedata["autn:hit"] ["autn:content"].DOCUMENT.SHORTESTNAVIGATIONPATH.$; productId = (checkValidity(seriesId)) ? productId.split("|") : ""; productId == "" ? "" : (productId = productId[productId.length-3]); tempDataforURL["productId"] = productId; } urlCreationTempData.push(tempDataforURL); }

urlCreationFilteredData = urlCreationTempData;

$.each(relevantDataIntrim, function(index, obj) { //filter relevantDataIntrim object user story 6523 var isChildItem = false; // check whether the product is child item from childnode array for(var i=0;i < childNodeParentArray.length;i++) { if(childNodeParentArray[i].indexOf(this["product"]) > -1) { isChildItem = true; break; } } ///if this item is a child item den discard if(isChildItem) { return true; } ////// end 6523

if (typeaheadResultCounter < TYPEAHEAD_MAX_LIMIT) { if(this["nodeDepth"] == lowestNodeDepth){ lowestNodeDepthCount++; typeaheadResultCounter++; var tempData = {}; tempData["label"] = this["title"]; tempData["productId"] = this["product"]; relevantData.product.suggestions.push(tempData); } else if( this["nodeDepth"]== lowestNodeDepth+1 && lowestNodeDepthCount==1){ typeaheadResultCounter++; var tempData = {}; tempData["label"] = this["title"]; tempData["productId"] = this["product"]; relevantData.product.suggestions.push(tempData); } else{ //do nothing }

} else { return false; }

} }

}); getMatch(relevantData,successHandlerParams);

} /*End*/ // Failure handler for ajax call function ajaxFailureHandler(){ $(".hasTypeahead .searching").hide(); } // Get the matched results for products and topics function getMatch(jsonData, paramObj) { // jsonData = jQuery.parseJSON(jsonData); var currentValue = paramObj.currentValue; var currentInput = paramObj.currentInput; var typeAheadObjClass = paramObj.typeAheadObjClass; $(".hasTypeahead .searching").hide(); var jsonProdLen = jsonData.product.suggestions.length; var jsonTopicLen = jsonData.topic.suggestions.length; var jsonTotalLength = jsonProdLen + jsonTopicLen; var jsonObj = new Array(); var j = 0; for (var i = 0; i < jsonProdLen; i++) { if ((currentValue != "")) { var tempData = {}; tempData["label"] = jsonData.product.suggestions[i].label; tempData["productId"] = jsonData.product.suggestions[i].productId; jsonObj[j] = tempData; j++; } } for (var i = 0; i < jsonTopicLen; i++) { if ((currentValue != "")) { var tempData = {}; tempData["label"] = jsonData.topic.suggestions[i].label; tempData["productId"] = (jsonData.topic.suggestions[i].productId); jsonObj[j] = tempData; j++; } } createList(jsonObj, jsonProdLen, currentInput, currentValue, typeAheadObjClass); } // This creates the DOM for the predictive results and append it function createList(jsonObj, jsonProdLen, currentInput, currentValue,typeAheadObjClass) { (currentInput).siblings("ul").remove(); /* * type head highlighting - creating array with each word in user query for * search box */ var userQuery = (currentInput).val(); var userQueryWord; var userQueryWordLen = 0;

if (userQuery != undefined && userQuery != "") { userQueryWord = userQuery.split(" "); } /* * type head highlighting - creating array with each word in user query for * search box - end */ var jsonLen = jsonObj.length; var typeaheadLeftHook = (currentInput).siblings(".typeaheadHook").val() + "px"; if($("html").attr("dir")=="ltr"){ var stringList = "
    "; } else{ var stringList = "
      "; } for (var i = 0; i < jsonLen; i++) { /* * type head highlighting - using array to highlight type ahead * suggestions */ for (var count = 0; count < userQueryWord.length; count++) { var toBeHighlighted = userQueryWord[count]; var suggestedStr = jsonObj[i].label; if (toBeHighlighted != "") { suggestedStr = highlightSuggestion(suggestedStr,toBeHighlighted); jsonObj[i].label = suggestedStr; } } /* * type head highlighting - using array to highlight type ahead * suggestions - end */ if (i == jsonProdLen) { stringList += "
    • " + jsonObj[i] + "
    • "; } else { stringList += "
    • " + jsonObj[i].label + "
    • "; } } stringList += "
    " if ((currentValue != "") && (jsonLen != 0)) { if ((currentValue.toLowerCase() != jsonObj[0].label.toLowerCase())) { (currentInput).parents(".hasTypeahead").append(stringList); if( (currentInput).hasClass("pfinder-search") ){ comingFromPFinder=true; } else{ comingFromPFinder=false; } } } // $(".autoCompleteList").css("top", (currentInput).css("height")); // $(".typeAheadBox").val(jsonObj[0]);

    } //This function calls the typeahead function after an interval of 100ms after user inputs function callTypeAhead(reqTypeaheadBox, typeAheadObjClass) { // this is to get the typeAheadLimit i.e. beyond this count no typeahead call, #arka var typeAheadLimit = reqTypeaheadBox.data("typeaheadlimit"); // Don't call IDOL for type ahead if the lenght of text is less than 2 or greater than the configured limit #arka if ((reqTypeaheadBox).val().length > 1 && (reqTypeaheadBox).val().length < typeAheadLimit) { clearTimeout(typeAheadTimeout); typeAheadTimeout = setTimeout(function() { autocomplete(reqTypeaheadBox, typeAheadObjClass) }, 100); // autocomplete(reqTypeaheadBox, typeAheadObjClass); } else { clearTimeout(typeAheadTimeout); $("." + typeAheadObjClass + "").remove(); $(".hasTypeahead .searching").hide(); } } /* created for typeahead keyword highlighting - Richa * this function creates and array from suggested string. Logic is to separate already highlighted * (keywords enfolded with <strong>) from other words. * to handle if user searches for s/t/r/o/n/g, need to remove <strong>highlighted from the suggestedStr */ function createSuggestedArr(suggestedStr) { var startTag = "<strong>"; var lastTag = ""; var remainingSuggestedStr = suggestedStr; var suggestedArr = [], arrCounter=0; var strongLastTagL = KEY.TAB; var strongFirstIndex = remainingSuggestedStr.indexOf(startTag); var strongLastIndex = remainingSuggestedStr.indexOf(lastTag); while(strongFirstIndex!=-1) { if (strongFirstIndex == 0){ var endTagLastIndex = strongLastIndex + strongLastTagL; suggestedArr[arrCounter] = remainingSuggestedStr.substring(0,endTagLastIndex); remainingSuggestedStr = remainingSuggestedStr.substring(endTagLastIndex); } else { suggestedArr[arrCounter] = remainingSuggestedStr.substring(0,strongFirstIndex); remainingSuggestedStr = remainingSuggestedStr.substring(strongFirstIndex);

    } arrCounter++; strongFirstIndex = remainingSuggestedStr.indexOf(startTag); strongLastIndex = remainingSuggestedStr.indexOf(lastTag); } //strong doesnt occur if(remainingSuggestedStr!="") { suggestedArr[arrCounter] = remainingSuggestedStr; } return suggestedArr; } /* created for typeahead keyword highlighting - Richa * this function sends suggestion array to createHiglightedStr for adding strong tags * */ function highlightSuggestion(suggestedStrComplete, toBeHighlighted) { var suggestedArr = createSuggestedArr(suggestedStrComplete); var suggestedArrL = suggestedArr.length; var suggestedStr, finalSuggestedStr = ""; var noOfMatches; var regEx = new RegExp(toBeHighlighted, "gi"); for(var counterArr=0; counterArr<suggestedArrL; counterArr++) { suggestedStr = suggestedArr[counterArr]; noOfMatches = suggestedStr.match(regEx) != null ? suggestedStr.match(regEx).length : 0; /* * for the first matched string, add <strong> to the keyword based * on its "keyword" occurrence */ if (noOfMatches != 0) {

    }

    if (suggestedStr.indexOf("<strong>")==-1) { suggestedStr = createHiglightedStr(suggestedStr, toBeHighlighted); } /* * from the second match onwards, add <strong> to the keyword * based on its "keyword+" occurrence */ else { var index = suggestedStr.lastIndexOf(toBeHighlighted+''); if (index != -1) { firstPartStr = suggestedStr.substring(0, index); lastPartStr = suggestedStr.substring(index); suggestedStr = firstPartStr + createHiglightedStr(lastPartStr, toBeHighlighted); } }

    finalSuggestedStr = finalSuggestedStr + suggestedStr; } return finalSuggestedStr;

    } /*created for typeahead keyword highlighting - Richa * this function adds strong tag around matching text * */ function createHiglightedStr(strValue, toBeHighlighted) { var startTag = "<strong>"; var lastTag = ""; var index = strValue.toLowerCase().indexOf(toBeHighlighted.toLowerCase()); strValue = strValue.substring(0, index) + startTag + strValue.substring(index, index + toBeHighlighted.length) + lastTag + strValue.substring(index + toBeHighlighted.length); return strValue; } /* created for typeahead keyword highlighting - end - Richa */ function isHidePrediction(typeAheadObjClass, reqTypeaheadBox){ setTimeout(function() { if($("." + typeAheadObjClass + " li a").is(":focus") || $ (".clearQuestionText").is(":focus") ||(reqTypeaheadBox).is(":focus") ){ } else{ $("." + typeAheadObjClass).remove(); } }, 200);

    }

    /** * @returns */ function getFilterIdForDriversPage(){ var url = window.location.href; var id = ""; if(url.indexOf('drivers/printer') > 0){ id = printerId; }else if(url.indexOf('drivers/laptop') > 0){ id = laptopId; }else if(url.indexOf('drivers/desktop') > 0){ id = desktopId; } }

    return id;

    /** * This method will find the parameter named fieldText and * append additionalFieldText to it and modify the original * URL with the new overall fieldText * * @param url * @param additionalFieldText * @returns

    */ function addFieldTextConditionToURL(url, additionalFieldText, filterId){ var finalUrl = url; if(url.indexOf('}:NAVIGATIONPATH') == -1){ var indexOfFieldText = url.indexOf("fieldtext"); var urlPartOne = url.substr(0, indexOfFieldText); var urlPartTwo = url.substr(indexOfFieldText, url.length); var indexOfFieldTextEnd = urlPartTwo.indexOf('&'); var oldFieldText = urlPartTwo.substr(0, indexOfFieldTextEnd); var newFieldText = oldFieldText + additionalFieldText; var urlPartThree = urlPartTwo.substr(indexOfFieldTextEnd, urlPartTwo.length); finalUrl = urlPartOne + newFieldText + urlPartThree; // URL already has this condition }else{ // the URL has this condition with some other ID if(url.indexOf(filterId) == -1){ var var i = var

    fieldTextParamString = '+AND+STRING{'; i = url.indexOf(fieldTextParamString); i + fieldTextParamString.length; j = url.indexOf('}:NAVIGATIONPATH');

    finalUrl = url.slice(0, i) + filterId + url.slice(j, url.length); } } }

    return finalUrl;

    /** * Remove fieldText param of navigation * path. For any search other than * SWD Type Ahead * @param url * @returns */ function removeFieldTextCondition(url){ var fieldTextParamString = '+AND+STRING{'; var fieldTextParamNavigation = '}:NAVIGATIONPATH'; var i = url.indexOf(fieldTextParamString); var j = url.indexOf(fieldTextParamNavigation); j = j + fieldTextParamNavigation.length; return url.slice(0, i) + url.slice(j, url.length); }/* Copyright (c) 2016, 2017, HP and/or its affiliates. All rights reserved. */ /******************************************************************************

    * NAME * assetConversionIntegration.js * * DESCRIPTION * Has functions which can convert a potential Samsung product's * product or serial number into equivalent HP product number * or serial number, and vice-versa. * * *****************************************************************************/ /** * Converts HP product number to Samsung * and vice-versa using CAL * * @author [email protected] * */ function convertProductNumber(productNumberRequest, callback){ var responseData = {}; // set the request object var requestJSON = {}; requestJSON.productNumber = productNumberRequest.productNumber; requestJSON.captchaToken = productNumberRequest.captchaToken; requestJSON.cc=productNumberRequest.cc; requestJSON.lc=productNumberRequest.lc; var ssid = getSSIDForAssetConv('product'); var url = "/hp-pps-services/asset/conversion/productnumber?ssid=" + ssid; $.ajax({ type: 'POST', url : url, dataType:'json', data: JSON.stringify(requestJSON), type: "POST", beforeSend: function(xhr) { xhr.setRequestHeader('Content-Type', 'application/json'); $("#conversionGifSpinner").modal("show"); }, success : function(data) { // Set HPPN and EPN in final response responseData.hpProductNumber = data.hpProductNumber; responseData.equivalentProductNumber = data.equivalentProductNumber; // Check if it is an HP asset if(productNumberRequest.productNumber == data.hpProductNumber){ // input PN matches HPPN in response, HP Asset responseData.isHPAsset = true; }else{

    }

    // Not an HP asset responseData.isHPAsset = false;

    // Check if the response has both HPPN and EPN if((data.hpProductNumber != null && data.hpProductNumber != '')

    &&(data.equivalentProductNumber != null && data.equivalentProductNumber != '')){ // set match found as true responseData.isMatchFound = true; }else { // no match found responseData.isMatchFound = false;

    } console.log(responseData); populateSSID(); callback(productNumberRequest,responseData); }, error : function(e) {

    });

    responseData.error = 'service error'; console.log('ERROR: ', e); console.log(xhr.status); populateSSID(); callback(productNumberRequest,responseData); }, complete : function(e) { $("#conversionGifSpinner").modal("hide"); }

    } function getSSIDForAssetConv(type){ var secureTokenVal = $('#secureTokenField').val(); //retrieve string in which key is stored var tokenId; if(type == "product"){ tokenId = $('#samsungProductBtn').attr("token"); if(tokenId == null){ tokenId = $('#hpProductBtn').attr("token"); } } if(type == "serial"){ tokenId = $('#samsungSerialBtn').attr("token"); if(tokenId == null){ tokenId = $('#hpSerialBtn').attr("token"); } } var ssidValue = ""; if(secureTokenVal.indexOf(tokenId)!=-1){ //check if the token key is present in the string of tokens ssidValue = JSON.parse($("#secureFieldJson").val()); } return ssidValue[tokenId]; } /** * Converts HP serial number to Samsung * and vice-versa using an external service * * @author [email protected] *

    */ function convertSerialNumber(serialNumberRequest, callback){ var responseData = {}; // set the request object var requestJSON = {}; requestJSON.serialNumber = serialNumberRequest.serialNumber; requestJSON.captchaToken = serialNumberRequest.captchaResponse; requestJSON.cc=serialNumberRequest.cc; requestJSON.lc=serialNumberRequest.lc; var ssid = getSSIDForAssetConv('serial'); var url = "/hp-pps-services/asset/conversion/serialnumber?ssid=" + ssid; $.ajax({ type: 'POST', url : url, dataType:'json', data: JSON.stringify(requestJSON), type: "POST", beforeSend: function(xhr) { xhr.setRequestHeader('Content-Type', 'application/json'); $("#conversionGifSpinner").modal("show"); }, success : function(data) { // Set HPPN and EPN in final response responseData.hpSerialNumber = data.hpSerialNumber; responseData.equivalentSerialNumber = data.equivalentSerialNumber; responseData.status=data.status; responseData.statusMessage=data.statusMessage; if((data.equivalentSerialNumber != null && data.equivalentSerialNumber != '')){ // set match found as true responseData.isMatchFound = true; }else { // no match found responseData.isMatchFound = false;

    } console.log(responseData); populateSSID(); callback(serialNumberRequest,responseData); }, error : function(e) {

    });

    responseData.error = 'service error'; console.log('ERROR: ', e); console.log(xhr.status); populateSSID(); callback(serialNumberRequest,responseData); }, complete : function(e) { $("#conversionGifSpinner").modal("hide"); }

    } /*----------------------- SMO with split hpi and hpe --------------------------*/

    paintPFinderResultsWithSplit = function (jsonData,categorylistheading) { var totalResCount = 0; var globalLength=0; var localLength=0; var categoriesLength = 0; if (!(jsonData.pfinder.local.categories[0] == undefined)) { var localCategories = jsonData.pfinder.local.categories; var categoryString = ""; $.each(localCategories, function(index, obj) { if(isSWDPage()){ categoryString = categoryString + createSWDCategoryListWithSplit(index, obj,categorylistheading); } else{ categoryString = categoryString + createCategoryListWithSplit(obj,categorylistheading); } localLength = localLength + getResultCountWithSplit(obj); }); $(".localResults").append(categoryString); $(".localResultsHolder").text("("+localLength+")"); $(".localResults").css("display","block"); if(isSWDPage()){ //open the first dropdown if length = 1 if(localCategories.length==1){ var panelAnchor = $('.pFinderResults .hp-section-md .paneltitle a')[0];

    var panelTitle = $('.pFinderResults .hp-section-md .panel-

    title')[0];

    var panelCollapse = $('.pFinderResults .hp-section-md .panel-

    collapse')[0]; $(panelAnchor).addClass('toggled'); $(panelAnchor).attr("aria-expanded","true"); $(panelTitle).addClass('open'); $(panelCollapse).addClass('in').removeAttr('style'); }

    }

    } if (!(jsonData.pfinder.worldwide.categories[0] == undefined)) { var globalCategories = jsonData.pfinder.worldwide.categories; var categoryString = ""; $.each(globalCategories, function(index, obj) { categoryString = categoryString + createCategoryList(obj); globalLength = globalLength + getResultCount(obj); });

    }

    $(".globalResults").append(categoryString); $(".globalResultsHolder").text("("+globalLength+")"); $(".globalResults").css("display","block");

    categoriesLength = jsonData.pfinder.worldwide.categories.length + jsonData.pfinder.local.categories.length ; if(categoriesLength == 1){ setTimeout(function() { $(".hp-expand-colapse").trigger("click"); },100); } totalResCount = globalLength + localLength; $(".totalResCountHolder").text("("+totalResCount+")"); }; createCategoryListWithSplit = function(categories,categorylistheading) { var builtString; var productsLength = getResultCountWithSplit(categories); builtString = "
    \ <span class=\"linkText \"><span class=\" rtlAlignText \">" + categories.category.name + "<span class=\"rtlAlignText\"> ("+ productsLength +")\ <span class=\"expandIcon\">\
      "; if(!(typeof categories.category[0] !== 'undefined' && (categories.category[0]! == null))){ var hpeString = ""; var hpiString = ""; for(var key in categories.category) { var val= categories.category[key]; if(key=="hpiProducts" && val.length>0){ hpiString += otherProducts("",val,key,categorylistheading);/*sending a null string to other products as it is being appended on return*/ } else if(key=="hpeProducts"&& val.length>0){ hpeString += otherProducts("",val,key,categorylistheading); } } builtString += hpiString+hpeString + ' '
    '+ '
    '+ '
    '; return builtString;

'+

} }; createSWDCategoryListWithSplit = function(index, categories,categorylistheading){

var builtString; var productsLength = getResultCountWithSplit(categories); builtString = '
'+ ''+ ''+ '
'; return builtString;

'+

} }; getResultCountWithSplit = function(categories){ var len= categories.category.hpiProducts.length + categories.category.hpeProducts.length; return len; }; otherProducts = function(accrodianstring,val,productType,categorylistheading){ if(productType=="hpiProducts") { accrodianstring += "
  • "+categorylistheading.hpiProducts+"

  • "; } else if(productType=="hpeProducts") { accrodianstring += "
  • "+categorylistheading.hpeProducts+"

  • "; }

    $.each(val, function(index, obj) { accrodianstring += "
  • " + obj.product.productName + "
  • " }); return accrodianstring;

    };

    /*----------------------- end SMO with split hpi and hpe --------------------------*/ /*----------------------- old structure --------------------------*/ paintPFinderResults = function(jsonData) { var totalResCount = 0; var globalLength=0; var localLength=0; var categoriesLength = 0; if (!(jsonData.pfinder.local.categories[0] == undefined)) { var localCategories = jsonData.pfinder.local.categories; var categoryString = ""; $.each(localCategories, function(index, obj) { //US 5247: always create the SWD experience - HH categoryString = categoryString + createSWDCategoryList(index, obj); localLength = localLength + getResultCount(obj); }); $(".localResults").append(categoryString); $(".localResultsHolder").text("("+localLength+")"); $(".localResults").css("display","block");

    [0];

    //US 5247: always create the SWD experience - HH //removed the if(SWDPage) condition //open the first dropdown if length = 1 if(localCategories.length==1){ var panelAnchor = $('.pFinderResults .hp-section .panel-title a') var panelTitle = $('.pFinderResults .hp-section .panel-title')[0]; var panelCollapse = $('.pFinderResults .hp-section .panel-

    collapse')[0]; $(panelAnchor).addClass('toggled'); $(panelAnchor).attr('aria-expanded',"true"); $(panelTitle).addClass('open'); $(panelCollapse).addClass('in').removeAttr('style'); }

    } if (!(jsonData.pfinder.worldwide.categories[0] == undefined)) { var globalCategories = jsonData.pfinder.worldwide.categories; var categoryString = "";

    }

    $.each(globalCategories, function(index, obj) { categoryString = categoryString + createCategoryList(obj); globalLength = globalLength + getResultCount(obj); }); $(".globalResults").append(categoryString); $(".globalResultsHolder").text("("+globalLength+")"); $(".globalResults").css("display","block");

    categoriesLength = jsonData.pfinder.worldwide.categories.length + jsonData.pfinder.local.categories.length ; if(categoriesLength == 1){ setTimeout(function() { $(".hp-expand-colapse").trigger("click"); },100); } totalResCount = globalLength + localLength; $(".totalResCountHolder").text("("+totalResCount+")"); } function createCategoryList(categories) { var builtString; var productsLength = getResultCount(categories); builtString = "
    \ <span class=\"linkText \"><span class=\" rtlAlignText \">" + categories.category.name + "<span class=\"rtlAlignText\"> ("+ productsLength +")\ <span class=\"expandIcon\">\
      "; var productsInCategory = categories.category.products; $.each(productsInCategory, function(index, obj) { builtString += "
    • " + obj.product.productName + "
    • " });

      }

      builtString += "
    " return builtString;

    function createSWDCategoryList(index, categories){ var builtString; var productsLength = getResultCount(categories); builtString = '
    '+ ''+

    +' <span

    ''+ '
    '; return builtString;

    } function getResultCount(categories){ return categories.category.products.length; } pFinderResultClick = function(pOid){ //on click of certain pfinder results populate the value in a form and submit it instead of redirecting directly if($('#pFinderClickForm').length>0){ $('#pFinderClickPOid').attr('value',pOid); $('#pFinderClickForm').submit(); } } function isSWDPage(){ /*

    return true; var pageName = $('#pageIdentifier').val() if(pageName.indexOf('SWD')==0){ return true; } else{ return false; }*/

    }/* $(document).ready(function() { autocompleteSR();

    }); function autocompleteSR() { $.ajax({ type: 'POST', url: "js/searchResult.json", dataType: 'JSON', success: function(results) { paintSearchResults(results); }, error: function(xml, status, error) { //$(".hasTypeahead .searching").hide(); } }); }*/ function paintSearchResults(jsonData) { JsonData2 = jsonData; if (!(jsonData.searchResultObjArr == undefined)) { var var var var

    searchResults = jsonData.searchResultObjArr; searchResultMarkupString = ""; searchResultsPromotion = ""; searchResultsOrganic = "";

    $.each(searchResults, function(index, obj) { var resultObj = obj.searchResult; if((typeof(resultObj.searchId) == "undefined") && (typeof(resultObj.searchType) == "undefined")){ searchResultsOrganic = searchResultsOrganic + createSearchResultMarkup(obj); } else if((typeof(resultObj.searchId) == "undefined") && (typeof(resultObj.searchType) != "undefined") && (resultObj.searchType=="promotion")){ searchResultsPromotion = searchResultsPromotion + createSearchResultMarkup(obj); } else{ searchResultsPromotion = searchResultsPromotion + createSearchResultMarkup(obj); } // searchResultMarkupString = searchResultMarkupString + createSearchResultMarkup(obj); }); if(promoIdsArr.length != 0){ globalDataLayer.Search.PromotionIds = promoIdsArr; } searchResultMarkupString = "
    "+searchResultsPromotion+"
    "+searchResultsOrganic+"
    "; //console.log("search String: "+searchResultMarkupString);

    $("#searchResultsWrapper").append(searchResultMarkupString); $(".search-result:not(:last)").after("
    "); } // External Link Image for Search Result Page // add external image symbol if needed $('.search-result a').each(function () { // "this" is the current element in the loop var link = this.href; // internal site regex var regex = new RegExp("([\w0-9._:/-]+hp.com(.*))"); if(link.indexOf('http') > -1 && !regex.test(link)){ $(this).append(' '); } }); } var promoIdsArr = []; function createSearchResultMarkup(searchResultsObj) { var builtString; var resultObj = searchResultsObj.searchResult; if((typeof(resultObj.searchId) == "undefined") && (typeof(resultObj.searchType) == "undefined")){ var Url= resultObj.searchURL; var splitUrl = Url.split("/"); var docID = splitUrl[splitUrl.length - 1]; builtString = "
    " + resultObj.searchTitle +"

    "+resultObj.searchDesc+"

    "; }else if((typeof(resultObj.searchId) == "undefined") && (typeof(resultObj.searchType) != "undefined") && (resultObj.searchType=="promotion")){ builtString = "
    " + resultObj.searchTitle +"

    "+resultObj.searchDesc+"

    "; } else{ builtString = "
    " + resultObj.searchTitle +"

    "+resultObj.searchDesc+"

    "; promoIdsArr.push(resultObj.searchId); } return builtString; } /*Pagination - Richa */ function parsePaginationJson(pageJson) { var pageJson2 = pageJson; var current = pageJson.pagination.current; var total = pageJson.pagination.total; var first = pageJson.pagination.first; var last = pageJson.pagination.last; var totalCount = pageJson.totalCount;

    var searchQueryForDisplay = pageJson.searchQueryForDisplay; var searchQuery = pageJson.searchQuery; var actualQuery = pageJson.actualQuery; var searchResultLink = pageJson.searchResultLink; var resultsFor = pageJson.foundResultFor; var facets = pageJson.facets; var productFacets = pageJson.ProductFacets; var osFacets = pageJson.OSFacets; var topicFacets = pageJson.TopicFacets; var promotionList = pageJson.promotionList; $("#promotionList").val(JSON.stringify(promotionList)); $("#searchResultsWrapper").html(""); var seoFriendlyName = pageJson.searchResults.seoFriendlyName; $("#seoFriendlyName").val(seoFriendlyName); paintPaginationSection(first,last,current,total); paintSearchResults(pageJson.searchResults); paintCountQuery(totalCount,searchQueryForDisplay,actualQuery,searchResultLink,searc hQuery,resultsFor); // do not reload facets if(facets==undefined || (facets!=undefined && facets!='empty')) paintFacets(productFacets,osFacets,topicFacets); $(".searchSectionWrapper").show(); // to bind - on click of clear and clear all bindClearFacets(); } function nonEnglishLocale(){ $(".englishResults").on("click tap",function (event){ searchlc = "en"; var count = $($(".resultsCount2")[0]).text(); $("#storeResultCount").val(count); englishResultsAjax(searchlc); }); $(".localeResults").on("click tap",function (event){ searchlc = getCCLC(lc); $("#storeResultCount").val(""); localResultsAjax(searchlc); }); } /*Locale based rendering */ function parsePaginationJsonEnglish(pageJson) { //$("#resultsInLc").addClass("hide"); if(pageJson.totalCount>0){ parsePaginationJson(pageJson); resultsEnglishJson(); } else{ }

    noResultsEnglishJson();

    } function parsePaginationJsonLocale(pageJson) {

    parsePaginationJson(pageJson); //$("#resultsInLc").removeClass("hide"); $(".optionsResultsInLc").removeClass("hide"); $(".englishResults").removeClass("hide"); $(".localeResults").addClass("hide"); $(".resultsInEng").addClass("hide"); $(".englishLocale").addClass("hide"); $("#resultCurrentLocale").removeClass("hide"); $(".resultsInLocal").removeClass("locale-results"); $("#nonUSLocaleSecondView").html(""); $(".searchForNonENLocale").clone().appendTo("#nonUSLocaleSecondView"); $(".resultsColor").addClass("color-black"); $("#searchProdInfo").removeClass("hide"); nonEnglishLocale(); } function resultsEnglishJson() { $(".optionsResultsInLc").addClass("hide"); $(".englishResults").addClass("hide"); $(".localeResults").removeClass("hide"); $(".resultsInEng").removeClass("hide"); $(".englishLocale").removeClass("hide"); $("#resultCurrentLocale").addClass("hide"); $("#nonUSLocaleSecondView").html(""); $(".searchForNonENLocale").clone().appendTo("#nonUSLocaleSecondView"); $(".resultsInLocal").addClass("locale-results"); $(".resultsColor").removeClass("color-black"); $("#searchProdInfo").addClass("hide"); nonEnglishLocale(); } function noResultsEnglishJson() { $(".noEnglishResults").removeClass("hide"); $(".optionsResultsInLc").addClass("hide"); $(".englishResults").addClass("hide"); $("#nonUSLocaleSecondView").html(""); $(".searchForNonENLocale").clone().appendTo("#nonUSLocaleSecondView"); nonEnglishLocale(); } function paintCountQuery(totalCount,searchQueryForDisplay,actualQuery,searchResultLink,searc hQuery,resultsFor) { // populate 1.total count, 2,search query - user enters and 3.actual query search query if search query is misspelled. globalDataLayer.Search.setValue('Count',totalCount); $(window).trigger('SearchCount',{ SearchCount : totalCount }); $('.resultsCount1').html(totalCount); var totalCountLocal = $("#storeResultCount").val(); if(totalCountLocal!= undefined && totalCountLocal!=totalCount &&

    totalCountLocal!=""){ $('.resultsCount2').html(totalCountLocal); } else{ $('.resultsCount2').html(totalCount); } $('.resultsCount3').html(totalCount); /* $('#search-input').val(searchQueryForDisplay); Removing this as the search query now is painted directly from searchparent.jsp */ $('#searchQuery').val(searchQuery); if($('#actualQuery')!=undefined) { $('#actualQuery').val(actualQuery); //$('#actualQuery').attr("href",searchResultLink); } if(resultsFor!='') { //$('#resultsCountSearch').html(resultsFor); //$('#resultsCountSearch_val').val(resultsFor); //Changes made for XSS Vulnerability $('#resultsCountSearch').html(""); var searchInput_Text = $('#search-input').val(); searchInput_Text = $('<span>', {text: searchInput_Text}); $('#resultsCountSearch').append(searchInput_Text); } } function paintPaginationSection(first,last,current,total) { // clear the existing pages and remove disabled class from button. $('.pagination-container ul.pagination-pages').html(''); enableDisablePageButton('enable'); // if only 1st page is displayed. if(first == 0) { $('.paginationWrapper').hide(); return; } else if( $('.paginationWrapper').css('display') == 'none' ) { $('.paginationWrapper').show(); } //paint the pages and add active class for(var count=first; count<=last; count++) { if(count == current) { $('.pagination-container ul.pagination-pages').append('
  • <span style="fontsize:0">'+paginationTBK.pages +' <span class="pageCount">'+count+'<span style="font-size:0px"> ' + paginationTBK.of + last +'
  • '); } else { $('.pagination-container ul.pagination-pages').append('
  • <span style="font-size:0">'+paginationTBK.pages +' <span class="pageCount">'+count+'<span style="font-size:0px"> ' + paginationTBK.of + last +'
  • '); } } //check for disabling first/last button if(current == 1) { enableDisablePageButton('disable','less');

    } if(current == total) { enableDisablePageButton('disable','more'); } $('ul.pagination-pages li').on('click',function() { if(!($(this).find('a').hasClass('active'))) { var current = $(this).find('a .pageCount').html(); var currentNum = parseInt(current); pagination(currentNum); } }); } function pagination(pageNum) { var ajaxParam = facetsPaginationParams(pageNum); var requestJson = JSON.stringify(ajaxParam.paramData); var pageURL = $('#paginationURL').val(); callAjaxUtil("pagination",pageURL,"POST",parsePaginationJson,"JSON", requestJson, null,null,null,true,handleLoadingResult,true,handleLoadingResult,false); } function pageButtonHandle(buttonVal) { var current = $('ul.pagination-pages li a.active .pageCount').html(); var currentNum = parseInt(current); if(buttonVal == "less") { pagination(currentNum-1); }else if(buttonVal == "more") { pagination(currentNum+1); } } //this function is called on beforesend and complete of ajax call for pagination function handleLoadingResult(showOrHide) { // showOrHide will be true for beforesend and false for complete if(showOrHide == true) { $('.hp-loading-results').show(); } else { $('.hp-loading-results').hide(); $(window).scrollTop(0); $("#searchResultsWrapper").find("a")[0].focus(); // This is to take the focus to the first result. } } function enableDisablePageButton(enableDisable,buttonName) { if(enableDisable == 'disable') { if(buttonName == 'less') { $('.pagination-button.paginationless').attr('disabled','disabled'); $('.pagination-button.pagination-less').css('backgroundcolor','#DDD'); } else { $('.pagination-button.paginationmore').attr('disabled','disabled'); $('.pagination-button.pagination-more').css('background-

    color','#DDD'); } } else {

    // enable less $('.pagination-button.pagination-less').removeAttr('disabled'); $('.pagination-button.pagination-less').css('background-

    color','#FFF');

    color','#FFF'); }

    // enable more $('.pagination-button.pagination-more').removeAttr('disabled'); $('.pagination-button.pagination-more').css('background-

    } /*Pagination - RIcha - end */ function handlePaginationRtl() { // RTL for pagination buttons - Richa if($('html').attr('dir') == 'rtl') { $('.pagination-button.pagination-less i').removeClass('fa fa-chevronleft').addClass('fa fa-chevron-right'); $('.pagination-button.pagination-more i').removeClass('fa fa-chevronright').addClass('fa fa-chevron-left'); } // RTL for pagination buttons - Richa - end } $(document).ready(function() { hpExpandableInit(); }); function hpExpandableInit() { $(document).on("click", ".hp-expand-colapse", function() { $(this).addClass("opened"); $(this).siblings(".hp-expandable-section").slideDown().addClass("opened"); }); $(document).on("click", ".hp-expand-colapse.opened", function() { $(this).removeClass("opened"); $(this).siblings(".hp-expandable-section").removeClass("opened").slideUp(); }); } /** * Protect window.console method calls, e.g. console is not defined on IE * unless dev tools are open, and IE doesn't define console.debug */ (function() { if (!window.console) { window.console = {}; } // union of Chrome, FF, IE, and Safari console methods var m = [ "log", "info", "warn", "error", "debug", "trace", "dir", "group",

    "groupCollapsed", "groupEnd", "time", "timeEnd", "profile", "profileEnd", "dirxml", "assert", "count", "markTimeline", "timeStamp", "clear" ]; // define undefined methods as noops to prevent errors for (var i = 0; i < m.length; i++) { if (!window.console[m[i]]) { window.console[m[i]] = function() {}; } } })();// This plugin is based on the Bootstrap collapse component, with some extended functionality // This plugin looks for an element with a data-toggle="collapse" // The href attr of the toggle will determine which accordion to collapse/expand // If the toggle element also has a data-group attr, any accordion inside that #id will collapse, allowing only one to be visiblea at a time // Also you can pass in a data-scroll boolean on the toggle element, to determine wether the page will scrollTo the now visible accordion content // // This will control any expandable component, including Accordions, Sortable Table, and Instruction Panels Accordion = (function(){ var init = function(){ if($('[data-toggle="collapse"]').length){ addHandlers(); } }; var addHandlers = function(){ $('[data-toggle="collapse"]').on('tap click', checkState); $('[data-toggle="collapse"]').on('slideDown', slideDown); $('[data-toggle="collapse"]').on('slideUp', slideUp); $('.acc-ex-all').on('tap click', expandAll); $('.acc-coll-all').on('tap click', collapseAll); }; var checkState = function(e){ // This is the entry point. It checks the state of the accordion and handles its accordingly (lolz). e.preventDefault(); e.stopPropagation(); //Get the e.target handler var $toggle = $(this); var scroll = $toggle.data('scroll'); //IF IT IS UP, slide it down if(!$($toggle.attr('href')).hasClass('in')){ //IF IN GROUP, then we need to close all sibling panels in the group if($toggle.data('parent')){ var group = $toggle.data('parent'); $(group).find('[datatoggle="collapse"]').not($toggle).trigger('slideUp'); $toggle.trigger('slideDown', [scroll]); } else { $toggle.trigger('slideDown', [scroll]); } //IF DOWN, slide that up } else { $toggle.trigger('slideUp');

    } }; var expandAll = function(e){ //This expands all panels in the group e.preventDefault(); var $toggle = $(this); var $group = $($toggle.data('group')); $group.find('[data-toggle="collapse"]').trigger('slideDown', [false]); }; var collapseAll = function(e){ //Collapses all panels in their group e.preventDefault(); var $toggle = $(this); var $group = $($toggle.data('group')); $group.find('[data-toggle="collapse"]').trigger('slideUp'); }; var slideDown = function(e, scroll){ //Slides down an individual panel var $toggle = $(this); var $panel = $ (this).addClass('toggled').closest('[class^="panel"]').addClass('open'); var accordionId = $toggle.attr('href'); var $accordion = $(accordionId); $toggle.attr("aria-expanded","true"); $accordion.slideDown(function(){ $(this).addClass('in'); if(scroll){ $('html, body').animate({scrollTop: $accordion.offset().top-200}, true); } if($(this).attr("id") == "os-selector"){ $(".os-heading").css("pointer-events",""); } }); }; var slideUp = function(e){ var $toggle = $(this); var $panel = $ (this).removeClass('toggled').closest('[class^="panel"]').removeClass('open'); var accordionId = $toggle.attr('href'); var $accordion = $(accordionId); $toggle.attr("aria-expanded","false"); $accordion.slideUp(function(){ $(this).removeClass('in'); if($(this).attr("id") == "os-selector"){ $(".os-heading").css("pointer-events",""); } }); }; return { init: init }; }());// This has been made obsolete by the addition of iCheck plugin // Saving code here for backup for now

    // Checkboxes = (function(){ // var init = function(){ // var $inputs = $('input[type="checkbox"]'); // if($inputs.length){ // $inputs.each(function(){ // var $label = $(this).parent('label'); // preCheckBox($label); // }); // addHandlers(); // } // } // var addHandlers = function(){ // $('input[type="checkbox"]').parent('label').on('tap click', checkBox); // } // var checkBox = function(e){ // e.stopPropagation(); // e.preventDefault(); // var $label = $(this); // var $input = $label.find('input'); // if($input.attr('checked')){ // $input.removeAttr('checked').change(); // $label.removeClass('selected'); // } else { // $input.attr('checked', 'checked').change(); // $label.addClass('selected'); // } // } // var preCheckBox = function($label){ // var $input = $label.find($('input[type="checkbox"]')); // if($input.attr('checked')){ // $input.attr('checked', 'checked').change(); // $label.addClass('selected'); // } else { // $input.removeAttr('checked').change(); // $label.removeClass('selected'); // } // } // return { // init: init // } // }()); // // ---------------------------------------------- FILTERS-DESKTOP // $('.filters-desktop .expandable').on('click touchstart', function(e) { // e.preventDefault(); // $(this).toggleClass('open'); // }); {

    // $('.filters-desktop .filter-options label').on('click touchstart', function(e) // e.preventDefault(); // $(this).toggleClass('selected'); // });

    // $('.show-more').on('click touchstart', function(e) { // e.preventDefault(); // $(this).closest('.filter-optionsnested').find('.more').removeClass('more').addClass('less'); // $(this).hide(); // $('.show-less').show(); // }); // $('.show-less').on('click touchstart', function(e) { // e.preventDefault(); // $(this).closest('.filter-optionsnested').find('.less').removeClass('less').addClass('more'); // $(this).hide(); // $('.show-more').show(); // }); // $('.show-more-expandables').on('click touchstart', function(e) { // e.preventDefault(); // $(this).closest('.filter-level-1').find('.more-category').removeClass('morecategory').addClass('less-category'); // $(this).hide(); // $('.show-less-expandables').show(); // }); // $('.show-less-expandables').on('click touchstart', function(e) { // e.preventDefault(); // $(this).closest('.filter-level-1').find('.less-category').removeClass('lesscategory').addClass('more-category'); // $(this).hide(); // $('.show-more-expandables').show(); // }); // // ---------------------------------------------- FILTERS-TRIGGER // $('#filter-trigger').on('click touchstart', function(e) { // e.preventDefault(); // $('.filters').toggleClass('open'); // }); // $('.filters .close').on('click touchstart', function(e) { // e.preventDefault(); // $('.filters').removeClass('open'); // }); // $('.filters').on('scroll', function(e) { // e.stopPropagation(); // }); // // ---------------------------------------------- FILTERS-MOBILE // $('#close-tab-content').on('click touchstart', function(e) { // e.preventDefault(); // $('.tab-content').removeClass('open'); // }); // $('.hp-nav-tabs a').on('click touchstart', function(e) { // e.preventDefault(); // $('.tab-content').toggleClass('open');

    // }); // $('.filter-trigger').on('click touchstart', function(e) { // e.preventDefault(); // $('.filters-mobile').toggleClass('open'); // }); // $('.filter-title').on('click touchstart', function(e) { // e.preventDefault(); // $(this).next('.filter-options').toggleClass('open'); // $(this).closest('.filter-category').toggleClass('open'); // }); // $('.filter-options label').on('click touchstart', function(e) { // e.preventDefault(); // $(this).toggleClass('open'); // //

    var $filterOption = $(this).find('input[type="checkbox"]'); $filterOption.attr('checked', !$filterOption.is(':checked'));

    // $(this).next('.filter-options-nested').toggleClass('open'); // }); // This component mimics the basic functionality of the bootstrap dropdown component Dropdown = (function(){ var init = function(){ if($('[data-toggle="customDropdown"]').length){ addHandlers(); } }; var addHandlers = function(){ $('[data-toggle="customDropdown"]').on('tap click', checkSize); $('.customDropdown').on('dClose', dClose); $('.customDropdown').on('dOpen', dOpen); $(document).on('tap click', clearDropdowns); $('.customDropdown').on('tap click', function(e){ e.stopPropagation(); }); }; var checkSize = function(e){ // if($(window).width() > 767){ e.preventDefault(); e.stopPropagation(); normalDropdown(this); // } else { // mobileDropdown(this); // } }; var clearDropdowns = function(e){ var container = $(".customDropdown"); if (!container.is(e.target) // if the target of the click isn't the container...

    the container {

    && container.has(e.target).length === 0) // ... nor a descendant of $dropdowns = $('.customDropdown'); $dropdowns.trigger('dClose');

    } }; var normalDropdown = function(target){ $dropdown = $(target).parent();

    $dropdowns = $('.customDropdown'); if($dropdown.hasClass('open')){ $dropdown.trigger('dClose'); } else { $dropdowns.not($dropdown).trigger('dClose'); $dropdown.trigger('dOpen'); }

    }; var dClose = function(e){ e.stopPropagation(); $this = $(this); $this.removeClass('open'); }; var dOpen = function(e){ $this = $(this); $this.addClass('open'); };

    return { init: init }; }());// This is placeholder code to demonstrate filter functionality // It basically adds a bunch of handlers to fire mock-AJAX calls and update the filter breadcrumbs // This has a dependency on iCheck Filters = (function(){ var filterTitles = {}; var init = function(){ var $inputs = $('.filter-options input[type="checkbox"]'); if($inputs.length){ addHandlers($inputs); } }; var addHandlers = function($inputs){ $inputs.on('change', applyFilter); $('[data-filter="clear"]').on('tap click', clearFilters); $('[data-filter="all"]').on('change', clearSiblingFilters); $('#filter-form').on('submit', submitFilters); $('.expandable').on('tap click', expand); $('[data-more]').on('tap click', expandLevel); $('#filter-trigger').on('tap click', showMobile); $('#filter-close').on('tap click', showMobile); if (window.addEventListener) { window.addEventListener('orientationchange', function(){ if (window.innerWidth > 800){

    $('body').removeClass('hp-filter-open'); } else { if ($('.filters.open').length) { $('body').addClass('hp-filter-open'); } } }); }

    };

    var applyFilter = function(e){ // make ajax call var $input = $(this); if($input.is('[data-filter="all"]')){ $('#filter-form').submit(); } else { $input.parents('.filter-category').find('[datafilter="all"]').icheck('unchecked'); $('#filter-form').submit(); } }; var expand = function(e){ var $expander = $(this); if($expander.hasClass('selected')){ $expander.removeClass('selected'); $expander.find("a[data-expandable]").attr("aria-expanded","false"); $expander.siblings('.filter-options-nested').hide(); } else { $expander.addClass('selected'); $expander.siblings('.filter-options-nested').show(); $expander.find("a[data-expandable]").attr("aria-expanded","true"); } }; var expandLevel = function(e){ var $expander = $(this); var group = $(this).data('more'); var text; if($expander.hasClass('in')){ $('.'+group).show(); text = $expander.text(); $expander.text($expander.data('text')).removeClass('in'); $expander.data('text',text); } else { $('.'+group).hide(); text = $expander.text(); $expander.text($expander.data('text')).addClass('in'); $expander.data('text',text); } }; var showMobile = function(e){ var $filters = $('#filter-form'); if($filters.hasClass('open')){

    $filters.css('-webkit-transition', 'all 300ms ease-in-out'); setTimeout(function(){ $filters.removeAttr('style'); }, 300); $filters.removeClass('open'); $('body').removeClass('hp-filter-open'); } else { $filters.addClass('open'); $('body').addClass('hp-filter-open'); } }; var submitFilters = function(e){ var url = "#"; // the script where you handle the form input. //do not uncomment - Richa $('#loading-results').show(); var $filterList = $('.applied-filters'); var $filterClear = $('#filter-clear'); //var $scf = $('#scf'); $filterList.find('li, ul').remove(); //$('#scf li').remove('li'); var numFilters = 0; //var $clearButton = $(document.createElement('button')).addClass('appliedfilters-item').attr('data-filter','clear'); $('.filter-options input[type="checkbox"]').not('[datafilter="all"]').each(function(){ var $input = $(this); if($input.prop('checked')){ var $tag = $(document.createElement('li')); var $button = $(document.createElement('button')); var parentTitle = $(this).parents('.filter-category').children('.filtertitle').html(); var title; var categoryList; //var $top; $button.addClass('filter-close icon').attr('ref', $input.attr('class').split(' ').pop()); $tag.text($(this).parents('label').text()).attr('ref', $input.attr('class').split(' ').pop()).addClass('applied-filtersitem').prepend($button); if ($('.filter-selected-title[data-selected-title="' + parentTitle + '"]').length){ $('.filter-selected-title[data-selected-title="' + parentTitle + '"]').append($tag); } else { title = $(document.createElement('li')).html(parentTitle); categoryList = $(document.createElement('ul')).addClass('filter-selectedtitle').attr('data-selected-title',parentTitle).append(title).append($tag); $filterList.append(categoryList); } SCF.initElem($tag); //Adding filter on top //$top = $tag.clone().removeClass('hidden-lg'); //$scf.append($top.removeClass('hidden-lg')[0]); //SCF.initElem($top); numFilters += 1; }

    if(numFilters === 0){ $('#filter-badge').text(''); //$scf.next().hide().css('visibility', 'hidden'); } else { $('#filter-badge').text(numFilters); //$scf.next().show().css('visibility', 'visible'); } }); $('#filter-trigger span').remove(); if (numFilters > 0){ $filterList.show(); $('#filter-trigger').append('<span> ('+ numFilters +')'); $('#filter-title').css('display','inline'); } else { $filterList.hide(); $('#filter-title').hide(); $('#filter-trigger').remove('span'); } if (numFilters >= 3) { $filterClear.show(); } else { $filterClear.hide(); } /*do not uncomment - Richa setTimeout(function(){ $.ajax({ type: "POST", url: url, data: $("#filter-form").serialize(), // serializes the form's elements. success: function(data) { $('#loading-results').hide(); }, error: function(data){ $('#loading-results').hide(); } }); }, 1000); */ return false; }; var clearFilters = function(e){ e.preventDefault(); var $inputs = $('.filter-options input[type="checkbox"]'); $('.applied-filters li').remove(); $inputs.not('[data-filter="all"]').icheck('unchecked'); var $all = $('[data-filter="all"]'); $all.attr('checked', 'checked').parent('label').addClass('selected'); applyFilter(); }; var clearSiblingFilters = function(e){ var $all = $(this); if($all.attr('checked')){ var $inputs = $all.parents('.filter-options').find('input[type="checkbox"]'); $inputs.not($all).icheck('unchecked'); applyFilter(); } }; return {

    };

    init: init

    }()); //These elements are created from filters.js by clicking the input filters SCF = (function(){ var init = function(){ var $toggles; if ($('.applied-filters-item').length) { $toggles = $('.applied-filters-item').find('.filter-close'); addHandlers($toggles); } }; var initElem = function($el){ addHandlers($el.find('.filter-close')); }; var addHandlers = function($toggles){ $toggles.on('click', close); }; var close = function(e){ var $target = $(e.currentTarget); var $parent = $target.parent(); var $input; $input = $('#filter-form input.icheck\\[' + $target.attr('ref').split('[').pop().split(']').shift() + '\\]'); $input.prop('checked', false).change(); console.log($input.prop('checked')); if ($target.prop('tagName') === 'LI'){ $target.remove(); } else if ($parent.prop('tagName') === 'LI'){ $parent.remove(); } }; return { init: init, initElem: initElem }; })();Pagination = (function(){ var $pagContainer, $contentSelector, $controls, controlTriggers, maxResults, totalResults; var init = function(){ $pagContainer = $('.pagination-container'); if($pagContainer.length){ $contentSelector = $('.pagination-container li'); $controls = $('.pagination'); controlTriggers = '.pagination li a'; maxResults = 10; totalResults = $contentSelector.length; renderControls();

    };

    }

    var renderControls = function(){ // // THIS MODULE IS STILL IN PROCESS // // }; return { init: init }; }());// This is to demonstrate functionality of the dependent select boxes // whenever a change is made in a parent select box, an ajax call needs to fire // to pull in the next set of options available // this is dependant on the fancy select plugin ajaxSelect = (function(){ // create a blank image object to reserver for our loader gif var loaderGif = new Image(); // var init = function(){ // grab all our instances var $ajaxSelects = $('[data-class="ajax-select"]'); var $fancySelects = $('.fancy-select'); if($ajaxSelects.length){ // add handlers addHandlers($ajaxSelects, $fancySelects); // this is dummy call fakeIt(); // set the image object's src loaderGif.src = ('_/images/i-pre-sm-hpe.gif'); $(loaderGif).addClass('select-loader'); // append a loader gid before each instance of the submit button or if no submit button // after all the select boxes $('.dependant-select').each(function(){ if($(this).find('input[type="submit"]').length){ $ (this).find('input[type="submit"]').before(loaderGif); } else { $(this).append($(loaderGif).clone()); } }); } }; // add our handlers var addHandlers = function($ajaxSelects, $fancySelects){ // change.fs is an event provided to us by fancy select $ajaxSelects.on('change.fs', callNextLevel); $fancySelects.on('open', open); };

    // var open = function(e){ // } // This is a dummy call to hide all the results on one of the tabs in PDP, as well as hide all the // dependant select would otherwise not be visible/returned by ther server yet var fakeIt = function(){ $('.troubleshoot-results').hide(); // Hide all the selects except the first $('.dependant-select').each(function(){ $(this).find('.fancy-select.ajax-select').slice(1).hide(); }); // Make it so the first dropdown is expanded by default. omg this is so ugly why. much bad ux. $('.dependant-select.open').each(function(){ $(this).find('.fancy-select.ajaxselect').first().children().addClass('open'); }); }; // this fires after the change event on a fancy select box var callNextLevel = function(e){ // set up some variables for the AJAX call var $select = $(this); var $parent = $select.parent(); var $form = $(this).parents('form'); var url = $form.attr('action'); // show the loader while the AJAX call is made if( $select.parent().next('.fancy-select').length){ $select.parent().siblings('.select-loader').css({'display': 'block'}); } else { $select.parent().removeClass('last'); } // this timeout fakes the time it would take for an ajax to complete setTimeout(function(){ $.ajax({ type: "POST", url: url, data: $form.serialize(), // serializes the form's elements. success: function(data) { // DO SOME STUFF IN HERE TO BUILD OUT THE NEXT LEVEL's SELECT OPTIONS BASED ON DATA RETURNED FROM SERVER if( $select.parent().next('.fancy-select').length){ $select.parent().removeClass('last'); $select.parent().next('.fancyselect').show().addClass('last').children('select').focus(); $select.parent().siblings('.select-loader').hide(); } else { $select.parent().siblings('.select-loader').hide(); $('.troubleshoot-results').show(); } }, error: function(data){ if( $select.parent().next('.fancy-select').length){

    $select.parent().next('.fancy-select').show(); $select.parent().removeClass('last'); $select.parent().next('.fancyselect').show().addClass('last'); $form.find('.select-loader').hide(); } else { $form.find('.select-loader').hide(); $('.troubleshoot-results').show(); } } }); }, 1000); return false; }; return { init: init }; }()); narrowModal = (function(){ var $resultsModal, $narrowForm; var init = function(){ $resultsModal = $('#refine-results-modal'); if($resultsModal.length){ $narrowForm = $('#narrow-results'); addHandlers(); } }; var addHandlers = function(){ $narrowForm.on('submit', fetchResults); }; var fetchResults = function(e){ e.preventDefault(); $('#refine-results-modal').modal('toggle'); var url = $narrowForm.attr('action'); $.ajax({ type: "POST", url: url, data: $narrowForm.serialize(), // serializes the form's elements. success: function(data) { //HANDLE SUCCESS }, error: function(data){ //HANDLE THE ERROR } }); return false; }; return { init: init }; }());// This is placeholder code for predicitve results in the search bar

    // You can see this in action on search.php // As of current, this functionality will happen if there is a #predictive-results element Search = (function(){ // Modukle variables var $searchInput, $predictiveList; // Check if we need to initialize var init = function(){ $searchInput = $('#search-input.predictive'); $predictiveList = $('#predictive-results'); if($searchInput.length){ addHandlers(); } }; // add our handlers var addHandlers = function(){ $searchInput.on('keydown', switchToList); $searchInput.on('focus', showList); $predictiveList.on('keydown','a', checkKeymap); $predictiveList.on('click tap','a', changeValue); }; // This code will change focus to the list when the user hits the down arrow var switchToList = function(e){ // Check for down arrow event if(e.keyCode == 40 && $predictiveList.length){ e.preventDefault(); // Find first li in the list and focus it and add a hover class // in some browsers, simply focusing an element does not add a hover state // so we need to do this manully $predictiveList.find('li:first a').trigger('focus').addClass('hover'); } }; var showList = function(e){ // Simple call to show the list $predictiveList.show(); }; var checkKeymap = function(e){ // A switch statement! Wow! switch(e.keyCode){ // Check if down arrow case 40: // Check if the parent is not the last element if(!$(this).parent().is(':last-child')){ $ (this).removeClass('hover').parent().next().find('a').focus().addClass('hover'); } // if it is, nothing should happen return false; //UP // Check if parent li is the first element case 38: if($(this).parent().is(':first-child')){

    $(this).removeClass('hover'); //if it is, focus on the search $searchInput.focus(); } else { // if it isnt, then simply iterate up the list $ (this).removeClass('hover').parent().prev().find('a').focus().addClass('hover'); } return false; // Check if 'enter' key is pressed case 13: // trigger a click event to select this value $(this).removeClass('hover'); $(this).trigger('click'); break; };

    }

    // this is the function that swaps the value from the list to search bar var changeValue = function(e){ $searchInput.val($(this).text()); $predictiveList.hide(); }; return { init: init }; }());Tooltips = (function(){ var $modalTemplate = $('#tooltip-modal'); var init = function(){ if($('.badge-tooltip').length || ($('.with-tooltip').length)){ // Do not remove / modify - Varun. checkBrowser(); } }; var checkBrowser = function(){ if(Modernizr.touch || $(window).width()<768){ addTouchHandlers(); } else { addTouchlessHandlers(); } }; var addTouchlessHandlers = function(){ $('.badge-tooltip').popover({ trigger: 'focus', html: true, container: 'body' }).click(function(e){ if(!$(this).is(':focus')){ e.preventDefault(); $(this).focus(); } }); $('.with-tooltip').popover({ trigger: 'hover',

    html: true, container: 'body' }).click(function(e){ if(!$(this).is(':focus')){ e.preventDefault(); $(this).focus(); } }); }; var addTouchHandlers = function(){ $('.badge-tooltip').on('tap click', buildModal); }; var buildModal = function(){ var $badge = $(this); var $modal = $('#tooltip-modal'); if($badge.data('title')){ $modal.find('h3').empty().html($badge.data('title')).show(); } else { $modal.find('h3').hide(); } if ($badge.data('content')){ $modal.find('.content').empty().html($badge.data('content')); showModal(); } }; var showModal = function(){ $modalTemplate.modal(); }; return { init: init }; }());CLC = (function(){ var init = function(){ // After selecting a country, // display that country flag and country name in the next step $('#clc-choose-country .country-options a').on('tap click', function(e) { e.preventDefault(); var selectedCountry = $(this).text(); var selectedCountryFlag = $(this).find('.flag').attr('class'); var totalLanguages = $('#clc-choose-language .language-options li').size(); $('#clc-choose-language').find('#selectedCountry').text(selectedCountry); $('#clc-chooselanguage').find('#selectedCountryFlag').addClass(selectedCountryFlag); // Count the number of supported languages // and display them in the modal-title $('#totalLanguages').text(totalLanguages); }); // When switching from Country to Language, // change the size of the modal from modal-xl to modal-sm $('.country-options a').on('tap click', function(e) { e.preventDefault();

    $('#clc-choose-country').hide(); // $('#clc-choose-language').show(); $('#clc-modal').find('.modal-dialog').removeClass('modalxl').addClass('modal-sm'); }); // When switching back from Language to Country, // change the size of the modal back to modal-xl $('#clc-back').on('tap click', function(e) { e.preventDefault(); $('#clc-choose-language').hide(); $('#clc-choose-country').show(); //$('#clc-modal').find('.modal-dialog').removeClass('modalsm').addClass('modal-xl');//do not remove this - Pratisha }); // After clicking on a support language, // add the selected language to the Confirm button and enable it $('#clc-choose-language .language-options a').on('tap click', function(e) { e.preventDefault(); $('#clc-choose-language .language-options a').removeClass('selected'); $(this).addClass('selected'); var selectedLanguage = $(this).text(); $('#selected-language').text(selectedLanguage); $('#confirm-language').removeAttr('disabled'); }); }; return { init: init }; }());PSF = (function(){ var var var var

    $window; $footer; $psf; psfHeight;

    var init = function(){ if($('#psf').length){ $window = $(window); $footer = $('#footer'); $psf = $('#psf'); psfHeight = $('#psf').height(); addHandlers(); //$('#notifications-trigger').trigger('click'); uncomment this. This is handled in the portlet with session } }; var isMobile = function(){ if(viewport().width <= 800){ return true; } else { return false; } }; function viewport() { var e = window, a = 'inner';

    //Please do not

    }

    if (!('innerWidth' in window )) { a = 'client'; e = document.documentElement || document.body; } return { width : e[ a+'Width' ] , height : e[ a+'Height' ] };

    var addHandlers = function(){ // $window.on('scroll', checkPos); }; function debounce(func, wait, immediate) { var timeout; return function() { var context = this, args = arguments; clearTimeout(timeout); timeout = setTimeout(function() { timeout = null; if (!immediate) func.apply(context, args); }, wait); if (immediate && !timeout) func.apply(context, args); }; }; // var checkPos = debounce(function(){ // if($footer){ // var footerPos = $footer.offset().top; // var psfPos = $psf.offset().top + psfHeight; // var windowScroll = $window.scrollTop(); // var windowHeight = $window.height(); // var oldFix; // if(isMobile()){ // oldFix = 0; // } else { // oldFix = 72; // } // if((psfPos > footerPos) || (windowScroll + windowHeight >= $ (document).height())){ // $psf.css({'bottom':'0', 'position':'absolute'}); // } // if(!(psfPos+oldFix <= (windowScroll+windowHeight)) && ($psf.offset().top >= windowScroll)){ // $psf.css({'top':oldFix, 'position':'fixed'}); // } // } // }, 10); var countNotifications = function() { var totalNotifications = $('.notificationsbg').find('.notification').size(); $('#totalNotifications').text(totalNotifications); }; countNotifications(); // Open notifications on click $('#notifications-trigger').on('tap click', function(e) { e.preventDefault();

    });

    $('.notifications-bg').addClass('open'); $(this).toggleClass('open'); $("#dismiss-notifications").attr("aria-hidden","false");

    // Close notifications on click of dismissal $('#dismiss-notifications').on('tap click', function(e) { e.preventDefault(); $(this).attr("aria-hidden","true"); $('.notifications-bg').removeClass('open').addClass('viewed'); $('#notifications-trigger').addClass('viewed'); countNotifications(); // If there no more notifications, show the empty notifications message if ($('.notification').length === 0) { $('#empty-notifications').show(); // Automatically close notifications after 2 sec. setTimeout(function() { $('.notifications-bg').removeClass('open'); }, 2000); } }); var psfWidgetVisible=false; // Toggle the PSF on mobile $('#psf-gripper').on('tap click swipeleft swiperight', function() { //Ios transition hack fix if ($('#psf.open').length) { psfWidgetVisible=false; $('#psf').css('-webkit-transition', 'right 300ms ease-in-out'); setTimeout(function(){ $('#psf').removeAttr('style'); //3439: restore position of PSF setPSFPosition(); }, 300); $('#psf.open #psf-gripper .icon').removeClass('iconrght').addClass('icon-lft'); } else { $('#psf-gripper .icon').removeClass('icon-lft').addClass('iconrght'); //3439: restore position of PSF psfWidgetVisible=true; setPSFPosition(); } $('#psf').toggleClass('open'); }); //3439 start: position psf according to steps bar presence setPSFPosition(); function setPSFPosition(){ var pageIdentifier=$("#pageIdentifier").val(); if($(window).width() < 776){ if($("#steps-bar").is(":visible")){ $("#psf").css("top", "53px"); } else{ $("#psf").css("top", "0px"); }

    if(pageIdentifier == "multipleWarranty" || pageIdentifier == "multipleWarrantyResults"){ if(psfWidgetVisible){ $("#psf").css("right", "-41px"); } else{ $("#psf").css("right", "-103%"); } } } else{ $("#psf").css("top", "72px"); if(pageIdentifier == "multipleWarranty" || pageIdentifier == "multipleWarrantyResults"){ $("#psf").css("right", "0px"); } } } //position psf on window resize $(window).resize(function(){ setPSFPosition(); }); //3439 end return { init: init }; }());// This component handles stickyness in the responsive footer // Note, the desktop and mobile header use the same markup Header = function(){ //Set some module variables var $window = $(window); var $header = $('.hp-header'); var $input = $('#search-input'); var init = function(){ addHandlers(); //fire the reset function on load just to sync everything up reset(); // Check cookie to see if users already visted the site, if true then hide the search bar if (!(document.cookie.replace(/(?:(?:^|.*;\s*)hpSession\s*\=\s*([^;]*).*$)| ^.*$/, "$1"))) { if (isMobile()) { $('#hp-search').slideDown(0); $('.mobile-search-toggle').trigger('slideDown'); } } else { if (isMobile()){ $('.mobile-search-toggle').trigger('slideUp'); } } $.cookie('hpSession','true');

    }; // check if we are in mobile layout var isMobile = function(){ if(viewport().width <= 800){ return true; } else { return false; } }; // this gives us a better representation of screen width than window.width function viewport() { var e = window, a = 'inner'; if (!('innerWidth' in window )) { a = 'client'; e = document.documentElement || document.body; } return { width : e[ a+'Width' ] , height : e[ a+'Height' ] }; } //this limits a function from firing too many times unecessarily, good for optimization function debounce(func, wait, immediate) { var timeout; return function() { var context = this, args = arguments; clearTimeout(timeout); timeout = setTimeout(function() { timeout = null; if (!immediate) func.apply(context, args); }, wait); if (immediate && !timeout) func.apply(context, args); }; }; // This function check our scroll position and positions the header correctly // Start HP 453 // This function check our scroll position and positions the header correctly // Depricated: caused buggy input focus when keyboard triggered scroll event on search. // var checkPos = debounce(function () { // if (isMobile()) { // var windowScroll = $window.scrollTop(); // // if we are past 80 pixels, sticky nav // if (windowScroll > 80) { // $header.css({'position': 'fixed', 'top': '0', 'z-index': '999'}); // } else { // // other wise, make it not sticky // $header.css({'position': 'absolute'}); // } // // once we scroll past 80, we want the search bar to pop up, but we dont want it to happen every time we // // scroll, so we limit this functionality between 80 and 120px // // Note: There is a better way to do this, perhaps making use of a libraries .once() function // if (windowScroll > 80 && windowScroll < 120) { // $('.mobile-nav-toggle').removeClass('out'); // $header.find('.mobile-search-toggle').trigger('slideUp'); Leave the search box open and not attached to scroll for keyboards on mobile that trigger

    scroll event. // } // } else { // // if we are not in mobile, ensure header is not sticky // $header.css({'position': 'relative'}); // } // }, 10); $window.scroll(function() { var st = scrollY(), changeHeaderAt = 120, $header = $('.hp-header'); var pageTitle = $('#hpProductContextPageTitle'); // Shrink Header only if scrolling down if( st >= changeHeaderAt ) { //pageTitle.hide(); $header.addClass('sticky'); } else { //pageTitle.show(); }

    $header.removeClass('sticky');

    }); function scrollY() { return window.pageYOffset || document.documentElement.scrollTop; } // End HP 453 // this function fires on window resize, and makes sure all functionality is cleared out between layouts // Not sure why this isnt handled by css classes, surely I had a good reason var reset = debounce(function(){ // if not in mobile, clear out all applied inline styles and change placeholder content //Do not remove - Varun var typeaheadLeftHookDesktop = "0"; var isDesktop = true; if(!isMobile()){ $('#hp-search').hasClass('in') && $('.hp-header .hpsearch').css({'display': 'block'}); $('#psf').insertAfter('#footer');/*Moved this to site.js VV */ //removed as it hides the H1 tag when browser is resized // $('#body').css({'padding-top': '0'}); //Do not remove - Varun $(".search-input").each(function(){ $(this).attr("ghosttext",$(this).data("placeholderlg")); if($(this).val()==$(this).data("placeholdersm") ){ // removed the null check as keeping it on null made ghost text editable while size changed on focus $(this).val($(this).data("placeholderlg")); } typeaheadLeftHookDesktop = $(this).parents(".searchbg").find("#search-dropdown").innerWidth() + 15; $(this).siblings(".typeaheadHook").val(typeaheadLeftHookDesktop);

    $(this).css("padding-left",typeaheadLeftHookDesktop); $(this).parents(".search-bg").find("#search-dropdown").innerWidth() + 15;

    });

    isDesktop=true; $(this).unbind("blur"); handleGhostScript(jQuery(this)); $(this).on("blur",function(){ $(this).trigger("blurTypeahead"); })

    // do not uncomment - Varun $('.hp-header #searchinput').attr('placeholder', 'Enter your product number, a question or keywords'); // if it is mobile, apply mobile styling and change search box placeholder content } else { // $header.css({'position': 'absolute'}); // now handled by .sticky in _hp-navigation.less // $('#body').css({'padding-top': '60px'}); //moved to _hpstructure.less //for positioning the widgets in mobile devices :: Pratisha $('#psf').appendTo('.fixedWidgets'); //Do not remove - Varun $(".search-input").each(function(){ $(this).attr("ghosttext",$(this).data("placeholdersm")); if(!($(this).is(":focus"))){ if($(this).val()==$(this).data("placeholderlg") ){ $(this).val($(this).data("placeholdersm")); } typeaheadLeftHookDesktop = $ (this).siblings(".typeaheadHook").val(); $(this).siblings(".typeaheadHook").val("0")

    });

    isDesktop = false; $(this).unbind("blur"); handleGhostScript(jQuery(this)); $(this).on("blur",function(){ $(this).trigger("blurTypeahead"); }) }

    // do not uncomment - Varun $('.hp-header #search-input').attr('placeholder', 'Search HP Support'); } }, 10); // this is a simple handler to clear text out of search box var clearSearch = function(){ //modified by Varun do not change

    $('.hp-header #search-input').val($('.hp-header #searchinput').attr("ghosttext")); $('.hp-header #search-input').addClass("placeholderText"); }; // add our event handlers var addHandlers = function(){ //$window.on('scroll', checkPos); $window.on('resize', reset); //Do not remove - Varun //$('#clear-search').on('tap click', clearSearch); $('.mobile-nav-toggle').on('click', function(){ $('.mobile-search-toggle').trigger('slideUp'); }); $('.mobile-search-toggle-close').on('click', clearSearch); //added by varun $('.mobile-search-toggle').on('tap click', function(){ $('.mobile-nav-toggle').trigger('dClose'); }); }; return { init: init, isMobile:isMobile, viewport:viewport, debounce:debounce }; }();/* Modified by Pavan Kamath Do not merge Modified By AA to add accessibility for the page */ Tabs = (function(){ var $toggles; var init = function(){ if($('[data-toggle="tab"]').length){ addHandlers(); $toggles = $('[data-toggle="tab"]'); checkState(); initCurrentURL(); } } var initCurrentURL = function(){ productSeries = $('#productSeries').val(); modelDetails = $('#modelDetails').val(); productNameOid = $('#productSeriesId').val(); // UAT defect fix: undefined is appending in url after clicking on homepage tabs var identifier = $('#pageIdentifier').val(); if( identifier == "Product Details Page"){ currentURL = "/"+getCCLC('cc')+"-"+getCCLC('lc') +"/product/"+productSeries+"/"+productNameOid; if(modelDetails!=""){ currentURL = currentURL + "/model/" + modelDetails; }

    } if(identifier == "caseCreation"){ currentURL = window.location.href; } } var addHandlers = function(){ $('[data-toggle="tab"]').on('tap click', pushState); $('[data-toggle="tab"]').on('showTab', showTab); $('[data-toggle="tab"]').on('hideTab', hideTab); window.setTimeout(function () { window.addEventListener("popstate", function (e) { checkState(); }, false); }, 1); } var pushState = function(){ var activelink = $(this).attr("id"); if($("#pageIdentifier").val() == "caseCreation"){ link = currentURL; } else{ link = currentURL + '/' + activelink; }

    }

    //Remove query parametes as they will never come again if( location.href.indexOf('?')>0){ var queryparams = location.href.split('?'); link = link + '?' +queryparams[1]; } history.pushState(null, null, link); checkState(); //console.log('setCanonicalUrl called from tabs.js.....'); setCanonicalUrl();

    var checkState = function(){ var $toggle = getActiveTabFromURL(); if($toggle.parent().hasClass('active')) return; $('.tab-content.col-lg16>div.active').removeClass('active').addClass('fade'); $toggle.trigger('showTab'); $toggles.not($toggle).trigger('hideTab'); } var hideTab = function(){ var $toggle = $(this); if(!$toggle.parent().hasClass('active')) return; $toggle.parent().removeClass('active'); $toggle.parent().attr({"tabindex" : "-1"}); var $tabContent = $($toggle.attr('href')); $tabContent.removeClass('active'); $tabContent.attr({"tabindex" : "-1"}); $tabContent.attr('aria-hidden', 'true');

    } var showTab = function(){ var $toggle = $(this); $(".tab").removeClass("active"); $toggle.parent().addClass('active'); $toggle.parent().attr({"tabindex" : "0"}); var activelink = $(this).attr("id"); // if(activelink == "drivers"){ // if(typeof currentURL == "undefined" || currentURL == null || currentURL == ""){ // initCurrentURL(); // } // link = currentURL + '/'; // //Remove query parametes as they will never come again // if( location.href.indexOf('?')>0){ // var queryparams = location.href.split('?'); // link = link + '?' +queryparams[1]; // } // history.replaceState(null, null, link); // setCanonicalUrl(); // } var $tabContent = $($toggle.attr('href')); $tabContent.addClass('active'); $tabContent.attr({"tabindex" : "0"}); $tabContent.attr('aria-hidden', 'false'); } var getActiveTabFromURL = function(){ var tabString = "solutions+drivers+troubleshooting+how-to+productinfo+manuals+videos+more-options"; var removeHash = location.href.split("#"); var urllocation = removeHash[0].split("/"); //support for query Params urllocation = urllocation[urllocation.length-1].split("?"); var identifyActiveTab = ""; currentTab = ''; if(tabString.indexOf(urllocation[0])>0){ currentTab = $("#"+urllocation[0]); if(!currentTab.is(':visible')){ currentTab = $('[data-toggle=tab]:visible').first(); currentTab.attr({"tabindex" : "0"}); } } else{

    }

    currentTab = $('[data-toggle=tab]:visible').first(); currentTab.attr({"tabindex" : "0"});

    /*if(urllocation.indexOf('?')>0){ var urlSplit = identifyActiveTab.split('?'); currentTab = $("#"+urlSplit[0]); //currentTab = urllocation[urllocation.length - 1]; if(tabString.indexof(currentTab)>0){ currentTab = $("#"+urllocation[urllocation.length 1]); } } else{ }*/

    }

    currentTab =

    $("#findSolutions");

    return currentTab;

    return { init: init } }()); /*$(document).ready(function(){ handleAccessibility(); function handleAccessibility(){ var indexValue = $(".nav.nav-tabs.hp-nav-tabs li").filter(".active").index(); $(".hp-nav-tabs a[data-toggle='tab']").each(function(){ if(typeof ($(this).attr("tabindex")) === 'undefined' && ($(".hpnav-tabs li").index($(this).parent())
    }

    });

    $(".hp-nav-tabs a[data-toggle='tab']").on("keydown keypress keyup",function(e){ var keycode = e.keycode || e.which; if(keycode == 13){ handleAccessibility(); } }); /* $(".hp-nav-tabs a[data-toggle='tab']").on("keydown keypress keyup",function(e){ var keyCode = e.keyCode || e.which;

    == "none"){

    if (keyCode == 9) { var nextElement = $(".hp-nav-tabs li.active").next(); while($(nextElement).find("a[data-toggle='tab']").css("display") nextElement = $(nextElement).next(); } $(nextElement).find("a[data-toggle='tab']").attr("tabindex","0");

    });

    }

    }); */ //Do not remove the comment //Pratisha /* $("body").on('keydown keypress keyup', ".nav.nav-tabs.hp-nav-tabs .active", function(e) { var keyCode = e.keyCode || e.which; if (keyCode == 9) { if($(".tab-pane.hp-row.fade.active").length > 0){ /*e.preventDefault(); // call custom function here $(".tab-pane.hp-row.fade.active").attr({"tabindex":"0","aria-expanded":true}); } else{ return false; } } });*/Guided = (function(){ var step = 1; var step11state = 1; var timeout; var init = function(){ if($('#guided').length){

    };

    addHandlers(); } stepsLabel();

    var addHandlers = function(){ $('#step-1 .guided-action').on('click', showNext); $('#step-2 .guided-action').on('click', showStep3); $('#step-3 .product-selection a').on('click', showLoading);

    $('.steptrigger').on('click', triggerState); $('#step-3 .re-scan').on('click', resetStep3); $('#step-5 .download-list .button').on('click', showNext); $('#step-5 input').on('change', handleUncheck); $('#step-7 .guided-action').on('click', showProgressBar); $('#step-9 .guided-action').on('click', showLoading); }; var triggerState = function(e){ e.preventDefault(); var $el = $('.step'+ step + 'rotation:visible'); $el.addClass('hidden'); if ($el.next('.step'+ step +'rotation')[0]){ $el.next().removeClass('hidden'); } else { $('.step'+ step +'rotation').first().removeClass('hidden'); } if (step === 11){ step6state++; changeTitle1(); if (step6state === 3){ step6state = 1; } };

    }

    var stepsLabel = function(){ var $container = $('div#guided #steps-bar'); var $list = $('div#guided #steps-bar li'); switch (step){ case 1: case 2: case 3: $list.first().removeClass('next'); break; case 4: case 5: case 7: case 8: case 9: case 10: $list.first().addClass('done'); $list.eq(1).removeClass('next'); break; case 6: $list.eq(1).addClass('done'); $list.eq(2).removeClass('next'); break; } }; var showNext = function(e){ $('#step-' + step).addClass('hidden'); step++; $('#step-' + step).removeClass('hidden'); stepsLabel();

    };

    if (step == 6) { changeTitle1(); }

    var changeTitle1 = function(){ $('#swd-title').text('Thank you for using the HP guided experience for your software and drivers'); $('#swd-title-text').remove(); }; var handleUncheck = function(e){ var self = this; if (!this.checked && this.value == 1) { $('#driver-download-warning').modal('toggle'); $('.cancel').unbind().on('click', function(){ $(self).click(); }); } if (!$('.download-list .list-body input').is(':checked')) { $('.download-list .button').addClass('button-disabled').unbind(); } else { $('.download-list .button').removeClass('buttondisabled').on('click',showProgressBar); } }; var resetStep3 = function(e) { e.preventDefault(); step = 2; showStep3(); }; var showStep3 = function(){ var $items = $('#step-3 .selection-group .product-selection'); var finishLoading = 6000; $('#step-3 .progress-bar-component').show(); $('#found-count').html('(0)'); $('#network-count').html('(0)'); $('#step-3 .header1').removeClass('hidden'); $('#step-3 .header2').addClass('hidden'); window.runProgressBar(); if (timeout) { clearTimeout(timeout); } $items.hide(); showNext(); $items.each(function(index, el){ setTimeout(function(){ $('#found-selections').removeClass('hidden'); }, finishLoading / 4); setTimeout(function(){ $('#network-selections').removeClass('hidden'); }, finishLoading / 2); setTimeout(function(){ $(el).show(); var $network = $('#network-selections .productselection:visible');

    selection:visible');

    var $found = $('#found-selections .product-

    $('#found-count').html('(' + $found.length+')'); $('#network-count').html('(' + $network.length+')'); },finishLoading/4 * (index + 1));

    };

    }); timeout = setTimeout(function(){ $('#step-3 .progress-bar-component').hide(); $('#step-3 .header1').first().addClass('hidden'); $('#step-3 .header2').first().removeClass('hidden'); $('#identify-text1').addClass('hidden'); $('#identify-text2').removeClass('hidden'); },finishLoading + 500);

    var showLoading = function(e){ e.preventDefault(); showNext(); setTimeout(showNext,4000); }; var showProgressBar = function(){ window.runProgressBar(); setTimeout(showNext,6000); showNext(); }; return { init: init }; }());OsSelector = (function(){ var init = function(){ if ($('#os-selector').length) { /* added as a part of new build during merge. Needs to be validated $('#os-selector').hide(); $('#os-heading2').hide();*/ addHandlers(); } }; var addHandlers = function(){ $('#os-update').on('click', updateOs); $('#os-heading1').on('click', wordHandler); $('#os-heading2').on('click', xHandler); /* added as a part of new build. Pratisha to validate $('#os-word-trigger').on('click', wordHandler); $('#os-x-trigger').on('click', xHandler);*/ $('.fancy-select .trigger').on('click', dropdownHandler); }; var dropdownHandler = function(e){ $('.fancy-select .trigger + .options').not($(this)).not($ (this).next()).removeClass('open'); }; var xHandler = function(){ $("#os-heading1").css("pointer-events","none"); $('#os-heading1').show(); $('#os-heading2').hide();

    };

    $('#os-x-trigger').show();

    var wordHandler = function(){ $("#os-heading2").css("pointer-events","none"); $('#os-heading2').show(); $('#os-heading1').hide(); $('#os-selector').show(); }; var updateOs = function(e){ e.preventDefault(); var resultArray = $('#os-selector').serializeArray(); $.each(resultArray, function(index, value){ console.log(value); var platform = 'os-' + value.name; var text = value.value; $('#'+platform).html(text); }); $('#os-selector').removeClass('in').slideUp(); $('.os-selector-trigger').removeClass('toggled'); $('#os-heading2').hide(); $('#os-heading1').show(); }; return { init : init }; })();DownloadTable = (function(){ var init = function(){ if ($('.download-table').length){ addHandlers(); } }; var addHandlers = function() { $('#download-table .swd-dropdown').on('click', swdDropdown); $('a.accordionTitle').on('click', featuredDriverShow); /*VV*/ }; /* featuredDriver and swdDropdown function moved to swdAccordion.js in the portlet VV*/ /*AA - function ends here*/ var sort = function(ev){ var reverse; var $this = $(this); var sortCat = $this.data('sort-trigger'); var $toggles = $('#sortable-table .panel'); ev.preventDefault(); $('[data-sorttrigger]').removeClass('active').parent().removeClass('active'); $('[data-sort-trigger]').not($(this)).removeClass('reverse'); $this.addClass('active').parent().addClass('active'); $this.hasClass('reverse') ? reverse = true : reverse = false $toggles.each(function(index){ var sortEls = $(this).find('[data-sort="'+sortCat+'"]'); sortEls.sort(function(a,b){ var result; if (sortCat === 'date') {

    a = new Date($(a).html()); b = new Date($(b).html()); } else { a = $(a).html(); b = $(b).html(); } if (a > b) { result = 1; } else if (a < b) { result = -1; } else { result = 0; } return reverse ? result : -result;

    }); $sortEls = $(sortEls).map(function(index){ return $(this).parents('.sortable-row')[0]; }); console.log($(this).find('.table > tbody')); console.log($sortEls); $(this).find('.table > tbody').html($sortEls); }); $this.toggleClass('reverse'); $('.swd-dropdown').on('click', swdDropdown);

    }; var mobileSort = function(ev){ var $this = $(this); var sortCat = $this.data('mobile-trigger'); var reverse = $this.data('reverse'); var $toggles = $('#sortable-table .panel'); }; return { init : init }; }());$(document).ready(function(){ var set_tab = function(tab_container_id, tab_id){ $('#' + tab_container_id + ' ul li').removeClass('active'); // Now add class "active" to the selected/clicked tab $('#' + tab_container_id + ' a[rel="'+tab_id+'"]').parent().addClass("active"); $('#' + tab_container_id + '-content .tab-pane').removeClass("active").hide();

    }

    // Show the selected tab content $('#' + tab_container_id + '-content #' + tab_id).addClass("active").fadeIn();

    // Function that gets the hash from URL var get_hash = function(){ if (window.location.hash) { // Get the hash from URL var url = window.location.hash; // Remove the # var current_hash = url.substring(1);

    // Split the IDs with comma var current_hashes = current_hash.split(","); $.each(current_hashes, function(i, v){ set_tab($('a[rel="'+v+'"]').parent().parent().parent().attr('id'), v); }); }

    }

    // Called when page is first loaded or refreshed get_hash(); // Looks for changes in the URL hash $(window).bind('hashchange', function() { get_hash(); }); // Called when we click on the tab itself $('.tab-box ul li').click(function() { var tab_id = $(this).children('a').attr('rel'); // Update the hash in the url window.location.hash = tab_id; // Do nothing when tab is clicked return false; }); });/* ======================================================================== * Bootstrap: modal.js v3.0.2 * http://getbootstrap.com/javascript/#modals * ======================================================================== * Copyright 2013 Twitter, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ======================================================================== */ +function ($) { "use strict"; // MODAL CLASS DEFINITION // ====================== var Modal = function (element, options) { this.options = options this.$element = $(element) this.$backdrop = this.isShown = null if (this.options.remote) this.$element.load(this.options.remote)

    } Modal.DEFAULTS = { backdrop: true , keyboard: true , show: true } Modal.prototype.toggle = function (_relatedTarget) { return this[!this.isShown ? 'show' : 'hide'](_relatedTarget) } Modal.prototype.show = function (_relatedTarget) { var that = this var e = $.Event('show.bs.modal', { relatedTarget: _relatedTarget }) this.$element.trigger(e) if (this.isShown || e.isDefaultPrevented()) return this.isShown = true this.escape() this.$element.on('click.dismiss.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this)) this.backdrop(function () { var transition = $.support.transition && that.$element.hasClass('fade') if (!that.$element.parent().length) { that.$element.appendTo(document.body) // don't move modals dom position } that.$element.show() if (transition) { that.$element[0].offsetWidth // force reflow } that.$element .addClass('in') .attr('aria-hidden', false) that.enforceFocus() var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget }) transition ? that.$element.find('.modal-dialog') // wait for modal to slide in .one($.support.transition.end, function () { that.$element.focus().trigger(e) }) .emulateTransitionEnd(300) : that.$element.focus().trigger(e)

    }) }

    Modal.prototype.hide = function (e) {

    if (e) e.preventDefault() e = $.Event('hide.bs.modal') this.$element.trigger(e) if (!this.isShown || e.isDefaultPrevented()) return this.isShown = false this.escape() $(document).off('focusin.bs.modal') this.$element .removeClass('in') .attr('aria-hidden', true) .off('click.dismiss.modal') $.support.transition && this.$element.hasClass('fade') ? this.$element .one($.support.transition.end, $.proxy(this.hideModal, this)) .emulateTransitionEnd(300) : this.hideModal() } Modal.prototype.enforceFocus = function () { $(document) .off('focusin.bs.modal') // guard against infinite focus loop .on('focusin.bs.modal', $.proxy(function (e) { if (this.$element[0] !== e.target && !this.$element.has(e.target).length) { this.$element.focus() } }, this)) } Modal.prototype.escape = function () { if (this.isShown && this.options.keyboard) { this.$element.on('keyup.dismiss.bs.modal', $.proxy(function (e) { e.which == 27 && this.hide() }, this)) } else if (!this.isShown) { this.$element.off('keyup.dismiss.bs.modal') } } Modal.prototype.hideModal = function () { var that = this this.$element.hide() this.backdrop(function () { that.removeBackdrop() that.$element.trigger('hidden.bs.modal') }) } Modal.prototype.removeBackdrop = function () { this.$backdrop && this.$backdrop.remove() this.$backdrop = null }

    Modal.prototype.backdrop = function (callback) { this.options.backdrop = 'static' var that = this var animate = this.$element.hasClass('fade') ? 'fade' : '' if (this.isShown && this.options.backdrop) { var doAnimate = $.support.transition && animate this.$backdrop = $('