Media-wiki:GoogleSearch/test: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
No edit summary |
||
Line 29: | Line 29: | ||
Results: | Results: | ||
<html> | <html> | ||
<div id="cse" style="width:100%;"></div> | <div id="cse" style="width:100%;"></div> | ||
<script type="text/javascript"> | |||
google.load('search', '1', {language : 'en'}); | |||
google.setOnLoadCallback(function() { | |||
var customSearchOptions = {}; | |||
var imageSearchOptions = {}; | |||
imageSearchOptions['layout'] = google.search.ImageSearch.LAYOUT_POPUP; | |||
customSearchOptions['enableImageSearch'] = true; | |||
customSearchOptions['imageSearchOptions'] = imageSearchOptions; var customSearchControl = new google.search.CustomSearchControl( | |||
'010823241464583136657:h3lzpyuunqm', customSearchOptions); | |||
customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET); | |||
var options = new google.search.DrawOptions(); | |||
options.setAutoComplete(true); | |||
customSearchControl.draw('cse', options); | |||
function parseParamsFromUrl() { | |||
var params = {}; | |||
var parts = window.location.search.substr(1).split('\x26'); | |||
for (var i = 0; i < parts.length; i++) { | |||
var keyValuePair = parts[i].split('='); | |||
var key = decodeURIComponent(keyValuePair[0]); | |||
params[key] = keyValuePair[1] ? | |||
decodeURIComponent(keyValuePair[1].replace(/\+/g, ' ')) : | |||
keyValuePair[1]; | |||
} | |||
return params; | |||
} | |||
var urlParams = parseParamsFromUrl(); | |||
var queryParamName = "q"; | |||
if (urlParams[queryParamName]) { | |||
customSearchControl.execute(urlParams[queryParamName]); | |||
} | |||
}, true); | |||
</script> | |||
</html> | </html> |
Revision as of 13:28, 28 March 2012
Test:
Results: