diff --git a/client/html/index.html b/client/html/index.html index 32711fe..81888f3 100644 --- a/client/html/index.html +++ b/client/html/index.html @@ -20,7 +20,7 @@
Visualizer
- +
diff --git a/client/scripts/application.js b/client/scripts/application.js index f66504c..572f6dc 100644 --- a/client/scripts/application.js +++ b/client/scripts/application.js @@ -66,6 +66,27 @@ }); $('#historyIndex').on('slideStop', onSelectSnapshot); + + $('#learn').click(function() { + var keyword = prompt('Input keyword to learn as'); + if (name === null) { + return; + } + + var query = { + keyword: keyword, + features: _ctx.query.features + }; + + $.getJSON('/add_keyword', query, function(results) { + if (results.success) { + + } + else { + alert('Failed to learn keyword'); + } + }); + }); }); } diff --git a/server/search.js b/server/search.js index 2c6a310..65de42a 100644 --- a/server/search.js +++ b/server/search.js @@ -133,32 +133,24 @@ function loadDb(params) { } function addKeyword(query, callback) { - // var keyword = (query.keyword || '').toLowerCase(); - // if (!/^[a-zA-Z0-9]+$/.test(keyword)) { - // callback({ - // keyword: keyword, - // success: false - // }); - // } - // else { - // getKeywords(function(keywords) { - // var features = combine(keywords, query.params); - // var values = [ - // keyword, - // features.food || 0.0, - // features.service || 0.0, - // features.value || 0.0, - // features.atmosphere || 0.0 - // ]; + if (!/^[a-zA-Z0-9]+$/.test(query.keyword)) { + callback({ keyword: query.keyword, success: false }); + return; + } - // pool.query('INSERT INTO keywords VALUES(?, ?, ?, ?, ?)', values, function(err) { - // callback({ - // keyword: keyword, - // success: err === null - // }); - // }); - // }); - // } + getKeywords(function(keywords) { + var values = [ + query.keyword, + query.features.food, + query.features.service, + query.features.value, + query.features.atmosphere + ]; + + pool.query('INSERT INTO keywords VALUES(?, ?, ?, ?, ?)', values, function(err) { + callback({ keyword: query.keyword, success: err === null }); + }); + }); } function removeKeyword(query, callback) {