-
Notifications
You must be signed in to change notification settings - Fork 0
/
event.php
98 lines (86 loc) · 2.74 KB
/
event.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
<?php
require_once "util/sql_queries.php";
$event = null;
$users = null;
function main() {
global $event;
global $users;
session_start();
if (!isset($_GET["event_id"])) {
header("Location:sign_in.php");
exit;
}
if (!isset($_SESSION["username"])) {
header("Location:sign_in.php");
exit;
}
$event = get_event(intval($_GET["event_id"]));
$users = get_event_users(intval($_GET["event_id"]));
}
main();
include "includes/head.php";
?>
<body>
<?php
include "includes/header.php";
?>
<main>
<div>
<h1>
<?php echo $event["name"];?>
</h1>
<h2>
People
</h2>
<?php
if (!user_in_event($_SESSION["username"], $_GET["event_id"])) {
printf("<a href='util/event_join.php?event_id={$_GET["event_id"]}'>Join event</a>");
}
?>
<ul>
<?php
foreach ($users as $user) {
printf("<li>%s</li>", $user["username"]);
}
?>
</ul>
<form method="post" id="route_form" onsubmit="onDownload()"
action="<?php echo "util/export_path.php?event_id={$_GET['event_id']}"; ?>">
<input type="hidden" name="route" id="route" value="" />
<input type="submit" value="Save path"/>
</form>
<script>
function onDownload(){
const formInfo = document.forms["route_form"];
formInfo.route.value = JSON.stringify(polyPoints);
}
</script>
</div>
<div id="map"></div>
<script type="text/javascript">
var map = L.map('map', {
center: [38.6488, -90.3108],
zoom: 15
});
<?php
if (is_null($event["route"])) {
printf("var polyPoints = [];");
} else {
printf("var polyPoints = JSON.parse('%s');", $event["route"]);
}
?>
var polyLine = L.polyline(polyPoints).addTo(map);
map.on('click', function (e) {
var marker = new L.marker(e.latlng).addTo(map);
polyPoints.push([e.latlng.lat.toFixed(4), e.latlng.lng.toFixed(4)]);
var polyLine = L.polyline(polyPoints).addTo(map).openOn(map);
});
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
</script>
</main>
</body>
<?php
include "includes/tail.php";
?>