diff --git a/dist/bundle.js b/dist/bundle.js index aaed281..df905e4 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -257,7 +257,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony default export */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"PresentsHandler\", function() { return PresentsHandler; });\nvar __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nclass PresentsHandler {\n constructor() {\n this.presents = {};\n // @ts-ignore\n this.basePath = \"http://localhost:5001\";\n }\n loadPresents() {\n return __awaiter(this, void 0, void 0, function* () {\n const presents = __webpack_require__(/*! ./presents */ \"./src/client/js/presents.ts\").default;\n presents.forEach(p => this.presents[p.id] = p);\n yield this.updateStates();\n });\n }\n updateStates() {\n return __awaiter(this, void 0, void 0, function* () {\n const presentData = yield fetch(this.basePath + \"/presents\", {\n \"credentials\": \"same-origin\",\n \"method\": \"GET\",\n }).then(function (res) {\n return res.json();\n });\n presentData.forEach(data => {\n const present = this.presents[data.id];\n if (present) {\n present.isBought = data.isBought === 1;\n present.version = data.version;\n }\n });\n });\n }\n showPresents() {\n return __awaiter(this, void 0, void 0, function* () {\n const presentContainer = document.getElementById(\"present-container\");\n const presentTemplate = document.getElementById(\"present-template\");\n presentTemplate.remove();\n presentTemplate.removeAttribute(\"id\");\n yield this.loadPresents();\n presentContainer.innerText = \"\";\n Object.values(this.presents).forEach(present => {\n const element = presentTemplate.cloneNode(true);\n element.querySelector(\".present-image\").src = present.image;\n element.querySelector(\".present-name\").innerText = present.name;\n element.querySelector(\".present-description\").innerText = present.description;\n element.href = present.link;\n const checkboxElement = element.querySelector(\".present-checkbox\");\n if (present.isBought) {\n checkboxElement.classList.add(\"checked\");\n }\n checkboxElement.addEventListener(\"click\", (e) => __awaiter(this, void 0, void 0, function* () {\n e.preventDefault();\n yield this.setPresentIsBought(present, !present.isBought);\n if (present.isBought) {\n checkboxElement.classList.add(\"checked\");\n }\n else {\n checkboxElement.classList.remove(\"checked\");\n }\n }));\n presentContainer.appendChild(element);\n });\n });\n }\n setPresentIsBought(present, isBought) {\n return __awaiter(this, void 0, void 0, function* () {\n const url = this.basePath + \"/presents\";\n const params = {\n id: present.id,\n version: present.version,\n isBought: isBought\n };\n const res = yield this.send(url, params);\n console.log(\"result\", res);\n if (res.present && res.present.id === present.id) {\n present.version = res.present.version;\n present.isBought = res.present.isBought === 1;\n }\n if (res.success === false) {\n if (res.error === \"wrong-version\") {\n alert(\"Jemand hat schon vor dir das Geschenk bearbeitet. Bitte versuche es erneut.\");\n }\n }\n });\n }\n send(url, params) {\n return __awaiter(this, void 0, void 0, function* () {\n let headers = {};\n if (!(params instanceof FormData) && typeof params === \"object\") {\n params = JSON.stringify(params);\n headers = {\n \"Content-Type\": \"application/json\"\n };\n }\n return fetch(url, {\n \"credentials\": \"same-origin\",\n \"method\": \"POST\",\n \"headers\": headers,\n \"body\": params,\n }).then(function (res) {\n return res.json();\n }).catch(function (e) {\n debugger;\n console.error(\"error\", e);\n return {\n \"success\": false,\n \"errors\": [\n \"not-online\"\n ]\n };\n });\n });\n }\n}\n\n\n//# sourceURL=webpack:///./src/client/js/PresentsHandler.ts?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"PresentsHandler\", function() { return PresentsHandler; });\nvar __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nclass PresentsHandler {\n constructor() {\n this.presents = {};\n // @ts-ignore\n this.basePath = \".\";\n }\n loadPresents() {\n return __awaiter(this, void 0, void 0, function* () {\n const presents = __webpack_require__(/*! ./presents */ \"./src/client/js/presents.ts\").default;\n presents.forEach(p => this.presents[p.id] = p);\n yield this.updateStates();\n });\n }\n updateStates() {\n return __awaiter(this, void 0, void 0, function* () {\n const presentData = yield fetch(this.basePath + \"/presents\", {\n \"credentials\": \"same-origin\",\n \"method\": \"GET\",\n }).then(function (res) {\n return res.json();\n });\n presentData.forEach(data => {\n const present = this.presents[data.id];\n if (present) {\n present.isBought = data.isBought === 1;\n present.version = data.version;\n }\n });\n });\n }\n showPresents() {\n return __awaiter(this, void 0, void 0, function* () {\n const presentContainer = document.getElementById(\"present-container\");\n const presentTemplate = document.getElementById(\"present-template\");\n presentTemplate.remove();\n presentTemplate.removeAttribute(\"id\");\n yield this.loadPresents();\n presentContainer.innerText = \"\";\n Object.values(this.presents).forEach(present => {\n const element = presentTemplate.cloneNode(true);\n element.querySelector(\".present-image\").src = present.image;\n element.querySelector(\".present-name\").innerText = present.name;\n element.querySelector(\".present-description\").innerText = present.description;\n element.href = present.link;\n const checkboxElement = element.querySelector(\".present-checkbox\");\n if (present.isBought) {\n checkboxElement.classList.add(\"checked\");\n }\n checkboxElement.addEventListener(\"click\", (e) => __awaiter(this, void 0, void 0, function* () {\n e.preventDefault();\n yield this.setPresentIsBought(present, !present.isBought);\n if (present.isBought) {\n checkboxElement.classList.add(\"checked\");\n }\n else {\n checkboxElement.classList.remove(\"checked\");\n }\n }));\n presentContainer.appendChild(element);\n });\n });\n }\n setPresentIsBought(present, isBought) {\n return __awaiter(this, void 0, void 0, function* () {\n const url = this.basePath + \"/presents\";\n const params = {\n id: present.id,\n version: present.version,\n isBought: isBought\n };\n const res = yield this.send(url, params);\n console.log(\"result\", res);\n if (res.present && res.present.id === present.id) {\n present.version = res.present.version;\n present.isBought = res.present.isBought === 1;\n }\n if (res.success === false) {\n if (res.error === \"wrong-version\") {\n alert(\"Jemand hat schon vor dir das Geschenk bearbeitet. Bitte versuche es erneut.\");\n }\n }\n });\n }\n send(url, params) {\n return __awaiter(this, void 0, void 0, function* () {\n let headers = {};\n if (!(params instanceof FormData) && typeof params === \"object\") {\n params = JSON.stringify(params);\n headers = {\n \"Content-Type\": \"application/json\"\n };\n }\n return fetch(url, {\n \"credentials\": \"same-origin\",\n \"method\": \"POST\",\n \"headers\": headers,\n \"body\": params,\n }).then(function (res) {\n return res.json();\n }).catch(function (e) {\n debugger;\n console.error(\"error\", e);\n return {\n \"success\": false,\n \"errors\": [\n \"not-online\"\n ]\n };\n });\n });\n }\n}\n\n\n//# sourceURL=webpack:///./src/client/js/PresentsHandler.ts?"); /***/ }), diff --git a/dist/img/geschenke.jpg b/dist/img/geschenke.jpg index ee2dc03..0c746d5 100644 Binary files a/dist/img/geschenke.jpg and b/dist/img/geschenke.jpg differ diff --git a/dist/img/home.jpg b/dist/img/home.jpg index ae14348..3caa5f5 100644 Binary files a/dist/img/home.jpg and b/dist/img/home.jpg differ diff --git a/dist/img/unterkunft.jpg b/dist/img/unterkunft.jpg index 9ac2e7c..d00bfc8 100644 Binary files a/dist/img/unterkunft.jpg and b/dist/img/unterkunft.jpg differ diff --git a/dist/index.html b/dist/index.html index 1911501..9987e65 100644 --- a/dist/index.html +++ b/dist/index.html @@ -45,33 +45,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - -