Skip to content

Commit f4b76f7

Browse files
committed
Proper project setup done.
Signed-off-by: Someshdiwan <[email protected]>
1 parent d0a68c1 commit f4b76f7

File tree

1 file changed

+12
-26
lines changed

1 file changed

+12
-26
lines changed

site/_layouts/default.html

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@
6565
}
6666
</script>
6767

68-
6968
<script>
70-
// Update Live Time
7169
function updateLiveTime() {
7270
const now = new Date();
7371
let hours = now.getHours();
@@ -76,51 +74,39 @@
7674
const ampm = hours >= 12 ? 'PM' : 'AM';
7775
hours = hours % 12 || 12;
7876
const timeString = `${hours}:${minutes}:${seconds} ${ampm}`;
79-
80-
const offset = now.getTimezoneOffset();
81-
const offsetHours = Math.floor(Math.abs(offset) / 60);
82-
const offsetMinutes = Math.abs(offset) % 60;
83-
const offsetSign = offset > 0 ? '-' : '+';
84-
const offsetString = `GMT${offsetSign}${offsetHours.toString().padStart(2, '0')}:${offsetMinutes.toString().padStart(2, '0')}`;
85-
86-
document.getElementById('live-time').textContent = `Time: ${timeString} ${offsetString}`;
77+
document.getElementById('live-time').textContent = `Time: ${timeString}`;
8778
}
8879

89-
// Fetch and Display User Location using OpenStreetMap API
9080
function fetchUserLocation() {
9181
if (!navigator.geolocation) {
92-
document.getElementById('user-location').textContent = '📍 Location not supported';
82+
document.getElementById('user-location').textContent = 'Location: Not supported';
9383
return;
9484
}
9585

9686
navigator.geolocation.getCurrentPosition(position => {
9787
const { latitude, longitude } = position.coords;
98-
// Using OpenStreetMap's Nominatim API for reverse geocoding:
9988
fetch(`https://nominatim.openstreetmap.org/reverse?format=jsonv2&lat=${latitude}&lon=${longitude}`)
100-
.then(response => response.json())
89+
.then(res => res.json())
10190
.then(data => {
102-
const city = data.address.city || data.address.town || data.address.village || "Unknown City";
103-
const country = data.address.country || "Unknown Country";
104-
document.getElementById('user-location').textContent = `📍 Location: ${city}, ${country}`;
91+
const city = data.address.city || data.address.town || data.address.village || "Unknown";
92+
const country = data.address.country || "Unknown";
93+
document.getElementById('user-location').textContent = `Location: ${city}, ${country}`;
10594
})
10695
.catch(() => {
107-
document.getElementById('user-location').textContent = '📍 Location unavailable';
96+
document.getElementById('user-location').textContent = 'Location: Unavailable';
10897
});
10998
}, () => {
110-
document.getElementById('user-location').textContent = '📍 Location permission denied';
99+
document.getElementById('user-location').textContent = 'Location: Permission denied';
111100
});
112101
}
113102

114-
// Initialize functions on load
115-
window.onload = () => {
103+
window.addEventListener('DOMContentLoaded', () => {
116104
updateLiveTime();
117-
setInterval(updateLiveTime, 1000); // Update every second
105+
setInterval(updateLiveTime, 1000);
118106
fetchUserLocation();
119-
};
107+
});
120108
</script>
121109

122110
</div>
123111
</body>
124-
</html>
125-
126-
112+
</html>

0 commit comments

Comments
 (0)