diff --git a/client/html/index.html b/client/html/index.html index b4b3bc2..f0533c8 100644 --- a/client/html/index.html +++ b/client/html/index.html @@ -19,7 +19,8 @@
Visualizer -
+
+
diff --git a/client/scripts/application.js b/client/scripts/application.js index 0395024..71e686d 100644 --- a/client/scripts/application.js +++ b/client/scripts/application.js @@ -35,7 +35,7 @@ $.getJSON('/search', _ctx.query, function(results) { saveSnapshot(results); outputSnapshot(results); - $('#customized').show(); + setCustomized(true); }); } @@ -60,40 +60,43 @@ $('#searchKeyword').append($('', { value: keyword, text: keyword })); } - search(); - - $('#searchKeyword,#minScore,#hintSteps,#maxResults').change(function() { - search(); - }); + onSearch(); + $('#searchKeyword,#minScore,#hintSteps,#maxResults').change(onSearch); $('#historyIndex').on('slideStop', onSelectSnapshot); - - $('#learn').click(function() { - var keyword = prompt('Input keyword to learn as (alphanumeric, no spaces)'); - if (keyword === null) { - return; - } - - var query = { - keyword: keyword, - features: _ctx.query.features - }; - - $.getJSON('/add_keyword', query, function(results) { - if (results.success) { - _ctx.parameters.keywords[keyword] = query.features; - $('#searchKeyword').append($('', { value: keyword, text: keyword })); - $('#searchKeyword').val(keyword); - } - else { - alert('Failed to learn keyword'); - } - }); - }); + $('#learn').click(onLearn); + $('#forget').click(onForget); }); } - function search() { + function onLearn() { + var keyword = prompt('Input keyword to learn as (alphanumeric, no spaces)'); + if (keyword === null) { + return; + } + + var query = { + keyword: keyword, + features: _ctx.query.features + }; + + $.getJSON('/add_keyword', query, function(results) { + if (results.success) { + _ctx.parameters.keywords[keyword] = query.features; + $('#searchKeyword').append($('', { value: keyword, text: keyword })); + $('#searchKeyword').val(keyword); + } + else { + alert('Failed to learn keyword'); + } + }); + } + + function onForget() { + + } + + function onSearch() { var keyword = $('#searchKeyword').val(); _ctx.query = { @@ -134,14 +137,14 @@ $.getJSON('/search', _ctx.query, function(results) { saveSnapshot(results); outputSnapshot(results); - $('#customized').hide(); + setCustomized(false); }); } function onSelectSnapshot() { var index = $('#historyIndex').slider('getValue'); outputSnapshot(_ctx.log[index]); - $('#customized').show(); + setCustomized(true); } function saveSnapshot(results) { @@ -157,6 +160,16 @@ } } + function setCustomized(customized) { + $('#forget').prop('disabled', customized); + if (customized) { + $('#customized').show(); + } + else { + $('#customized').hide(); + } + } + function outputSnapshot(results) { for (var name in results.columns) { _ctx.query.features[name] = results.columns[name].value;