-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgsurvey.php
344 lines (262 loc) · 10.2 KB
/
gsurvey.php
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Spørgeskema om dit nabolag</title>
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true&libraries=drawing"></script>
<script>
var map;
var drawingManager;
var selectedShape;
var DKcentercoords = new google.maps.LatLng(56.1, 10.6);
var polyPoints = [];
var form = document.getElementById("questions");
//This variable gets all coordinates of polygone and save them. Finally you should use this array because it contains all latitude and longitude coordinates of polygon.
var coordinates = [];
//This variable saves polygon.
var polygons = [];
function clearSelection() {
if (selectedShape) {
selectedShape.setEditable(false);
selectedShape = null;
}
}
function setSelection(shape) {
clearSelection();
selectedShape = shape;
shape.setEditable(true);
// selectColor(shape.get('fillColor') || shape.get('strokeColor'));
}
function deleteSelectedShape() {
if (selectedShape) {
selectedShape.setMap(null);
}
// To show:
drawingManager.setOptions({
drawingControl: true
});
}
function initialize() {
var mapOptions = {
center: DKcentercoords,
zoom: 7,
mapTypeId: google.maps.MapTypeId.ROADMAP,
disableDefaultUI: true,
zoomControl: true
};
map = new google.maps.Map(document.getElementById('clickingmap'),
mapOptions);
drawingManager = new google.maps.drawing.DrawingManager({
drawingMode: google.maps.drawing.OverlayType.POLYGON,
drawingControlOptions: {
position: google.maps.ControlPosition.TOP_CENTER,
drawingModes: [
google.maps.drawing.OverlayType.POLYGON
]
},
markerOptions: {
icon: 'images/beachflag.png'
},
polygonOptions: {
fillColor: '#FF1493',
fillOpacity: 0.45,
strokeWeight: 0,
clickable: false,
editable: true,
zIndex: 1
},
map: map
});
google.maps.event.addListener(drawingManager, 'overlaycomplete', function(e) {
if (e.type != google.maps.drawing.OverlayType.MARKER) {
// Switch back to non-drawing mode after drawing a shape.
drawingManager.setDrawingMode(null);
// To hide:
drawingManager.setOptions({
drawingControl: false
});
// Add an event listener that selects the newly-drawn shape when the user
// mouses down on it.
var newShape = e.overlay;
newShape.type = e.type;
google.maps.event.addListener(newShape, 'click', function() {
setSelection(newShape);
});
setSelection(newShape);
polyPoints.push(newShape); // FH added to push polygon to polyPoints array
}
});
drawingManager.setMap(map);
google.maps.event.addListener(drawingManager, 'drawingmode_changed', clearSelection);
// google.maps.event.addListener(map, 'click', clearSelection);
google.maps.event.addDomListener(document.getElementById('delete-button'), 'click', deleteSelectedShape);
}
google.maps.event.addDomListener(window, 'load', initialize);
// FH from original script - functions to pass polyPoints to form
function addCoords(i, lat, longi){
//create form variables in <div> to hold lat/long pairs. <div> is invisible
var newdiv = document.createElement('div');
newdiv.innerHTML = "<input type='text' name='lat" + i +"' value='" + lat + "'> <input type='text' name='lon" + i +"' value='" + longi + "'>";
document.getElementById("coordDiv").appendChild(newdiv);
// style='display:none'
}
function parse_coords(){
//if survey has been properly completed, pass polyPoints array to addCoords
//alert('into parse_coords');
// var retval = validate_form();
// if (retval == true)
// {
// polyPoints er et array
for (var i = 0; i<(polyPoints[0].getPath().getLength()); i++) {
//var lat = polyPoints[i].lat();
//var longi = polyPoints[i].lng();
// Gammelt API i ovenstående?
// SE: https://developers.google.com/maps/documentation/javascript/examples/polygon-arrays
var lat = polyPoints[0].getPath().getAt(i).lat();
var longi = polyPoints[0].getPath().getAt(i).lng();
addCoords(i, lat, longi);
}
//alert ('out of parse co-ords');
//document.forms[0].submit();
// }
}
//change visibility of <div>s to mimic pagination
function changevis(oldchoice,newchoice) {
oldchoice.style.display = "none";
newchoice.style.display = "";
//force scroll to top of page, not previous scroll level
scroll(0,0);
}
</script>
</head>
<!-- FH previous body <body onload="load();" onunload="GUnload()"> -->
<body>
<form name="questions" id="questions" method="post" action="adddata.php">
<div id="divwide" class="mainwide"><!--allows instructions to sit beside map in table cell -->
<div id="divsub" class="mainwithin"><!--constrains rest of text to 750px as usual -->
<h2><i>Spørgeskema om dit nabolag</i></h2>
<p class="red">
<i>Brug venligst ikke browserens frem/tilbage-knapper.</i>
</p>
<br>
<?php
//generate new row in questdata table and retrieve value of respid.
//respid is auto-incremented for each new row.
require("dbinfo.php");
// Opens a connection to a MySQL server
$connection=mysql_connect ($host, $username, $password);
if (!$connection) {
die('Not connected : ' . mysql_error());
}
// Set the active MySQL database
$db_selected = mysql_select_db($database, $connection);
if (!$db_selected) {
die ('Can\'t use db : ' . mysql_error());
}
$query="insert into questdata (respid) values (null)";
$result=mysql_query($query);
$respid=mysql_insert_id();
echo "<input type='text' name='respid' id='respid' value=$respid style='display:none'>"
?>
<div id="page1">
<br><br>
<b>1.</b>
<br>Fri tekstboks her.
<br>
<textarea name="fritekstspm1" id="fritekst1" cols="70" rows="5" class="mandatory"></textarea>
<br><br>
<b>2.</b>
<br>
Likert-skala item her.
<br>
<input type="radio" name="likertspm1" id="likertspm1_1" value="1" class="mandatory">Helt uenig
<br>
<input type="radio" name="likertspm1" id="likertspm1_2" value="2">Delvist uenig
<br>
<input type="radio" name="likertspm1" id="likertspm1_3" value="3">Hverken-eller
<br>
<input type="radio" name="likertspm1" id="likertspm1_4" value="4">Delvist enig
<br>
<input type="radio" name="likertspm1" id="likertspm1_5" value="5">Helt enig
<br><br>
<div id="div2" class="mainwithin">
<b>3. Her er et kort. Tegn dit nabolag i kortet ved at zoome ind på hvor du bor og klikke for at tegne et område.</b>
<p>
<b>Vejledning</b><br>
Find dit nabolag:<br><br>
<table>
<tr><td colspan="2"><ul><li><i>zoom til det omraade, du bor i</i> ved at klikke paa <img src="zoom-in.gif" alt="+"> og <img src="zoom-out.gif" alt="-"> oeverst til venstre;
</li></ul></td></tr>
<tr><td class="r10"><ul><li><i>flyt kortet</i> ved at traekke med musen;
</li></ul></td><td><img src="pan.gif" alt="arrows"></td></tr>
<tr><td colspan="2"><ul><li><i>se forskellige detaljer om omraadet</i> ved at klikke paa "Map", "Satellite" og "Hybrid"
oeverst til hoejre.</li></ul>
</td></tr>
</table>
Hvis du "farer vild", klik her for at vende tilbage til Danmarkskortet:<br>
<input type="button" name="recentre" id="recentre" onclick="map.setCenter(DKcentercoords);" value="Re-centre map">
<br><br>
Det er okay hvis du tegner forkert. Du kan bruge knappen her til at rette fejlen:
<br><input type="button" id="delete-button" value="Slet og begynd forfra">
<br><br>
<div id="clickingmap" style="width:600px; height:600px;"></div>
<br>
<b>Klik her for at gemme nabolaget:</b>
<br>
<input type="button" value="Gem nabolaget" name="submitbtn" id="submitbtn" onclick="javascript: parse_coords()">
<br><br>
Når du har gemt nabolaget, klik på knappen herunder for at gå videre.
<input type="button" value="Videre" name="p1next" id="p1next" onclick="javascript: changevis(document.getElementById('page1'),document.getElementById('page2'))">
</div> <!--page1 -->
</div> <!--mainwithin -->
<div id="page2" style="display: none">
<div id="div2" class="mainwithin">
<b>4.</b>
<br>
Rangering af faktorer.
<br><br>
<table border=0 cellpadding=5 cellspacing=0>
<tr>
<td bgcolor="#dddddd"><b>Faktor</b></td>
<td align="right" bgcolor="#dddddd"><b>Placering -></b></td>
<td align="center" bgcolor="#dddddd"><b>1</b></td>
<td align="center" bgcolor="#dddddd"><b>2</b></td>
<td align="center" bgcolor="#dddddd"><b>3</b></td>
<td align="center" bgcolor="#dddddd"><b>4</b></td>
<td align="center" bgcolor="#dddddd"><b>5</b></td>
<td align="center" bgcolor="#dddddd"><b>DK</b></td>
</tr>
<tr>
<td>Faktor nr 1</td>
<td> </td>
<td align="center"><input type="radio" name="rankspm1" id="rankspm1_1" value="1" class="mandatory"></td>
<td align="center"><input type="radio" name="rankspm1" id="rankspm1_2" value="2"></td>
<td align="center"><input type="radio" name="rankspm1" id="rankspm1_3" value="3"></td>
<td align="center"><input type="radio" name="rankspm1" id="rankspm1_4" value="4"></td>
<td align="center"><input type="radio" name="rankspm1" id="rankspm1_5" value="5"></td>
<td align="center"><input type="radio" name="rankspm1" id="rankspm1_6" value="6"></td>
</tr>
<br><br>
Til sidst nogle spm. om dig selv.
<br><br>
Køn:
<br>
<input type="radio" name="gender" id="gender_female" value="1" class="mandatory"> Kvinde
<br>
<input type="radio" name="gender" id="gender_male" value="2"> Mand
<br><br>
Alder:
<br>
<input type="text" name="age" id="age" size="2">
<br><br>
<div id="coordDiv" style="display:none"> <!--this is a place to hold the coords, and does not display on screen--> </div>
<input type="button" value="Tilbage" name="p2prev" id="p2prev" onclick="javascript: changevis(document.getElementById('page2'),document.getElementById('page1'))">
<input type="submit" value="Afslut">
</div><!--mainwithin -->
</div><!--page3 -->
</div><!--mainwide -->
</form>
</body>
</html>