From f3c36614a7dc60196fad15c89373758b21040e69 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sat, 8 Nov 2014 16:13:06 +0900 Subject: [PATCH] Cleanup --- client/html/index.html | 27 +----------- client/scripts/application.js | 81 +++++++++++------------------------ 2 files changed, 27 insertions(+), 81 deletions(-) diff --git a/client/html/index.html b/client/html/index.html index ada94b3..b7d5a70 100644 --- a/client/html/index.html +++ b/client/html/index.html @@ -16,9 +16,9 @@
- +
- +
@@ -61,28 +61,6 @@
- - -
@@ -90,7 +68,6 @@
Semantic tweaker
-
diff --git a/client/scripts/application.js b/client/scripts/application.js index 7a86fe1..0f7ad3b 100644 --- a/client/scripts/application.js +++ b/client/scripts/application.js @@ -39,7 +39,6 @@ } function onReady() { - $('#history').on('slideStop', onSelectSnapshot); $('#history').slider({ formatter: function(value) { var delta = _ctx.log.length - (value + 1); @@ -54,39 +53,27 @@ } }); - $('#learnKeyword').click(onLearn); - $('#learnDialog').on('show.bs.modal', function() { - $('#learnError').hide(); - $('#learnKeyword').prop('disabled', true); - $('#keywordToLearn').val(''); - }); - $('#keywordToLearn').bind('input', function() { - $('#learnKeyword').prop('disabled', !$(this).val()); - }); - $.getJSON('/get_parameters', function(parameters) { _ctx.parameters = parameters; for (var keyword in parameters.keywords) { - $('#keywordsToSearch').append($('', { value: keyword, text: keyword })); + $('#searchKeyword').append($('', { value: keyword, text: keyword })); } search(); + + $('#searchKeyword').change(function() { + search(); + }); + + $('#history').on('slideStop', onSelectSnapshot); }); } - function search(keyword) { - var features = {}; - if (typeof(keyword) == 'undefined') { - for (var i = 0, count = _ctx.parameters.features.length; i < count; ++i) { - features[_ctx.parameters.features[i]] = 0.0; - } - } - else { - features = _ctx.parameters.keywords[keyword]; - } + function search() { + var keyword = $('#searchKeyword').val(); _ctx.query = { - features: features, + features: _ctx.parameters.keywords[keyword], range: { min: -1.0, max: 1.0 }, minScore: parseFloat($('#minScore').val()), hintSteps: parseInt($('#hintSteps').val()), @@ -127,27 +114,6 @@ }); } - function onLearn() { - $('#learnKeyword').prop('disabled', true); - $('#learnError').slideUp(function() { - var query = { - keyword: $('#keywordToLearn').val(), - params: _ctx.query.features - }; - - $.getJSON('/add_keyword', query, function(results) { - if (results.success) { - $('#learnDialog').modal('hide'); - } - else { - $('#learnError').slideDown(function() { - $('#learnKeyword').prop('disabled', false); - }); - } - }); - }); - } - function onSelectSnapshot() { var index = $('#history').slider('getValue'); outputSnapshot(_ctx.log[index]); @@ -188,18 +154,21 @@ } $(document).on({ - ajaxStart: function() { $('#spinner').show(); }, - ajaxStop: function() { $('#spinner').hide(); }, - ready: onReady() + ajaxStart: function() { + if (_.has(_ctx, 'grapher')) { + _ctx.grapher.enable(false); + } + $('#spinner').show(); + }, + + ajaxStop: function() { + if (_.has(_ctx, 'grapher')) { + _ctx.grapher.enable(true); + } + $('#spinner').hide(); + }, + + ready: onReady() }); }(window.hscd = window.hscd || {})); - -/* -global - $, - Handlebars, - document, - grapher, - window, -*/