-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.js
130 lines (90 loc) · 3.02 KB
/
utils.js
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
closePopup = () => {
resetOV();
setOv(App.selectedSign);
}
cancelMoving = () => {
let confirmation_overlay = document.getElementById('confirmation-overlay');
App.states.isMoving = true;
App.states.movingCoords = null;
if(confirmation_overlay.classList.contains('is-visible')) confirmation_overlay.classList.remove('is-visible');
}
openSearch = () => {
document.getElementById('search-overlay').classList.add('is-visible');
}
searchSigns = (event) => {
let returnSigns = new Array();
let signNumber = 0;
let t = jQuery('#search-table').DataTable();
t.clear().draw();
let value;
if(event != null){
value = event.target.value;
}else{
value = document.getElementById('searchbar').value;
}
if(value != ""){
for(let i = 0; i < App.signList.length; i++){
let sign = App.signList[i];
if(sign.getName().toUpperCase().includes(value.toUpperCase())){
returnSigns.push(sign);
continue;
}
}
for(let i = 0; i < returnSigns.length; i++){
signNumber += 1;
if(signNumber > 50) break;
let sign = returnSigns[i];
signs.insertRow(sign);
}
}
document.getElementById('search-results-count').innerHTML = `${signNumber}/${returnSigns.length} Ergebnisse`
}
deleteMarker = () => {
let confirmationPopup = new ConfirmationPopup(
{description: "Möchten Sie den Marker wirklich <b>löschen</b>?"},
'completeDeletion()',
'closePopup()'
);
confirmationPopup.render();
}
completeDeletion = () => {
let sign = App.selectedSign;
unselectMarker();
let marker = signs.findMarkerById(sign.getID());
marker.setMap(null);
let mi = App.markerList.indexOf(marker);
App.markerList.splice(mi, 1)
let si = App.signList.indexOf(sign);
App.signList.splice(si, 1);
//remove from db
}
createMarker = (latLng) => {
App.states.isCreating = true;
App.states.createCoords = latLng;
document.getElementById('create-overlay').classList.add('is-visible');
}
completeCreation = (e) => {
e.preventDefault();
if(App.states.isCreating && App.states.createCoords){
let title = e.target.title.value;
let category = e.target.category.value;
let bent = e.target.bent.value;
let dirPath = e.target.dirPath.value;
let id = String(signs.getNewId());
let date = getFormattedDate();
let coordinats = App.states.createCoords;
let sign = new signs.Sign(id, title, bent, category, dirPath, date, coordinats);
App.signList.push(sign);
//Save Marker to Database
signs.placeMarker(sign); //not necessary if in database
selectMarker(sign);
closePopup();
}else{
closePopup();
}
e.target.reset();
}
getFormattedDate = () => {
let date = new Date();
return `${date.getDate()}.${date.getMonth()+1}.${date.getFullYear()} ${date.getHours()}:${date.getMinutes()}`;
}