summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2020-09-22 15:25:24 +0300
committerAndrew Dolgov <[email protected]>2020-09-22 15:25:24 +0300
commit2df368d49228ed4529a06501fdc5c2ce8eb631d5 (patch)
tree301a53114d416fbd37d67eafa4b41a7fa4edebdc
parent7349c8fbae44928924293219df8f3c80794e8ff3 (diff)
show dictionary popup before request completes
-rw-r--r--backend.php2
-rw-r--r--js/reader.js8
2 files changed, 9 insertions, 1 deletions
diff --git a/backend.php b/backend.php
index e245fb2..6318853 100644
--- a/backend.php
+++ b/backend.php
@@ -290,6 +290,8 @@
array_push($result, "No results for: <b>$orig_word</b>");
print json_encode(["result" => $result]);
+ } else {
+ print json_encode(["result" => ["Dictionary lookups are disabled."]]);
}
break;
diff --git a/js/reader.js b/js/reader.js
index e71d157..99ff269 100644
--- a/js/reader.js
+++ b/js/reader.js
@@ -941,15 +941,21 @@ const Reader = {
lookupWord: function(word, callback) {
word = word.replace(/­/g, "");
+ $(".dict_result").html('Loading, please wait...');
+
+ $("#dict-modal").modal('show');
+
$.post("backend.php", {op: 'define', word: word}, function (data) {
if (data) {
$(".dict_result").html(data.result.join("<br/>"));
$(".dict_query").val(word);
- $("#dict-modal").modal('show');
if (callback) callback();
}
+ }).fail(function(res) {
+ console.warn(res);
+ $(".dict_result").html('Network error while looking up word: ' + res.statusText);
});
},
search: function() {