-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkitchenAppliances.php
More file actions
180 lines (147 loc) · 6.99 KB
/
Copy pathkitchenAppliances.php
File metadata and controls
180 lines (147 loc) · 6.99 KB
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
<?php
require_once 'shared/global.php';
global $pdo;
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Küchengeräte</title>
<link rel="apple-touch-icon" sizes="180x180" href="<?php echo BASE_URL ?>icons/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="<?php echo BASE_URL ?>icons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="<?php echo BASE_URL ?>icons/favicon-16x16.png">
<link rel="manifest" href="<?php echo BASE_URL ?>icons/site.webmanifest">
<link rel="mask-icon" href="<?php echo BASE_URL ?>icons/safari-pinned-tab.svg" color="#5bbad5">
<link rel="shortcut icon" href="<?php echo BASE_URL ?>icons/favicon.ico">
<meta name="apple-mobile-web-app-title" content="Kochbuch">
<meta name="mobile-web-app-capable" content="yes">
<meta name="application-name" content="Kochbuch">
<meta name="msapplication-TileColor" content="#f6f6f6">
<meta name="msapplication-config" content="<?php echo BASE_URL ?>icons/browserconfig.xml">
<meta name="theme-color" content="#ffffff">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js" integrity="sha512-v2CJ7UaYy4JwqLDIrZUI/4hqeoQieOmAZNXBeQyjo21dadnwR+8ZaIJVT8EE2iyI61OV8e6M8PP2/4hpQINQ/g==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://kit.fontawesome.com/8482ce4752.js" crossorigin="anonymous"></script>
<!-- QuillJS -->
<link href="https://cdn.quilljs.com/1.3.6/quill.snow.css" rel="stylesheet">
<!-- Include jQuery UI -->
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<!-- jQuery UI Touch Punch -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui-touch-punch/0.2.3/jquery.ui.touch-punch.min.js"></script>
<link rel="stylesheet" href="style.css">
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<script src="script.js"></script>
<style>
#kuechengeräte {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
gap: 10px;
}
.kitchenAppliance {
padding: 10px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
background: var(--secondaryBackground);
cursor: pointer;
}
.kitchenAppliance:hover {
background: var(--selected_highlight);
}
.kitchenAppliance img {
display: block;
margin: 0 auto;
}
.kitchenAppliance h2 {
text-align: center;
}
</style>
</head>
<body>
<div class="nav-grid-content">
<?php require_once 'shared/navbar.php'; ?>
<div class="container">
<h1>Küchengeräte</h1>
<div id="kuechengeräte">
</div>
<script>
function updateKuechengeräte() {
var kuechengeräte = $('#kuechengeräte');
kuechengeräte.empty();
fetch('api?task=getKitchenAppliances')
.then(response => response.json())
.then(data => {
data.forEach(kitchenAppliance => {
var div = $('<div class="kitchenAppliance"></div>');
div.append($('<h2>' + kitchenAppliance.Name + '</h2>'));
div.append($('<img src="' + kitchenAppliance.Image + '" alt="' + kitchenAppliance.Name + '" style="width: 100px; height: 100px;">'));
kuechengeräte.append(div);
div.click(() => {
var form = new FormBuilder('Küchengerät bearbeiten', (data) => {
var formData = new FormData();
formData.append('id', kitchenAppliance.ID);
formData.append('Name', data.Name);
formData.append('Image', data.Bild);
fetch('api?task=updateKitchenAppliance', {
method: 'POST',
body: formData
}).then(response => response.json())
.then(data => {
if (data.success) {
updateKuechengeräte();
}
});
}, () => {
})
form.addInputField('Name', 'Name', kitchenAppliance.Name);
form.addFileField('Bild', "image/*");
form.addButton('Löschen', () => {
fetch('api?task=deleteKitchenAppliance&id=' + kitchenAppliance.ID)
.then(response => response.json())
.then(data => {
if (data.success) {
updateKuechengeräte();
form.closeForm();
}
});
});
form.renderForm();
});
});
});
}
updateKuechengeräte();
</script>
<br>
<div>
<button class="btn green" id="addKuechengerät">Küchengerät hinzufügen</button>
</div>
<script>
$('#addKuechengerät').click(function () {
var form = new FormBuilder('Küchengerät hinzufügen', (data) => {
var formData = new FormData();
formData.append('Name', data.Name);
formData.append('Image', data.Bild);
fetch('api?task=addKitchenAppliance', {
method: 'POST',
body: formData
}).then(response => response.json())
.then(data => {
if (data.success) {
updateKuechengeräte();
form.closeForm();
}
});
}, () => {
})
form.addInputField('Name', 'Name', '');
form.addFileField('Bild', "image/*");
form.renderForm();
});
</script>
</div>
</div>
</body>
</html>