Moved hardcoded URL's to main.js instead of config.
This commit is contained in:
@@ -29,13 +29,7 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"searchEngines":{
|
"searchEngine":"Yahoo",
|
||||||
"Google":"https://www.google.com/search?q=",
|
|
||||||
"DuckDuckGo":"https://duckduckgo.com/?q=",
|
|
||||||
"Bing":"https://www.bing.com/search?q=",
|
|
||||||
"Yahoo":"https://search.yahoo.com/search?p="
|
|
||||||
},
|
|
||||||
"searchEngine":"Google",
|
|
||||||
"user": "Deepjyoti",
|
"user": "Deepjyoti",
|
||||||
"disableMessage": false,
|
"disableMessage": false,
|
||||||
"disableDate": false,
|
"disableDate": false,
|
||||||
|
|||||||
11
js/main.js
11
js/main.js
@@ -36,6 +36,13 @@ dateMap = {
|
|||||||
11: "Dec"
|
11: "Dec"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
searchEngines = {
|
||||||
|
"Google": "https://www.google.com/search?q=",
|
||||||
|
"DuckDuckGo": "https://duckduckgo.com/?q=",
|
||||||
|
"Bing": "https://www.bing.com/search?q=",
|
||||||
|
"Yahoo": "https://search.yahoo.com/search?p="
|
||||||
|
}
|
||||||
|
|
||||||
function initBody() {
|
function initBody() {
|
||||||
/**
|
/**
|
||||||
* Function called when the body is loaded.
|
* Function called when the body is loaded.
|
||||||
@@ -52,10 +59,10 @@ function initSearchBar(jsonData) {
|
|||||||
document.getElementById(searchBarId).value = ""
|
document.getElementById(searchBarId).value = ""
|
||||||
document.getElementById(searchBarId).focus()
|
document.getElementById(searchBarId).focus()
|
||||||
searchEngine = jsonData["searchEngine"]
|
searchEngine = jsonData["searchEngine"]
|
||||||
if(!Object.keys(jsonData["searchEngines"]).includes(searchEngine)){
|
if(!Object.keys(this.searchEngines).includes(searchEngine)){
|
||||||
searchEngine = "Google"
|
searchEngine = "Google"
|
||||||
}
|
}
|
||||||
searchUrl = jsonData["searchEngines"][searchEngine]
|
searchUrl = this.searchEngines[searchEngine]
|
||||||
document.getElementById(searchBarId).placeholder = `Search something on ${searchEngine}`
|
document.getElementById(searchBarId).placeholder = `Search something on ${searchEngine}`
|
||||||
document.getElementById(searchBarId).addEventListener("keypress", (event) => {
|
document.getElementById(searchBarId).addEventListener("keypress", (event) => {
|
||||||
if (event.key != 'Enter') return
|
if (event.key != 'Enter') return
|
||||||
|
|||||||
Reference in New Issue
Block a user