//百度统计(总) var _hmt = _hmt || []; var _hmUrl = 'https://hm.baidu.com/hm.js?'; var allBdUrl = ""; var url = window.location.href; allBdUrl = _hmUrl+"c96a4a6196399d3b709c2a18169352d4";//PC var hm = document.createElement("script"); hm.src = allBdUrl; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); //百度统计个人 if (typeof _webInfo != "undefined") {//add tongji for everyBJ var bjname = _webInfo.Username; var hm = document.createElement("script"); if (bjname != '') { switch (bjname){ case 'empty': hm.src = _hmUrl+"cb1e2cc98455bc75422a604efe2fdf16"; break; } if(typeof(_pageinfo) == "undefined"){ var _pageinfo = {}; } if (hm.src != '' && _pageinfo.path != "CMS") { var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); } } } //baidu自动推送代码 (function(){ var canonicalURL, curProtocol; var x=document.getElementsByTagName("link"); if(x.length > 0){ for (i=0;i$1<\/strong>')};Autocomplete.prototype={killerFn:null,initialize:function(){var that=this,suggestionSelector='.'+that.classes.suggestion,selected=that.classes.selected,options=that.options,container;that.element.setAttribute('autocomplete','off');that.killerFn=function(e){if($(e.target).closest('.'+that.options.containerClass).length===0){that.killSuggestions();that.disableKillerFn()}};that.noSuggestionsContainer=$('
').html(this.options.noSuggestionNotice).get(0);that.suggestionsContainer=Autocomplete.utils.createNode(options.containerClass);container=$(that.suggestionsContainer);container.appendTo(options.appendTo);if(options.width!=='auto'){container.width(options.width)}container.on('mouseover.autocomplete',suggestionSelector,function(){that.activate($(this).data('index'))});container.on('mouseout.autocomplete',function(){that.selectedIndex=-1;container.children('.'+selected).removeClass(selected)});container.on('click.autocomplete',suggestionSelector,function(){that.select($(this).data('index'))});that.fixPositionCapture=function(){if(that.visible){that.fixPosition()}};$(window).on('resize.autocomplete',that.fixPositionCapture);that.el.on('keydown.autocomplete',function(e){that.onKeyPress(e)});that.el.on('keyup.autocomplete',function(e){that.onKeyUp(e)});that.el.on('blur.autocomplete',function(){that.onBlur()});that.el.on('focus.autocomplete',function(){that.onFocus()});that.el.on('change.autocomplete',function(e){that.onKeyUp(e)})},onFocus:function(){var that=this;that.fixPosition();if(that.options.minChars<=that.el.val().length){that.onValueChange()}},onBlur:function(){this.enableKillerFn()},setOptions:function(suppliedOptions){var that=this,options=that.options;$.extend(options,suppliedOptions);that.isLocal=$.isArray(options.lookup);if(that.isLocal){options.lookup=that.verifySuggestionsFormat(options.lookup)}options.orientation=that.validateOrientation(options.orientation,'bottom');$(that.suggestionsContainer).css({'max-height':options.maxHeight+'px','width':options.width+'px','z-index':options.zIndex})},clearCache:function(){this.cachedResponse={};this.badQueries=[]},clear:function(){this.clearCache();this.currentValue='';this.suggestions=[]},disable:function(){var that=this;that.disabled=true;clearInterval(that.onChangeInterval);if(that.currentRequest){that.currentRequest.abort()}},enable:function(){this.disabled=false},fixPosition:function(){var that=this,$container=$(that.suggestionsContainer),containerParent=$container.parent().get(0);if(containerParent!==document.body&&!that.options.forceFixPosition)return;var orientation=that.options.orientation,containerHeight=$container.outerHeight(),height=that.el.outerHeight(),offset=that.el.offset(),styles={'top':offset.top,'left':offset.left};if(orientation=='auto'){var viewPortHeight=$(window).height(),scrollTop=$(window).scrollTop(),topOverflow=-scrollTop+offset.top-containerHeight,bottomOverflow=scrollTop+viewPortHeight-(offset.top+height+containerHeight);orientation=(Math.max(topOverflow,bottomOverflow)===topOverflow)?'top':'bottom'}if(orientation==='top'){styles.top+=-containerHeight}else{styles.top+=height}if(containerParent!==document.body){var opacity=$container.css('opacity'),parentOffsetDiff;if(!that.visible){$container.css('opacity',0).show()}parentOffsetDiff=$container.offsetParent().offset();styles.top-=parentOffsetDiff.top;styles.left-=parentOffsetDiff.left;if(!that.visible){$container.css('opacity',opacity).hide()}}if(that.options.width==='auto'){styles.width=(that.el.outerWidth()-2)+'px'}$container.css(styles)},enableKillerFn:function(){var that=this;$(document).on('click.autocomplete',that.killerFn)},disableKillerFn:function(){var that=this;$(document).off('click.autocomplete',that.killerFn)},killSuggestions:function(){var that=this;that.stopKillSuggestions();that.intervalId=window.setInterval(function(){that.hide();that.stopKillSuggestions()},50)},stopKillSuggestions:function(){window.clearInterval(this.intervalId)},isCursorAtEnd:function(){var that=this,valLength=that.el.val().length,selectionStart=that.element.selectionStart,range;if(typeof selectionStart==='number'){return selectionStart===valLength}if(document.selection){range=document.selection.createRange();range.moveStart('character',-valLength);return valLength===range.text.length}return true},onKeyPress:function(e){var that=this;if(!that.disabled&&!that.visible&&e.which===keys.DOWN&&that.currentValue){that.suggest();return}if(that.disabled||!that.visible){return}switch(e.which){case keys.ESC:that.el.val(that.currentValue);that.hide();break;case keys.RIGHT:if(that.hint&&that.options.onHint&&that.isCursorAtEnd()){that.selectHint();break}return;case keys.TAB:if(that.hint&&that.options.onHint){that.selectHint();return}case keys.RETURN:if(that.selectedIndex===-1){that.hide();return}that.select(that.selectedIndex);if(e.which===keys.TAB&&that.options.tabDisabled===false){return}break;case keys.UP:that.moveUp();break;case keys.DOWN:that.moveDown();break;default:return}e.stopImmediatePropagation();e.preventDefault()},onKeyUp:function(e){var that=this;if(that.disabled){return}switch(e.which){case keys.UP:case keys.DOWN:return}clearInterval(that.onChangeInterval);if(that.currentValue!==that.el.val()){that.findBestHint();if(that.options.deferRequestBy>0){that.onChangeInterval=setInterval(function(){that.onValueChange()},that.options.deferRequestBy)}else{that.onValueChange()}}},onValueChange:function(){var that=this,options=that.options,value=that.el.val(),query=that.getQuery(value),index;if(that.selection&&that.currentValue!==query){that.selection=null;(options.onInvalidateSelection||$.noop).call(that.element)}clearInterval(that.onChangeInterval);that.currentValue=value;that.selectedIndex=-1;if(options.triggerSelectOnValidInput){index=that.findSuggestionIndex(query);if(index!==-1){that.select(index);return}}if(query.lengthlimit){data.suggestions=data.suggestions.slice(0,limit)}return data},getSuggestions:function(q){var response,that=this,options=that.options,serviceUrl=options.serviceUrl,params,cacheKey,ajaxSettings;options.params[options.paramName]=q;params=options.ignoreParams?null:options.params;if(options.onSearchStart.call(that.element,options.params)===false){return}if(that.isLocal){response=that.getSuggestionsLocal(q)}else{if($.isFunction(serviceUrl)){serviceUrl=serviceUrl.call(that.element,q)}cacheKey=serviceUrl+'?'+$.param(params||{});response=that.cachedResponse[cacheKey]}if(response&&$.isArray(response.suggestions)){that.suggestions=response.suggestions;that.suggest();options.onSearchComplete.call(that.element,q,response.suggestions)}else if(!that.isBadQuery(q)){if(that.currentRequest){that.currentRequest.abort()}ajaxSettings={url:serviceUrl,data:params,type:options.type,dataType:options.dataType};$.extend(ajaxSettings,options.ajaxSettings);that.currentRequest=$.ajax(ajaxSettings).done(function(data){var result;that.currentRequest=null;result=options.transformResult(data);that.processResponse(result,q,cacheKey);options.onSearchComplete.call(that.element,q,result.suggestions)}).fail(function(jqXHR,textStatus,errorThrown){options.onSearchError.call(that.element,q,jqXHR,textStatus,errorThrown)})}else{options.onSearchComplete.call(that.element,q,[])}},isBadQuery:function(q){if(!this.options.preventBadQueries){return false}var badQueries=this.badQueries,i=badQueries.length;while(i--){if(q.indexOf(badQueries[i])===0){return true}}return false},hide:function(){var that=this;that.visible=false;that.selectedIndex=-1;clearInterval(that.onChangeInterval);$(that.suggestionsContainer).hide();that.signalHint(null)},suggest:function(){if(this.suggestions.length===0){this.options.showNoSuggestionNotice?this.noSuggestions():this.hide();return}var that=this,options=that.options,groupBy=options.groupBy,formatResult=options.formatResult,value=that.getQuery(that.currentValue),className=that.classes.suggestion,classSelected=that.classes.selected,container=$(that.suggestionsContainer),noSuggestionsContainer=$(that.noSuggestionsContainer),beforeRender=options.beforeRender,html='',category,formatGroup=function(suggestion,index){var currentCategory=suggestion.data[groupBy];if(category===currentCategory){return''}category=currentCategory;return'
'+category+'
'},index;if(options.triggerSelectOnValidInput){index=that.findSuggestionIndex(value);if(index!==-1){that.select(index);return}}$.each(that.suggestions,function(i,suggestion){if(groupBy){html+=formatGroup(suggestion,value,i)}html+='
'+formatResult(suggestion,value)+'
'});this.adjustContainerWidth();noSuggestionsContainer.detach();container.html(html);if(options.autoSelectFirst){that.selectedIndex=0;container.children().first().addClass(classSelected)}if($.isFunction(beforeRender)){beforeRender.call(that.element,container)}that.fixPosition();container.show();that.visible=true;that.findBestHint()},noSuggestions:function(){var that=this,container=$(that.suggestionsContainer),noSuggestionsContainer=$(that.noSuggestionsContainer);this.adjustContainerWidth();noSuggestionsContainer.detach();container.empty();container.append(noSuggestionsContainer);that.fixPosition();container.show();that.visible=true},adjustContainerWidth:function(){var that=this,options=that.options,width,container=$(that.suggestionsContainer);if(options.width==='auto'){width=that.el.outerWidth()-2;container.width(width>0?width:300)}},findBestHint:function(){var that=this,value=that.el.val().toLowerCase(),bestMatch=null;if(!value){return}$.each(that.suggestions,function(i,suggestion){var foundMatch=suggestion.value.toLowerCase().indexOf(value)===0;if(foundMatch){bestMatch=suggestion}return!foundMatch});that.signalHint(bestMatch)},signalHint:function(suggestion){var hintValue='',that=this;if(suggestion){hintValue=that.currentValue+suggestion.value.substr(that.currentValue.length)}if(that.hintValue!==hintValue){that.hintValue=hintValue;that.hint=suggestion;(this.options.onHint||$.noop)(hintValue)}},verifySuggestionsFormat:function(suggestions){if(suggestions.length&&typeof suggestions[0]==='string'){return $.map(suggestions,function(value){return{value:value,data:null}})}return suggestions},validateOrientation:function(orientation,fallback){orientation=$.trim(orientation||'').toLowerCase();if($.inArray(orientation,['auto','bottom','top'])===-1){orientation=fallback}return orientation},processResponse:function(result,originalQuery,cacheKey){var that=this,options=that.options;result.suggestions=that.verifySuggestionsFormat(result.suggestions);if(!options.noCache){that.cachedResponse[cacheKey]=result;if(options.preventBadQueries&&result.suggestions.length===0){that.badQueries.push(originalQuery)}}if(originalQuery!==that.getQuery(that.currentValue)){return}that.suggestions=result.suggestions;that.suggest()},activate:function(index){var that=this,activeItem,selected=that.classes.selected,container=$(that.suggestionsContainer),children=container.find('.'+that.classes.suggestion);container.find('.'+selected).removeClass(selected);that.selectedIndex=index;if(that.selectedIndex!==-1&&children.length>that.selectedIndex){activeItem=children.get(that.selectedIndex);$(activeItem).addClass(selected);return activeItem}return null},selectHint:function(){var that=this,i=$.inArray(that.hint,that.suggestions);that.select(i)},select:function(i){var that=this;that.hide();that.onSelect(i)},moveUp:function(){var that=this;if(that.selectedIndex===-1){return}if(that.selectedIndex===0){$(that.suggestionsContainer).children().first().removeClass(that.classes.selected);that.selectedIndex=-1;that.el.val(that.currentValue);that.findBestHint();return}that.adjustScroll(that.selectedIndex-1)},moveDown:function(){var that=this;if(that.selectedIndex===(that.suggestions.length-1)){return}that.adjustScroll(that.selectedIndex+1)},adjustScroll:function(index){var that=this,activeItem=that.activate(index),offsetTop,upperBound,lowerBound,heightDelta=25;if(!activeItem){return}offsetTop=activeItem.offsetTop;upperBound=$(that.suggestionsContainer).scrollTop();lowerBound=upperBound+that.options.maxHeight-heightDelta;if(offsetToplowerBound){$(that.suggestionsContainer).scrollTop(offsetTop-that.options.maxHeight+heightDelta)}that.el.val(that.getValue(that.suggestions[index].value));that.signalHint(null)},onSelect:function(index){var that=this,onSelectCallback=that.options.onSelect,suggestion=that.suggestions[index];that.currentValue=that.getValue(suggestion.value);if(that.currentValue!==that.el.val()){that.el.val(that.currentValue)}that.signalHint(null);that.suggestions=[];that.selection=suggestion;if($.isFunction(onSelectCallback)){onSelectCallback.call(that.element,suggestion)}},getValue:function(value){var that=this,delimiter=that.options.delimiter,currentValue,parts;if(!delimiter){return value}currentValue=that.currentValue;parts=currentValue.split(delimiter);if(parts.length===1){return value}return currentValue.substr(0,currentValue.length-parts[parts.length-1].length)+value},dispose:function(){var that=this;that.el.off('.autocomplete').removeData('autocomplete');that.disableKillerFn();$(window).off('resize.autocomplete',that.fixPositionCapture);$(that.suggestionsContainer).remove()}};$.fn.autocomplete=$.fn.devbridgeAutocomplete=function(options,args){var dataKey='autocomplete';if(arguments.length===0){return this.first().data(dataKey)}return this.each(function(){var inputElement=$(this),instance=inputElement.data(dataKey);if(typeof options==='string'){if(instance&&typeof instance[options]==='function'){instance[options](args)}}else{if(instance&&instance.dispose){instance.dispose()}instance=new Autocomplete(this,options);inputElement.data(dataKey,instance)}})}})); $(function () { $("#keyword").focus(function () { autoSearch();//搜索提示框 }) }) function autoSearch() { $('head').append( ` ` ) $('#keyword').autocomplete({ serviceUrl: '//s.289.com/api/me/autoSearch', minChars: 1, delimiter: /(,|;)\s*/, // regex or character maxHeight: 400, width: 460, zIndex: 9999, type: 'GET', deferRequestBy: 500, // params: { stype: 'down', domain: '289' }, //aditional parameters paramName: 'key', noCache: false, //default is false, set to true to disable caching onSelect: function (suggestion) { if (browser.versions.mobile) { document.location = suggestion.murl; } else { document.location = suggestion.url; } } // local autosugest options: }); }