diff --git a/client/application.js b/client/application.js index 83c0a68..5244c06 100644 --- a/client/application.js +++ b/client/application.js @@ -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) { $('#results').empty(); @@ -104,6 +115,7 @@ } $('#search').click(onSearch); + $('#learn').click(onLearn); $('#keywords').selectpicker('refresh'); $('#keywords').change(function() { $('#search').prop('disabled', $(this).val() === null); diff --git a/client/index.html b/client/index.html index f6186a5..412f02b 100644 --- a/client/index.html +++ b/client/index.html @@ -91,7 +91,7 @@
diff --git a/server/search.js b/server/search.js index eeef4de..9148086 100644 --- a/server/search.js +++ b/server/search.js @@ -147,6 +147,15 @@ function loadDb(params) { } function addKeyword(query, callback) { + if (!query.keyword) { + callback({ + keyword: query.keyword, + success: false + }); + + return; + } + getKeywords(function(keywords) { var result = { food: 0.0,