Add ability to forget keywords
This commit is contained in:
parent
eba1774a6e
commit
720d80ae64
@ -72,11 +72,13 @@
|
||||
|
||||
function onLearn() {
|
||||
$('#learnKeyword').prop('disabled', true);
|
||||
|
||||
$('#learnError').slideUp(function() {
|
||||
var query = {
|
||||
keyword: $('#keywordToLearn').val(),
|
||||
params: ctx.searchParams
|
||||
};
|
||||
|
||||
$.getJSON('/node/addKeyword', query, function(results) {
|
||||
if (results.success) {
|
||||
$('#learnDialog').modal('hide');
|
||||
@ -90,6 +92,18 @@
|
||||
});
|
||||
}
|
||||
|
||||
function onForget() {
|
||||
$('#forgetKeyword').prop('disabled', true);
|
||||
|
||||
var query = {
|
||||
keyword: $('#keywordToForget').val()
|
||||
};
|
||||
|
||||
$.getJSON('/node/removeKeyword', query, function(results) {
|
||||
$('#forgetDialog').modal('hide');
|
||||
});
|
||||
}
|
||||
|
||||
function outputResults(results, count) {
|
||||
var searchResultCnt = String(results.length);
|
||||
if (results.length < count) {
|
||||
@ -113,30 +127,44 @@
|
||||
|
||||
ready: function() {
|
||||
$('#keywordsToSearch').selectpicker();
|
||||
$('#keywordToForget').selectpicker();
|
||||
|
||||
$.getJSON('/node/getKeywords', function(keywords) {
|
||||
$('#searchKeywords').click(onSearch);
|
||||
for (var i = 0, count = keywords.length; i < count; ++i) {
|
||||
$('#keywordsToSearch').append($('<option></option>', {
|
||||
value: keywords[i],
|
||||
text: keywords[i]
|
||||
}));
|
||||
}
|
||||
$('#keywordsToSearch').selectpicker('refresh');
|
||||
$('#keywordsToSearch').change(function() {
|
||||
$('#searchKeywords').prop('disabled', !$(this).val());
|
||||
});
|
||||
|
||||
$('#learnDialog').on('show.bs.modal', function() {
|
||||
$('#learnKeyword').prop('disabled', true);
|
||||
$('#keywordToLearn').val('');
|
||||
$('#learnError').hide();
|
||||
$('#forgetKeyword').click(onForget);
|
||||
$('#forgetDialog').on('show.bs.modal', function() {
|
||||
$.getJSON('/node/getKeywords', function(keywords) {
|
||||
$('#keywordToForget').empty();
|
||||
for (var i = 0, count = keywords.length; i < count; ++i) {
|
||||
$('#keywordToForget').append($('<option></option>', {
|
||||
value: keywords[i],
|
||||
text: keywords[i]
|
||||
}));
|
||||
}
|
||||
$('#keywordToForget').selectpicker('refresh');
|
||||
$('#forgetKeyword').prop('disabled', keywords.length === 0);
|
||||
});
|
||||
});
|
||||
|
||||
$('#learnKeyword').click(onLearn);
|
||||
$('#keywordToLearn').bind('input', function() {
|
||||
$('#learnKeyword').prop('disabled', !$(this).val());
|
||||
});
|
||||
|
||||
$('#searchKeywords').click(onSearch);
|
||||
$('#keywordsToSearch').selectpicker('refresh');
|
||||
$('#keywordsToSearch').change(function() {
|
||||
$('#searchKeywords').prop('disabled', !$(this).val());
|
||||
$('#learnDialog').on('show.bs.modal', function() {
|
||||
$('#learnKeyword').prop('disabled', true);
|
||||
$('#keywordToLearn').val('');
|
||||
$('#learnError').hide();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -99,7 +99,7 @@
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<label for="keywordToForget">Keyword to forget</label>
|
||||
<select class="form-control" id="keywordToForget"></select>
|
||||
<select id="keywordToForget" class="form-control" data-live-search="data-live-search" name="keywordToForget"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
|
Loading…
Reference in New Issue
Block a user