-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcitizen.html
More file actions
194 lines (170 loc) · 7.5 KB
/
citizen.html
File metadata and controls
194 lines (170 loc) · 7.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Citizen Dashboard - Tide Tracker</title>
<!-- Google Fonts -->
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap" rel="stylesheet">
<!-- Font Awesome -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css" rel="stylesheet">
<!-- Leaflet CSS -->
<link rel="stylesheet" href="https://unpkg.com/leaflet/dist/leaflet.css" />
<style>
body { margin: 0; font-family: 'Poppins', sans-serif; background: linear-gradient(to bottom right, #023e8a, #0096c7, #48cae4); color: #fff; }
header { display: flex; justify-content: space-between; align-items: center; padding: 15px 30px; background: rgba(0,0,0,0.2); }
header .role { font-weight: 600; font-size: 18px; display: flex; align-items: center; gap: 10px; }
header .controls { display: flex; align-items: center; gap: 15px; }
header select, header button { padding: 8px 12px; border: none; border-radius: 8px; font-size: 14px; cursor: pointer; }
header button { background: #ff4d6d; color: white; font-weight: bold; }
header button:hover { background: #ff1a3c; }
.dashboard { display: grid; grid-template-columns: 1fr 2fr; padding: 20px; gap: 20px; }
.sidebar { display: flex; flex-direction: column; gap: 20px; }
.card { background: rgba(255,255,255,0.15); border-radius: 15px; padding: 20px; }
.map-card { grid-column: span 2; background: rgba(255,255,255,0.1); border-radius: 15px; padding: 20px; }
input, select, textarea { width: 100%; padding: 10px; border-radius: 8px; border: none; margin-top: 8px; font-size: 14px; }
textarea { resize: none; }
button { width: 100%; padding: 12px; background: #00b4d8; border: none; border-radius: 10px; color: white; font-size: 16px; font-weight: bold; cursor: pointer; margin-top: 10px; }
button:hover { background: #0077b6; }
.alerts { background: rgba(255,255,255,0.15); border-radius: 15px; padding: 15px; }
</style>
</head>
<body>
<header>
<div class="role"><i class="fas fa-user"></i> Citizen</div>
<div class="controls">
<select id="language">
<option>English</option>
<option>हिंदी</option>
<option>తెలుగు</option>
<option>தமிழ்</option>
<option>മലയാളം</option>
<option>ಕನ್ನಡ</option>
<option>বাংলা</option>
</select>
<button onclick="logout()"><i class="fas fa-sign-out-alt"></i> Logout</button>
</div>
</header>
<div class="dashboard">
<div class="sidebar">
<div class="card alerts">
<h3><i class="fas fa-bell"></i> Government Alerts</h3>
<p>⚠️ High waves expected in coastal Maharashtra.</p>
<p>⚠️ Tsunami warning issued for Andaman & Nicobar.</p>
</div>
<div class="card alerts">
<h3><i class="fas fa-info-circle"></i> Notifications</h3>
<p>📢 Please report unusual tide activity.</p>
<p>📢 Coastal safety awareness campaign this weekend.</p>
</div>
</div>
<div>
<div class="map-card">
<h2><i class="fas fa-map"></i> Hazard Heatmap</h2>
<div id="map" style="height:400px; border-radius:12px;"></div>
</div>
<div class="card">
<h2><i class="fas fa-exclamation-triangle"></i> Report Hazard</h2>
<form id="reportForm">
<div class="form-group">
<label><i class="fas fa-wave-square"></i> Event Type</label>
<select id="hazardType" required>
<option value="" disabled selected>Select Hazard</option>
<option value="Unusual tide">Unusual tide</option>
<option value="High waves">High waves</option>
<option value="Coastal flooding">Coastal flooding</option>
<option value="Debris/Damage">Debris/Damage</option>
<option value="Other">Other</option>
</select>
</div>
<div class="form-group">
<label><i class="fas fa-align-left"></i> Description</label>
<textarea id="description" rows="3" placeholder="Describe the hazard..." required></textarea>
</div>
<div class="form-group">
<label><i class="fas fa-map-marker-alt"></i> Location</label>
<input type="text" id="location" placeholder="Enter place name e.g. Mumbai" required>
</div>
<div class="form-group">
<label><i class="fas fa-upload"></i> Upload Image/File</label>
<input type="file" id="media" accept="image/*,video/*,.pdf,.doc,.docx">
</div>
<button type="submit">Submit Report</button>
</form>
</div>
</div>
</div>
<!-- Leaflet JS -->
<script src="https://unpkg.com/leaflet/dist/leaflet.js"></script>
<script src="https://unpkg.com/leaflet.heat/dist/leaflet-heat.js"></script>
<script>
function logout(){
window.location.href = "index.html";
}
let map = L.map('map').setView([20.5937, 78.9629], 5);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© OpenStreetMap contributors' }).addTo(map);
let heatPoints = [];
let heat = L.heatLayer(heatPoints, {radius: 25, blur: 15, maxZoom: 17}).addTo(map);
document.getElementById("reportForm").addEventListener("submit", function(e){
e.preventDefault();
let hazardType = document.getElementById("hazardType").value;
let description = document.getElementById("description").value;
let locationName = document.getElementById("location").value;
let mediaFile = document.getElementById("media").files[0];
// Geocode location name → lat,lng
fetch(`https://nominatim.openstreetmap.org/search?format=json&q=${locationName}`)
.then(response => response.json())
.then(data => {
if(data.length === 0){
alert("Location not found. Please enter a valid place.");
return;
}
let lat = parseFloat(data[0].lat);
let lng = parseFloat(data[0].lon);
let now = new Date();
let date = now.toLocaleDateString();
let time = now.toLocaleTimeString();
let mediaHTML = "";
if(mediaFile){
const reader = new FileReader();
reader.onload = function(event){
const fileData = event.target.result;
if(mediaFile.type.startsWith("image")){
mediaHTML = `<br><b>Media:</b><br><img src="${fileData}" style="width:200px; border-radius:8px;">`;
} else if(mediaFile.type.startsWith("video")){
mediaHTML = `<br><b>Media:</b><br><video width="200" controls><source src="${fileData}"></video>`;
} else {
mediaHTML = `<br><b>File:</b> ${mediaFile.name}`;
}
showMarker(lat, lng, hazardType, description, date, time, locationName, mediaHTML);
};
reader.readAsDataURL(mediaFile);
} else {
showMarker(lat, lng, hazardType, description, date, time, locationName, mediaHTML);
}
})
.catch(error => {
console.error("Geocoding error:", error);
alert("Error finding location.");
});
});
function showMarker(lat, lng, hazardType, description, date, time, locationName, mediaHTML){
let popupContent = `
<b>Hazard Type:</b> ${hazardType}<br>
<b>Description:</b> ${description}<br>
<b>Date:</b> ${date}<br>
<b>Time:</b> ${time}<br>
<b>Location:</b> ${locationName}
${mediaHTML}
`;
let marker = L.marker([lat, lng]).addTo(map);
marker.bindPopup(popupContent).openPopup();
map.setView([lat, lng], 10);
heatPoints.push([lat, lng, 0.8]);
heat.setLatLngs(heatPoints);
alert("Hazard report submitted successfully!");
document.getElementById("reportForm").reset();
}
</script>
</body>
</html>