-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.html
277 lines (179 loc) · 8.23 KB
/
index.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
<!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 -->
<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>
<link href="https://fonts.googleapis.com/css?family=Pathway+Gothic+One|Source+Sans+Pro:400" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">
<link rel="stylesheet" href="css/3divs_css.css">
</head>
<body class="action_picker">
<input type="file" accept=".zip" style="display:none;">
<section id="timeline">
<div class="tl-item ld_projects">
<div class="tl-bg" style="background-image: url(img/img1.jpg);"></div>
<div class="tl-year">
<p class="f2 heading--sanSerif">LOAD PROJECT</p>
</div>
<div class="tl-content">
<h1>Lorem ipsum dolor sit</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit.</p>
</div>
</div>
<div class="tl-item ne_project">
<div class="tl-bg" style="background-image: url(img/img2.jpg);"></div>
<div class="tl-year">
<p class="f2 heading--sanSerif">CREATE PROJECT</p>
</div>
<div class="tl-content">
<h1 class="f3 text--accent ttu">Vestibulum laoreet lorem</h1>
<p>Suspendisse potenti. Sed sollicitudin eros lorem, eget accumsan risus dictum id. Maecenas dignissim ipsum vel mi rutrum egestas. Donec mauris nibh, facilisis ut hendrerit vel, fringilla sed felis. Morbi sed nisl et arcu.</p>
</div>
</div>
<div class="tl-item im_project">
<div class="tl-bg" style="background-image: url(img/img3.jpg);"></div>
<div class="tl-year">
<p class="f2 heading--sanSerif">IMPORT PROJECT</p>
</div>
<div class="tl-content">
<h1 class="f3 text--accent ttu">Vestibulum laoreet lorem</h1>
<p>Suspendisse potenti. Sed sollicitudin eros lorem, eget accumsan risus dictum id. Maecenas dignissim ipsum vel mi rutrum egestas. Donec mauris nibh, facilisis ut hendrerit vel, fringilla sed felis. Morbi sed nisl et arcu.</p>
</div>
</div>
</section>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery('.ne_project').click(function(){
window.location = "./map.html";
});
jQuery('.ld_projects').click(function(){
window.location = "./all_projects.html";
});
jQuery('.im_project').click(function(){
jQuery('input[type="file"]').click();
});
// Check if projects exists else build it
const fs = require("fs"); // Or `import fs from "fs";` with ESM
if (fs.existsSync("projects")) {
// Do something
//alert('PROJECT ALREADY EXISTS');
} else {
//console.log("not exist");
fs.mkdir('projects', function() {
//fs.writeFile('',"");
});
}
// Check if projects exists else build it
if (fs.existsSync("projects_centers")) {
// Do something
//alert('PROJECT ALREADY EXISTS');
} else {
fs.mkdir('projects_centers', function() {
fs.writeFileSync('./projects_centers/centers.txt',"plan_name:0;x:0;y:0");
});
}
});
</script>
<script>
jQuery(document).ready(function(){
jQuery('input[type="file"]').change(function(){
var get_file_path = document.getElementsByTagName('input')[0].files[0].path;
var get_file_name = document.getElementsByTagName('input')[0].files[0].name;
//console.log(get_file_name);
// diabazw onoma gia na mporesw na ftiaxw path
var read_name = get_file_name.split(".zip",3);
//console.log(read_name);
console.log(read_name[0]);
const fs = require("fs"); // Or `import fs from "fs";` with ESM
if (fs.existsSync('projects/'+read_name[0])) {
// Do something
//alert('PROJECT ALREADY EXISTS');
extract_zip('/projects/'+read_name[0],get_file_path,read_name[0]);
} else {
//console.log("not exist");
fs.mkdir('projects/'+read_name[0], function() {
extract_zip('/projects/'+read_name[0],get_file_path,read_name[0]);
});
}
});
// Extract Zip
function extract_zip(project_path,zip_path,project_name){
console.log(project_path,zip_path);
var path = require('path');
var appDir = path.dirname(require.main.filename);
var project_names = [];
var extract = require('extract-zip');
var source = zip_path;
var target = appDir + project_path;
console.log(target);
extract(source, {dir: target}, function (err) {
// extraction is complete. make sure to handle the err
try{
var data = JSON.parse(load_project_polygon(target+'/'));
alert('Project Imoprted Succcesfully');
}catch(error){
console.log('Cant load');
var rimraf = require("rimraf");
rimraf(appDir+"/projects/"+project_name, function () {
console.log("Remove Done");
});
}
console.log(data["features"][0]["geometry"]);
var polygonCenter = require('geojson-polygon-center');
var center = polygonCenter(data["features"][0]["geometry"]);
var load_centers = load_projects_centers();
var split_projects_center = load_centers.split(",");
jQuery.each(split_projects_center, function( index, value ) {
temp_name = value.split("plan_name:");
keep_name = temp_name[1].split(";");
project_names.push(keep_name[0]);
});
var item_exists = jQuery.inArray( project_name, project_names );
if(item_exists > 0){
console.log('Do not touch center of project');
}else{
load_centers += ',plan_name:'+project_name+';x:'+center["coordinates"][0]+';y:'+center["coordinates"][1];
const fs = require("fs");
fs.mkdir('projects_centers', function() {
fs.writeFileSync('./projects_centers/centers.txt', load_centers);
});
console.log('Centers Updated');
}
});
}
// Function in order to Call User database ( /login_system/users.txt)
function load_project_polygon(file_path) {
var fs = require('fs');
//var rimraf = require("rimraf");
//rimraf("/some/directory", function () { console.log("done"); });
try {
var contents = fs.readFileSync(file_path+'/map_data.geojson', 'utf8');
}
catch(error) {
console.error('Cant find Map_data.geojson');
// expected output: ReferenceError: nonExistentFunction is not defined
// Note - error messages will vary depending on browser
}
return contents;
}
// Function in order to Call User database ( /login_system/users.txt)
function load_projects_centers() {
var fs = require('fs');
var contents = fs.readFileSync('./projects_centers/centers.txt', 'utf8');
return contents;
}
});
</script>
</body>
</html>