Made search bar optional as well.
This commit is contained in:
@@ -31,5 +31,6 @@
|
|||||||
],
|
],
|
||||||
"user": "Deepjyoti",
|
"user": "Deepjyoti",
|
||||||
"disableMessage": false,
|
"disableMessage": false,
|
||||||
"disableDate": false
|
"disableDate": false,
|
||||||
|
"disableSearchBar": false
|
||||||
}
|
}
|
||||||
|
|||||||
14
js/main.js
14
js/main.js
@@ -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"]
|
||||||
|
|||||||
Reference in New Issue
Block a user