-
Notifications
You must be signed in to change notification settings - Fork 5
/
all_projects.html
367 lines (278 loc) · 9.56 KB
/
all_projects.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
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
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>
IKH - CoFly
</title>
<!-- Favicon -->
<link href="./assets/img/brand/favicon.png" rel="icon" type="image/png">
<!-- Fonts -->
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700" rel="stylesheet">
<!-- Icons -->
<!-- CSS Files -->
<link href="css/argon-dashboard.css?v=1.1.0" rel="stylesheet" />
<link href="css/style.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<!--Add mapbox.js -->
<script src="https://api.tiles.mapbox.com/mapbox.js/v3.3.1/mapbox.js"></script>
<link
href="https://api.tiles.mapbox.com/mapbox.js/v3.3.1/mapbox.css"
rel="stylesheet"
/>
<!--Add draw plugin -->
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/leaflet.draw/1.0.4/leaflet.draw.css"
/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet.draw/1.0.4/leaflet.draw.js"></script>
<style type="text/css">
#map {
position: absolute;
top: 0;
bottom: 0;
width: 100%;
height: 100vh;
}
#delete, #export {
position: absolute;
top:50px;
right:10px;
z-index:100;
background:white;
color:black;
padding:6px;
border-radius:4px;
font-family: 'Helvetica Neue';
cursor: pointer;
font-size:12px;
text-decoration:none;
}
#export {
top:90px;
}
path.leaflet-clickable {
fill: rgb(254,200,64);
stroke: rgb(254,200,64);
}
.leaflet-top.leaflet-left {
margin-top: 20%;
}
div#load_this_project {
background: rgba(0,0,0,.8);
position: absolute;
bottom: 2%;
z-index: 9;
left: 40%;
width: 40%;
height: 55px;
border-radius: 5px;
padding: 10px;
}
div#load_this_project {
display: none;
}
.forget_it {
width: 31%;
background: transparent;
border: 1px solid #fec840;
text-align: center;
border-radius: 22px;
padding: 5px;
color: #fec840;
cursor: pointer;
float: left;
display: inline-block;
position: relative;
}
.load_it {
width: 31%;
background: #fec840;
border: 1px solid #fec840;
text-align: center;
border-radius: 22px;
padding: 5px;
color: #222;
cursor: pointer;
float: left;
display: inline-block;
position: relative;
}
.delete_it {
width: 31%;
background: transparent;
border: 1px solid #fec840;
text-align: center;
border-radius: 22px;
padding: 5px;
color: #fec840;
cursor: pointer;
float: left;
display: inline-block;
position: relative;
}
div#load_this_project div {
margin-right: 2%;
}
.delete_it:hover {
background: #ff3c3cc7;
border-color: #000;
color: #fff;
}
</style>
</head>
<body class="">
<div id="load_this_project"><div class="forget_it">Close</div><div class="delete_it" path="">Delete Project</div><div class="load_it">Load Project</div></div>
<nav class="navbar navbar-vertical fixed-left navbar-expand-md navbar-light bg-white" id="sidenav-main">
<div class="container-fluid">
<a class="navbar-brand pt-0" href="./index.html">
<img src="img/coFLY_logo.png" class="navbar-brand-img" alt="...">
</a>
<!-- Collapse -->
<div class="collapse navbar-collapse" id="sidenav-collapse-main">
<hr class="my-3 white">
</div>
</div>
</nav>
<div class="main-content">
<div id='map'></div>
</div>
<!-- <script src="js/main_script.js"></script> -->
<script>
L.mapbox.accessToken = 'pk.eyJ1IjoiZWdnbGV6b3NrIiwiYSI6ImNra2Z0NndyczBsYTUydm43Yjh3bDRvMHUifQ.cvUwSVInY69HPVpp1YdVIA';
var map = L.mapbox.map('map')
.setView([38.6008630095356,24.187002848625298], 7)
.addLayer(L.mapbox.styleLayer('mapbox://styles/mapbox/satellite-v9'));
// Add layers to the map
/*
L.control.layers({
'Satellite Map': L.mapbox.tileLayer('mapbox.satellite', {
detectRetina: true
}).addTo(map),
'Terrain Map': L.mapbox.tileLayer('mapbox.mapbox-terrain-v2', {
detectRetina: true
})
}).addTo(map);
*/
//var featureGroup = L.featureGroup().addTo(map);
</script>
<style>
.leaflet-control-zoom.leaflet-bar.leaflet-control {
display: none;
}
.mapbox-control-info.mapbox-small.mapbox-control-info-right.leaflet-control {
display: none !important;
}
.leaflet-control-layers.leaflet-control {
display: none;
}
.make_it_active {
filter: grayscale(0) !important;
}
.marker_inactive {
filter: grayscale(1);
}
</style>
<script type="text/javascript">
jQuery(document).ready(function() {
var greenIcon = L.icon({
iconUrl: 'img/our_marker.png',
/*shadowUrl: 'img/leaf-shadow.png',*/
iconSize: [50, 73], // size of the icon
shadowSize: [50, 64], // size of the shadow
//iconAnchor: [22, 94], // point of the icon which will correspond to marker's location
iconAnchor: [25, 70], // point of the icon which will correspond to marker's location
shadowAnchor: [4, 62], // the same for the shadow
popupAnchor: [0, -76] // point from which the popup should open relative to the iconAnchor
});
// Draw All projects
const fs = require('fs');
const path = require('path');
var running_on = path.resolve(__dirname);
fs.readdir(running_on + '/projects', (err, files) => {
files.forEach(file => {
var pr_data = JSON.parse(read_project_preview_data(file));
var coords = pr_data["Center"].split(",");
//console.log(coords);
jQuery('div#sidenav-collapse-main').append('<div long="' + coords[0] + '"lat="' + coords[1] + '" class="project_button"> <label><i class="fas fa-map-pin"></i>' +pr_data["Name"] + '</label> </div>');
// Call Drawing pin func
draw_marks(pr_data["Name"],parseFloat(coords[0]),parseFloat(coords[1]));
});
});
// Function gia drawing pins twn project
function draw_marks(name,lat,lon){
console.log(name,lat,lon);
var marker = L.marker(
[lon, lat], {
title: name,
icon: greenIcon
}
).addTo(map).bindPopup('<h3>'+name+'</h3>');
L.DomUtil.addClass(marker._icon,name);
}
// Function that returns the project view json
function read_project_preview_data(name){
var fs = require('fs');
const path = require('path');
var running_on = path.resolve(__dirname);
var contents = fs.readFileSync(running_on + '/projects/'+name+'/preview_project.json', 'utf8');
return contents;
}
jQuery(document).on("click",".project_button",function() {
//console.log("aa");
jQuery('.leaflet-objects-pane svg g').remove();
jQuery('.project_button').removeClass('prj_active');
jQuery(this).addClass('prj_active');
var long = parseFloat(jQuery(this).attr('long'));
var lat = parseFloat(jQuery(this).attr('lat'));
localStorage.setItem("LoadedProjectCenter",long+","+lat);
//map.panTo(new L.LatLng(lat, long), 14);
//console.log(lat,long);
map.setView([lat,long], 18);
L.circle([lat, long], 100).addTo(map);
//jQuery('.img.leaflet-marker-icon.leaflet-zoom-animated.leaflet-clickable').removeClass('marker_inactive');
jQuery('img.leaflet-marker-icon.leaflet-zoom-animated').addClass('marker_inactive');
jQuery('.' + jQuery(this).text().replace(" ", "")).removeClass('marker_inactive');
jQuery('.load_it').attr('path', jQuery(this).text().replace(" ", ""));
jQuery('.delete_it').attr('path', jQuery(this).text().replace(" ", ""));
jQuery('div#load_this_project').slideDown();
});
jQuery('.forget_it').click(function() {
jQuery('div#load_this_project').slideUp();
jQuery('.leaflet-objects-pane svg g').remove();
jQuery('img.leaflet-marker-icon.leaflet-zoom-animated').removeClass('marker_inactive');
jQuery('.prj_active').removeClass('prj_active');
});
jQuery('.load_it').click(function() {
localStorage.setItem("LoadProject", jQuery(this).attr('path'));
window.location = "./load_project.html";
});
// Trigger Delete function
jQuery('.delete_it').click(function() {
//localStorage.setItem("LoadProject", jQuery(this).attr('path'));
const path = require('path');
const fs = require('fs');
var running_on = path.resolve(__dirname);
var final_path = "" + running_on + "/projects/"+jQuery(this).attr('path');
//rmdir directoryname
rmDir = function(dirPath) {
try { var files = fs.readdirSync(dirPath); }
catch(e) { return; }
if (files.length > 0)
for (var i = 0; i < files.length; i++) {
var filePath = dirPath + '/' + files[i];
if (fs.statSync(filePath).isFile())
fs.unlinkSync(filePath);
else
rmDir(filePath);
}
fs.rmdirSync(dirPath);
};
rmDir(final_path);
});
});
</script>
</body>
</html>