From aac76bfbc5c19824d0d84c77948fc628fa6f9902 Mon Sep 17 00:00:00 2001 From: Minteck Date: Sun, 12 Dec 2021 15:53:20 +0100 Subject: Commit --- assets/instant.js | 115 ++++++++++++++++++++++++++++--------------------- assets/loader.svg | 52 ++++++++++++++++++++++ assets/main.css | 17 +++++++- assets/search-v2.svg | 42 ------------------ ratelimited/answer.php | 2 +- search/index.php | 6 ++- 6 files changed, 141 insertions(+), 93 deletions(-) create mode 100644 assets/loader.svg delete mode 100644 assets/search-v2.svg 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 = "from DuckDuckGo:

" + instant.Abstract + "

" + instant.AbstractSource + "

"; + 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 = "from DuckDuckGo:

" + instant.Abstract + "

" + instant.AbstractSource + "

"; + } 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 = "from Wolfram|Alpha:

" + answer + "

DisclaimerThis 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.

"; - 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 = "from Wolfram|Alpha:

" + answer + "

DisclaimerThis 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.

"; + 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 = " " } catch (e) {} - try { document.getElementById("details-data-link").target = "" } catch (e) {} - } + if (!instant._WolfEye_External) { + try { document.getElementById("details-source").innerHTML = " " } 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 = '
Example
https://example.com/
' + document.getElementById("results").innerHTML; + } - if (instant.Results[0]) { - if (!document.getElementsByClassName("result-official")[0]) { - document.getElementById("results").innerHTML = '
Example
https://example.com/
' + 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 = "

Hold tight! Let's go home...

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.

" + document.getElementById("details-inner").style.display = "block"; - if (query === "wolfeye" || query === "wolf eye") { - document.getElementById("details").innerHTML = "

Hold tight! Let's go home...

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.

" - document.getElementById("details").style.display = "block"; + if (!document.getElementsByClassName("result-official")[0]) { + document.getElementById("results").innerHTML = '
Example
https://example.com/
' + document.getElementById("results").innerHTML; + } - if (!document.getElementsByClassName("result-official")[0]) { - document.getElementById("results").innerHTML = '
Example
https://example.com/
' + 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 = "from Wolfram|Alpha:

" + answer + "

DisclaimerThis 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.

"; + 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 diff --git a/assets/loader.svg b/assets/loader.svg new file mode 100644 index 0000000..4063eb1 --- /dev/null +++ b/assets/loader.svg @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/assets/main.css b/assets/main.css index a89ea8e..76ee40f 100644 --- a/assets/main.css +++ b/assets/main.css @@ -152,7 +152,6 @@ body, html { #details { padding-top: 10px !important; padding-bottom: 10px !important; - display: none; } #results-intro-bar-submit { @@ -283,4 +282,20 @@ div.searchbtn input { .home-btn:active { border-color: #777; background: #353535; +} + +#details-inner { + padding: 10px 20px; + background: #151515; + border-radius: 5px; +} + +#details-loader { + display: flex; + align-items: center; + justify-content: center; +} + +#details-loader img { + width: 64px; } \ No newline at end of file diff --git a/assets/search-v2.svg b/assets/search-v2.svg deleted file mode 100644 index 8e1d231..0000000 --- a/assets/search-v2.svg +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ratelimited/answer.php b/ratelimited/answer.php index 8bc9707..d44b978 100644 --- a/ratelimited/answer.php +++ b/ratelimited/answer.php @@ -88,7 +88,7 @@ if (file_exists($_SERVER["DOCUMENT_ROOT"] . "/private/answers/" . str_replace(" } else { $ds = "online"; $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, "https://api.wolframalpha.com/v1/result?appid=" . urlencode(trim(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/private/keys/wolfram"))) . "&i=" . urlencode($query)); + curl_setopt($ch, CURLOPT_URL, "https://api.wolframalpha.com/v1/result?appid=" . urlencode(trim(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/private/keys/wolfram"))) . "&i=" . urlencode($query) . "&units=metric&timeout=10"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); $data = curl_exec($ch); curl_close($ch); diff --git a/search/index.php b/search/index.php index 709a239..f2da683 100644 --- a/search/index.php +++ b/search/index.php @@ -218,7 +218,11 @@ $elapsed_io = microtime(true) - $start_io; ?>

results

-
+
+
+
Loading...
+
+
-- cgit