diff --git a/index.html b/index.html index cb737b5..9a4780d 100644 --- a/index.html +++ b/index.html @@ -11,7 +11,6 @@ - diff --git a/manifest.json b/manifest.json deleted file mode 100755 index 9de1eaa..0000000 --- a/manifest.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "name": "Amedorf & Ritzenbergen", - "short_name": "ritzenbergen.de", - "theme_color": "#FFBF00", - "background_color": "#FE9A2E", - "display": "fullScreen", - "orientation": "portrait", - "scope": "/", - "start_url": "https://ritzenbergen.netlify.app/", - "icons": [ - { - "src": "images/icons/icon-72x72.png", - "sizes": "72x72", - "type": "image/png" - }, - { - "src": "images/icons/icon-96x96.png", - "sizes": "96x96", - "type": "image/png" - }, - { - "src": "images/icons/icon-128x128.png", - "sizes": "128x128", - "type": "image/png" - }, - { - "src": "images/icons/icon-144x144.png", - "sizes": "144x144", - "type": "image/png" - }, - { - "src": "images/icons/icon-152x152.png", - "sizes": "152x152", - "type": "image/png" - }, - { - "src": "images/icons/icon-192x192.png", - "sizes": "192x192", - "type": "image/png" - }, - { - "src": "images/icons/icon-384x384.png", - "sizes": "384x384", - "type": "image/png" - }, - { - "src": "images/icons/icon-512x512.png", - "sizes": "512x512", - "type": "image/png" - } - ] -} \ No newline at end of file diff --git a/src/components/FormResults.vue b/src/components/FormResults.vue new file mode 100644 index 0000000..f782fc6 --- /dev/null +++ b/src/components/FormResults.vue @@ -0,0 +1,93 @@ + + + + Ergebnisse {{ form.name }} + + + + + {{ field.displayname ?? field.name }} + + Zeitstempel + + + + + + {{ + prettyResult( + result.data.find( + (el) => + el.name == field.name || + el.name + "[]" == field.name + ) + ) + }} + + + {{ result.timestamp }} + + + + + + diff --git a/src/components/startseite/Forms.vue b/src/components/startseite/Forms.vue index 744bd29..47229d0 100644 --- a/src/components/startseite/Forms.vue +++ b/src/components/startseite/Forms.vue @@ -1,183 +1,135 @@ - - - - - - - - - {{ form.ueberschrift }} - - - - - {{ form.inhalt }} - - + + + + + + + + + + + {{ form.name }} + + + + {{ form.minitext }} + + + + + + + + + + + + {{ + field.displayvalue ?? field.displayname ?? field.name + }}: + + + + {{ field.value }} + - - {{ form.modalueberschrift }} - - - - {{ form.labelone }} - {{ form.labeltwo }} - Datum - - - {{ result.value1 }} - {{ result.value2 }} - {{ result.timestamp }} - - - - - - {{ process_minitext(form.minitext) }} - - - - - - - - - - - - - - - - - - Absenden - - - - - - - - - - + + + Absenden + + + + + + + + + - + diff --git a/src/ritzenbergenlib.ts b/src/ritzenbergenlib.ts index 3b9a3cd..cc065a7 100644 --- a/src/ritzenbergenlib.ts +++ b/src/ritzenbergenlib.ts @@ -1,127 +1,297 @@ import $ from "jquery"; +import { ref } from "vue"; class User { - public username: string; - public kuerzel: string; - public points: number; - public id: number; - constructor (username: string, kuerzel: string, points: number, id: number) { - this.username = username; - this.kuerzel = kuerzel; - this.points=points; - this.id=id; - } - hatgetippt():boolean{ - var hatgetippt=false; - $.ajax(RitzenbergenLib.api("/bulitipp/hatgetippt.php?userid="+this.id),{ - async: false, - success(response): any{ - hatgetippt=response==1; - console.log(response); - } - }); - return hatgetippt; - } + public username: string; + public kuerzel: string; + public points: number; + public id: number; + constructor(username: string, kuerzel: string, points: number, id: number) { + this.username = username; + this.kuerzel = kuerzel; + this.points = points; + this.id = id; + } + hatgetippt(): boolean { + var hatgetippt = false; + $.ajax( + RitzenbergenLib.api("/bulitipp/hatgetippt.php?userid=" + this.id), + { + async: false, + success(response): any { + hatgetippt = response == 1; + console.log(response); + }, + } + ); + return hatgetippt; + } } class SpieltagSumme { - public user: User; - public tsPoints: number; - constructor (user: User, tsPoints: number) { - this.user = user; - this.tsPoints = tsPoints; - } + public user: User; + public tsPoints: number; + constructor(user: User, tsPoints: number) { + this.user = user; + this.tsPoints = tsPoints; + } } class RitzenbergenLib { - static get_img(mypath: string) { - if(mypath.startsWith("/")) return "https://bilder.ritzenbergen.de"+mypath; - else return "https://bilder.ritzenbergen.de/"+mypath; - } - static api(path:string){ - if(path.startsWith("/")) return "http://192.168.188.38/Jonas/ritzenbergenapi"+path; - else return "http://192.168.188.38/Jonas/ritzenbergenapi/"+path; - } + static get_img(mypath: string) { + if (mypath.startsWith("/")) + return "https://bilder.ritzenbergen.de" + mypath; + else return "https://bilder.ritzenbergen.de/" + mypath; + } + static api(path: string) { + if (path.startsWith("/")) + return "http://192.168.188.38/Jonas/ritzenbergenapi" + path; + else return "http://192.168.188.38/Jonas/ritzenbergenapi/" + path; + } } class Paarung { - public heim: string; - public gast: string; - public id: number; - constructor (heim: string, gast: string, id: number) { - this.heim = heim; - this.gast = gast; - this.id=id; - } + public heim: string; + public gast: string; + public id: number; + constructor(heim: string, gast: string, id: number) { + this.heim = heim; + this.gast = gast; + this.id = id; + } } class Ergebnis { - paarung: Paarung; - heim: number; - gast: number; - constructor (paarung: Paarung, heim: number, gast: number) { - this.paarung = paarung; - this.heim = heim; - this.gast = gast; - } + paarung: Paarung; + heim: number; + gast: number; + constructor(paarung: Paarung, heim: number, gast: number) { + this.paarung = paarung; + this.heim = heim; + this.gast = gast; + } } -class Tipp{ - heim: number|null; - gast: number|null; - paarung: Paarung|null; +class Tipp { + heim: number | null; + gast: number | null; + paarung: Paarung | null; - constructor (paarung: Paarung|null, heim: number|null, gast: number|null) { - this.heim = heim; - this.gast = gast; - this.paarung = paarung; - } + constructor( + paarung: Paarung | null, + heim: number | null, + gast: number | null + ) { + this.heim = heim; + this.gast = gast; + this.paarung = paarung; + } } class Spiel { - public paarung: Paarung; - public result: [number, number]|null; - public tipp: [number, number]|null; - - constructor (paarung: Paarung, result: [number, number], tipp: [number, number]|null) { - this.paarung = paarung; - this.result = result; - this.tipp = tipp; - } - public calcPoints(){ - if(this.tipp==null) return 0; - if(this.result[0]==this.tipp[0] && this.result[1]==this.tipp[1]) return 3; - let differenztipp=this.tipp[0]-this.tipp[1]; - let differenz=this.result[0]-this.result[1]; - if(differenztipp==differenz) return 2; - if( - (this.tipp[0]>this.tipp[1] && this.result[0]>this.result[1]) || - (this.tipp[0]{ - return response.json(); - }).then((data)=>{ - return data.data; - }).then((data)=>{ - return data.map((el)=>{ - return new Spiel(new Paarung(el.paarung.heim, el.paarung.gast, el.paarung.id),el.result, el.tipp); - }); + public paarung: Paarung; + public result: [number, number] | null; + public tipp: [number, number] | null; + + constructor( + paarung: Paarung, + result: [number, number], + tipp: [number, number] | null + ) { + this.paarung = paarung; + this.result = result; + this.tipp = tipp; + } + public calcPoints() { + if (this.tipp == null) return 0; + if (this.result[0] == this.tipp[0] && this.result[1] == this.tipp[1]) + return 3; + let differenztipp = this.tipp[0] - this.tipp[1]; + let differenz = this.result[0] - this.result[1]; + if (differenztipp == differenz) return 2; + if ( + (this.tipp[0] > this.tipp[1] && this.result[0] > this.result[1]) || + (this.tipp[0] < this.tipp[1] && this.result[0] < this.result[1]) + ) + return 1; + return 0; + } + public static async fetchSpiele(spieltag: number, userid: number): Spiel[] { + let params = new URLSearchParams({ + spieltag: spieltag + 1, + user: userid, + }); + return fetch( + RitzenbergenLib.api("/bulitipp/spieltag-user.php?") + + params.toString() + ) + .then((response) => { + return response.json(); + }) + .then((data) => { + return data.data; + }) + .then((data) => { + return data.map((el) => { + return new Spiel( + new Paarung( + el.paarung.heim, + el.paarung.gast, + el.paarung.id + ), + el.result, + el.tipp + ); }); + }); + } +} +class Formular { + public id: number; + public name: string; + public minitext: string; + public ispublic: boolean; + public multiple: boolean; + public fields=ref([]); + constructor( + id: number, + name: string, + minitext: string, + ispublic: boolean, + multiple: boolean + ) { + this.id = id; + this.name = name; + this.minitext = minitext; + this.ispublic = ispublic; + this.multiple = multiple; + this.getFields().then((fields)=>this.fields.value=fields); + } + public static async getForms(): Promise { + let forms: Formular[] = []; + forms = await fetch( + RitzenbergenLib.api("/formulare/get_formulare.php"), + { + method: "GET", + } + ) + .then((response) => response.json()) + .then((result) => + result.map( + (el: any) => + new Formular( + el.id, + el.name, + el.minitext, + el.public, + el.multiple + ) + ) + ); + + return forms; + } + private async getFields(): Promise { + return fetch( + RitzenbergenLib.api( + "/formulare/get_fields.php?formular=" + this.id + ), + { + method: "GET", + } + ) + .then((response) => response.json()) + .then((result) => + result.map( + (el: any) => + new Field(el.formular, el.name, el.value, el.type, { + id: el.id, + displayname: el.displayname, + displayvalue: el.displayvalue, + placeholder: el.placeholder, + title: el.title, + required: el.required == 1, + maxlength: el.maxlength, + min: el.min, + max: el.max, + multiple: el.multiple == 1, + checked: el.checked == 1, + }) + ) + ); + } +} +type FieldType = + | "text" + | "password" + | "number" + | "range" + | "date" + | "time" + | "checkbox" + | "radio" + | "color" + | "submit" + | "textarea"; + +class Field { + id?: number; + formular: number; + name: string; + displayname?: string | null; + value: string; + displayvalue?: string | null; + placeholder?: string | null; + type: FieldType; + title?: string | null; + required: boolean; + maxlength?: number | null; + min?: number | null; + max?: number | null; + checked?: boolean | null; + constructor( + formular: number, + name: string, + value: string, + type: FieldType, + options?: { + id?: number; + displayname?: string | null; + displayvalue?: string | null; + placeholder?: string | null; + title?: string | null; + required?: boolean; + maxlength?: number | null; + min?: number | null; + max?: number | null; + multiple?: boolean | null; + checked?: boolean | null; } + ) { + this.id = options?.id; + this.formular = formular; + this.name = name; + this.displayname = options?.displayname ?? null; + this.value = value; + this.displayvalue = options?.displayvalue ?? null; + this.placeholder = options?.placeholder ?? null; + this.type = type; + this.title = options?.title ?? null; + this.required = options?.required ?? false; + this.maxlength = options?.maxlength ?? null; + this.min = options?.min ?? null; + this.max = options?.max ?? null; + this.checked = options?.checked ?? null; + } } export default { - RitzenbergenLib, - User, - SpieltagSumme, - Paarung, - Ergebnis, - Tipp, - Spiel -} + RitzenbergenLib, + User, + SpieltagSumme, + Paarung, + Ergebnis, + Tipp, + Spiel, + Formular, + Field, +};
- {{ process_minitext(form.minitext) }} -