Skip to content

Commit dd30551

Browse files
author
Son Nguyen
committed
Updated frontend logic
1 parent 1e81bf3 commit dd30551

File tree

4 files changed

+35
-1
lines changed

4 files changed

+35
-1
lines changed

index.html

+5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ <h1 id="my-heading" style="margin-bottom: -10px">
2727
The Mo<span class="highlight">vieV</span>erse
2828
</h1>
2929

30+
<div>
31+
<p id="time-label">Local Time:</p>
32+
<h1 id="clock" class="clock"></h1>
33+
</div>
34+
3035
<!-- Create a button to toggle the side navigation bar -->
3136
<button id="nav-toggle" class="nav-toggle" title="Toggle Side Navbar" onclick="toggleNav()">
3237
<i class="fas fa-bars"></i>

movie-details.js

-1
Original file line numberDiff line numberDiff line change
@@ -377,5 +377,4 @@ async function showMovieOfTheDay(){
377377
console.error('Error fetching movie:', error);
378378
alert('Failed to fetch the movie of the day. Please try again later.');
379379
}
380-
381380
}

script.js

+20
Original file line numberDiff line numberDiff line change
@@ -1274,5 +1274,25 @@ function showMoviesDirectorSpotlight(movies) {
12741274

12751275
main20.appendChild(movieE1);
12761276
});
1277+
}
1278+
1279+
function updateClock() {
1280+
var now = new Date();
1281+
var hours = now.getHours();
1282+
var minutes = now.getMinutes();
1283+
1284+
// Add leading zero to minutes if less than 10
1285+
minutes = minutes < 10 ? '0' + minutes : minutes;
12771286

1287+
// Format the time in HH:MM format
1288+
var timeString = hours + ':' + minutes;
1289+
1290+
// Update the clock element
1291+
document.getElementById('clock').innerHTML = timeString;
12781292
}
1293+
1294+
// Update the clock every second
1295+
setInterval(updateClock, 1000);
1296+
1297+
// Initialize the clock on page load
1298+
window.onload = updateClock;

style.css

+10
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,16 @@ p {
705705
margin: 10px auto;
706706
}
707707

708+
.clock {
709+
text-align: center;
710+
font-size: 20px;
711+
color: #ff8623;
712+
}
713+
714+
#time-label {
715+
color: #ff8623;
716+
}
717+
708718
.app-btn:hover {
709719
background-color: #ff8623;
710720
}

0 commit comments

Comments
 (0)