-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
468 lines (442 loc) · 18.1 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
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
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Fruchtfolge</title>
<meta name="description" content="Fruchtfolge Optimierung">
<meta name="author" content="Christoph Pahmeyer">
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="src/lib/pouchdb-6.2.0.js"></script>
<script src="src/lib/pouchdb.authentication.min.js"></script>
<script src="src/parseElanXml.js"></script>
<script src="src/parseElanGml.js"></script>
<script src='https://api.mapbox.com/mapbox-gl-js/v0.39.1/mapbox-gl.js'></script>
<link href='https://api.mapbox.com/mapbox-gl-js/v0.39.1/mapbox-gl.css' rel='stylesheet' />
<script src='https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-draw/v0.19.0/mapbox-gl-draw.js'></script>
<script src='https://cdn.jsdelivr.net/bluebird/latest/bluebird.min.js'></script>
<script src="src/map.js"></script>
<script src='src/requests.js' type="text/javascript"></script>
<script src='src/soilQuality.js' type="text/javascript"></script>
<script src='src/plotData.js' type="text/javascript"></script>
<script src="src/deleteProcedure.js"></script>
<script src="src/replaceProcedure.js"></script>
<script src="src/varCostTable.js"></script>
<script src="src/grossMargin.js"></script>
<script src="src/constraints.js"></script>
<script type="text/javascript" src="src/gams/lstParse.js"></script>
<script type="text/javascript" src="src/gams/neos.js"></script>
<script type="text/javascript" src="src/gams/reformatGAMS.js"></script>
<script type="text/javascript" src="src/gams/solver.js"></script>
<script type="text/javascript" src="src/gmPlot.js"></script>
<script type="text/javascript" src="src/model.js"></script>
<script type="text/javascript" src="src/createChart.js"></script>
<script type="text/javascript" src="src/createLineChart.js"></script>
<script type="text/javascript" src="src/updateResults.js"></script>
<script src="src/lib/Chart.bundle.min.js"></script>
<script src="src/lib/ObjTree.js"></script>
<script src="src/lib/proj4.js"></script>
<script src="src/lib/turf.min.js"></script>
<script src="src/requests.js"></script>
<script src="src/lib/spin.js"></script>
<link rel="stylesheet" href="css/page1.css" />
<link rel="stylesheet" href="css/page2.css" />
<link rel="stylesheet" href="css/page3.css" />
<link rel="stylesheet" href="css/part4.css" />
<link rel="stylesheet" href="css/mapbox-gl-draw.css" />
</head>
<body>
<!--
Header
-->
<div class="menu">
<p id='fruchtfolge'>FRUCHTFOLGE</p>
<div id='menuNav'>
<div class="dropdown-content">
<a onclick="loadingScreen(dirtyHack, 2, 'weiter-data', null, 'LÄDT');">DATENEINGABE</a>
<a onclick="loadingScreen(drawCropPage, 3, 'weiter-data', null, 'KARTENDARSTELLUNG WIRD GELADEN')">KARTENDARSTELLUNG</a>
<a onclick="loadingScreen(createCroppingPage, 4, 'weiter-map', null, 'DECKUNGSBEITRÄGE WERDEN ABGEFRAGT')">DECKUNGSBEITRÄGE</a>
<a onclick="loadingScreen(constraints, 5, 'weiter-costs', null, 'EINEN AUGENBLICK BITTE')">NEBENBEDINGUNGEN</a>
<a onclick="loadingScreen(createModel, 6, 'weiter-costs',null, 'DECKUNGSBEITRÄGE PRO FELD UND KULTUR WERDEN ERRECHNET')">ERGEBNIS</a>
<a onclick="logout(); hideMenu(true)">LOGOUT</a>
</div>
</div>
</div>
<div id="blur">
<h2 id="loading-status" style="position: relative; top: 50%;margin-top: 60px;font-size: 20px; text-align: center; letter-spacing: 0.1em;"></h2>
</div>
<!--
Login Page
-->
<div page='1'>
<input id="anmelden" class="anmelden-oben" type="button" value="ANMELDEN" onclick="flip2()" />
<input id="registrieren" class="registrieren-oben" type="button" value="REGISTRIEREN" onclick="flip()" />
<img id="background" class="background" src="img/background3.jpeg" alt="Hintergrund" />
<div class="overlay"></div>
<div class="flip-container" id="login">
<div class="flipper">
<div class="login">
<p>ANBAUPLANUNG OPTIMIEREN</p>
<div id="emailFalsch" class="emailFalsch">Die angegebene E-Mail Adresse konnte nicht gefunden werden</div>
<input id="email" class="email" placeholder="E-Mail" name="email" autofocus="autofocus" />
<input class="password" onkeypress="return checkEnterLogin(event)" placeholder="Passwort" type="password" name="password" id="password" />
<input class="checkbox" type="checkbox" />
<input type="checkbox" id="c1" name="cc" />
<label for="c1" class="label-login"><span></span>Angemeldet bleiben</label>
<button type="button" class="login-button" id="login-button">ANMELDEN</button>
<a class="forgot" href="index.html">Passwort vergessen?</a>
</div>
<div class="registrierung">
<p>JETZT KOSTENLOS ANMELDEN</p>
<input id='name' class="name" placeholder="Vor- und Nachname" />
<input id="street" class="street" placeholder="Strasse u. Hausnr." />
<input id="postcode" class="postcode" placeholder="PLZ" />
<input id="email2" class="email2" placeholder="E-Mail Adresse" />
<input id='password2' class="password2" placeholder="Passwort" type="password" />
<input id="repeatPass" class="repeat-password" placeholder="Passwort wiederholen" type="password" />
<button type="button" class="register-button" id="signup">REGISTRIEREN</button>
</div>
</div>
</div>
<script type="text/javascript">
function hideMenu(bool) {
var menu = document.getElementById('menuNav');
if(bool === true) menu.classList.add('hide');
else menu.classList.remove('hide');
}
hideMenu(true);
</script>
</div>
<!--
Data input
-->
<div page='2'>
<div style="width: 50vw; position: absolute; top: 120px; left: 50%; margin-left: -25vw">
<h1 style="font-family: 'open_sanscondensed_light'; font-weight: normal; letter-spacing: 0.2em">DATENEINGABE</h1>
<span>Für die Optimierung werden Daten bezüglich Ihrer bewirtschafteten Flächen benötigt. Dabei werden insbesondere die Schlagskizzen (Geodaten) sowie die Vorfrüchte der Felder für die Optimierungsrechnung verwendet. Die Flächendaten können aus dem ELAN-Downloadportal durch eingabe der ZID-Nummer und Passwort bzw. durch einen Dateiupload hochgeladen werden.
<br>
<strong>Datenschutzhinweis:</strong> Ihre Invekos-Daten (Betriebsnummer und Passwort) werden über eine gesicherte SSL-Verbindung zur Abfrage im ELAN-Downloadportal übertragen. Die Anmeldedaten werden nicht gespeichert.</span>
<div style="width: 100%; height: 12px; border-bottom: 1px solid black; text-align: center; margin-top: 40px; margin-bottom: 40px">
<span style="font-size: 20px; letter-spacing: 0.2em; background-color: #F3F5F6; padding: 0 20px;">
ZID-DATEN ABFRAGE <!--Padding is optional-->
</span>
</div>
<input type="text" id='zid' class="input" name="zid" placeholder="ZID-Betriebsnummer">
<br>
<input type="password" id='zid-pw' class="input" name="zid-pw" placeholder="Passwort">
<br>
<button type="button" id='zid-btn' class="invekosBtn" name="zid-btn">ABSENDEN</button>
<div style="width: 100%; height: 12px; border-bottom: 1px solid black; text-align: center; margin-top: 40px; margin-bottom: 40px">
<span style="font-size: 20px; letter-spacing: 0.2em; background-color: #F3F5F6; padding: 0 20px;">
ODER ELAN-DATEI UPLOAD
</span>
</div>
<span>XML-Datei</span>
<input type="file" accept=".xml" id='xml' name="xml">
<br>
<span>GML-Datei</span>
<input type="file" accept=".gml" id='gml' name="gml">
</div>
<input id="weiter-data" class="weiter-oben" type="button" value="WEITER" />
<script type="text/javascript">
document.getElementById('weiter-data').onclick = function() {
profile.get('fields').then(function (fields) {
if (fields[Object.keys(fields)[0]].polygon) return loadingScreen(drawCropPage, 3, 'weiter-data', null, 'DIE DATEN WERDEN EINGELESEN');
else return alert("Bitte ZID-Betriebsnummer und Passwort eingeben oder Dateien hochladen")
})
};
</script>
</div>
<!--
Map
-->
<div id='page3' page='3'>
<div id="Leiste"></div>
<div id='map'></div>
<input id="weiter-map" class="weiter-oben" type="button" value="WEITER" />
<script type="text/javascript">
document.getElementById('weiter-map').onclick = function() {
return loadingScreen(null, 4, 'weiter-map', [plotData,createCroppingPage], 'DISTANZEN UND BODENQUALITÄTEN WERDEN ABGEFRAGT')
};
</script>
</div>
<!--
Variable Costs
-->
<div id='page4' page='4'>
<div class='hide' id="blur-costs"></div>
<div id='stepProcedures'>
<div id='tabelle'></div>
<div class='hide' id='replacementBox'>
<div id='machInputs'>
<label class='labelDropDown' for='procedure.group'>Verfahrensgruppe</label>
<select class='replacementDropDown' id="procedure.group">
</select>
<label class='labelDropDown' for='procedure.procedure'>Arbeitsverfahren</label>
<select class='replacementDropDown' id="procedure.procedure">
</select>
<label class='labelDropDown' for='procedure.combination'>Maschinenkombination</label>
<select class='replacementDropDown' id="procedure.combination">
</select>
<label class='labelDropDown' for='procedure.amount'>Menge</label>
<select class='replacementDropDown' id="procedure.amount">
</select>
<label class='labelDropDown' for='procedure.workingWidth'>Arbeitsbreite</label>
<select class='replacementDropDown' id="procedure.workingWidth">
</select>
</div>
<button id='buttonOk'>ÜBERNEHMEN</button>
<button id="buttonCancel">ABBRECHEN</button>
</div>
<div id='subseqCrops'></div>
<div id='subseqCropsRight'></div>
</div>
<div id="LeisteCrops"></div>
<input id="weiter-costs" class="weiter-oben" type="button" value="WEITER" />
<script type='text/javascript'>
document.getElementById('weiter-costs').onclick = function() {
return loadingScreen(constraints, 5, 'weiter-costs', null, 'EINEN AUGENBLICK BITTE')
};
</script>
</div>
<!--
Constraints
-->
<div id='page5' page='5'>
<div class="hide" id="blur-const"></div>
<div class="hide" id='addConstraint'>
<div id='constraintInputs'>
<h2 style="text-align: center;">NEUE NEBENBEDINGUNG HINZUFÜGEN</h2>
<label class='labelDropDown' for='constraint.crop'>Kultur</label>
<select class='replacementDropDown' id="constraint.crop"></select>
<button id='addCrop'></button>
<label class='labelDropDown' for='constraint.type'>Bedingung</label>
<select class='replacementDropDown' id="constraint.type">
<option selected="">maximal</option>
<option selected="">mindestens</option>
</select>
<label class='labelDropDown' for='constraint.amount'>Anbaufläche in ha</label>
<input type="text" class='constAmountInput' pattern="[0-9]" id="constraint.amount">
</div>
<button id="buttonConstOk" class='buttonConstOk'>ÜBERNEHMEN</button>
<button id="buttonConstCancel" class="buttonConstCancel">ABBRECHEN</button>
</div>
<div id='containerConst' style="width: 50vw; position: absolute; top: 120px; left: 50%; margin-left: -25vw">
<h1 style="font-family: 'open_sanscondensed_light'; font-weight: normal; letter-spacing: 0.2em">NEBENBEDINGUNGEN</h1>
<table id='tableConst'></table>
</div>
<input id="weiter-const" class="weiter-oben" type="button" value="WEITER" />
<script type="text/javascript">
document.getElementById('weiter-const').onclick = function() {
return loadingScreen(createModel, 6, 'weiter-costs',null, "EINEN AUGENBLICK BITTE")
};
</script>
</div>
<!--
Results
-->
<div id="page6" page='6'>
<div id="wrapper">
<div id="tabelle-results"></div>
<div id="canvas-holder">
<canvas id="chart-area" /></div>
<div id="alerts-box"></div>
<div id="canvas-line">
<div id="line-wrapper">
<canvas id="linechart" />
</div>
</div>
</div>
<div id='mapResults'>
<h2 style="margin-left: 40px">KARTE</h2>
<div id='crop-legend' class='legend'>
<h4>Anbaukulturen</h4>
</div>
</div>
</div>
<script type="text/javascript">
// check promise support
if(typeof Promise !== "undefined" && Promise.toString().indexOf("[native code]") !== -1){
var promiseScript = document.createElement('script');
promiseScript.setAttribute('src','https://cdn.jsdelivr.net/bluebird/latest/bluebird.min.js');
document.head.appendChild(promiseScript);
}
// G L O B A L E S
var profile;
var couchPath = 'https://v-server-node.ilb.uni-bonn.de/db';
function loadingScreen(func1, step, button, PromiseArr, status) {
// post status to status elem
document.getElementById('loading-status').innerHTML = status;
//
var button = document.getElementById(button)
// start spinner
var target = document.getElementById("blur");
var opts = {lines: 13 , length: 10 , width: 3 , radius: 9 , scale: 1 , corners: 1 , color: '#000', opacity: 0.25 , rotate: 0 , direction: 1 , speed: 1 , trail: 60 , fps: 20 , zIndex: 2e9 , className: 'spinner', top: '50%', left: '50%', shadow: false , hwaccel: false , position: 'absolute'}
var spinner = new Spinner(opts).spin(target);
// change button value to "wait"
button.value = "WARTEN...";
//
var elem = document.getElementById("wrapper");
target.className = "";
target.style.opacity = 1;
setTimeout(function() {
goTo(step);
if (func1) {
func1().then(function () {
target.style.opacity = 0;
button.value = 'WEITER';
setTimeout(function () {
target.className = "blur-overlay";
spinner.stop();
}, 700)
if (func1 !== 'dirtyHack' && step !== 1) {
profile.get('info').then(function (info) {
info.status = step;
return profile.put(info);
});
};
}).catch(function (err) {
alert(err);
goTo(1);
target.style.opacity = 0;
});
}
else {
Promise.all(PromiseArr.map(function (promise) {
return promise();
})).then(function () {
target.style.opacity = 0;
button.value = 'WEITER';
setTimeout(function () {
target.className = "blur-overlay";
spinner.stop();
}, 700);
if (func1 !== 'dirtyHack' && step !== 1) {
profile.get('info').then(function (info) {
info.status = step;
return profile.put(info);
});
};
}).catch(function (err) {
alert(err);
goTo(1);
target.style.opacity = 0;
});
}
}, 1000);
}
function toHex (str) {
var hex= ''
for (var i=0; i < str.length; i++) {
hex += str.charCodeAt(i).toString(16);
}
return hex
}
var db = new PouchDB(couchPath + '/users', {skip_setup: true});
db.getSession(function (err, response) {
if (err) {
// network error
} else if (!response.userCtx.name) {
// hide blur element
loadingScreen(dirtyHack, 1, 'weiter-data', null, 'LÄDT');
} else {
profile = new PouchDB(response.userCtx.name);
profile.sync( couchPath + '/userdb-' + toHex(response.userCtx.name), {
live: true,
retry: true
}).on('change', function (info) {
// handle change
}).on('paused', function (err) {
// replication paused (e.g. replication up to date, user went offline)
}).on('active', function () {
// replicate resumed (e.g. new changes replicating, user went back online)
}).on('denied', function (err) {
// a document failed to replicate (e.g. due to permissions)
}).on('complete', function (info) {
// handle complete
}).on('error', function (err) {
// handle error
});
profile.get('info').then(function (info) {
var state = info.status,
func = '';
switch(state) {
case 2:
hideMenu(false);
loadingScreen(dirtyHack, 2, 'weiter-data', null, 'LÄDT');
break;
case 3:
hideMenu(false);
loadingScreen(drawCropPage, 3, 'weiter-data', null, 'KARTENDARSTELLUNG WIRD GELADEN');
break;
case 4:
hideMenu(false);
loadingScreen(createCroppingPage, 4, 'weiter-map', null, 'DECKUNGSBEITRÄGE WERDEN ABGEFRAGT')
break;
case 5:
hideMenu(false);
loadingScreen(constraints, 5, 'weiter-costs', null, 'EINEN AUGENBLICK BITTE');
break;
case 6:
hideMenu(false);
loadingScreen(createModel, 6, 'weiter-costs',null, "DECKUNGSBEITRÄGE PRO FELD UND KULTUR WERDEN ERRECHNET")
break;
default:
loadingScreen(dirtyHack, 1, 'weiter-data', null, 'LÄDT');
}
});
//goTo(2);
}
});
function flip(){
document.querySelector("#login").classList.toggle("flip");
document.getElementById("registrieren").style.display = 'none';
document.getElementById("anmelden").style.display = 'block';
}
function flip2(){
document.querySelector("#login").classList.toggle("flip");
document.getElementById("registrieren").style.display = 'block';
document.getElementById("anmelden").style.display = 'none';
}
function goTo(page) {
var pages = document.querySelectorAll('[page]'),
formStep,
formStepNo,
i;
for (i = 0; i < pages.length; i++) {
formStep = pages[i];
formStepNo = formStep.getAttribute('page');
if (page == formStepNo) {
formStep.style.display = 'block';
} else {
formStep.style.display = 'none';
}
}
}
var page = 1;
goTo(page);
function nextStep() {
page++;
goTo(page);
}
function backStep() {
page--;
goTo(page);
}
function checkEnterLogin(e) {
e = e || window.event;
if (e.keyCode == '13') {
loadingScreen(login, 2, 'weiter-data', null, 'EINEN AUGENBLICK BITTE');
return false;
}
}
function dirtyHack () {
return new Promise(function (resolve,reject) {
resolve();
})
}
</script>
<script src="src/app.js"></script>
<script src="src/fileReading.js"></script>
</body>
</html>