diff options
author | Andrew Dolgov <[email protected]> | 2019-06-24 09:24:51 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2019-06-24 09:24:51 +0300 |
commit | 337bd2bdf525f4c6d783faacaec4f4189daf1d57 (patch) | |
tree | b59111ff9dda2a45b30dda42f31805f753bd6448 /js/read.js | |
parent | 6bbce144df1e35a4844afbbf10735ddecbe81819 (diff) |
add basic wiktionary support
Diffstat (limited to 'js/read.js')
-rw-r--r-- | js/read.js | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -344,6 +344,30 @@ function init_reader() { window.open("https://duckduckgo.com/?q=" + $(".dict_query").val()); }); + $(".wiki_search_btn").on("click", function() { + $(".dict_result").html("Loading, please wait..."); + + $.post("backend.php", {op: "wikisearch", query: $(".dict_query").val()}) + .then((resp) => { + try { + let tmp = ""; + + $.each(resp.query.pages, (i,p) => { + tmp += p.extract; + }); + + $(".dict_result").html(tmp && tmp != "undefined" ? tmp : "No definition found for " + $(".dict_query").val() + "."); + } catch (e) { + console.error(e); + $(".dict_result").text("Error while processing data: " + e); + } + }) + .fail((e) => { + console.error(e); + $(".dict_result").text("Error while retrieving data."); + }) + }); + function toc_loc_msg(href) { try { const cfiBase = book.spine.get(href).cfiBase; |