1

More cleanup

This commit is contained in:
Alex Yatskov 2014-09-19 20:26:46 +09:00
parent bf3725bcb8
commit eba1774a6e
2 changed files with 11 additions and 13 deletions

View File

@ -27,7 +27,7 @@
}
function onSearch() {
var keywords = $('#keywords').val() || [];
var keywords = $('#keywordsToSearch').val() || [];
var searchParams = {};
for (var i = 0, count = keywords.length; i < count; ++i) {
@ -91,8 +91,6 @@
}
function outputResults(results, count) {
$('#results').empty();
var searchResultCnt = String(results.length);
if (results.length < count) {
searchResultCnt += ' of ' + count;
@ -100,6 +98,7 @@
$('#count').text(searchResultCnt);
var template = Handlebars.compile($('#template').html());
$('#results').empty();
$('#results').append(template({'results': results}));
}
@ -113,18 +112,16 @@
},
ready: function() {
$('#keywords').selectpicker();
$('#keywordsToSearch').selectpicker();
$.getJSON('/node/getKeywords', function(keywords) {
for (var i = 0, count = keywords.length; i < count; ++i) {
$('#keywords').append($('<option></option>', {
$('#keywordsToSearch').append($('<option></option>', {
value: keywords[i],
text: keywords[i]
}));
}
$('#search').click(onSearch);
$('#learnDialog').on('show.bs.modal', function() {
$('#learnKeyword').prop('disabled', true);
$('#keywordToLearn').val('');
@ -136,9 +133,10 @@
$('#learnKeyword').prop('disabled', !$(this).val());
});
$('#keywords').selectpicker('refresh');
$('#keywords').change(function() {
$('#search').prop('disabled', !$(this).val());
$('#searchKeywords').click(onSearch);
$('#keywordsToSearch').selectpicker('refresh');
$('#keywordsToSearch').change(function() {
$('#searchKeywords').prop('disabled', !$(this).val());
});
});
}

View File

@ -17,9 +17,9 @@
<!-- Query Selector -->
<div id="input" class="form-horizontal">
<div class="form-group">
<label for="keywords" class="col-md-2 control-label">Keywords</label>
<label for="keywordsToSearch" class="col-md-2 control-label">Keywords</label>
<div class="col-md-10">
<select id="keywords" class="form-control" multiple="multiple" data-max-options="4" data-live-search="data-live-search" name="keywords"></select>
<select id="keywordsToSearch" class="form-control" multiple="multiple" data-max-options="4" data-live-search="data-live-search" name="keywordsToSearch"></select>
</div>
</div>
<div class="form-group">
@ -42,7 +42,7 @@
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<button class="btn btn-primary" id="search" type="button" disabled="disabled">
<button class="btn btn-primary" id="searchKeywords" type="button" disabled="disabled">
<span class="glyphicon glyphicon-search"></span> Search
</button>
</div>