Changed around line 1
+ document.addEventListener('DOMContentLoaded', () => {
+ const cities = {
+ manila: {
+ timezone: 'Asia/Manila',
+ coords: { lat: 14.5995, lon: 120.9842 }
+ },
+ newyork: {
+ timezone: 'America/New_York',
+ coords: { lat: 40.7128, lon: -74.0060 }
+ },
+ london: {
+ timezone: 'Europe/London',
+ coords: { lat: 51.5074, lon: -0.1278 }
+ }
+ };
+
+ function updateTime() {
+ Object.keys(cities).forEach(city => {
+ const timeElement = document.querySelector(`#${city} .time`);
+ const time = new Date().toLocaleTimeString('en-US', {
+ timeZone: cities[city].timezone,
+ hour12: true,
+ hour: 'numeric',
+ minute: '2-digit'
+ });
+ timeElement.textContent = time;
+ });
+ }
+
+ function updateWeather() {
+ Object.keys(cities).forEach(city => {
+ const tempElement = document.querySelector(`#${city} .temperature`);
+ const condElement = document.querySelector(`#${city} .condition`);
+
+ // Simulate weather data (replace with actual API calls in production)
+ const temp = Math.floor(Math.random() * 30) + 10;
+ const conditions = ['Sunny', 'Cloudy', 'Rainy', 'Partly Cloudy'];
+ const condition = conditions[Math.floor(Math.random() * conditions.length)];
+
+ tempElement.textContent = `${temp}°C`;
+ condElement.textContent = condition;
+ });
+ }
+
+ // Update time every second
+ updateTime();
+ setInterval(updateTime, 1000);
+
+ // Update weather every 5 minutes
+ updateWeather();
+ setInterval(updateWeather, 300000);
+ });