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