使用搜索:谷歌必应百度
ToKeyCode('Enter')) { searchPost(); } }); } }); } function closeSearch () { $('body').css({ overflow: 'auto' }); $('.search-popup').css({ display: 'none' }); $('.search-mask').css({ display: 'none' }); } window.addEventListener('DOMContentLoaded', function () { Stun.utils.pjaxReloadLocalSearch = function () { $('.header-nav-search').on('click', function (e) { e.stopPropagation(); $('body').css('overflow', 'hidden'); $('.search-popup') .velocity('stop') .velocity('transition.expandIn', { duration: 300, complete: function () { $('.search-popup input').focus(); } }); $('.search-mask') .velocity('stop') .velocity('transition.fadeIn', { duration: 300 }); initSearch(); }); $('.search-mask, .search-close').on('click', function () { closeSearch(); }); $(document).on('keydown', function (e) { // Escape <=> 27 if (e.keyCode === Stun.utils.codeToKeyCode('Escape')) { closeSearch(); } }); }; Stun.utils.pjaxReloadLocalSearch(); }, false); function safeOpenUrl(url) { var newTab = window.open(); newTab.opener = null; newTab.location = url; } function extSearch(engine) { var engines = { google: 'https://www.google.com/search?q=', bing: 'https://cn.bing.com/search?q=', baidu: 'https://www.baidu.com/s?ie=UTF-8&wd=', }; var host = window.location.host; var query = $('.search-input input').val().toLowerCase().trim(); var uri = engines[engine] + query + ' site:' + host; if (query) { safeOpenUrl(uri); } else { Stun.utils.popAlert('warning', '请输入字符'); } } var assistSearchList = window.CONFIG.assistSearch; if (Array.isArray(assistSearchList)) { assistSearchList.forEach(function (name) { document.querySelector('.search-btns-item--' + name).addEventListener('click', function () { extSearch(name); }, false); }); }