{ "version": 3, "sources": ["../../javascript/src/announcement.js", "../../javascript/pwa.js"], "sourcesContent": ["class Announcement {\n // example options = { action: \"\", dismissable: true, onclose: ()=>{...} }\n constructor(subject, body, options) {\n this.subject = subject;\n this.body = body;\n this.options = options ?? {};\n this.options.onclose ??= () => this.hide();\n }\n\n get dismissable() {\n return this.options.dismissable;\n }\n\n set dismissable(value) {\n this.options.dismissable = value;\n }\n\n render() {\n const template = document.getElementById(\"js-announcement\");\n this.element = template.cloneNode(true).content.firstElementChild;\n this.element.querySelector(\".announcement-subject\").innerHTML = this.subject;\n this.element.querySelector(\".announcement-body\").innerHTML = this.body;\n if (this.options.action) {\n const action = this.element.querySelector(\".announcement-action\")\n action.innerHTML = this.options.action;\n action.parentElement.classList.remove(\"d-none\");\n }\n if (this.options.dismissable) {\n this.element.querySelector(\".btn-close\").classList.remove(\"d-none\");\n } else {\n this.element.querySelector(\".btn-close\").classList.add(\"d-none\");\n }\n if (this.options.icon) {\n this.element.querySelector(\".announcement-icon\").classList.remove(\"bi-exclamation-square\");\n this.element.querySelector(\".announcement-icon\").classList.add(this.options.icon);\n }\n this.element.querySelector(\".btn-close\").addEventListener(\"click\", () => this.options.onclose());\n return this.element;\n }\n\n onclose(handler) {\n this.options.onclose = handler;\n }\n\n show() {\n if (this.element) {\n this.element.classList.remove(\"d-none\");\n } else {\n const container = document.getElementById(\"js-announcement-container\");\n container.prepend(this.render());\n }\n }\n\n hide() {\n if (this.element) {\n this.element.classList.add(\"d-none\");\n }\n }\n}\n\nexport default Announcement;\n", "import Announcement from \"./src/announcement\";\n\nclass PwaInstallBase extends Announcement {\n constructor(description, options) {\n options ??= {};\n options.icon ??= \"bi-question-square\";\n super(`M\u00F6chtest Du die App installieren?`, description, options);\n }\n\n ignore() {\n // store the user's decision to ignore the installation prompt.\n // keep it in local storage instead of session, so it persists\n // even when session times out.\n window.localStorage.setItem(\"ignore-pwa-installation\", \"true\");\n this.hide();\n }\n\n isIgnored() {\n return window.localStorage.getItem(\"ignore-pwa-installation\") === \"true\";\n }\n\n show() {\n if (!this.isIgnored()) {\n super.show();\n }\n }\n}\n\n// PwaInstallGuide shows a news item with instructions on how to install the PWA.\n// It contains no platform specific instructions, those need to be provided via\n// the constructor's description parameter. The news item is dismissable, and\n// when dismissed, the user will not be asked again on this device.\nclass PwaInstallGuide extends PwaInstallBase {\n constructor(description) {\n super(description, { dismissable: true, onclose: () => this.ignore() });\n }\n}\n\n// PwaInstallPrompt shows a news item with buttons to accept or decline\n// installation of the PWA. If the user accepts, the installation prompt\n// is shown. If the user declines, the prompt is hidden and the user is\n// not asked again on this devices.\nclass PwaInstallPrompt extends PwaInstallBase {\n constructor(installPrompt) {\n super(\n `Mit der App kannst du tennisplatz.io bequem vom Homescreen aus starten.`,\n {\n action:\n `
\n
\n
\n \n
\n
\n \n
\n
\n
`,\n icon: \"bi-question-square\"\n }\n )\n\n this.installPrompt = installPrompt;\n }\n\n async install() {\n const result = await this.installPrompt.prompt();\n if (result.outcome === \"accepted\") {\n this.hide();\n }\n }\n\n show() {\n if (!this.isIgnored()) {\n super.show();\n $(\"#install-pwa\").on(\"click\", () => this.install());\n $(\"#ignore-pwa\").on(\"click\", () => this.ignore());\n }\n }\n}\n\n\n// Event beforeInstallPrompt is fired by the browser when it encounters\n// the PWA manifest. That event is suppressed by class PwaNews, in\n// order to show our own version of installation prompt.\nfunction beforeinstallpromptHandler(event) {\n event.preventDefault();\n $(() => {\n new PwaInstallPrompt(event).show();\n });\n // after installation has been cancelled, another beforeinstallprompt event\n // will be fired, which would create a second PwaInstallPrompt instance.\n // so remove the event listener after the news is shown initially.\n window.removeEventListener(\"beforeinstallprompt\", beforeinstallpromptHandler);\n}\n\nfunction clientIsIOS() {\n return /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;\n}\n\nfunction clientExecutesPwa() {\n // display mode to search for must be identical to the one in the manifest!\n return window.matchMedia('(display-mode: standalone)').matches;\n}\n\nif (!clientExecutesPwa()) {\n if (clientIsIOS()) {\n $(() => {\n new PwaInstallGuide(\n `Zum Installieren \u00F6ffne das Men\u00FC mit \n und w\u00E4hle 'Zum Home-Bildschirm '.\n Danach kannst du die App bequem vom Homescreen aus starten.`\n ).show();\n });\n\n } else {\n // do not put the following line inside some sort of document-ready block,\n // because beforeinstallprompt event is fired even before that.\n window.addEventListener(\"beforeinstallprompt\", beforeinstallpromptHandler);\n }\n}\n"], "mappings": ";AAAA,IAAM,eAAN,MAAmB;AAAA;AAAA,EAEjB,YAAY,SAAS,MAAM,SAAS;AAClC,SAAK,UAAU;AACf,SAAK,OAAO;AACZ,SAAK,UAAU,WAAW,CAAC;AAC3B,SAAK,QAAQ,YAAY,MAAM,KAAK,KAAK;AAAA,EAC3C;AAAA,EAEA,IAAI,cAAc;AAChB,WAAO,KAAK,QAAQ;AAAA,EACtB;AAAA,EAEA,IAAI,YAAY,OAAO;AACrB,SAAK,QAAQ,cAAc;AAAA,EAC7B;AAAA,EAEA,SAAS;AACP,UAAM,WAAW,SAAS,eAAe,iBAAiB;AAC1D,SAAK,UAAU,SAAS,UAAU,IAAI,EAAE,QAAQ;AAChD,SAAK,QAAQ,cAAc,uBAAuB,EAAE,YAAY,KAAK;AACrE,SAAK,QAAQ,cAAc,oBAAoB,EAAE,YAAY,KAAK;AAClE,QAAI,KAAK,QAAQ,QAAQ;AACvB,YAAM,SAAS,KAAK,QAAQ,cAAc,sBAAsB;AAChE,aAAO,YAAY,KAAK,QAAQ;AAChC,aAAO,cAAc,UAAU,OAAO,QAAQ;AAAA,IAChD;AACA,QAAI,KAAK,QAAQ,aAAa;AAC5B,WAAK,QAAQ,cAAc,YAAY,EAAE,UAAU,OAAO,QAAQ;AAAA,IACpE,OAAO;AACL,WAAK,QAAQ,cAAc,YAAY,EAAE,UAAU,IAAI,QAAQ;AAAA,IACjE;AACA,QAAI,KAAK,QAAQ,MAAM;AACrB,WAAK,QAAQ,cAAc,oBAAoB,EAAE,UAAU,OAAO,uBAAuB;AACzF,WAAK,QAAQ,cA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