1

More work on getting multiple keywords working

This commit is contained in:
Alex Yatskov 2014-09-12 16:54:21 +09:00
parent 14e22e0d31
commit aa347e91c2
2 changed files with 27 additions and 21 deletions

View File

@ -17,8 +17,8 @@
$.getJSON('/node/search', params, function(results) { $.getJSON('/node/search', params, function(results) {
var hintData = {}; var hintData = {};
for (var feature in results.columns) { for (var keyword in results.columns) {
hintData[feature] = results.columns[feature].hints; hintData[keyword] = results.columns[keyword].hints;
} }
ctx.grapher.setColumnHints(hintData); ctx.grapher.setColumnHints(hintData);
@ -28,7 +28,7 @@
function onSearch() { function onSearch() {
var params = { var params = {
keyword: $('#keyword').val(), keywords: $('#keywords').val(),
searchRange: { min: -1.0, max: 1.0 }, searchRange: { min: -1.0, max: 1.0 },
minScore: parseInt($('#minScore').val()), minScore: parseInt($('#minScore').val()),
hintSteps: parseInt($('#hintSteps').val()), hintSteps: parseInt($('#hintSteps').val()),
@ -73,24 +73,28 @@
$('#results').append(template({'results': results})); $('#results').append(template({'results': results}));
} }
$(document).ready(function() { $(document).on({
$(document).on({ ajaxStart: function() {
ajaxStart: function() { $('#spinner').show();
$('#spinner').show(); },
},
ajaxStop: function() {
$('#spinner').hide();
}
});
$.getJSON('/node/keywords', function(keywords) { ajaxStop: function() {
for (var i = 0; i < keywords.length; ++i) { $('#spinner').hide();
var properties = { value: keywords[i], text: keywords[i] }; },
$('#keyword').append($('<option></option>', properties));
}
$('#search').prop('disabled', false); ready: function() {
$('#search').click(onSearch); $.getJSON('/node/keywords', function(keywords) {
}); for (var i = 0, count = keywords.length; i < count; ++i) {
$('#keywords').append($('<option></option>', {
value: keywords[i],
text: keywords[i]
}));
}
$('#search').prop('disabled', false);
$('#search').click(onSearch);
});
}
}); });
}(window.hscd = window.hscd || {})); }(window.hscd = window.hscd || {}));

View File

@ -118,6 +118,8 @@ module.exports.execQuery = function(query) {
var searchResults = null; var searchResults = null;
if (!searchParams) { if (!searchParams) {
searchParams = {};
for (var i = 0, count = query.keywords.length; i < count; ++i) { for (var i = 0, count = query.keywords.length; i < count; ++i) {
var keyword = query.keywords[i]; var keyword = query.keywords[i];
if (_.has(db_keywords, keyword)) { if (_.has(db_keywords, keyword)) {
@ -142,7 +144,7 @@ module.exports.execQuery = function(query) {
query.hintSteps query.hintSteps
); );
graphColumns[param.name] = { graphColumns[keyword] = {
color: '#607080', color: '#607080',
value: searchParams[keyword], value: searchParams[keyword],
hints: searchHints, hints: searchHints,