Skip to content

Commit

Permalink
Hitting search button actually searches now
Browse files Browse the repository at this point in the history
  • Loading branch information
yuvipanda committed Jan 31, 2012
1 parent 844ee16 commit f295c70
Showing 1 changed file with 33 additions and 5 deletions.
38 changes: 33 additions & 5 deletions assets/www/js/search.js
Expand Up @@ -15,11 +15,11 @@ window.search = function() {
$('#search').addClass('inProgress');

if(!isSuggestion) {
var url = app.urlForTitle(term);
app.navigateToPage(url);
return;
console.log('for term: ' + term);
getFullTextSearchResults(term);
} else {
getSearchResults( term );
}
getSearchResults( term );
} else {
if(!isSuggestion)
chrome.showNoConnectionMessage();
Expand Down Expand Up @@ -61,7 +61,35 @@ window.search = function() {
return false;
}
}


function getFullTextSearchResults(term) {

var requestUrl = app.baseURL + "/w/api.php";
$.ajax({
type: 'GET',
url: requestUrl,
data: {
action: 'query',
list: 'search',
srsearch: term,
srinfo: '',
srprop: '',
format: 'json'
},
success: function(data) {
var searchResults = [];
for(var i = 0; i < data.query.search.length; i++) {
var result = data.query.search[i];
searchResults.push(result.title);
}
renderResults([term, searchResults], false);
},
error: function(err) {
console.log("ERROR!" + JSON.stringify(err));
}
});
}

function getSearchResults(term, didyoumean) {
console.log( 'Getting search results for term:', term );
var requestUrl = app.baseURL + "/w/api.php";
Expand Down

0 comments on commit f295c70

Please sign in to comment.