Added option to search only via GET request (#36)

This addresses #18, which brought up the issue of searching with Whoogle
with the search instance set to always use a specific container in
Firefox Container Tabs.

Could also be useful if you want to share your search results or
something, I guess. Though nobody likes when people do that.
This commit is contained in:
Ben Busby
2020-05-13 00:19:51 -06:00
committed by GitHub
parent db7cf7381b
commit f4bd3df2bb
5 changed files with 26 additions and 15 deletions
+14 -11
View File
@@ -13,9 +13,16 @@ const setupSearchLayout = () => {
searchBtn.click();
}
});
}
};
const fillConfigValues = () => {
// Establish all config value elements
const near = document.getElementById("config-near");
const noJS = document.getElementById("config-nojs");
const dark = document.getElementById("config-dark");
const url = document.getElementById("config-url");
const getOnly = document.getElementById("config-get-only");
const fillConfigValues = (near, nojs, dark, url) => {
// Request existing config info
let xhrGET = new XMLHttpRequest();
xhrGET.open("GET", "/config");
@@ -29,15 +36,16 @@ const fillConfigValues = (near, nojs, dark, url) => {
let configSettings = JSON.parse(xhrGET.responseText);
near.value = configSettings["near"] ? configSettings["near"] : "";
nojs.checked = !!configSettings["nojs"];
noJS.checked = !!configSettings["nojs"];
dark.checked = !!configSettings["dark"];
getOnly.checked = !!configSettings["get_only"];
// Addresses the issue of incorrect URL being used behind reverse proxy
url.value = configSettings["url"] ? configSettings["url"] : "";
};
xhrGET.send();
}
};
const setupConfigLayout = () => {
// Setup whoogle config
@@ -54,13 +62,8 @@ const setupConfigLayout = () => {
content.classList.toggle("open");
});
const near = document.getElementById("config-near");
const noJS = document.getElementById("config-nojs");
const dark = document.getElementById("config-dark");
const url = document.getElementById("config-url");
fillConfigValues(near, noJS, dark, url);
}
fillConfigValues();
};
document.addEventListener("DOMContentLoaded", function() {
setTimeout(function() {