跳转到内容

User:Liangent/Gadgets/Toolkit/ajaxsearch.js

维基百科,自由的百科全书
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google ChromeFirefoxMicrosoft EdgeSafari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
// '''Compressed version''' // [[User:Liangent/Gadgets/Toolkit/ajaxsearch.uncompressed.js|Uncompressed version]] //

require(['jquery',{src:'uri',data:'http://www.google.com/jsapi'}],function(){google.load('search','1');(function($){$(function(){var searchform=$('#searchform');var searchformdiv=$('div',searchform);if(searchformdiv.length!=0){searchform=searchformdiv;}
searchform.append('&nbsp;<input type="button" class="searchButton" '+'id="ajax-searchButton" value="AJAX" title="Search with Google\'s AJAX search" />');$('#ajax-searchButton').click(function(){if($('#searchInput').val().length==0){$('#ajax-search').remove();return;}
if($('#ajax-search').length==0){$('#jump-to-nav').after('<div id="ajax-search"></div>');}
$('#ajax-search').html('<div id="ajax-search-close-div" style="float: right;">'+'<a id="ajax-search-close" href="#">[X]</a></div>'+'<div id="ajax-search-form"></div><div id="ajax-search-results"></div>');$('#ajax-search-close').click(function(){$('#ajax-search').remove();return false;});var searchControl=new google.search.CustomSearchControl('009212467671870524522:mw9ug06rtl4');var options=new google.search.DrawOptions();options.setSearchFormRoot($('#ajax-search-form').hide()[0]);searchControl.draw($('#ajax-search-results')[0],options);searchControl.execute($('#searchInput').val());});});})(jQuery);});