Added date to the startpage and option to disable it.

This commit is contained in:
deepjyoti30
2020-05-13 11:57:16 +05:30
parent 8babc4becc
commit 4a50ac0d42
21 changed files with 74 additions and 10 deletions

View File

@@ -30,5 +30,6 @@
} }
], ],
"user": "Deepjyoti", "user": "Deepjyoti",
"disableMessage": true "disableMessage": false,
"disableDate": false
} }

View File

@@ -1,7 +1,14 @@
@import url("https://fonts.googleapis.com/css2?family=Roboto&display=swap"); @import url("https://fonts.googleapis.com/css2?family=Roboto&display=swap");
.roboto, body { .roboto {
font-family: 'Roboto', sans-serif; } font-family: 'Roboto', sans-serif; }
@font-face {
font-family: "JetBrains Mono";
src: url("../fonts/woff/JetBrainsMono-Regular.woff") format("woff"), url("../fonts/woff2/JetBrainsMono-Regular.woff2") format("woff2"); }
.jetbrains-mono, body {
font-family: 'JetBrains Mono'; }
body { body {
height: 97.5vh; height: 97.5vh;
display: flex; display: flex;
@@ -13,12 +20,14 @@ body {
.main { .main {
width: 100%; width: 100%;
text-align: center; } text-align: center; }
.main #message { .main #date-text {
padding-bottom: 35px; } padding-top: 15px;
color: #d9d9d9; }
.main #search-bar { .main #search-bar {
width: 50%; width: 50%;
margin: 0 auto 50px auto; margin: 0 auto 50px auto;
height: 45px; } height: 45px;
padding-top: 35px; }
.main #search-bar input { .main #search-bar input {
height: inherit; height: inherit;
width: 100%; width: 100%;

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -12,6 +12,9 @@
<div id="message"> <div id="message">
<h1 id="message-text">Hey Deepjyoti, Good Morning!</h1> <h1 id="message-text">Hey Deepjyoti, Good Morning!</h1>
</div> </div>
<div id="date">
<h2 id="date-text">13 May, 11:30</h2>
</div>
<div id="search-bar"> <div id="search-bar">
<input id="search-bar-input" placeholder="Search something on Google"></input> <input id="search-bar-input" placeholder="Search something on Google"></input>
</div> </div>

View File

@@ -4,6 +4,8 @@ window.onload = function() {
searchBarId = "search-bar-input" searchBarId = "search-bar-input"
messageDivId = "message" messageDivId = "message"
dateDivId = "date"
dateId = "date-text"
messageId = "message-text" messageId = "message-text"
otherContentId = "other-content" otherContentId = "other-content"
userName = "Deepjyoti" userName = "Deepjyoti"
@@ -13,6 +15,20 @@ bgClassContainer = [
"social", "social",
"others" "others"
] ]
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"
}
function initBody() { function initBody() {
/** /**
@@ -70,6 +86,25 @@ function buildMsg() {
return "" return ""
} }
function updateTime() {
/**
* Get the current time and date and return it.
*/
currentDate = new Date()
date = currentDate.getDate()
month = dateMap[currentDate.getMonth()]
time = currentDate.getHours() + ":" + currentDate.getMinutes()
finalDate = date + " " + month + ", " + time
document.getElementById(dateId).textContent = finalDate
}
function updateTimeHook() {
updateTime()
interval = setInterval(() => {
updateTime()
}, 30 * 1000)
}
function inRange(number, min, max) { function inRange(number, min, max) {
return (number >= min && number <= max) return (number >= min && number <= max)
} }
@@ -96,9 +131,12 @@ function parseAndCreate(jsonData) {
document.getElementById(messageId).textContent = builtMsg document.getElementById(messageId).textContent = builtMsg
// Check if welcome message is supposed to be disabled // Check if welcome message is supposed to be disabled
disableMsg = jsonData["disableMessage"] if (jsonData["disableMessage"])
if (disableMsg)
document.getElementById(messageDivId).style.display = "none" document.getElementById(messageDivId).style.display = "none"
if (jsonData["disableDate"])
document.getElementById(dateDivId).style.display = "none"
else
updateTimeHook()
sqrs = jsonData["squares"] sqrs = jsonData["squares"]

View File

@@ -10,6 +10,17 @@ $others: #81C784;
font-family: 'Roboto', sans-serif; font-family: 'Roboto', sans-serif;
} }
// JetBrains Mono
@font-face {
font-family: "JetBrains Mono";
src: url("../fonts/woff/JetBrainsMono-Regular.woff") format("woff"),
url("../fonts/woff2/JetBrainsMono-Regular.woff2") format("woff2");
}
.jetbrains-mono {
font-family: 'JetBrains Mono';
}
body { body {
height: 97.5vh; height: 97.5vh;
display: flex; display: flex;
@@ -17,21 +28,23 @@ body {
justify-content: center; justify-content: center;
background: $background; background: $background;
color: $foreground; color: $foreground;
@extend .roboto; @extend .jetbrains-mono;
} }
.main { .main {
width: 100%; width: 100%;
text-align: center; text-align: center;
#message { #date-text {
padding-bottom: 35px; padding-top: 15px;
color: darken($foreground, 15);
} }
#search-bar { #search-bar {
width: 50%; width: 50%;
margin: 0 auto 50px auto; margin: 0 auto 50px auto;
height: 45px; height: 45px;
padding-top: 35px;
input { input {
height: inherit; height: inherit;