1

Enable keyword learning

This commit is contained in:
Alex Yatskov 2014-09-18 17:32:59 +09:00
parent 5aa4ebcbc1
commit ba8f1b3c99
3 changed files with 22 additions and 1 deletions

View File

@ -70,6 +70,17 @@
}); });
} }
function onLearn() {
var query = {
keyword: $('#keyword').val(),
params: ctx.searchParams
};
$.getJSON('/node/addKeyword', query, function(results) {
console.log(results);
});
}
function outputResults(results, count) { function outputResults(results, count) {
$('#results').empty(); $('#results').empty();
@ -104,6 +115,7 @@
} }
$('#search').click(onSearch); $('#search').click(onSearch);
$('#learn').click(onLearn);
$('#keywords').selectpicker('refresh'); $('#keywords').selectpicker('refresh');
$('#keywords').change(function() { $('#keywords').change(function() {
$('#search').prop('disabled', $(this).val() === null); $('#search').prop('disabled', $(this).val() === null);

View File

@ -91,7 +91,7 @@
<div class="modal-footer"> <div class="modal-footer">
<div class="btn-group"> <div class="btn-group">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Learn</button> <button type="button" class="btn btn-primary" id="learn">Learn</button>
</div> </div>
</div> </div>
</div> </div>

View File

@ -147,6 +147,15 @@ function loadDb(params) {
} }
function addKeyword(query, callback) { function addKeyword(query, callback) {
if (!query.keyword) {
callback({
keyword: query.keyword,
success: false
});
return;
}
getKeywords(function(keywords) { getKeywords(function(keywords) {
var result = { var result = {
food: 0.0, food: 0.0,