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", "user": "Deepjyoti",
"disableMessage": false, "disableMessage": false,
"disableDate": false "disableDate": false,
"disableSearchBar": false
} }

View File

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