diff options
author | Minteck <contact@minteck.org> | 2021-12-12 15:17:06 +0100 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2021-12-12 15:17:06 +0100 |
commit | a985b2769f6c3dc907b57841134a293842c06fa6 (patch) | |
tree | 9a12a5b5d49f69357cf9ab05456caab3aa2a5343 /assets | |
parent | dfdb8f100de53f3e0ca6b9143a6aab4c04554830 (diff) | |
download | wolfeye-php-a985b2769f6c3dc907b57841134a293842c06fa6.tar.gz wolfeye-php-a985b2769f6c3dc907b57841134a293842c06fa6.tar.bz2 wolfeye-php-a985b2769f6c3dc907b57841134a293842c06fa6.zip |
Add answers
Diffstat (limited to 'assets')
-rw-r--r-- | assets/instant.js | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/assets/instant.js b/assets/instant.js index 439daab..bc643ab 100644 --- a/assets/instant.js +++ b/assets/instant.js @@ -8,9 +8,25 @@ )); document.getElementById("details").innerHTML = "<small id='details-source'>from <a id='details-source-link' href='https://duckduckgo.com' target='_blank'>DuckDuckGo</a>:</small><p>" + instant.Abstract + "</p><p><i>— <a href='" + instant.AbstractURL + "' id='details-data-link' target='_blank'>" + instant.AbstractSource + "</a></i></p>"; - if (instant.Abstract.trim() !== "") document.getElementById("details").style.display = "block"; - if (instant.Abstract.trim() !== "") document.getElementById("results").classList.add("with-details"); - if (instant.Abstract.trim() !== "") try {document.getElementsByClassName("dym-section")[0].outerHTML = ""; } catch (e) {} + + if (instant.Abstract.trim() !== "") { + document.getElementById("details").style.display = "block"; + document.getElementById("results").classList.add("with-details"); + try {document.getElementsByClassName("dym-section")[0].outerHTML = ""; } catch (e) {} + } else { + answer = (await ( + await ( + await window.fetch("/ratelimited/answer.php?q=" + query) + ).blob() + ).text() + ) + if (answer.trim() !== "Wolfram|Alpha did not understand your input" && answer.trim() !== "No short answer available") { + document.getElementById("details").innerHTML = "<small id='details-source'>from <a id='details-source-link' href='https://www.wolframalpha.com/input/?i=" + encodeURI(query) + "' target='_blank'>Wolfram|Alpha</a>:</small><p>" + answer + "</p><p><details><summary style='cursor:pointer;'>Disclaimer</summary>This information is provided by Wolfram|Alpha. Results and information from this site are not a certified or definitive source of information that can be relied on for legal, financial, medical, life-safety or any other critical purposes.</details></p>"; + document.getElementById("details").style.display = "block"; + document.getElementById("results").classList.add("with-details"); + try {document.getElementsByClassName("dym-section")[0].outerHTML = ""; } catch (e) {} + } + } if (!instant._WolfEye_External) { try { document.getElementById("details-source").innerHTML = " " } catch (e) {} |