Show counter that displays number of results returned from search
This commit is contained in:
parent
30b84608d3
commit
a2aeaf5a50
@ -22,7 +22,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctx.grapher.setColumnHints(hintData);
|
ctx.grapher.setColumnHints(hintData);
|
||||||
outputResults(results.items, params.maxResults);
|
outputResults(results.items, results.count);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,7 +46,7 @@
|
|||||||
ctx.grapher.setColumns(results.columns);
|
ctx.grapher.setColumns(results.columns);
|
||||||
ctx.grapher.setValueChangedListener(onAdjust);
|
ctx.grapher.setValueChangedListener(onAdjust);
|
||||||
|
|
||||||
outputResults(results.items, params.maxResults);
|
outputResults(results.items, results.count);
|
||||||
|
|
||||||
if (params.keywords) {
|
if (params.keywords) {
|
||||||
$('#query').text(params.keywords.join(', '));
|
$('#query').text(params.keywords.join(', '));
|
||||||
@ -66,11 +66,14 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function outputResults(results, maxResults) {
|
function outputResults(results, count) {
|
||||||
$('#results').empty();
|
$('#results').empty();
|
||||||
$('#count').text(results.length);
|
|
||||||
|
|
||||||
results = results.splice(0, maxResults);
|
var searchResultCnt = String(results.length);
|
||||||
|
if (results.length < count) {
|
||||||
|
searchResultCnt += ' of ' + count;
|
||||||
|
}
|
||||||
|
$('#count').text(searchResultCnt);
|
||||||
|
|
||||||
var template = Handlebars.compile($('#template').html());
|
var template = Handlebars.compile($('#template').html());
|
||||||
$('#results').append(template({'results': results}));
|
$('#results').append(template({'results': results}));
|
||||||
|
@ -45,7 +45,7 @@ function countData(searchParams, minScore) {
|
|||||||
return dataCount;
|
return dataCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
function findData(searchParams, minScore, maxResults) {
|
function findData(searchParams, minScore) {
|
||||||
var results = [];
|
var results = [];
|
||||||
|
|
||||||
for (var i = 0, count = db_data.length; i < count; ++i) {
|
for (var i = 0, count = db_data.length; i < count; ++i) {
|
||||||
@ -71,7 +71,7 @@ function findData(searchParams, minScore, maxResults) {
|
|||||||
return b.score - a.score;
|
return b.score - a.score;
|
||||||
});
|
});
|
||||||
|
|
||||||
return results.slice(0, maxResults);
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
function searchStepper(range, steps, callback) {
|
function searchStepper(range, steps, callback) {
|
||||||
@ -138,8 +138,7 @@ module.exports.execQuery = function(query) {
|
|||||||
|
|
||||||
var searchResults = findData(
|
var searchResults = findData(
|
||||||
query.searchParams,
|
query.searchParams,
|
||||||
query.minScore * _.keys(query.searchParams).length,
|
query.minScore * _.keys(query.searchParams).length
|
||||||
query.maxResults
|
|
||||||
);
|
);
|
||||||
|
|
||||||
var graphColumns = {};
|
var graphColumns = {};
|
||||||
@ -163,6 +162,7 @@ module.exports.execQuery = function(query) {
|
|||||||
return {
|
return {
|
||||||
columns: graphColumns,
|
columns: graphColumns,
|
||||||
params: query.searchParams,
|
params: query.searchParams,
|
||||||
items: searchResults
|
items: searchResults.slice(0, query.maxResults),
|
||||||
|
count: searchResults.length
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user