- {promoMarkup}{notifMarkup}
‘,panelEmptyTemplate=’
{emptyPanelMsg}
‘,panelErrorTemplate=’
{errorMsg}
‘,panelParentTemplate=”,notifOnboardPromoTemplate=’
{notifOnboardMsg}
‘,EXPANDED_PANEL=”expanded_panel”,ERROR_PANEL=”error_panel”,NotificationView=function(){function e(n,t){classCallCheck(this,e);var i=this;i._config=n,i._panelNode=null,i._store=t}return createClass(e,[{key:”_generatePanelMarkup”,value:function(e,n){var t=this._config,i=void 0,o=void 0;”undefined”!=typeof window&&(i=window.Notification&&”default”===window.Notification.permission,o=t.promos.bypassEligibleClassCheck||hasClass(document.body,t.promos.eligibleBodyClass));var s=t.promos.enableNotifOnboard&&i&&o?notifOnboardPromoTemplate:””;if(s){var r=t.promos.showYahooLogo?””:”yns-no-logo”;s=s.replace(“{notifOnboardBtnLabel}”,t.promos.notifOnboardBtnLabel).replace(“{notifOnboardMsg}”,t.promos.notifOnboardMsg).replace(“{subscriptionTopic}”,t.promos.subscriptionTopic).replace(“{noLogoClass}”,r).replace(“{promoLogo}”,t.promos.promoLogo)}var a=n.newCount>t.panel.maxCount?n.newCount:””,c=t.panel.notificationCenterPath,l=c?””:constants.panelHideElement,u=t.panel.headerMsg?””:” “+constants.panelHideElement,d=c?constants.panelPaddingBtm:””,p=void 0;n.count?p=n.markup:p=panelEmptyTemplate.replace(“{emptyPanelMsg}”,t.panel.emptyPanelMsg);return e=e.replace(“{notifMarkup}”,p).replace(“{promoMarkup}”,s).replace(“{hideClass}”,l).replace(“{notifCenterLink}”,c).replace(“{paddingClass}”,d).replace(“{headerMsg}”,t.panel.headerMsg).replace(“{hideHeaderClass}”,u).replace(/{notificationCenterNavMsg}/g,t.panel.notificationCenterNavMsg).replace(/{newCount}/g,a)}},{key:”render”,value:function(e,n){var t=this;if(t._panelNode){var i=void 0,o=t._panelNode,s=void 0,r=void 0;switch(e){case EXPANDED_PANEL:i=panelTemplate,r=t._store.getNotifications(),s=t._generatePanelMarkup(i,r),o.innerHTML=s;break;case ERROR_PANEL:s=(i=panelErrorTemplate).replace(“{errorMsg}”,t._config.panel.errorMsg),o.innerHTML=s}n&&n()}else n&&n(new Error(“No panel parent”))}},{key:”createPanelParentNode”,value:function(e){e&&(e.innerHTML=panelParentTemplate,this._panelNode=document.getElementById(constants.panelNodeId))}},{key:”updateBadgeNode”,value:function(e){if(e){var n=this._store.getNotifications().newCount,t=this._config.badge.maxCount;if(n){var i=n>t?t+”+”:n;e.innerHTML=i}else e.innerHTML=””}}},{key:”addStyles”,value:function(e){if(e&&”undefined”!=typeof window){var n=document.getElementById(this._config.panel.styleTagId);n||((n=document.createElement(“style”)).type=”text/css”,n.id=this._config.panel.styleTagId,n.innerText=e,document.head.appendChild(n))}}}]),e}(),EXPANDED_PANEL$1=”expanded_panel”,ERROR_PANEL$1=”error_panel”,PanelController=function(){function e(n,t,i){classCallCheck(this,e);var o=this;o._store=t,o._view=i,o._config=n;var s=o._config.panel;o._panelParentNode=document.querySelector(s.parentSelector),o._badgeNode=o._config.badge.selector&&document.querySelector(o._config.badge.selector),o._indicatorNode=s.indicatorSelector&&document.querySelector(s.indicatorSelector)}return createClass(e,[{key:”createPanelParentNode”,value:function(){this._view.createPanelParentNode(this._panelParentNode),this._notifPanelNode=document.getElementById(constants.panelNodeId)}},{key:”refreshPanelNode”,value:function(e,n){var t=this;addClass(t._notifPanelNode,constants.panelLoading),t._store.fetchNotifications(e,(function(e,i){var o=window.wafer&&window.wafer.base;o&&o.destroy(t._notifPanelNode),e?t._notifPanelNode.innerHTML||(t._view.render(ERROR_PANEL$1),addClass(t._notifPanelNode,constants.panelLoading)):(t._view.render(EXPANDED_PANEL$1),t._view.updateBadgeNode(t._badgeNode),t._showBadge(),t._showIndicator(),t._view.addStyles(i.css)),removeClass(t._notifPanelNode,constants.panelLoading),o&&o.sync(t._notifPanelNode.parentNode),n&&n(e,i)}))}},{key:”resetBadge”,value:function(){var e=this;e._store.resetNewCount(),e._view.updateBadgeNode(e._badgeNode),addClass(e._badgeNode,e._config.badge.hideClass)}},{key:”_showIndicator”,value:function(){this._indicatorNode&&(this._store.getNotifications().newCount?addClass(this._indicatorNode,this._config.panel.indicatorClass):removeClass(this._indicatorNode,this._config.panel.indicatorClass))}},{key:”_showBadge”,value:function(){var e=this;e._store.getNotifications().newCount?removeClass(e._badgeNode,e._config.badge.hideClass):addClass(e._badgeNode,e._config.badge.hideClass)}}]),e}(),config={promos:{eligibleBodyClass:”display-push-promos”,enableNotifOnboard:!0,bypassEligibleClassCheck:!1,notifOnboardBtnLabel:”Notify Me”,notifOnboardMsg:”Get alerts for breaking news and top stories”,promoLogo:”https://s.yimg.com/cv/apiv2/ae/news/circle_bell.png”,showYahooLogo:!0,subscriptionTopic:”gondor_homerun_news”},badge:{hideClass:””,maxCount:5,selector:””},panel:{emptyPanelMsg:”You have no new notifications.”,errorMsg:””,headerMsg:”Notifications”,imageTag:”img:40×40|2|80″,indicatorClass:”yns-indicator”,indicatorSelector:null,maxCount:6,notificationCenterNavMsg:”View all {newCount} notifications”,notificationCenterPath:””,notificationTypes:””,parentSelector:null,styleTagId:”notificationStyles”,theme:”default”},service:{attemptCount:2,attemptDelay:1,url:null,resetUrl:null,isRMP:!1,responseType:”json”,timeout:1500}},Main=function(){function e(n){classCallCheck(this,e);var t=this;t.config=t._parseConfig(n),t._validateRequiredConfigs()&&(t._request=new NotificationRequest(t.config),t._store=new NotificationStore(t.config,t._request),t._view=new NotificationView(t.config,t._store),t._panelController=new PanelController(t.config,t._store,t._view),t._panelController.createPanelParentNode(),t._assignHelperMethods())}return createClass(e,[{key:”_parseConfig”,value:function(e){var n={};for(var t in objectAssign(n,config),n)if(n.hasOwnProperty(t)){var i=n[t],o=e[t];”object”===(void 0===i?”undefined”:_typeof(i))?objectAssign(i,o):n[t]=e[t]}return n}},{key:”_validateRequiredConfigs”,value:function(){var e=this.config;return!(!e.panel.parentSelector||!e.service.url)}},{key:”_assignHelperMethods”,value:function(){var e=this;e.helpers={refreshPanelNode:e._panelController.refreshPanelNode.bind(e._panelController),resetBadge:e._panelController.resetBadge.bind(e._panelController),resetIndicator:function(){removeClass(e._panelController._indicatorNode,e.config.panel.indicatorClass)}}}}]),e}(),notificationClient_module_min=Main,notificationClient={NotificationClient:notificationClient_module_min},CONSUMPTION_STORAGE_KEY=”lnct”,NotifClient=function(){function e(){var e,n;this.personalized=!1,this.ybarElem=document.getElementById(“ybar”),this.partnerClasses=null===(n=null===(e=this.ybarElem)||void 0===e?void 0:e.className)||void 0===n?void 0:n.match(/ybar-variant-([a-z]*)/),this.client=new notificationClient.NotificationClient(this.getConfig())}return e.prototype.refreshPanel=function(){var e,n,t,i=this,o={lastUpdate:this.getTimeStamp()||this.setTimeStamp(),loadInHpViewer:!0,includePersonalized:this.personalized},s=(null===(e=window.YAHOO)||void 0===e?void 0:e.context)||(null===(n=window.Af)||void 0===n?void 0:n.context)||{};return s.region&&s.lang&&(o.lang=s.lang,o.region=s.region),(null===(t=this.partnerClasses)||void 0===t?void 0:t.length)&&(o.partner=this.partnerClasses[1]),new Promise((function(e,n){i.client.helpers.refreshPanelNode({matrixParams:o},(function(t,i){t&&(logError(“Notification refresh error:”,t),n(t)),e(i)}))}))},e.prototype.resetBadge=function(){this.client.helpers.resetBadge(),this.setTimeStamp()},e.prototype.getConfig=function(){var e,n,t={promos:{eligibleBodyClass:”display-push-promos”,enableNotifOnboard:!0},badge:{selector:”#notif-badge”,hideClass:”ybar-notification-hidden”},panel:{emptyPanelMsg:”You have no new notifications.”,errorMsg:”Please check back later.”,headerMsg:”Notifications”,maxCount:5,parentSelector:”#ybarNotificationBody”,notificationTypes:”breakingNews”},service:{url:”/tdv2_fp/api/resource/NotificationHistory.getHistory”,isRMP:!1}},i=document.getElementById(“notification-container”),o=null===(e=null==i?void 0:i.dataset)||void 0===e?void 0:e.config,s={};if(o){“att”===(null===(n=this.partnerClasses)||void 0===n?void 0:n[1])&&(t.promos.showYahooLogo=!1);try{var r=JSON.parse(o);s=__assign({},r),this.personalized=1===r.personalize}catch(e){logError(“Notifications config parsing error”,e)}i&&delete i.dataset.config}return this.mergeConfigs(t,s)},e.prototype.mergeConfigs=function(e,n){var t=__assign({},e);for(var i in e)t[i]=__assign(__assign({},e[i]),n[i]);return t},e.prototype.getTimeStamp=function(){var e;return null===(e=window.localStorage)||void 0===e?void 0:e.getItem(CONSUMPTION_STORAGE_KEY)},e.prototype.setTimeStamp=function(){var e,n=””+Math.floor((new Date).getTime()/1e3);return null===(e=window.localStorage)||void 0===e||e.setItem(CONSUMPTION_STORAGE_KEY,n),n},e}(),notifClient=new NotifClient,getNotifClient=function(){return notifClient},reInit=function(){notifClient=new NotifClient},ybarRapid,ybarRapidInterval,ybarRapidErrMsg=””,beaconQueue=[],noop=function(){},logRapidError=function(){window.removeEventListener(“beforeunload”,logRapidError),””!==ybarRapidErrMsg&&logError(“Rapid not found on page”,new Error(ybarRapidErrMsg))},findRapidWithSpaceid=function(e){var n=void 0;if(e&&e.length>0)for(var t=0;t
/*!**********************!*
!*** ./src/index.js ***!
**********************/function(__unused_webpack_module,__unused_webpack_exports,__webpack_require__){eval(“var I18n = __webpack_require__(/*! ./lib/I18n */ “./src/lib/I18n.js”);nn(function (win, doc) {n “use strict”;nn var defaultConfig = {n uiLang: ‘en-US’,n speechLang: ‘en-US’,n voiceButton: ‘#voice-btn’,n searchBox: {n form: ‘#sf’,n input: ‘#yschsp’,n params: {n fr: ”,n fr2: ”n }n },n enable_voice_trending: false,n trending: {n market: “en-us”n },n ui: {n speechOverlay: {n disableBlur: falsen }n },n browsers: {n edge: falsen }n };nn function VoiceSearch(config) {n var self = this;n self.config = Object.assign(defaultConfig, config || {});n self.i18n = new VoiceSearch.I18n({n lang: self.config.uiLangn });n self.renderPermissionGuide(self);n self.renderSpeechPanel(self);n self.speechResult = ”;n self.noSpeech = true;n self.isRecognitionStart = false;n self.recognition = null;n self.voiceButton = doc.querySelector(self.config.voiceButton);n self.searchBoxForm = doc.querySelector(self.config.searchBox.form);n self.searchBoxQuery = doc.querySelector(self.config.searchBox.input);n self.speechPanel = doc.querySelector(‘#spch’);n self.speechButtonContainer = doc.querySelector(‘#spchbc’);n self.speechButton = doc.querySelector(‘#spchbc-btn’);n self.speechText = doc.querySelector(‘#spcht’);n self.speechOverlay = doc.getElementById(‘spch-overlay’);n self.retryLink = doc.querySelector(‘#spcht-retry’);n self.trending = doc.getElementById(‘spch-trending’);n self.trendingTerms = doc.getElementById(‘trending-terms’);n self.termSpans = doc.getElementsByClassName(“trending-term”);n self.closeButton = doc.querySelector(‘#spchx’);n self.startAudio = new Audio(‘https://s.yimg.com/pv/static/misc/voice-start-202105050733.wav’);n self.resultAudio = new Audio(‘https://s.yimg.com/pv/static/misc/voice-result-202105050733.wav’);n self.errorAudio = new Audio(‘https://s.yimg.com/pv/static/misc/voice-error-202105050733.wav’);n self.closeAudio = new Audio(‘https://s.yimg.com/pv/static/misc/voice-close-202105050733.wav’);n self.permissionGuide = doc.querySelector(‘#spchp’);n self.permissionGuideClose = doc.querySelector(‘#spchpx’);n self.permissionGuideTimer = null;nn self.onEscKeyDown = function (e) {n if (e.code !== ‘Escape’) {n return;n }nn self.recognition.stop();n self.sendBeacon(‘keybrd’, ‘voicesearch_cancel_esc’); // The clean up should put inside closePanel() instead of here,n // or func won’t be cleaned up if user close panel with btn or overlaynn self.closePanel(self);n };nn if (self.isBrowserSupported()) {n var SpeechRecognition = win.SpeechRecognition || win.webkitSpeechRecognition;n var SpeechGrammarList = win.SpeechGrammarList || win.webkitSpeechGrammarList;n var speechGrammar = ‘#JSGF V1.0;’;n self.recognition = new SpeechRecognition();n var speechRecognitionList = new SpeechGrammarList();nn if (speechRecognitionList.addFromString) {n speechRecognitionList.addFromString(speechGrammar, 1);n }nn self.recognition.grammars = speechRecognitionList;n self.recognition.continuous = false;n self.recognition.lang = self.config.speechLang;n self.recognition.interimResults = false;n self.recognition.maxAlternatives = 1;n /* Listeners */nn if (self.voiceButton) {n self.voiceButton.onclick = function () {n self.recognition.start();nn if (self.permissionGuideTimer) {n win.clearTimeout(self.permissionGuideTimer);n }nn self.permissionGuideTimer = win.setTimeout(function () {n if (!self.isRecognitionStart) {n self.showPermissionGuide(self);n }n }, 300); // Also close when pressing escnn doc.addEventListener(‘keydown’, self.onEscKeyDown);n self.sendBeacon(‘clk’, ‘voicesearch’);n };n }nn if (self.speechButton) {n self.speechButton.onclick = function () {n if (!self.isRecognitionStart) {n self.recognition.start();n self.sendBeacon(‘clk’, ‘voicesearch_panel_mic_restart’);n } else {n self.recognition.stop();n self.sendBeacon(‘clk’, ‘voicesearch_panel_mic_close’);n self.closePanel(self);n }n };n }nn if (self.retryLink) {n self.retryLink.onclick = function () {n if (!self.isRecognitionStart) {n self.recognition.start();n self.sendBeacon(‘clk’, ‘voicesearch_panel_retry’);n }n };n }nn if (self.speechOverlay) {n self.speechOverlay.onclick = function () {n self.recognition.stop();n self.sendBeacon(‘clk’, ‘voicesearch_cancel_outside’);n self.closePanel(self);n };n }nn if (self.closeButton) {n self.closeButton.onclick = functionn /*event*/n () {n self.recognition.stop();n self.sendBeacon(‘clk’, ‘voicesearch_cancel’);n self.closePanel(self);n };n }nn if (self.permissionGuideClose) {n self.permissionGuideClose.onclick = functionn /*event*/n () {n self.recognition.stop();n self.sendBeacon(‘clk’, ‘voicesearch_permission_close’);n self.closeAudio.play();n self.hidePermissionGuide(self);n };n }n /* Recognition Events */nnn self.recognition.onresult = function (event) {n // The SpeechRecognitionEvent results property returns a SpeechRecognitionResultList objectn // The SpeechRecognitionResultList object contains SpeechRecognitionResult objects.n // It has a getter so it can be accessed like an arrayn // The first [0] returns the SpeechRecognitionResult at the last position.n // Each SpeechRecognitionResult object contains SpeechRecognitionAlternative objects that contain individual results.n // These also have getters so they can be accessed like arrays.n // The second [0] returns the SpeechRecognitionAlternative at position 0.n // We then return the transcript property of the SpeechRecognitionAlternative objectn // console.log(‘Confidence: ‘ + event.results[0][0].confidence);n self.speechResult = event.results[0][0].transcript;n /* Punctuation Handling: Check last character and strip it if necessary */nn self.handlePunctuation(self);nn if (self.speechText) {n self.speechText.innerText = self.speechResult;n }nn if (self.searchBoxQuery) {n self.searchBoxQuery.value = self.speechResult;n }nn self.resultAudio.play();n win.setTimeout(function () {n if (self.speechPanel) {n self.speechPanel.classList.remove(“s2tb”);n self.speechPanel.classList.add(“s2tb-h”);n }nn self.hideRetryLink(self);nn if (self.searchBoxForm) {n var inputFr = self.searchBoxForm.querySelector(‘[name=fr]’);n var inputFr2 = self.searchBoxForm.querySelector(‘[name=fr2]’);nn if (inputFr && self.config.searchBox && self.config.searchBox.params && self.config.searchBox.params.fr) {n inputFr.value = config.searchBox.params.fr;n inputFr.disabled = false; // for homepage casen }nn if (inputFr2 && self.config.searchBox && self.config.searchBox.params && self.config.searchBox.params.fr2) {n inputFr2.value = config.searchBox.params.fr2;n inputFr2.disabled = false; // for homepage casen }nn self.searchBoxForm.submit();n }n }, 1000);n };nn self.recognition.onspeechstart = functionn /*event*/n () {// Fired when speech startsn };nn self.recognition.onspeechend = function () {n // Fired when speech endsn self.recognition.stop();n };nn self.recognition.onerror = functionn /*event*/n () {n // console.log(‘Error occurred in recognition: ‘ + event.error);n if (self.speechText) {n self.speechText.innerText = self.i18n.t(‘search.voice.recognition_error’);n }nn self.hideTrending(self);n self.showRetryLink(self);n self.errorAudio.play();n };nn self.recognition.onaudiostart = functionn /*event*/n () {n // Fired when the user agent has started to capture audio.n if (self.speechButtonContainer) {n self.speechButtonContainer.classList.add(“listening”);n }n };nn self.recognition.onaudioend = functionn /*event*/n () {n // Fired when the user agent has finished capturing audio.n if (self.speechButtonContainer) {n self.speechButtonContainer.classList.remove(“listening”);n }n };nn self.recognition.onsoundstart = functionn /*event*/n () {n // Fired when any sound — recognisable speech or not — has been detected.n self.hideTrending(self);n self.noSpeech = false;nn if (self.speechButtonContainer) {n self.speechButtonContainer.classList.remove(“listening”);n self.speechButtonContainer.classList.add(“speaking”);n }n };nn self.recognition.onsoundend = functionn /*event*/n () {n // Fired when no sound presentn if (self.speechButtonContainer) {n self.speechButtonContainer.classList.remove(“speaking”);n }n };nn self.recognition.onstart = functionn /*event*/n () {n // Fired when the speech recognition service has begun listeningn self.recognitionInit(self);n self.startRecognition(self);n };nn self.recognition.onend = functionn /*event*/n () {n // Fired when the speech recognition service has disconnected.n self.isRecognitionStart = false;nn if (self.noSpeech == false && self.speechResult == ”) {n // No match: Fired when the speech recognition can’t recognise speechn if (self.speechText) {n self.speechText.innerText = self.i18n.t(‘search.voice.recognition_nomatch’);n }nn self.hideTrending(self);n self.showRetryLink(self);n self.errorAudio.play();n }n }; // trigger onReady event when initializednnn if (document && document.dispatchEvent) {n document.dispatchEvent(new Event(‘VOICE_JS_READY’));n }n }n } // static membersnnn VoiceSearch.I18n = I18n; // instance membersnn VoiceSearch.prototype.renderPermissionGuide = function (self) {n var tmpl = “\n
\n “);n var dom = new DOMParser().parseFromString(tmpl, ‘text/html’);n document.body.appendChild(dom.body.children[0]);n };nn VoiceSearch.prototype.renderSpeechPanel = function (self) {n var tmpl = “\n
\n
\n \n \n “.concat(self.i18n.t(‘search.voice.recognition_retry’), “\n
\n
\n
\n
\n
\n “).concat(self.i18n.t(‘search.voice.trending_title’), “\n \n
\n
\n
\n “);n var dom = new DOMParser().parseFromString(tmpl, ‘text/html’);nn if (self && self.config && self.config.ui && self.config.ui.speechOverlay && self.config.ui.speechOverlay.disableBlur) {n dom.body.children[0].classList.add(‘disable-blur-overlay’);n }nn document.body.appendChild(dom.body.children[0]);n };nn VoiceSearch.prototype.isBrowserSupported = function () {n var isSupported = false;n var self = this;n var isChromium = Boolean(window.chrome);n var isIOSChrome = /CriOS/.test(window.navigator.userAgent);n var isEdge = /Edg\//.test(window.navigator.userAgent);n var isLegacyEdge = /Edge\//.test(window.navigator.userAgent);n var isOpera = Boolean(window.opr);n var isBrave = Boolean(window.navigator.brave);n var browsers = [// chromen {n checkEnabled: function checkEnabled() {n return true;n },n checkBrowser: function checkBrowser() {n return isChromium && !isIOSChrome && !isEdge && !isOpera && !isBrave;n },n checkAPI: function checkAPI() {n return win && (‘SpeechRecognition’ in win || ‘webkitSpeechRecognition’ in win) && (‘SpeechGrammarList’ in win || ‘webkitSpeechGrammarList’ in win);n }n }, // edgen {n checkEnabled: function checkEnabled() {n return self && self.config && self.config.browsers && self.config.browsers.edge;n },n checkBrowser: function checkBrowser() {n return isChromium && isEdge && !isLegacyEdge;n },n checkAPI: function checkAPI() {n return win && (‘SpeechRecognition’ in win || ‘webkitSpeechRecognition’ in win) && (‘SpeechGrammarList’ in win || ‘webkitSpeechGrammarList’ in win);n }n }];nn for (var b = 0; b 0) {n var lastChar = self.speechResult.charAt(self.speechResult.length – 1);nn if (lastChar === ‘.’ || lastChar === ‘?’ || lastChar === ‘。’ || lastChar === ‘?’) {n self.speechResult = self.speechResult.slice(0, -1);n }n }n };nn VoiceSearch.prototype.sendBeacon = function (actn, slk) {n var ULT = win.YAHOO.ULT || {},n SB = win.YAHOO.SB || {};nn if (ULT.beacon_click) {n var trackParams = {n _S: SB.config.i13n.spaceid,n _I: SB.config.i13n.pvid,n actn: actn,n sec: ‘search’,n slk: slkn };n win.YAHOO.ULT.beacon_click(trackParams);n }n };nn VoiceSearch.prototype.ajaxReq = function (url, callback) {n var DONE_STATE = XMLHttpRequest.DONE || 4; // for IE-compatibilitynn var xhr = new XMLHttpRequest();n var responseRaw;n var response; // CORS request only for IE8/IE9nn if (doc.documentMode && doc.documentMode n // tags it will allow on a pagenn if (!options.singleton && typeof options.singleton !== ‘boolean’) {n options.singleton = isOldIE();n }nn list = list || [];n var lastIdentifiers = modulesToDom(list, options);n return function update(newList) {n newList = newList || [];nn if (Object.prototype.toString.call(newList) !== ‘[object Array]’) {n return;n }nn for (var i = 0; i >>0;if(“function”!=typeof e)throw new TypeError(e+” is not a function”);for(arguments.length>1&&(t=n),i=0;i>>0;if(“function”!=typeof e)throw new TypeError;for(var i=[],o=arguments.length>=2?arguments[1]:void 0,s=0;s
“+e.config.saAria.closedText+”
“),e.app.notify(M)},clearAssist:function(){this.elems.saTray.innerHTML=””,this.items.splice(0,this.items.length),this.assistItem=null},createItem:function(e){var n,t={idx:e.idx,data:e.origData},i=v.htmlEncode,o=this.config,s=(n=this.app.createElem)(o.saItem,”li”);return(n=(v.set(s,”pos”,e.idx),n(o.saTitle,”span”))).innerHTML=e.t||(o.boldTag&&e.k&&e.q?v.bold(o.boldTag,i(e.k),i(e.q),o.highlight||{}):i(e.k)),s.appendChild(n),t.li=s,t.title=n,this.app.notify(k,[t,e]),t},resetQuery:function(){this.elems.sbInput.value=this.origQuery},reset:function(){var e=this,n=e.config,t=e.elems.sbForm;n.resetQuery&&e.resetQuery(),e.hide(),t.action=e.origAction,e.app.notify(I)},sameQuery:function(){return this.elems.sbInput.value==this.lastInput}},Q),l.initConfig=function(){return{elems:{sbForm:”sb-form”,sbInput:”sb-input”,sbSubmit:”sb-search”,sbClear:”sb-clr”,sbCancel:”sb-cancel”,saTray:”sa-tray”},customEvent:{},sa:{css:”sa”,attrs:{type:”normal”}},saList:{css:”sa-list”,attrs:{role:”listbox”},style:{cursor:”pointer”}},saItem:{css:”sa-item”,attrs:{role:”option”}},saTitle:{css:”sa-item-title”},saAria:{shownText:”new suggestions shown”,closedText:”Suggestion box closed”,css:”sa-aria-live-region”,attrs:{“aria-live”:”polite”},style:{position:”absolute”,left:”-9999px”}},saBE:{host:””,base:”/sugg/gossip/gossip-us-ura/”,params:{l:1,bm:3,output:”sd1″,nresults:10}},shBE:{host:””,base:”/history”},minInput:0,maxInput:255,boldTag:”{s}“,ylc:{_r:2},ylcAssist:{use_case:””},hideOnOutsideClick:!0,noQueryClass:”sa-noQuery”,typingClass:”typing”,noResultClass:”sf-noResult”}},b.hideSbClr=(X.prototype={init:function(e){(this.app=e).on(L,K,this)}},X),b.saFr=(te.prototype={init:function(e){(this.app=e).on(E,Z,this),e.on(N,ee,this),e.on(I,ne,this)}},te),b.ipos=(se.prototype={init:function(e){(this.app=e).on(L,ie,this),e.on(_,oe,this)}},se),b.saTray=(ae.prototype={init:function(e){(this.app=e).on(C,re,this)}},ae),b.saFlvr=(le.prototype={init:function(e){e.on(k,ce,this)}},le),b.saEdit=(de.prototype={init:function(e){e.on(k,ue,this)}},de),b.saAnnot=(he.prototype={init:function(e){e.on(k,pe,this)}},he),b.saImg=(me.prototype={init:function(e){e.on(k,fe,this)}},me),b.saGroup=(ve.prototype={init:function(e){this.app=e,this.idxs={},e.on(k,ge,this),e.on(T,ye,this)}},ve),b.saPCActn=(Ee.prototype={init:function(e){var n=this;n.app=e,n.selectedIndex=-1,e.on(w,be,n),e.on(A,_e,n),e.on(V,we,n),e.on(U,Ce,n)}},Ee),b.tapRmv=(Se.prototype={init:function(e){(this.app=e).on(R,xe,this)}},Se),b.tapClr=(ke.prototype={init:function(e){(this.app=e).on(A,Te,this)}},ke)}();var history=”_yb_t3kan”,lowlight=”_yb_1rfe6″,sa=”_yb_12lbp”,trending=”_yb_giv8h”,Css$4={“bot-search-icon”:”_yb_10w0n”,”bot-search-icon-container”:”_yb_115jc”,”bot-search-item”:”_yb_15mkm”,”bot-search-item-col”:”_yb_uqnvx”,”bot-search-span”:”_yb_1v5pe”,history:history,”list-item-hover”:”_yb_kb76q”,lowlight:lowlight,”no-wrap”:”_yb_1dols”,”related-title”:”_yb_k7j4o”,sa:sa,”sa-annot-rich”:”_yb_1x2xx”,”sa-annot-subtitle”:”_yb_4t9wj”,”sa-annot-title”:”_yb_1fmjg”,”sa-edit”:”_yb_uddgb”,”sa-edit-icon”:”_yb_1x25z”,”sa-edit-text”:”_yb_10am4″,”sa-fd-actn-cont”:”_yb_1t2gt”,”sa-grp-hdr”:”_yb_18ci3″,”sa-grp-hdr-title”:”_yb_15mj1″,”sa-history”:”_yb_dj7ky”,”sa-img”:”_yb_5s8gd”,”sa-img-ctn”:”_yb_12kwl”,”sa-img-icon”:”_yb_1wxvv”,”sa-item”:”_yb_15sr7″,”sa-item-title”:”_yb_p3tel”,”sa-rich-thumb”:”_yb_1bnwv”,”sa-sbx-container”:”_yb_9eom6″,”sa-sugg”:”_yb_1j92j”,”sa-thumb-icon”:”_yb_19vi3″,”sa-tray”:”_yb_13rju”,”sa-tray-list-container”:”_yb_iic2m”,”sa-trending”:”_yb_89r9g”,”sub-assist”:”_yb_1bkbb”,”suggestion-title”:”_yb_jb9n1″,trending:trending,”trending-title”:”_yb_3dsf5″,”yui3-highlight”:”_yb_f2eds”},saConfV1={boldTag:’{s}‘,customEvent:{customBtn:”searchBtnClicked”,customKeyBoard:”enterKeyPressed”,customSelection:”assistSelectionClicked”},elems:{sbForm:”ybar-sf”,sbInput:”ybar-sbq”,sbSubmit:”ybar-search”,sbClear:”ybar-sbq-x”,sbCancel:”ybar-search-back-btn”},hightlight:{exact:!0,pattern:”^”},minInput:1,sa:{css:Css$4[“sa-tray”]},saBE:{base:””,host:””,params:{appid:”yfp-t”}},saItem:{css:””},saList:{css:Css$4[“sa-tray-list-container”]},saTitle:{css:””,style:{display:”block”}},plugins:{saFr:{disable:!0},saTray:{afterNode:”ybar-sbq”,ctn:{css:Css$4[“sa-sbx-container”]},tray:{css:Css$4.sa+” “+Css$4.lowlight}},saPCActn:{css:Css$4[“list-item-hover”]},ylcEncode:{disable:!0},saFlvr:{disable:!0},saEdit:{disable:!0},saAnnot:{disable:!0},saImg:{disable:!0},saPopup:{disable:!0}}},richSAConfV1={saBE:{base:””,host:””,params:{appid:”yfp-t”,”.crumb”:””,f:1}},shBE:{host:”https://search.yahoo.com”,base:”/history”,params:{_bcrumb:””}},minInput:0,plugins:{saFlvr:{m9:Css$4[“sa-trending”],m13:Css$4[“sa-history”],flvr:Css$4[“sa-sugg”]},saEdit:{ctn:{css:Css$4[“sa-edit”]},icon:{css:Css$4[“sa-edit-icon”]},text:{css:Css$4[“sa-edit-text”],text:”Remove”}},saAnnot:{title:{css:Css$4[“sa-annot-title”]},subtitle:{css:Css$4[“sa-annot-subtitle”]},richClass:Css$4[“sa-annot-rich”]},tapRmv:{placeholder:””},saImg:{placeholder:{css:Css$4[“sa-img-icon”]},thumbnail:{css:Css$4[“sa-img”]},ctn:{css:Css$4[“sa-img-ctn”]}},saGroup:{hdr:{css:Css$4[“sa-grp-hdr”]},title:{css:Css$4[“sa-grp-hdr-title”]},grps:{m9:{text:”Trending Now”,css:Css$4.trending},m13:{text:””,css:Css$4.history}}}}},richSAConfV1Smartphone={saBE:{base:””,host:””,params:{appid:”mi5″,”.crumb”:””,f:1}},shBE:{host:”https://search.yahoo.com”,base:”/history”,params:{_bcrumb:””}},saItem:{css:Css$4[“sa-item”]},saTitle:{css:Css$4[“sa-item-title”]},minInput:0,plugins:{saFlvr:{m9:Css$4[“sa-trending”],m13:Css$4[“sa-history”],flvr:Css$4[“sa-sugg”]},saEdit:{ctn:{css:Css$4[“sa-edit”]},icon:{css:Css$4[“sa-edit-icon”]},text:{css:Css$4[“sa-edit-text”]}},saAnnot:{title:{css:Css$4[“sa-annot-title”]},subtitle:{css:Css$4[“sa-annot-subtitle”]},richClass:Css$4[“sa-annot-rich”]},tapRmv:{placeholder:””},saImg:{placeholder:{css:Css$4[“sa-img-icon”],wrap:{css:Css$4[“sa-thumb-icon”]}},thumbnail:{css:Css$4[“sa-img”]},ctn:{css:Css$4[“sa-img-ctn”]},richClass:Css$4[“sa-rich-thumb”],showIconOnImgLoad:!0},saGroup:{hdr:{css:Css$4[“sa-grp-hdr”]},title:{css:Css$4[“sa-grp-hdr-title”]},grps:{m9:{text:”Trending Now”,css:Css$4.trending},m13:{text:””,css:Css$4.history}}}}},bottomSearch=function(e,n,t){var i=document.createElement(“div”);i.className=t[“bot-search-item”];var o=document.createElement(“div”),s=document.createElement(“div”);o.className=t[“bot-search-item-col”],s.className=t[“bot-search-item-col”];var r=document.createElement(“div”);r.className=t[“bot-search-icon-container”];var a=document.createElementNS(“http://www.w3.org/2000/svg”,”svg”),c=document.createElementNS(“http://www.w3.org/2000/svg”,”path”);a.setAttribute(“width”,”20″),a.setAttribute(“height”,”20″),a.setAttribute(“viewBox”,”0 0 24 24″),a.classList.add(t[“bot-search-icon”]),c.setAttribute(“d”,”M3.7634,15.837 L6.1814,15.837 C6.5214,17.45 7.0614,18.891 7.7584,20.045 C6.0094,19.118 4.6024,17.637 3.7634,15.837 L3.7634,15.837 Z M2.9144,12.008 C2.9144,11.351 2.9844,10.711 3.1164,10.094 L5.8884,10.094 C5.8264,10.717 5.7864,11.354 5.7864,12.008 C5.7864,12.663 5.8264,13.299 5.8884,13.922 L3.1164,13.922 C2.9844,13.305 2.9144,12.665 2.9144,12.008 L2.9144,12.008 Z M7.7584,3.971 C7.0614,5.125 6.5214,6.566 6.1814,8.179 L3.7634,8.179 C4.6024,6.379 6.0094,4.898 7.7584,3.971 L7.7584,3.971 Z M11.0504,3.142 L11.0504,8.179 L8.1054,8.179 C8.6604,5.664 9.7414,3.771 11.0504,3.142 L11.0504,3.142 Z M12.9654,3.142 C14.2754,3.771 15.3564,5.664 15.9114,8.179 L12.9654,8.179 L12.9654,3.142 Z M20.2524,8.179 L17.8344,8.179 C17.4954,6.566 16.9544,5.126 16.2574,3.971 C18.0064,4.898 19.4144,6.379 20.2524,8.179 L20.2524,8.179 Z M11.0504,20.875 C9.7414,20.245 8.6594,18.352 8.1054,15.837 L10.1354,15.837 C10.2104,15.161 10.3914,14.519 10.6584,13.922 L7.7984,13.922 C7.7354,13.305 7.7004,12.665 7.7004,12.008 C7.7004,11.351 7.7354,10.711 7.7984,10.094 L11.0504,10.094 L11.0504,13.184 C11.5394,12.388 12.1904,11.702 12.9654,11.183 L12.9654,10.094 L20.8994,10.094 C21.0284,10.697 21.0964,11.323 21.0994,11.964 L21.0994,11.964 L21.0994,12.661 C21.0994,13.19 21.5284,13.618 22.0574,13.618 L22.0584,13.618 C22.5874,13.618 23.0164,13.19 23.0164,12.661 L23.0164,11.965 L23.0144,11.965 C22.9904,5.662 17.6704,0.608 11.2724,1.024 C5.8994,1.373 1.4994,5.676 1.0414,11.04 C0.5134,17.228 5.1074,22.463 11.0504,22.975 C11.1664,22.985 11.3274,22.993 11.4844,22.999 C11.8104,23.012 12.1194,22.85 12.2904,22.572 L12.2924,22.569 C12.5734,22.113 12.3964,21.514 11.9124,21.284 L11.0504,20.875 Z M15.9434,18.874 C14.6054,18.874 13.5214,17.79 13.5214,16.452 C13.5214,15.115 14.6054,14.03 15.9434,14.03 C17.2804,14.03 18.3654,15.115 18.3654,16.452 C18.3654,17.79 17.2804,18.874 15.9434,18.874 M21.6354,20.908 L19.4524,18.725 C19.8774,18.07 20.1264,17.291 20.1264,16.452 C20.1264,14.145 18.2584,12.274 15.9514,12.269 L15.9354,12.269 C13.6284,12.274 11.7604,14.145 11.7604,16.452 C11.7604,18.763 13.6324,20.635 15.9434,20.635 C16.7814,20.635 17.5614,20.386 18.2154,19.961 L20.3984,22.144 C20.7404,22.486 21.2934,22.486 21.6354,22.144 C21.9774,21.803 21.9774,21.249 21.6354,20.908″),a.appendChild(c),r.appendChild(a),o.appendChild(r);var l=document.createElement(“span”),u=document.createElement(“span”);u.className=t[“bot-search-span”];var d=document.createElement(“span”),p=e.split(“{query}”);return l.textContent=p[0]||””,u.textContent=n,d.textContent=p[1]||””,s.appendChild(l),s.appendChild(u),s.appendChild(d),i.appendChild(o),i.appendChild(s),i},_getQueryStringByName=function(e){var n=new RegExp(“[?&]”+e+”=([^]*)”).exec(window.location.search);return n?n[1]:null},_getFrValueByMode=function(e,n,t){void 0===e&&(e=!1),void 0===n&&(n=!1);var i=document.getElementById(“ybar”),o=null==i?void 0:i.querySelector(‘input[name=”fr”]’),s=o?o.value:”yfp-t”,r=_getQueryStringByName(“fr”),a=r||s,c=i&&i.className&&i.className.match(/ybar-variant-([a-z]+)/),l=c?c[1]:””;return-1===[“att”,”frontier”,”rogers”].indexOf(l)&&(e&&(a+=”-m”),n&&(a+=”-s”)),”tn”!==t&&”tg”!==t||(a=r?a+”-tn”:(null==o?void 0:o.dataset.tnvalue)||a),a},_getFr2ValueByMode=function(e,n,t,i,o){void 0===t&&(t=!1);var s=null,r=”smartphone”===n&&!!document.querySelector(“.Reader-open”)||”smartphone”!==n&&!!document.querySelector(“.modal-open”),a=e.querySelector(‘input[name=”fr2″]’);if(a){s=a.value;var c=a.dataset&&a.dataset.savalue,l=a.dataset&&a.dataset.modalsb,u=a.dataset&&a.dataset.modalsa;t?s=r&&u?u:c:r&&l&&(s=l),i&&o&&(s=””.concat(s,”,ct:”).concat(i,”,kt:”).concat(o))}return s},_getTsrcValueByMode=function(e,n){void 0===n&&(n=!1);var t=null,i=e.querySelector(‘input[name=”.tsrc”]’);if(i){t=i.value;var o=i.dataset&&i.dataset.savalue;n&&o&&(t=o)}return t},_setInputValues=function(e,n,t){var i=e.querySelectorAll(n);if(i)for(var o=0;o
“+r.itemList.length+” “+this.config.text.ariaShown+”
“),this.show()},l.prototype.suggestionClick=function(e,n){this.formTag.submit()},l.prototype.show=function(){this.shown=!0,this.resetHighlight(),this.trayContainer.appendChild(this.tray)},l.prototype.hide=function(){this.aria&&(this.set(this.aria,”aria-expanded”,”false”),this.aria.innerHTML=”
“+this.config.text.ariaClosed+”
“),this.shown=!1,this.resetHighlight(),this.trayContainer.innerHTML=””},l.prototype.resetHighlight=function(){!1!==this.selectedItem&&this.itemList.length&&(this.itemList[this.selectedItem].className=this.config.cssClass.li)},l.prototype.resetHightlight=l.prototype.resetHighlight,l.prototype.tab=function(){if(!this.shown||!this.itemList.length)return!1;if(!1!==this.selectedItem)this.searchbox.value=this.get(this.itemList[this.selectedItem],”data”),this.saModel.fetch();else{if(this.searchbox.value===this.get(this.itemList[0],”data”))return this.saModel.unset(),!1;this.searchbox.value=this.get(this.itemList[0],”data”),this.saModel.fetch()}return!0},l.prototype.moveUpDown=function(e){return!(!this.shown||!this.itemList.length)&&(this.resetHighlight(),e?!1===this.selectedItem||this.selectedItem=this.itemList.length-1?this.selectedItem=0:this.selectedItem++,this.itemList[this.selectedItem].className=this.config.cssClass.li+” “+this.config.cssClass.liHighlight,this.searchbox.value=this.get(this.itemList[this.selectedItem],”data”),!0)},l.prototype.createItem=function(e){var t=n.createElement(“li”),i=this;if(t.className=this.config.cssClass.li,this.set(t,”pos”,e.idx),this.set(t,”role”,”option”),this.config.formatResult){var o=this.config.ylcVal;o&&(o=o.replace(“cposV”,e.idx),i.config.ylcParam&&(o=o.replace(“t9Val”,i.config.ylcParam.n_sugg)),this.set(t,”data-ylk”,o)),this.set(t,”data-position”,e.idx)}i.set(t,”data”,e.p);var s=n.createElement(“span”);s.className=i.config.cssClass.span,s.style.display=”block”,t.appendChild(s);var r=n.createElement(“span”);return r.className=i.config.cssClass.text,r.innerHTML=e.t,s.appendChild(r),{li:t,suggestionSpan:s}},l.prototype.getItemAnnotation=function(e){var t,i,o,s=this.config.annotation[e.m]||{},r=this.config.cssClass,a=e.fd,c=””,l=””,u=this.searchbox.clientWidth-2*this.config.trayPadding;if(s.subtitle&&a.subtitle){if(l=s.subtitle.replace(“{subtitle}”,this.htmlEncode(a.subtitle)),!(this.getWidth(e.p,l)‘+l+””)>u){l=””;break}l&&(c+=’‘+l+”“)}return c&&((t=n.createElement(“span”)).innerHTML=c),t},i(u,c),u.prototype.unset=function(){this.triggered=!1,this.saView.hide()},u.prototype.jsonp=function(e,t){var i={command:this.saView.searchbox.value,t_stmp:this.ts(),callback:”YAHOO.”+this.config.objectName+”.cb.”+e};this.merge(i,this.config.gossipParam),t&&this.merge(i,t);var o=this.buildUrl(this.config.saBase,i),s=n.getElementsByTagName(“head”)[0],r=n.createElement(“script”);this.set(r,”type”,”text/javascript”),this.set(r,”src”,o),s.appendChild(r),this.ae(r,”load”,(function(){s.removeChild(r)}))},u.prototype.read=function(e){var n,t=this,i=[],o=e.sqpos,s=e.q=e.q||””,r=””;e&&”object”==typeof e.r&&e.r.length>0?(t.config.subAssist&&o&&(s=e.q.substr(o),r=e.q.substr(0,o),e.r.forEach((function(n){t.saView.getWidth(n.k)>t.saView.searchbox.clientWidth&&(o=0,s=e.q,r=””)}))),e.r.forEach((function(e){n=t.config.subAssist&&o?e.k.substr(o):e.k,i.push({p:e.k,t:t.bold(t.config.boldTag,t.htmlEncode(n),t.htmlEncode(s),t.config.highlight),fd:e.fd,m:e.m})})),this.ylc.n_sugg=e.r.length,this.ylc.pos=0,this.saView.display({data:i,sqpos:o,hiddenNeedle:r})):(this.ylc.n_sugg=0,this.ylc.pos=0,this.saView.hide()),e&&e.l&&(this.ylc.gprid=e.l.gprid)},u.prototype.fetch=function(){var e,n=this.saView.searchbox,t=this,i=null,s=t.lastValue===t.saView.searchbox.value;if(t.config.suppressEmptyQuery&&””==o(n.value))return t.unset(),!0;if(t.saView.shown&&s)return!0;if(this.config.enableIpos&&!s&&void 0!==t.lastValue&&((e=this.getCursorPosition())===n.value.length&&(e=null),null!==e&&(i={ipos:e})),t.lastValue=t.saView.searchbox.value,this.config.minQueryLength&&this.saView.searchbox.value.length
Source