1
This commit is contained in:
Alex Yatskov 2014-11-08 16:13:06 +09:00
parent d6c76ba49c
commit f3c36614a7
2 changed files with 27 additions and 81 deletions

View File

@ -16,9 +16,9 @@
<!-- query input --> <!-- query input -->
<div class="form-horizontal"> <div class="form-horizontal">
<div class="form-group"> <div class="form-group">
<label for="keywordsToSearch" class="col-md-2 control-label">Keywords</label> <label for="searchKeyword" class="col-md-2 control-label">Keywords</label>
<div class="col-md-10"> <div class="col-md-10">
<select id="keywordsToSearch" class="form-control"></select> <select id="searchKeyword" class="form-control"></select>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -61,28 +61,6 @@
</div> </div>
</div> </div>
<!-- learn keyword dialog -->
<div class="modal fade" id="learnDialog" tabindex="-1">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header"><big>Learn Keyword</big></div>
<div class="modal-body">
<div class="form-group">
<label for="keywordToLearn" class="control-label">Learn keyword as</label>
<input id="keywordToLearn" class="form-control" type="text">
</div>
<div class="alert alert-danger" id="learnError" style="display: none;">Unable to learn keyword</div>
</div>
<div class="modal-footer">
<div class="btn-group">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-success" id="learnKeyword" disabled="disabled">Learn</button>
</div>
</div>
</div>
</div>
</div>
<!-- query output --> <!-- query output -->
<div> <div>
<!-- semantic tweaker --> <!-- semantic tweaker -->
@ -90,7 +68,6 @@
<div class="panel-heading"> <div class="panel-heading">
<big>Semantic tweaker</big> <big>Semantic tweaker</big>
<div class="btn-group pull-right"> <div class="btn-group pull-right">
<button class="btn btn-xs btn-success" data-toggle="modal" data-target="#learnDialog">Learn</button>
<button class="btn btn-xs btn-default" data-toggle="modal" data-target="#optionsDialog">Options</button> <button class="btn btn-xs btn-default" data-toggle="modal" data-target="#optionsDialog">Options</button>
</div> </div>
</div> </div>

View File

@ -39,7 +39,6 @@
} }
function onReady() { function onReady() {
$('#history').on('slideStop', onSelectSnapshot);
$('#history').slider({ $('#history').slider({
formatter: function(value) { formatter: function(value) {
var delta = _ctx.log.length - (value + 1); 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) { $.getJSON('/get_parameters', function(parameters) {
_ctx.parameters = parameters; _ctx.parameters = parameters;
for (var keyword in parameters.keywords) { for (var keyword in parameters.keywords) {
$('#keywordsToSearch').append($('<option></option>', { value: keyword, text: keyword })); $('#searchKeyword').append($('<option></option>', { value: keyword, text: keyword }));
} }
search(); search();
$('#searchKeyword').change(function() {
search();
});
$('#history').on('slideStop', onSelectSnapshot);
}); });
} }
function search(keyword) { function search() {
var features = {}; var keyword = $('#searchKeyword').val();
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];
}
_ctx.query = { _ctx.query = {
features: features, features: _ctx.parameters.keywords[keyword],
range: { min: -1.0, max: 1.0 }, range: { min: -1.0, max: 1.0 },
minScore: parseFloat($('#minScore').val()), minScore: parseFloat($('#minScore').val()),
hintSteps: parseInt($('#hintSteps').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() { function onSelectSnapshot() {
var index = $('#history').slider('getValue'); var index = $('#history').slider('getValue');
outputSnapshot(_ctx.log[index]); outputSnapshot(_ctx.log[index]);
@ -188,18 +154,21 @@
} }
$(document).on({ $(document).on({
ajaxStart: function() { $('#spinner').show(); }, ajaxStart: function() {
ajaxStop: function() { $('#spinner').hide(); }, if (_.has(_ctx, 'grapher')) {
_ctx.grapher.enable(false);
}
$('#spinner').show();
},
ajaxStop: function() {
if (_.has(_ctx, 'grapher')) {
_ctx.grapher.enable(true);
}
$('#spinner').hide();
},
ready: onReady() ready: onReady()
}); });
}(window.hscd = window.hscd || {})); }(window.hscd = window.hscd || {}));
/*
global
$,
Handlebars,
document,
grapher,
window,
*/