aboutsummaryrefslogtreecommitdiff
path: root/assets/instant.js
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2021-12-12 15:53:20 +0100
committerMinteck <contact@minteck.org>2021-12-12 15:53:20 +0100
commitaac76bfbc5c19824d0d84c77948fc628fa6f9902 (patch)
tree4656862cb10ac812c7113b459cb6aa98a15dec08 /assets/instant.js
parenta985b2769f6c3dc907b57841134a293842c06fa6 (diff)
downloadwolfeye-php-aac76bfbc5c19824d0d84c77948fc628fa6f9902.tar.gz
wolfeye-php-aac76bfbc5c19824d0d84c77948fc628fa6f9902.tar.bz2
wolfeye-php-aac76bfbc5c19824d0d84c77948fc628fa6f9902.zip
Commit
Diffstat (limited to 'assets/instant.js')
-rw-r--r--assets/instant.js115
1 files changed, 67 insertions, 48 deletions
diff --git a/assets/instant.js b/assets/instant.js
index bc643ab..3dbc0ac 100644
--- a/assets/instant.js
+++ b/assets/instant.js
@@ -1,66 +1,85 @@
(async () => {
- instant = JSON.parse(
- (await (
- await (
- await window.fetch("/ratelimited/instant.php?q=" + query)
- ).blob()
- ).text()
- ));
+ try {
+ instant = JSON.parse(
+ (await (
+ await (
+ await window.fetch("/ratelimited/instant.php?q=" + query)
+ ).blob()
+ ).text()
+ ));
- 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";
+ document.getElementById("results").classList.add("with-details");
+ 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 (
+ document.getElementById("details-inner").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>";
+ } 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 (answer.trim() !== "Wolfram|Alpha did not understand your input" && answer.trim() !== "No short answer available" && answer.trim() !== "") {
+ document.getElementById("details-inner").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) {}
+ } else {
+ document.getElementById("details").style.display = "none";
+ }
}
- }
- if (!instant._WolfEye_External) {
- try { document.getElementById("details-source").innerHTML = "&nbsp;" } catch (e) {}
- try { document.getElementById("details-data-link").target = "" } catch (e) {}
- }
+ if (!instant._WolfEye_External) {
+ try { document.getElementById("details-source").innerHTML = "&nbsp;" } catch (e) {}
+ try { document.getElementById("details-data-link").target = "" } catch (e) {}
+ }
+
+ if (instant.Results[0]) {
+ if (!document.getElementsByClassName("result-official")[0]) {
+ document.getElementById("results").innerHTML = '<div class="result result-official"><a href="https://example.com"><div class="result-name" style="font-size: 18px;"><img alt="" class="result-icon" src="about:blank"> <b>Example</b> <img class="result-relevant" src="/assets/relevant.svg" alt=""></div><div class="result-url"><small>https://example.com/</small></div></a></div>' + document.getElementById("results").innerHTML;
+ }
- if (instant.Results[0]) {
- if (!document.getElementsByClassName("result-official")[0]) {
- document.getElementById("results").innerHTML = '<div class="result result-official"><a href="https://example.com"><div class="result-name" style="font-size: 18px;"><img alt="" class="result-icon" src="about:blank"> <b>Example</b> <img class="result-relevant" src="/assets/relevant.svg" alt=""></div><div class="result-url"><small>https://example.com/</small></div></a></div>' + document.getElementById("results").innerHTML;
+ document.getElementsByClassName("result-official")[0].classList.add("result-verified");
+ document.getElementsByClassName("result-official")[0].children[0].href = instant.Results[0].FirstURL;
+ document.getElementsByClassName("result-official")[0].children[0].children[0].children[2].src = "/assets/verified.svg";
+ document.getElementsByClassName("result-official")[0].children[0].children[0].children[2].title = "Verified Website";
+ document.getElementsByClassName("result-official")[0].children[0].children[0].children[0].src = "https://duckduckgo.com" + instant.Results[0].Icon.URL;
+ document.getElementsByClassName("result-official")[0].children[0].children[0].children[1].innerText = instant.Heading;
+ document.getElementsByClassName("result-official")[0].children[0].children[1].children[0].innerText = instant.Results[0].FirstURL;
}
- document.getElementsByClassName("result-official")[0].classList.add("result-verified");
- document.getElementsByClassName("result-official")[0].children[0].href = instant.Results[0].FirstURL;
- document.getElementsByClassName("result-official")[0].children[0].children[0].children[2].src = "/assets/verified.svg";
- document.getElementsByClassName("result-official")[0].children[0].children[0].children[2].title = "Verified Website";
- document.getElementsByClassName("result-official")[0].children[0].children[0].children[0].src = "https://duckduckgo.com" + instant.Results[0].Icon.URL;
- document.getElementsByClassName("result-official")[0].children[0].children[0].children[1].innerText = instant.Heading;
- document.getElementsByClassName("result-official")[0].children[0].children[1].children[0].innerText = instant.Results[0].FirstURL;
- }
+ if (query === "wolfeye" || query === "wolf eye") {
+ document.getElementById("details-inner").innerHTML = "<h3>Hold tight! Let's go home...</h3><p>You are already using WolfEye; but you seem lost. Use the search bar at the top of this page to search for something on the Web.</p>"
+ document.getElementById("details-inner").style.display = "block";
- if (query === "wolfeye" || query === "wolf eye") {
- document.getElementById("details").innerHTML = "<h3>Hold tight! Let's go home...</h3><p>You are already using WolfEye; but you seem lost. Use the search bar at the top of this page to search for something on the Web.</p>"
- document.getElementById("details").style.display = "block";
+ if (!document.getElementsByClassName("result-official")[0]) {
+ document.getElementById("results").innerHTML = '<div class="result result-official"><a href="https://example.com"><div class="result-name" style="font-size: 18px;"><img alt="" class="result-icon" src="about:blank"> <b>Example</b> <img class="result-relevant" src="/assets/relevant.svg" alt=""></div><div class="result-url"><small>https://example.com/</small></div></a></div>' + document.getElementById("results").innerHTML;
+ }
- if (!document.getElementsByClassName("result-official")[0]) {
- document.getElementById("results").innerHTML = '<div class="result result-official"><a href="https://example.com"><div class="result-name" style="font-size: 18px;"><img alt="" class="result-icon" src="about:blank"> <b>Example</b> <img class="result-relevant" src="/assets/relevant.svg" alt=""></div><div class="result-url"><small>https://example.com/</small></div></a></div>' + document.getElementById("results").innerHTML;
+ document.getElementsByClassName("result-official")[0].classList.add("result-verified");
+ document.getElementsByClassName("result-official")[0].children[0].href = "https://wolfeye.minteck.org";
+ document.getElementsByClassName("result-official")[0].children[0].children[0].children[2].src = "/assets/verified.svg";
+ document.getElementsByClassName("result-official")[0].children[0].children[0].children[2].title = "Verified Website";
+ document.getElementsByClassName("result-official")[0].children[0].children[0].children[0].src = "/logo.svg";
+ document.getElementsByClassName("result-official")[0].children[0].children[0].children[1].innerText = "WolfEye";
+ document.getElementsByClassName("result-official")[0].children[0].children[1].children[0].innerText = "https://wolfeye.minteck.org";
+ }
+ } catch (e) {
+ 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" && answer.trim() !== "") {
+ document.getElementById("details-inner").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) {}
+ } else {
+ document.getElementById("details").style.display = "none";
}
-
- document.getElementsByClassName("result-official")[0].classList.add("result-verified");
- document.getElementsByClassName("result-official")[0].children[0].href = "https://wolfeye.minteck.org";
- document.getElementsByClassName("result-official")[0].children[0].children[0].children[2].src = "/assets/verified.svg";
- document.getElementsByClassName("result-official")[0].children[0].children[0].children[2].title = "Verified Website";
- document.getElementsByClassName("result-official")[0].children[0].children[0].children[0].src = "/logo.svg";
- document.getElementsByClassName("result-official")[0].children[0].children[0].children[1].innerText = "WolfEye";
- document.getElementsByClassName("result-official")[0].children[0].children[1].children[0].innerText = "https://wolfeye.minteck.org";
}
})() \ No newline at end of file