-
Notifications
You must be signed in to change notification settings - Fork 0
/
reportform.html
114 lines (108 loc) · 4.58 KB
/
reportform.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
<!DOCTYPE html>
<html>
<head>
<title>Report Form</title>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
<link rel="stylesheet" href="./site.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<script type='text/javascript' src='https://www.bing.com/api/maps/mapcontrol?key=AqYrASjV1i2G7IMFhw78XLFj7xF-eS_JBvp6k5waGaK1qpmbAq2MvBYB2VeH_4mc&callback=loadMapScenario' async defer></script>
</head>
<body id="reportFormBody">
<div class="container">
<h1>Report Incident Form</h1>
<h5>Please note that your information will remain confidential and annoymous.</h5>
<form onsubmit="return false">
<div class="form-group">
<label for="inputName">Your Name (Optional)</label>
<input type="text" class="form-control" id="inputName">
</div>
<div class="form-group">
<label for="inputPhoneNumber">Phone Number</label>
<input type="tel" class="form-control" id="inputPhoneNumber">
</div>
<div class="form-group">
<label for="inputIncident">Type of Incident</label>
<select class="form-control" id="inputIncident">
<option selected></option>
<option value="homophobic-incident">Homophobic Incident</option>
<option value="theft">Theft</option>
<option value="fight">Physical Fight</option>
<option value="bullying">Bullying</option>
<option value="sexual-assult">Sexual Assult</option>
</select>
</div>
<div class="form-group">
<label for="inputIncidentDate">Date and Time of Incident</label>
<input class="form-control" type="date" id="inputIncidentDate">
</div>
<div class="form-group">
<label for="inputIncident">Location of Incident</label>
<div id="printoutPanel"></div>
<div id="locationSearchBoxContainer">
<input type="text" id="locationSearchBox" class="form-control"/>
</div>
<div id="myMap"></div>
</div>
<div class="form-group">
<label for="inputVictimDescription">Victim Description</label>
<textarea class="form-control" id="inputVictimDescription" rows="3"></textarea>
</div>
<div class="form-group">
<label for="inputIncidentDescription">Description of Incident</label>
<textarea class="form-control" id="inputIncidentDescription" rows="3"></textarea>
</div>
<div class="form-group">
<label for="inputIncidentFile">Photos or Video of Incident</label>
<input type="file" class="form-control-file" id="inputIncidentFile">
</div>
<button id="submitBtn" class="btn btn-primary">Submit</button>
</form>
</div>
</body>
<script type='text/javascript'>
function loadMapScenario() {
Microsoft.Maps.loadModule('Microsoft.Maps.AutoSuggest', {
callback: onLoad,
errorCallback: onError
});
function onLoad() {
var options = { maxResults: 5 };
var manager = new Microsoft.Maps.AutosuggestManager(options);
manager.attachAutosuggest('#locationSearchBox', '#locationSearchBoxContainer');
}
function onError(message) {
document.getElementById('printoutPanel').innerHTML = message;
}
}
function handleSubmit() {
var formData = {
"description": $("#inputIncidentDescription").text(),
"date": $("#inputIncidentDate").text(),
"type": $( "#inputIncident option:selected" ).text(),
"latitude": suggestionResult.location.latitude,
"location_name": suggestionResult.formattedSuggestion,
"longitud": suggestionResult.location.longitude,
"victim_description": $("#inputVictimDescription").text(),
"phone_number": $("#inputPhoneNumber").text()
};
$.ajax({
url: "http://safety-hack.herokuapp.com/swagger-ui.html/api/createReport",
type: "POST",
headers: {
"Content-Type": "application/json"
},
data: JSON.stringify(formData),
success: function(result){
console.log(result);
},
error: function (request, status, error) {
console.log(request.responseText);
}
})
}
const form = document.querySelector('form');
console.log(form)
form.addEventListener('submit', handleSubmit);
</script>
</html>