1
0
mirror of synced 2024-11-05 02:59:16 +00:00
G940LEDControl/MSDN/SimConnect_files/SearchBox.jss

16 lines
17 KiB
Plaintext
Raw Normal View History

if (typeof epx_core === 'undefined') {
epx_loaded = false;
epx_core = function(s) {this.s = s;}
epx_core.prototype = {
exec: function(func, checkFunc, retry) {
if (retry) retry++; else retry = 1;
if (checkFunc()) {func();} else if (retry <= this.s.maxRetry) {var t = this.s.delay * retry;setTimeout(function() {epx_core_i.exec(func, checkFunc, retry);}, t);}
},
load: function() {function epx_htmlDecode(a){return jQuery("<div/>").html(a).text()}function epx_htmlEncode(a){return $("<div/>").text(a).html()}function epx_createDelegate(a,b){return function(){b.apply(a)}}if(typeof epx_timer==="undefined"){epx_timer=function(a,b){this._interval=a;this._enabled=false;this._timer=null;jQuery(this).bind("tick",this,b)};epx_timer.prototype={set_enabled:function(a){if(a!==this._enabled){this._enabled=a;a?this._startTimer():this._stopTimer()}},_timerCallback:function(){jQuery(this).trigger("tick")},_startTimer:function(){this._timer=window.setInterval(epx_createDelegate(this,this._timerCallback),this._interval)},_stopTimer:function(){window.clearInterval(this._timer);this._timer=null}}}epx_searchBoxState=function(){this.userSelectedTermFlag=false;this.userSelectedWordFlag=false;this.autocompleteTermsShownFlag=false;this.autocompleteWordsShownFlag=false};epx_searchBoxState.prototype={userSelectedTerm:function(){this.userSelectedTermFlag=true},userSelectedWord:function(){this.userSelectedWordFlag=true},autocompleteTermsShown:function(){this.autocompleteTermsShownFlag=true},autocompleteWordsShown:function(){this.autocompleteWordsShownFlag=true},getInstrumentationValue:function(){var a=0;if(!this.autocompleteTermsShownFlag)a=1;if(this.autocompleteTermsShownFlag)a=2;if(this.userSelectedTermFlag)a=3;if(!this.autocompleteTermsShownFlag&&!this.autocompleteWordsShownFlag)a=4;if(this.autocompleteWordsShownFlag&&!this.userSelectedWordFlag)a=5;if(this.autocompleteWordsShownFlag&&this.userSelectedWordFlag)a=6;return a}};epx_searchBoxCount=0;epx_searchBox=function(a){this.instanceId=epx_searchBoxCount++;this.sbData=a;this.serviceRequestDelay=400;this.flyoutSpeed=150;this.maxTerms=8;this.termItems=[];this.matchType="None";this.selectedTermIndex=-1;this.textBackground="#ffffff";this.state=new epx_searchBoxState;this.searchExecuting=false;this.flyoutEnabled=true;this.flyoutFocused=false;this.focused=false;this.wordMatchString="Word";this.termMatchString="Term";this.terms=[];this.textAlign="left";if(this.sbData.isRTL)this.textAlign="right";this.listStyle={"list-style":"none",padding:"4px 2px 0px 1px",cursor:"pointer",margin:"1px","white-space":"nowrap"};this.itemNormalStyle={backgroundColor:this.textBackground,"text-decoration":"none"};this.itemHoverStyle={"text-decoration":"underline",backgroundColor:"#eeeeee"}};epx_searchBox.prototype={loadTermsFromService:function(){this.requestTimer.set_enabled(false);var a=jQuery.trim(this.searchBoxElement.value),b=1024;if(a.length>=this.sbData.minimumTermLength&&a.length<=b&&!this.searchExecuting){var c=this.sbData.serviceUri+"Data/Terms?callback=?&t="+encodeURIComponent(a)+"&a="+this.sbData.appId+"&s="+this.sbData.scopeId+"&m="+this.maxTerms+"&mtl="+this.sbData.minimumTermLength;jQuery.ajax({url:c,success:this.termcb,global:false,dataType:"jsonp",context:this})}},instrumentSearch:function(a){var c=Math.floor(Math.random()*1e9),d=this.sbData.serviceUri+"Data/IS?a="+this.sbData.appId+"&s="+this.sbData.scopeId+"&t="+a+"&ac="+this.state.getInstrumentationValue();+"&rnd="+c;var b=new Image;b.src=d},updateTerms:function(){var a=jQuery.trim(this.searchBoxElement.value);if(!this.searchBoxElement.watermarkShown&&a.length>=this.sbData.minimumTermLength){if(a!==this.lastTerm){this.lastTerm=a;this.requestTimer.set_enabled(true)}}else{this.lastTerm="";this.clearTerms();this.updateFlyoutVisibility()}},clearTerms:function(){this.termItems=[];jQuery(this.completionListElement).empty();this.selectedTermIndex=-1},termcb:function(a){a.Term=epx_htmlDecode(a.Term);a.matchType=epx_htmlDecode(a.MatchType);a.Matches=jQuery.map(a.Matches,epx_htmlDecode);var b=this.context;if(b===undefined)b=this;if(b.shouldProcessResult(a)){b.clearTerms();this.matchType=a.MatchType;this.terms=a.Matches;for(var c=0;c<this.terms.length;c++){var d=b.createItem(this.terms[c],a.Term);b.termItems[c]=d;jQuery(b.completionListElement).append(d)}b.completionListElement.scrollTop=0;if(a.matchType==this.termMatchString)b.state.autocompleteTermsShown();else if(a.matchType==this.wordMatchString)b.state.autocompleteWordsS
epx_core_i = new epx_core({'delay':100,'maxRetry':20});
epx_core_i.exec(epx_core_i.load, function() {return typeof(jQuery) !== 'undefined'});
}
epx_core_i.exec(function(){
jQuery(document).ready(function(){new epx_searchBox({"allowEmptySearch":false,"appId":"1","boxId":"HeaderSearchTextBox","btnId":"HeaderSearchButton","focusOnInit":false,"isRTL":false,"maxTerms":null,"minimumTermLength":4,"paramsCallback":null,"pgArea":"header","queryParams":"&pgArea=header&emptyWatermark=true","scopeId":"9","searchLocation":"https:\/\/social.msdn.microsoft.com\/Search\/en-US","serviceUri":"https:\/\/services.social.microsoft.com\/Search\/","sr":{"close":"Close","searchButtonTooltip":"Search MSDN","searchLabel":""}} ).init();});},
function() {return epx_loaded});