-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathraise complaint mb (1).html
170 lines (150 loc) · 6.18 KB
/
raise complaint mb (1).html
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
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
<script src="https://kit.fontawesome.com/c81e574e1d.js" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx" crossorigin="anonymous"></script>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Raise a Complaint - Municipality</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 0;
}
.container {
width: 80%;
margin: auto;
padding: 20px;
background-color: white;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
border-radius: 8px;
margin-top: 50px;
}
h2 {
text-align: center;
}
label {
display: block;
margin-top: 10px;
font-weight: bold;
}
input, textarea, button, select {
width: 100%;
padding: 10px;
margin: 10px 0;
border: 1px solid #ccc;
border-radius: 4px;
}
button {
background-color: #4CAF50;
color: white;
cursor: pointer;
}
button:hover {
background-color: #45a049;
}
.camera-preview {
width: 100%;
max-height: 300px;
object-fit: cover;
margin-bottom: 10px;
}
</style>
</head>
<body>
<div class="container">
<h2>Raise a Complaint</h2>
<!-- Geolocation Section -->
<form action="/sumbit" method="post"><label for="location">Location (Automatically Tagged):</label>
<input type="text" id="location" placeholder="Fetching your location..." readonly>
<button id="getLocation">Get My Location</button>
<!-- Camera Capture Section -->
<label for="camera">Capture an Image of the Issue:</label>
<video id="cameraStream" class="camera-preview" autoplay></video>
<button id="captureImage">Capture Image</button>
<canvas id="cameraOutput" class="camera-preview" style="display:none;"></canvas>
<!-- Camera Switcher -->
<label for="cameraSwitch">Select Camera:</label>
<select id="cameraSwitch">
<option value="environment">Rear Camera</option>
<option value="user">Front Camera</option>
</select>
<!-- Upload Image -->
<label for="imageUpload">Or Upload an Image:</label>
<input type="file" id="imageUpload" accept="image/*">
<!-- Description -->
<label for="description">Description:</label>
<textarea id="description" rows="4" placeholder="Describe the issue..."></textarea>
<!-- Submit Button -->
<button id="submitComplaint">Submit Complaint</button></form>
<a href="ecosweep.html"><button>Back</button></a></div>
</div>
<script>
// Geolocation
const getLocationButton = document.getElementById('getLocation');
const locationInput = document.getElementById('location');
getLocationButton.addEventListener('click', () => {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition((position) => {
const { latitude, longitude } = position.coords;
locationInput.value = `Lat: ${latitude}, Long: ${longitude}`;
}, () => {
locationInput.value = "Unable to fetch location.";
});
} else {
locationInput.value = "Geolocation is not supported by this browser.";
}
});
// Camera Access Variables
let stream;
const cameraStream = document.getElementById('cameraStream');
const cameraOutput = document.getElementById('cameraOutput');
const captureButton = document.getElementById('captureImage');
const canvas = cameraOutput.getContext('2d');
const cameraSwitch = document.getElementById('cameraSwitch');
// Function to access the selected camera
function accessCamera(facingMode) {
if (stream) {
stream.getTracks().forEach(track => track.stop());
}
const constraints = {
video: { facingMode: facingMode }
};
navigator.mediaDevices.getUserMedia(constraints)
.then(function (mediaStream) {
stream = mediaStream;
cameraStream.srcObject = mediaStream;
cameraStream.play();
})
.catch(function (err) {
console.error("Error accessing camera: " + err);
});
}
// Initialize with front camera by default
accessCamera('environment');
// Event listener to switch between front and rear cameras
cameraSwitch.addEventListener('change', () => {
accessCamera(cameraSwitch.value);
});
// Capture Image
captureButton.addEventListener('click', () => {
cameraOutput.width = cameraStream.videoWidth;
cameraOutput.height = cameraStream.videoHeight;
canvas.drawImage(cameraStream, 0, 0, cameraOutput.width, cameraOutput.height);
cameraOutput.style.display = 'block';
cameraStream.style.display = 'none';
});
// Submit Complaint (Just a mockup of submission)
const submitButton = document.getElementById('submitComplaint');
submitButton.addEventListener('click', () => {
const description = document.getElementById('description').value;
const location = locationInput.value;
alert(`Complaint submitted!\nLocation: ${location}\nDescription: ${description}`);
});
</script>
</body>
</html>