Merge branch 'master' of github.com:deepjyoti30/startpage

This commit is contained in:
deepjyoti30
2020-05-14 18:12:25 +05:30
2 changed files with 7 additions and 22 deletions

View File

@@ -33,5 +33,6 @@
"user": "Deepjyoti", "user": "Deepjyoti",
"disableMessage": false, "disableMessage": false,
"disableDate": false, "disableDate": false,
"disableSearchBar": false "disableSearchBar": false,
"disable24Hour": false
} }

View File

@@ -10,6 +10,7 @@ dateId = "date-text"
messageId = "message-text" messageId = "message-text"
otherContentId = "other-content" otherContentId = "other-content"
userName = "Deepjyoti" userName = "Deepjyoti"
disable24Hour = false;
bgClassContainer = [ bgClassContainer = [
"media", "media",
"work", "work",
@@ -21,21 +22,6 @@ bgClassContainer = [
"indigo", "indigo",
"foxxy" "foxxy"
] ]
dateMap = {
0: "Jan",
1: "Feb",
2: "Mar",
3: "Apr",
4: "May",
5: "Jun",
6: "Jul",
7: "Aug",
8: "Sep",
9: "Oct",
10: "Nov",
11: "Dec"
}
searchEngines = { searchEngines = {
"Google": "https://www.google.com/search?q=", "Google": "https://www.google.com/search?q=",
"DuckDuckGo": "https://duckduckgo.com/?q=", "DuckDuckGo": "https://duckduckgo.com/?q=",
@@ -118,11 +104,7 @@ function updateTime() {
* Get the current time and date and return it. * Get the current time and date and return it.
*/ */
currentDate = new Date() currentDate = new Date()
date = currentDate.getDate() finalDate = currentDate.toLocaleString(undefined, {day:'numeric', month:'short', hour:'numeric', minute:'numeric',hour12:disable24Hour})
month = dateMap[currentDate.getMonth()]
minutes = currentDate.getMinutes()
time = currentDate.getHours() + ":" + (minutes < 10 ? "0" + minutes : minutes)
finalDate = date + " " + month + ", " + time
document.getElementById(dateId).textContent = finalDate document.getElementById(dateId).textContent = finalDate
} }
@@ -157,7 +139,8 @@ function parseAndCreate(jsonData) {
builtMsg == "" ? builtMsg == "" ?
builtMsg = `Hello ${this.userName}` : builtMsg = `Hey ${this.userName}, ${builtMsg}!` builtMsg = `Hello ${this.userName}` : builtMsg = `Hey ${this.userName}, ${builtMsg}!`
document.getElementById(messageId).textContent = builtMsg document.getElementById(messageId).textContent = builtMsg
// Check if 24 hour is disabled
disable24Hour = jsonData["disable24Hour"]
// Check if welcome message is supposed to be disabled // Check if welcome message is supposed to be disabled
if (jsonData["disableMessage"]) if (jsonData["disableMessage"])
document.getElementById(messageDivId).style.display = "none" document.getElementById(messageDivId).style.display = "none"
@@ -177,6 +160,7 @@ function parseAndCreate(jsonData) {
sqr = createSqr(element, index) sqr = createSqr(element, index)
document.getElementById(otherContentId).appendChild(sqr) document.getElementById(otherContentId).appendChild(sqr)
}) })
} }
function createSqr(sqrData, index) { function createSqr(sqrData, index) {