1

Interface improvements

This commit is contained in:
Alex Yatskov 2014-09-19 15:08:09 +09:00
parent 26760e135a
commit 0684fe9a69
3 changed files with 23 additions and 23 deletions

View File

@ -71,6 +71,9 @@
}
function onLearn() {
$('#learn').prop('disabled', true);
$('#learnError').slideUp(function() {
var query = {
keyword: $('#keyword').val(),
params: ctx.searchParams
@ -81,9 +84,12 @@
$('#learnDlg').modal('hide');
}
else {
$('#learnError').fadeIn();
$('#learnError').slideDown(function() {
$('#learn').prop('disabled', false);
});
}
});
});
}
function outputResults(results, count) {
@ -124,6 +130,7 @@
$('#learnDlg').on('show.bs.modal', function() {
$('#learn').prop('disabled', true);
$('#keyword').val('');
$('#learnError').hide();
});
$('#learn').click(onLearn);

View File

@ -87,7 +87,7 @@
</div>
</div>
</div>
<div class="alert alert-danger" id="learnError" style="display: none;">Error learning keyword</div>
<div class="alert alert-danger" id="learnError" style="display: none;">Error writing keyword to database</div>
</div>
<div class="modal-footer">
<div class="btn-group">

View File

@ -146,19 +146,12 @@ function loadDb(params) {
}
function addKeyword(query, callback) {
if (!query.keyword) {
callback({
keyword: query.keyword,
success: false
});
return;
}
getKeywords(function(keywords) {
var keyword = query.keyword.toLowerCase();
var features = combine(keywords, query.params);
var values = [
query.keyword,
keyword,
features.food || 0.0,
features.service || 0.0,
features.value || 0.0,
@ -167,7 +160,7 @@ function addKeyword(query, callback) {
connection.query('INSERT INTO keywords VALUES(?, ?, ?, ?, ?)', values, function(err) {
callback({
keyword: query.keyword,
keyword: keyword,
success: err === null
});
});