Made search bar optional as well.

This commit is contained in:
deepjyoti30
2020-05-13 12:49:29 +05:30
parent 2f140d680a
commit dacf4cff22
2 changed files with 13 additions and 4 deletions

View File

@@ -31,5 +31,6 @@
],
"user": "Deepjyoti",
"disableMessage": false,
"disableDate": false
"disableDate": false,
"disableSearchBar": false
}

View File

@@ -2,6 +2,7 @@ window.onload = function() {
this.initBody()
}
searchBarDivId = "search-bar"
searchBarId = "search-bar-input"
messageDivId = "message"
dateDivId = "date"
@@ -42,11 +43,14 @@ function initBody() {
* Do everything like adding an event listener to
* other things.
*/
// Clear the search bar on load, just in case
document.getElementById(searchBarId).value = ""
// Read the json file
json = readJSON("config.json")
}
function initSearchBar() {
// Clear the search bar on load, just in case
document.getElementById(searchBarId).value = ""
document.getElementById(searchBarId).focus()
document.getElementById(searchBarId).addEventListener("keypress", (event) => {
if (event.key != 'Enter') return
@@ -143,6 +147,10 @@ function parseAndCreate(jsonData) {
document.getElementById(dateDivId).style.display = "none"
else
updateTimeHook()
if (jsonData["disableSearchBar"])
document.getElementById(searchBarDivId).style.display = "none"
else
initSearchBar()
sqrs = jsonData["squares"]