eversync/weather_pick.html
2025-06-02 21:24:23 +02:00

130 lines
5.7 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Eversync</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css">
{% load static %}
<link rel="icon" href="{% static 'favicon.ico' %}">
<link rel="stylesheet" href="{% static 'index-style.css' %}" ">
{% block scripts %}
{% include "sentry_replay.html" %}
{% endblock %}
</head>
</head>
<body>
<div class="header">
<div class="header-content">
<a href="/"><img src="{% static 'eversync2.png' %}" alt="Eversync Logo" style="height: 80px; margin-right: 10px; display: flex; align-items: center; gap: 5px;"></a>
<a href="/" class="logo" >eversync</a>
<div class="nav-links" style="position: relative;">
<div class="dropdown">
<button class="dropdown-toggle" style="background: none; border: none; color: white; font-size: 16px; cursor: pointer;">
Welcome, {{ user.username }} <i class="fas fa-caret-down"></i>
</button>
<div class="dropdown-menu" style="display: none; position: absolute; right: 0; background-color: #333; border: 1px solid #444; border-radius: 4px; padding: 10px; width: 184px;">
<form action="{% url 'manage' %}" method="post" style="margin: 0;">
{% csrf_token %}
<button type="submit" class="logout-button" style="background-color: transparent; color: white; border: none; cursor: pointer;">Manage Account</button>
</form>
<form action="{% url 'logoutz' %}" method="post" style="margin: 0;">
{% csrf_token %}
<button type="submit" class="logout-button" style="background-color: transparent; color: white; border: none; cursor: pointer;">Log Out</button>
</form>
<button id="themeToggle" class="logout-button" style="background-color: transparent; color: white; border: none; cursor: pointer;">Toggle Dark Mode</button>
</div>
</div>
</div>
</div>
</div>
<div class="container">
<form onsubmit="event.preventDefault(); loadWeather();">
<input type="text" id="location-input" placeholder="Enter a location..." required style="padding: 10px; width: 100%; border-radius: 5px; border: none; margin-bottom: 10px;">
<button type="submit" style="padding: 10px 20px; border-radius: 5px; border: none; background-color: #4facfe; color: white; font-weight: bold;">Check Weather</button>
<button type="button" onclick="getLocation()" class="location-btn" style="padding: 10px 20px; border-radius: 5px; border: none; background-color: #4facfe; color: white; font-weight: bold;">
<i class="fas fa-location-arrow"></i> Use current location
</button>
<script>
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(success, error, {
enableHighAccuracy: true,
timeout: 10000,
maximumAge: 0
});
} else {
alert("Geolocation is not supported by your browser.");
}
}
function success(position) {
const lat = position.coords.latitude;
const lon = position.coords.longitude;
const accuracy = position.coords.accuracy;
document.getElementById("location-input").value = String(lat) + ',' + String(lon);
if (accuracy > 1000) {
alert("Warning: Your location is not very precise (" + Math.round(accuracy) + " meters). Please enter your location manually for better results.");
}
}
function error() {
alert("Error.");
}
</script>
</form>
<iframe id="weather-frame" src="" style="width: 100%; height: 800px; border: none; margin-top: 20px; display: none; border-radius: 12px;"></iframe>
<script>
function loadWeather() {
const location = document.getElementById('location-input').value.trim();
if (location) {
const iframe = document.getElementById('weather-frame');
iframe.src = `/weather/${encodeURIComponent(location)}/`;
iframe.style.display = 'block';
}
}
</script>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function () {
const toggle = document.querySelector('.dropdown-toggle');
const menu = document.querySelector('.dropdown-menu');
toggle.addEventListener('click', function () {
menu.style.display = menu.style.display === 'block' ? 'none' : 'block';
});
});
const toggle = document.getElementById("themeToggle");
const root = document.documentElement;
if (localStorage.getItem("theme") === "dark") {
root.classList.add("dark");
}
toggle.addEventListener("click", () => {
root.classList.toggle("dark");
if (root.classList.contains("dark")) {
localStorage.setItem("theme", "dark");
} else {
localStorage.setItem("theme", "light");
}
});
</script>
</body>
</html>