diff options
author | LarsVomMars | 2020-10-10 12:12:11 +0200 |
---|---|---|
committer | LarsVomMars | 2020-10-10 12:12:11 +0200 |
commit | 8377cd9881167dcde40f0947c623ddbb64120747 (patch) | |
tree | 249005836358fc73049b3e4c2c8c6040830353b1 | |
parent | 7a4ade2036140203cee39cc7622f835114862515 (diff) |
Some npm scripts
-rw-r--r-- | .eslintrc.js | 21 | ||||
-rw-r--r-- | db.js | 14 | ||||
-rwxr-xr-x | motto/get.sh | 3 | ||||
-rw-r--r-- | motto/index.js | 76 | ||||
-rw-r--r-- | motto/list.txt | 167 | ||||
-rw-r--r-- | motto/public/add.svg | 1 | ||||
-rw-r--r-- | motto/public/all.svg | 1 | ||||
-rw-r--r-- | motto/public/hammer.js | 1203 | ||||
-rw-r--r-- | motto/public/heart.svg | 1 | ||||
-rw-r--r-- | motto/public/index.html | 39 | ||||
-rw-r--r-- | motto/public/reload.svg | 1 | ||||
-rw-r--r-- | motto/public/script.js | 216 | ||||
-rw-r--r-- | motto/public/shuffle.svg | 1 | ||||
-rw-r--r-- | motto/public/skip.svg | 1 | ||||
-rw-r--r-- | motto/public/style.css | 143 | ||||
-rw-r--r-- | motto/public/x.svg | 1 | ||||
-rw-r--r-- | package.json | 5 |
17 files changed, 23 insertions, 1871 deletions
diff --git a/.eslintrc.js b/.eslintrc.js index 4d11b96..8b48d88 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,14 +1,15 @@ module.exports = { - "env": { - "browser": true, - "commonjs": true, - "es2020": true, - "node": true + env: { + browser: true, + commonjs: true, + es2020: true, + node: true, }, - "extends": "eslint:recommended", - "parserOptions": { - "ecmaVersion": 11 + extends: "eslint:recommended", + parserOptions: { + ecmaVersion: 11, + }, + rules: { + "no-unused-vars": "warn", }, - "rules": { - } }; @@ -37,7 +37,7 @@ class DB { await this.query("INSERT INTO types (name) VALUES ('pupil'), ('teacher')"); await this.query( - "INSERT INTO class (name) VALUES ('TGM13.1'), ('TGM13.2'), ('TGTM13.1'), ('TGI13.1'), ('TGI13.2'), ('teacher')" + "INSERT INTO class (name) VALUES ('TGM13.1'), ('TGM13.2'), ('TGTM13.1'), ('TGI13.1'), ('TGI13.2'), ('teacher')", ); fs.readFile(__dirname + "/poll.txt", "utf8", (err, data) => { @@ -48,7 +48,10 @@ class DB { const questions = part.split("\n"); questions.forEach((question) => { if (question.length > 0) - this.query("INSERT INTO ranking_questions (question, type_id) VALUE (?,?)", [question, i+1]); + this.query("INSERT INTO ranking_questions (question, type_id) VALUE (?,?)", [ + question, + i + 1, + ]); }); }); }); @@ -59,8 +62,7 @@ class DB { const mottos = data.split("\n"); mottos.forEach(async (motto) => { const [name, desc] = motto.split(" - "); - if (motto) - await this.query("INSERT INTO mottos (name, description) VALUES (?, ?)", [name, desc]); + if (motto) await this.query("INSERT INTO mottos (name, description) VALUES (?, ?)", [name, desc]); }); }); @@ -86,7 +88,7 @@ class DB { userPasswords[classIndex].push({ username, pwd }); await this.query( "INSERT INTO users (username, name, middlename, surname, password, class_id, type_id) VALUE (?,?,?,?,?,?,?)", - [username, names[0].replace("\r", ""), middlename, surname, password, classIndex + 1, 2] + [username, names[0].replace("\r", ""), middlename, surname, password, classIndex + 1, 2], ); } } @@ -102,8 +104,6 @@ class DB { const conn = await this.connect(); try { return await conn.query(query, params); - } catch (e) { - throw e; } finally { conn.release(); } diff --git a/motto/get.sh b/motto/get.sh deleted file mode 100755 index 106a6ed..0000000 --- a/motto/get.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -grep -E '^(([A-Z].*[aA]|A)[bB]|B)([iI].*|)$' german.dic | grep -v '[aA]bitur' >list.txt diff --git a/motto/index.js b/motto/index.js deleted file mode 100644 index 4a8ed3b..0000000 --- a/motto/index.js +++ /dev/null @@ -1,76 +0,0 @@ -const express = require("express"); -const rateLimit = require("express-rate-limit"); -const db = require("../db"); -const app = express.Router(); - -const apiLimiter = rateLimit({ - windowMs: 10 * 60 * 1000, - max: 100, - message: "Access overflow!", -}); - -//const fs = require("fs"); -//app.get("/sync", (req, res) => { -// fs.readFile(__dirname + "/list.txt", "utf8", (err, data) => { -// if (err) { -// console.error(err); -// return res.send("error"); -// } -// const lines = data.split("\n"); -// lines.forEach(async (line) => { -// const split = line.split(" - "); -// try { -// if (split.length >= 2) -// await db.query("INSERT INTO theme (main, description) VALUES (?, ?)", split.slice(0, 2)); -// else console.log(line); -// } catch (e) { -// console.error(e); -// } -// }); -// res.send("ok"); -// }); -//}); - -app.use("/", express.static(__dirname + "/public")); - -app.use("/api/", apiLimiter); - -app.get("/api/list", async (req, res) => { - try { - const themes = await db.query("SELECT * FROM theme WHERE hidden = FALSE ORDER BY votes DESC"); - res.json(themes); - } catch (e) { - console.error(e); - res.send("error"); - } -}); - -app.post("/api/add", async (req, res) => { - console.log(req.body.main, req.body.description); - if (!req.body.main || !req.body.description) return res.send("error"); - try { - await db.query("INSERT INTO theme (main, description) VALUES (?, ?)", [req.body.main, req.body.description]); - res.send("ok"); - } catch (e) { - console.error(e); - res.send("error"); - } -}); - -app.post("/api/vote", async (req, res) => { - console.log(req.body.id, req.body.vote); - if (req.body.vote < -1 || req.body.vote > 1) { - res.send("error"); - return; - } - - try { - await db.query("UPDATE theme SET votes = votes + ? WHERE id = ?", [req.body.vote, req.body.id]); - res.send("ok"); - } catch (e) { - console.error(e); - res.send("error"); - } -}); - -module.exports = app; diff --git a/motto/list.txt b/motto/list.txt deleted file mode 100644 index 6dd8d77..0000000 --- a/motto/list.txt +++ /dev/null @@ -1,167 +0,0 @@ -A, B, I, C - Und wir können’s trotzdem nicht
-A.B.I. - Association of being intelligent
-AB In den Puff - Die Noten tanzen an der Stange
-ABI 2,021‰ - Meist dichter als Denker
-ABI 2021 - Autogramme gibt’s später
-ABI 2021 - Die Elite braucht kein Motto
-ABI 2021 - Ein Drama in 13 Akten
-ABI 2021 - Scheiß auf PISA, ist ja nicht unser Turm
-ABI 2021 - Wir waren unschuldig und bekamen 13 Jahre
-ABI Baba und die 40 Unterkurse - ...
-ABI Curie - Zwischen Genie und Wahnsinn
-ABI DABU - Endlich weg!
-ABI Darnell - Drama, Baby, Drama!
-ABI Floyd - We don’t need no education
-ABI Rouge - Endlich raus aus dem Rotstiftmilieu
-ABI bitte mit Sahne! - ...
-ABI con carne - Scharf im Abgang
-ABI ergo sum - Ich habe Abi, also bin ich
-ABI heute - Captain Morgan
-ABI la vista - Die Zukunft wartet
-ABI looking for freedom - ...
-ABI there for you - ...
-ABI - Wir hätten jemanden fragen sollen, der sich damit auskennt
-ABI/DC - Highway to Hell
-ABIagra - Und das ABI steht
-ABIairlines - Wir hoffen, Sie hatten einen angenehmen Flug!
-ABIbaba - Aus jeder Flasche kann was werden
-ABIbama - Yes, we can!
-ABIbel - Hier gelten unsere Gebote
-ABIbolika - Der Stoff kam aus dem Lehrerzimmer
-ABIbook - Dir und XXX anderen gefällt das
-ABIcalypse now - ...
-ABIcatraz - Lang genug gesessen
-ABIcrombie & Fitch - Die Models gehen, die Elche bleiben
-ABIdas - Die Markenware verlässt das Geschäft
-ABIdisiakum - Wissen macht unwiderstehlich
-ABIdur - Nie wieder Moll
-ABIene Maja - Wo ein Willi ist, ist auch ein Weg
-ABIertur - Trinkt aus, wir gehen
-ABIgasmus - Aber das war nur das Vorspiel
-ABIgasmus - 13 Jahre bis zum Höhepunkt
-ABIgeddon - Das war knapp
-ABIgent - Ausgelernt und Ziel erfasst
-ABIgeschrieben - ...
-ABIkaribik - Der Fluch hat ein Ende
-ABIkea - Lernst du noch oder lebst du schon?
-ABIkini - Knapp, aber passt schon!
-ABIkur - Endlich relaxen
-ABIlanz - Vom Soll ins Haben
-ABIleave I can fly - ...
-ABIlirium - Wir schlucken einiges
-ABIlymp - Wenn Götter gehen
-ABIman’s Friends - Sind sie zu schlau, bist du zu dumm
-ABImbledon - Auf Gras sind wir besser
-ABImorphose - Vom Hugo zum Boss
-ABImtote - 13 Jahre unterm Nullniveau
-ABIn die Freiheit - ...
-ABInal und Elmex - Doppelt hält besser
-ABInal - Alles für’n Arsch
-ABInet - Wir haben uns durchgegoogelt
-ABIpedia - 13 Jahre Copy & Paste
-ABIpfiff - Die Champions verlassen das Stadion
-ABIpunktur - Jeder Punkt kostet Nerven
-ABIputtel - 13 Jahre geknechtet, jetzt geht’s zum Ball
-ABIquarium - Die großen Fische verlassen das Becken
-ABIraten - Wir verlassen das sinkende Schiff
-ABIrobic - Die Gymnasten gehen
-ABIsasam - 13 Jahre nicht entwickelt
-ABIsaurus Rex - Das Ende der Kreidezeit
-ABIsexuell - Offen für alles
-ABIsinth - Wir gehen mit Weh(r)mut
-ABIsolierzange - Wir haben nicht gekniffen
-ABIstokratie - Der Adel geht, der Pöbel bleibt
-ABIsutra - Ab sofort auf Stellungssuche
-ABItendo - Level 13 complete
-ABItiner - Ausreichend gepunktet
-ABItomie - Wir haben alles rausgeholt
-ABItricks und Mogelnix - Die spinnen, die Lehrer!
-ABItuhr - Die schönste Zeit ist vorbei
-ABItur est un perroquet - ...
-ABIturientchen - Wir watscheln ins Leben
-ABItür - Wir haben den Ausgang gefunden
-ABIwatchers - Bei meinen Punkten wäre ich fast verhungert!
-ABIwehr - getarnte Intelligenz
-ABIwesend - für immer entschuldigt
-ABIwood - 13 Jahre im falschen Film
-ABIós Amigos - ...
-AbiCurie - Zwischen Genie und Wahnsinn
-Abikalypse - und nach uns die Sintflut
-AlABIn - Die Genies sind frei
-BABIcue - Wir sind heiß und brauchen Kohle
-BABIlon - Und das war erst der Anfang
-BArBIe - Yes, we Ken!
-BacABI Feeling - ...
-BrausetABIlette - Wir zischen ab
-CABIsino - 13 Jahre Glück gehabt
-CannABIs - Higher educated
-CannABIs - Wir haben’s durchgezogen
-Circus ABIgalli - Raus aus dem Wahnsinn
-CoronABI - Wir haben's überstanden!
-C’est l’ABI, chérie! - ...
-Don’t worry, ABI happy! - ...
-DuschkABIne - Wir brausen ab
-El ABIturo - Schule kam uns schon immer Spanisch vor
-EnergiespABIlampe - Die wahren Leuchten verschwinden
-FerrABI - Leben auf der Überholspur
-GABI - Es war eng aber geil!
-GABIdalf - Flieht, ihr Narren!
-Get ABI or die tryin‘ - ...
-GruselkABInett - 13 Jahre Horrorshow
-Grün geärgert, blau gemacht, weise geworden - Jetzt wird’s uns zu bunt!
-HABI Potter - Wir verlassen die Kammer des Schreckens
-HABI Potter - 13 Jahre durchgemuggelt
-HABIwaii - Reif für die Insel
-Hakuna MatABI - Die Könige von morgen
-How I met my ABI - It was legen... (wait for it) ...dary
-I can’t be what I wannABI - ...
-IlluminABI - Endlich erleuchtet
-KABInett - Die Chefetage geht
-KABItalismus - 13 Jahre Klassenkampf
-KGB - Kampf gegen die Blödheit - Wir haben gesiegt
-KafkABI - Der Prozess hat ein Ende
-KarABIner - Nichts kann uns halten
-KennABI - Ick bin ein Abiturient!
-KleptomABIe - Wir stehlen uns davon
-KohlrABI - Wir machen uns vom Acker
-KollABIeren - nach 13 Jahren am Ende
-LABIrinth - Planlos zum Ziel
-LABIrinth - Endlich am Ziel
-MABIfiosi - 13 Jahre abgezockt
-MDMAbi - Alles geschmissen außer die Schule!
-MafiABI - 13 Jahre unorganisiertes Verbrechen
-Mahatma ABI - Mahatma’s nicht!
-MilkABI - Die zarteste Versuchung, seit es Abiturienten gibt
-Muhammad ABI - Sieg nach Punkten
-My heart skips ABI - ...
-NSABI - Wir wissen alles
-NinjABI - Unsere Augen waren überall
-NutellABI - Alles wie geschmiert
-OsamABInladen - 13 Jahre Terror
-PABI Schlumpf - 13 Jahre blau
-PandABI - Die letzten ihrer Art
-PirABI - alle Mann von Board!
-RABInson Crusoe - Gerettet nach 13 Jahren
-RentABIlität - Und es hat sich doch gelohnt
-SalABI - Ist doch alles Wurscht
-SemipermeABIlität - Nur die Besten kommen durch
-ShishABI - Die Köpfe qualmen
-Spieglein, Spieglein an der Wand - wer hat das ABI in der Hand?
-Spongebob SchwABIkopf - Die Burger Brater von morgen
-Suit up! It’s gonnABI legendary! - ...
-SwABIrowski - Die Diamanten sind geschliffen
-TeletABI - Wir sagen winke, winke
-TherABIe beendet - Wir verlassen die Anstalt
-TirABIsu - Auch die Crème de la Crème muss mal gehen
-Tour d’ABI - Die härtesten 13 Etappen unseres Lebens
-Veni, vidi, abi - ...
-Vitamin C, E und ABI - Wir sind gestärkt
-VokABI - Voll im Lernstress
-Wake me up when ABI ends - ...
-WasABI - Der schärfste Jahrgang aller Zeiten
-Westminster ABI - Der Adel geht
-WhatsABI - zuletzt online 20:21
-WubbalABIdubdub - ...
-ZABIlando - Schrei vor Glück!
-ZABIlando - Schrei vor Glück
-ZebrABI - Wir streifen durch das Land
diff --git a/motto/public/add.svg b/motto/public/add.svg deleted file mode 100644 index 7e535dc..0000000 --- a/motto/public/add.svg +++ /dev/null @@ -1 +0,0 @@ -<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#424242" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-plus"><line x1="12" y1="5" x2="12" y2="19"></line><line x1="5" y1="12" x2="19" y2="12"></line></svg> diff --git a/motto/public/all.svg b/motto/public/all.svg deleted file mode 100644 index b1b93c2..0000000 --- a/motto/public/all.svg +++ /dev/null @@ -1 +0,0 @@ -<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#424242" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-layers"><polygon points="12 2 2 7 12 12 22 7 12 2"></polygon><polyline points="2 17 12 22 22 17"></polyline><polyline points="2 12 12 17 22 12"></polyline></svg> diff --git a/motto/public/hammer.js b/motto/public/hammer.js deleted file mode 100644 index ffe1c70..0000000 --- a/motto/public/hammer.js +++ /dev/null @@ -1,1203 +0,0 @@ -/*! Hammer.JS - v2.0.8 - 2016-04-23 - * http://hammerjs.github.io/ - * - * Copyright (c) 2016 Jorik Tangelder; - * Licensed under the MIT license */ -!(function (a, b, c, d) { - "use strict"; - function e(a, b, c) { - return setTimeout(j(a, c), b); - } - function f(a, b, c) { - return Array.isArray(a) ? (g(a, c[b], c), !0) : !1; - } - function g(a, b, c) { - var e; - if (a) - if (a.forEach) a.forEach(b, c); - else if (a.length !== d) - for (e = 0; e < a.length; ) b.call(c, a[e], e, a), e++; - else for (e in a) a.hasOwnProperty(e) && b.call(c, a[e], e, a); - } - function h(b, c, d) { - var e = "DEPRECATED METHOD: " + c + "\n" + d + " AT \n"; - return function () { - var c = new Error("get-stack-trace"), - d = - c && c.stack - ? c.stack - .replace(/^[^\(]+?[\n$]/gm, "") - .replace(/^\s+at\s+/gm, "") - .replace(/^Object.<anonymous>\s*\(/gm, "{anonymous}()@") - : "Unknown Stack Trace", - f = a.console && (a.console.warn || a.console.log); - return f && f.call(a.console, e, d), b.apply(this, arguments); - }; - } - function i(a, b, c) { - var d, - e = b.prototype; - (d = a.prototype = Object.create(e)), - (d.constructor = a), - (d._super = e), - c && la(d, c); - } - function j(a, b) { - return function () { - return a.apply(b, arguments); - }; - } - function k(a, b) { - return typeof a == oa ? a.apply(b ? b[0] || d : d, b) : a; - } - function l(a, b) { - return a === d ? b : a; - } - function m(a, b, c) { - g(q(b), function (b) { - a.addEventListener(b, c, !1); - }); - } - function n(a, b, c) { - g(q(b), function (b) { - a.removeEventListener(b, c, !1); - }); - } - function o(a, b) { - for (; a; ) { - if (a == b) return !0; - a = a.parentNode; - } - return !1; - } - function p(a, b) { - return a.indexOf(b) > -1; - } - function q(a) { - return a.trim().split(/\s+/g); - } - function r(a, b, c) { - if (a.indexOf && !c) return a.indexOf(b); - for (var d = 0; d < a.length; ) { - if ((c && a[d][c] == b) || (!c && a[d] === b)) return d; - d++; - } - return -1; - } - function s(a) { - return Array.prototype.slice.call(a, 0); - } - function t(a, b, c) { - for (var d = [], e = [], f = 0; f < a.length; ) { - var g = b ? a[f][b] : a[f]; - r(e, g) < 0 && d.push(a[f]), (e[f] = g), f++; - } - return ( - c && - (d = b - ? d.sort(function (a, c) { - return a[b] > c[b]; - }) - : d.sort()), - d - ); - } - function u(a, b) { - for ( - var c, e, f = b[0].toUpperCase() + b.slice(1), g = 0; - g < ma.length; - - ) { - if (((c = ma[g]), (e = c ? c + f : b), e in a)) return e; - g++; - } - return d; - } - function v() { - return ua++; - } - function w(b) { - var c = b.ownerDocument || b; - return c.defaultView || c.parentWindow || a; - } - function x(a, b) { - var c = this; - (this.manager = a), - (this.callback = b), - (this.element = a.element), - (this.target = a.options.inputTarget), - (this.domHandler = function (b) { - k(a.options.enable, [a]) && c.handler(b); - }), - this.init(); - } - function y(a) { - var b, - c = a.options.inputClass; - return new (b = c ? c : xa ? M : ya ? P : wa ? R : L)(a, z); - } - function z(a, b, c) { - var d = c.pointers.length, - e = c.changedPointers.length, - f = b & Ea && d - e === 0, - g = b & (Ga | Ha) && d - e === 0; - (c.isFirst = !!f), - (c.isFinal = !!g), - f && (a.session = {}), - (c.eventType = b), - A(a, c), - a.emit("hammer.input", c), - a.recognize(c), - (a.session.prevInput = c); - } - function A(a, b) { - var c = a.session, - d = b.pointers, - e = d.length; - c.firstInput || (c.firstInput = D(b)), - e > 1 && !c.firstMultiple - ? (c.firstMultiple = D(b)) - : 1 === e && (c.firstMultiple = !1); - var f = c.firstInput, - g = c.firstMultiple, - h = g ? g.center : f.center, - i = (b.center = E(d)); - (b.timeStamp = ra()), - (b.deltaTime = b.timeStamp - f.timeStamp), - (b.angle = I(h, i)), - (b.distance = H(h, i)), - B(c, b), - (b.offsetDirection = G(b.deltaX, b.deltaY)); - var j = F(b.deltaTime, b.deltaX, b.deltaY); - (b.overallVelocityX = j.x), - (b.overallVelocityY = j.y), - (b.overallVelocity = qa(j.x) > qa(j.y) ? j.x : j.y), - (b.scale = g ? K(g.pointers, d) : 1), - (b.rotation = g ? J(g.pointers, d) : 0), - (b.maxPointers = c.prevInput - ? b.pointers.length > c.prevInput.maxPointers - ? b.pointers.length - : c.prevInput.maxPointers - : b.pointers.length), - C(c, b); - var k = a.element; - o(b.srcEvent.target, k) && (k = b.srcEvent.target), (b.target = k); - } - function B(a, b) { - var c = b.center, - d = a.offsetDelta || {}, - e = a.prevDelta || {}, - f = a.prevInput || {}; - (b.eventType !== Ea && f.eventType !== Ga) || - ((e = a.prevDelta = { x: f.deltaX || 0, y: f.deltaY || 0 }), - (d = a.offsetDelta = { x: c.x, y: c.y })), - (b.deltaX = e.x + (c.x - d.x)), - (b.deltaY = e.y + (c.y - d.y)); - } - function C(a, b) { - var c, - e, - f, - g, - h = a.lastInterval || b, - i = b.timeStamp - h.timeStamp; - if (b.eventType != Ha && (i > Da || h.velocity === d)) { - var j = b.deltaX - h.deltaX, - k = b.deltaY - h.deltaY, - l = F(i, j, k); - (e = l.x), - (f = l.y), - (c = qa(l.x) > qa(l.y) ? l.x : l.y), - (g = G(j, k)), - (a.lastInterval = b); - } else - (c = h.velocity), (e = h.velocityX), (f = h.velocityY), (g = h.direction); - (b.velocity = c), (b.velocityX = e), (b.velocityY = f), (b.direction = g); - } - function D(a) { - for (var b = [], c = 0; c < a.pointers.length; ) - (b[c] = { - clientX: pa(a.pointers[c].clientX), - clientY: pa(a.pointers[c].clientY), - }), - c++; - return { - timeStamp: ra(), - pointers: b, - center: E(b), - deltaX: a.deltaX, - deltaY: a.deltaY, - }; - } - function E(a) { - var b = a.length; - if (1 === b) return { x: pa(a[0].clientX), y: pa(a[0].clientY) }; - for (var c = 0, d = 0, e = 0; b > e; ) - (c += a[e].clientX), (d += a[e].clientY), e++; - return { x: pa(c / b), y: pa(d / b) }; - } - function F(a, b, c) { - return { x: b / a || 0, y: c / a || 0 }; - } - function G(a, b) { - return a === b ? Ia : qa(a) >= qa(b) ? (0 > a ? Ja : Ka) : 0 > b ? La : Ma; - } - function H(a, b, c) { - c || (c = Qa); - var d = b[c[0]] - a[c[0]], - e = b[c[1]] - a[c[1]]; - return Math.sqrt(d * d + e * e); - } - function I(a, b, c) { - c || (c = Qa); - var d = b[c[0]] - a[c[0]], - e = b[c[1]] - a[c[1]]; - return (180 * Math.atan2(e, d)) / Math.PI; - } - function J(a, b) { - return I(b[1], b[0], Ra) + I(a[1], a[0], Ra); - } - function K(a, b) { - return H(b[0], b[1], Ra) / H(a[0], a[1], Ra); - } - function L() { - (this.evEl = Ta), - (this.evWin = Ua), - (this.pressed = !1), - x.apply(this, arguments); - } - function M() { - (this.evEl = Xa), - (this.evWin = Ya), - x.apply(this, arguments), - (this.store = this.manager.session.pointerEvents = []); - } - function N() { - (this.evTarget = $a), - (this.evWin = _a), - (this.started = !1), - x.apply(this, arguments); - } - function O(a, b) { - var c = s(a.touches), - d = s(a.changedTouches); - return b & (Ga | Ha) && (c = t(c.concat(d), "identifier", !0)), [c, d]; - } - function P() { - (this.evTarget = bb), (this.targetIds = {}), x.apply(this, arguments); - } - function Q(a, b) { - var c = s(a.touches), - d = this.targetIds; - if (b & (Ea | Fa) && 1 === c.length) - return (d[c[0].identifier] = !0), [c, c]; - var e, - f, - g = s(a.changedTouches), - h = [], - i = this.target; - if ( - ((f = c.filter(function (a) { - return o(a.target, i); - })), - b === Ea) - ) - for (e = 0; e < f.length; ) (d[f[e].identifier] = !0), e++; - for (e = 0; e < g.length; ) - d[g[e].identifier] && h.push(g[e]), - b & (Ga | Ha) && delete d[g[e].identifier], - e++; - return h.length ? [t(f.concat(h), "identifier", !0), h] : void 0; - } - function R() { - x.apply(this, arguments); - var a = j(this.handler, this); - (this.touch = new P(this.manager, a)), - (this.mouse = new L(this.manager, a)), - (this.primaryTouch = null), - (this.lastTouches = []); - } - function S(a, b) { - a & Ea - ? ((this.primaryTouch = b.changedPointers[0].identifier), T.call(this, b)) - : a & (Ga | Ha) && T.call(this, b); - } - function T(a) { - var b = a.changedPointers[0]; - if (b.identifier === this.primaryTouch) { - var c = { x: b.clientX, y: b.clientY }; - this.lastTouches.push(c); - var d = this.lastTouches, - e = function () { - var a = d.indexOf(c); - a > -1 && d.splice(a, 1); - }; - setTimeout(e, cb); - } - } - function U(a) { - for ( - var b = a.srcEvent.clientX, c = a.srcEvent.clientY, d = 0; - d < this.lastTouches.length; - d++ - ) { - var e = this.lastTouches[d], - f = Math.abs(b - e.x), - g = Math.abs(c - e.y); - if (db >= f && db >= g) return !0; - } - return !1; - } - function V(a, b) { - (this.manager = a), this.set(b); - } - function W(a) { - if (p(a, jb)) return jb; - var b = p(a, kb), - c = p(a, lb); - return b && c ? jb : b || c ? (b ? kb : lb) : p(a, ib) ? ib : hb; - } - function X() { - if (!fb) return !1; - var b = {}, - c = a.CSS && a.CSS.supports; - return ( - ["auto", "manipulation", "pan-y", "pan-x", "pan-x pan-y", "none"].forEach( - function (d) { - b[d] = c ? a.CSS.supports("touch-action", d) : !0; - } - ), - b - ); - } - function Y(a) { - (this.options = la({}, this.defaults, a || {})), - (this.id = v()), - (this.manager = null), - (this.options.enable = l(this.options.enable, !0)), - (this.state = nb), - (this.simultaneous = {}), - (this.requireFail = []); - } - function Z(a) { - return a & sb - ? "cancel" - : a & qb - ? "end" - : a & pb - ? "move" - : a & ob - ? "start" - : ""; - } - function $(a) { - return a == Ma - ? "down" - : a == La - ? "up" - : a == Ja - ? "left" - : a == Ka - ? "right" - : ""; - } - function _(a, b) { - var c = b.manager; - return c ? c.get(a) : a; - } - function aa() { - Y.apply(this, arguments); - } - function ba() { - aa.apply(this, arguments), (this.pX = null), (this.pY = null); - } - function ca() { - aa.apply(this, arguments); - } - function da() { - Y.apply(this, arguments), (this._timer = null), (this._input = null); - } - function ea() { - aa.apply(this, arguments); - } - function fa() { - aa.apply(this, arguments); - } - function ga() { - Y.apply(this, arguments), - (this.pTime = !1), - (this.pCenter = !1), - (this._timer = null), - (this._input = null), - (this.count = 0); - } - function ha(a, b) { - return ( - (b = b || {}), - (b.recognizers = l(b.recognizers, ha.defaults.preset)), - new ia(a, b) - ); - } - function ia(a, b) { - (this.options = la({}, ha.defaults, b || {})), - (this.options.inputTarget = this.options.inputTarget || a), - (this.handlers = {}), - (this.session = {}), - (this.recognizers = []), - (this.oldCssProps = {}), - (this.element = a), - (this.input = y(this)), - (this.touchAction = new V(this, this.options.touchAction)), - ja(this, !0), - g( - this.options.recognizers, - function (a) { - var b = this.add(new a[0](a[1])); - a[2] && b.recognizeWith(a[2]), a[3] && b.requireFailure(a[3]); - }, - this - ); - } - function ja(a, b) { - var c = a.element; - if (c.style) { - var d; - g(a.options.cssProps, function (e, f) { - (d = u(c.style, f)), - b - ? ((a.oldCssProps[d] = c.style[d]), (c.style[d] = e)) - : (c.style[d] = a.oldCssProps[d] || ""); - }), - b || (a.oldCssProps = {}); - } - } - function ka(a, c) { - var d = b.createEvent("Event"); - d.initEvent(a, !0, !0), (d.gesture = c), c.target.dispatchEvent(d); - } - var la, - ma = ["", "webkit", "Moz", "MS", "ms", "o"], - na = b.createElement("div"), - oa = "function", - pa = Math.round, - qa = Math.abs, - ra = Date.now; - la = - "function" != typeof Object.assign - ? function (a) { - if (a === d || null === a) - throw new TypeError("Cannot convert undefined or null to object"); - for (var b = Object(a), c = 1; c < arguments.length; c++) { - var e = arguments[c]; - if (e !== d && null !== e) - for (var f in e) e.hasOwnProperty(f) && (b[f] = e[f]); - } - return b; - } - : Object.assign; - var sa = h( - function (a, b, c) { - for (var e = Object.keys(b), f = 0; f < e.length; ) - (!c || (c && a[e[f]] === d)) && (a[e[f]] = b[e[f]]), f++; - return a; - }, - "extend", - "Use `assign`." - ), - ta = h( - function (a, b) { - return sa(a, b, !0); - }, - "merge", - "Use `assign`." - ), - ua = 1, - va = /mobile|tablet|ip(ad|hone|od)|android/i, - wa = "ontouchstart" in a, - xa = u(a, "PointerEvent") !== d, - ya = wa && va.test(navigator.userAgent), - za = "touch", - Aa = "pen", - Ba = "mouse", - Ca = "kinect", - Da = 25, - Ea = 1, - Fa = 2, - Ga = 4, - Ha = 8, - Ia = 1, - Ja = 2, - Ka = 4, - La = 8, - Ma = 16, - Na = Ja | Ka, - Oa = La | Ma, - Pa = Na | Oa, - Qa = ["x", "y"], - Ra = ["clientX", "clientY"]; - x.prototype = { - handler: function () {}, - init: function () { - this.evEl && m(this.element, this.evEl, this.domHandler), - this.evTarget && m(this.target, this.evTarget, this.domHandler), - this.evWin && m(w(this.element), this.evWin, this.domHandler); - }, - destroy: function () { - this.evEl && n(this.element, this.evEl, this.domHandler), - this.evTarget && n(this.target, this.evTarget, this.domHandler), - this.evWin && n(w(this.element), this.evWin, this.domHandler); - }, - }; - var Sa = { mousedown: Ea, mousemove: Fa, mouseup: Ga }, - Ta = "mousedown", - Ua = "mousemove mouseup"; - i(L, x, { - handler: function (a) { - var b = Sa[a.type]; - b & Ea && 0 === a.button && (this.pressed = !0), - b & Fa && 1 !== a.which && (b = Ga), - this.pressed && - (b & Ga && (this.pressed = !1), - this.callback(this.manager, b, { - pointers: [a], - changedPointers: [a], - pointerType: Ba, - srcEvent: a, - })); - }, - }); - var Va = { - pointerdown: Ea, - pointermove: Fa, - pointerup: Ga, - pointercancel: Ha, - pointerout: Ha, - }, - Wa = { 2: za, 3: Aa, 4: Ba, 5: Ca }, - Xa = "pointerdown", - Ya = "pointermove pointerup pointercancel"; - a.MSPointerEvent && - !a.PointerEvent && - ((Xa = "MSPointerDown"), - (Ya = "MSPointerMove MSPointerUp MSPointerCancel")), - i(M, x, { - handler: function (a) { - var b = this.store, - c = !1, - d = a.type.toLowerCase().replace("ms", ""), - e = Va[d], - f = Wa[a.pointerType] || a.pointerType, - g = f == za, - h = r(b, a.pointerId, "pointerId"); - e & Ea && (0 === a.button || g) - ? 0 > h && (b.push(a), (h = b.length - 1)) - : e & (Ga | Ha) && (c = !0), - 0 > h || - ((b[h] = a), - this.callback(this.manager, e, { - pointers: b, - changedPointers: [a], - pointerType: f, - srcEvent: a, - }), - c && b.splice(h, 1)); - }, - }); - var Za = { touchstart: Ea, touchmove: Fa, touchend: Ga, touchcancel: Ha }, - $a = "touchstart", - _a = "touchstart touchmove touchend touchcancel"; - i(N, x, { - handler: function (a) { - var b = Za[a.type]; - if ((b === Ea && (this.started = !0), this.started)) { - var c = O.call(this, a, b); - b & (Ga | Ha) && c[0].length - c[1].length === 0 && (this.started = !1), - this.callback(this.manager, b, { - pointers: c[0], - changedPointers: c[1], - pointerType: za, - srcEvent: a, - }); - } - }, - }); - var ab = { touchstart: Ea, touchmove: Fa, touchend: Ga, touchcancel: Ha }, - bb = "touchstart touchmove touchend touchcancel"; - i(P, x, { - handler: function (a) { - var b = ab[a.type], - c = Q.call(this, a, b); - c && - this.callback(this.manager, b, { - pointers: c[0], - changedPointers: c[1], - pointerType: za, - srcEvent: a, - }); - }, - }); - var cb = 2500, - db = 25; - i(R, x, { - handler: function (a, b, c) { - var d = c.pointerType == za, - e = c.pointerType == Ba; - if ( - !(e && c.sourceCapabilities && c.sourceCapabilities.firesTouchEvents) - ) { - if (d) S.call(this, b, c); - else if (e && U.call(this, c)) return; - this.callback(a, b, c); - } - }, - destroy: function () { - this.touch.destroy(), this.mouse.destroy(); - }, - }); - var eb = u(na.style, "touchAction"), - fb = eb !== d, - gb = "compute", - hb = "auto", - ib = "manipulation", - jb = "none", - kb = "pan-x", - lb = "pan-y", - mb = X(); - V.prototype = { - set: function (a) { - a == gb && (a = this.compute()), - fb && - this.manager.element.style && - mb[a] && - (this.manager.element.style[eb] = a), - (this.actions = a.toLowerCase().trim()); - }, - update: function () { - this.set(this.manager.options.touchAction); - }, - compute: function () { - var a = []; - return ( - g(this.manager.recognizers, function (b) { - k(b.options.enable, [b]) && (a = a.concat(b.getTouchAction())); - }), - W(a.join(" ")) - ); - }, - preventDefaults: function (a) { - var b = a.srcEvent, - c = a.offsetDirection; - if (this.manager.session.prevented) return void b.preventDefault(); - var d = this.actions, - e = p(d, jb) && !mb[jb], - f = p(d, lb) && !mb[lb], - g = p(d, kb) && !mb[kb]; - if (e) { - var h = 1 === a.pointers.length, - i = a.distance < 2, - j = a.deltaTime < 250; - if (h && i && j) return; - } - return g && f - ? void 0 - : e || (f && c & Na) || (g && c & Oa) - ? this.preventSrc(b) - : void 0; - }, - preventSrc: function (a) { - (this.manager.session.prevented = !0), a.preventDefault(); - }, - }; - var nb = 1, - ob = 2, - pb = 4, - qb = 8, - rb = qb, - sb = 16, - tb = 32; - (Y.prototype = { - defaults: {}, - set: function (a) { - return ( - la(this.options, a), - this.manager && this.manager.touchAction.update(), - this - ); - }, - recognizeWith: function (a) { - if (f(a, "recognizeWith", this)) return this; - var b = this.simultaneous; - return ( - (a = _(a, this)), - b[a.id] || ((b[a.id] = a), a.recognizeWith(this)), - this - ); - }, - dropRecognizeWith: function (a) { - return f(a, "dropRecognizeWith", this) - ? this - : ((a = _(a, this)), delete this.simultaneous[a.id], this); - }, - requireFailure: function (a) { - if (f(a, "requireFailure", this)) return this; - var b = this.requireFail; - return ( - (a = _(a, this)), - -1 === r(b, a) && (b.push(a), a.requireFailure(this)), - this - ); - }, - dropRequireFailure: function (a) { - if (f(a, "dropRequireFailure", this)) return this; - a = _(a, this); - var b = r(this.requireFail, a); - return b > -1 && this.requireFail.splice(b, 1), this; - }, - hasRequireFailures: function () { - return this.requireFail.length > 0; - }, - canRecognizeWith: function (a) { - return !!this.simultaneous[a.id]; - }, - emit: function (a) { - function b(b) { - c.manager.emit(b, a); - } - var c = this, - d = this.state; - qb > d && b(c.options.event + Z(d)), - b(c.options.event), - a.additionalEvent && b(a.additionalEvent), - d >= qb && b(c.options.event + Z(d)); - }, - tryEmit: function (a) { - return this.canEmit() ? this.emit(a) : void (this.state = tb); - }, - canEmit: function () { - for (var a = 0; a < this.requireFail.length; ) { - if (!(this.requireFail[a].state & (tb | nb))) return !1; - a++; - } - return !0; - }, - recognize: function (a) { - var b = la({}, a); - return k(this.options.enable, [this, b]) - ? (this.state & (rb | sb | tb) && (this.state = nb), - (this.state = this.process(b)), - void (this.state & (ob | pb | qb | sb) && this.tryEmit(b))) - : (this.reset(), void (this.state = tb)); - }, - process: function (a) {}, - getTouchAction: function () {}, - reset: function () {}, - }), - i(aa, Y, { - defaults: { pointers: 1 }, - attrTest: function (a) { - var b = this.options.pointers; - return 0 === b || a.pointers.length === b; - }, - process: function (a) { - var b = this.state, - c = a.eventType, - d = b & (ob | pb), - e = this.attrTest(a); - return d && (c & Ha || !e) - ? b | sb - : d || e - ? c & Ga - ? b | qb - : b & ob - ? b | pb - : ob - : tb; - }, - }), - i(ba, aa, { - defaults: { event: "pan", threshold: 10, pointers: 1, direction: Pa }, - getTouchAction: function () { - var a = this.options.direction, - b = []; - return a & Na && b.push(lb), a & Oa && b.push(kb), b; - }, - directionTest: function (a) { - var b = this.options, - c = !0, - d = a.distance, - e = a.direction, - f = a.deltaX, - g = a.deltaY; - return ( - e & b.direction || - (b.direction & Na - ? ((e = 0 === f ? Ia : 0 > f ? Ja : Ka), - (c = f != this.pX), - (d = Math.abs(a.deltaX))) - : ((e = 0 === g ? Ia : 0 > g ? La : Ma), - (c = g != this.pY), - (d = Math.abs(a.deltaY)))), - (a.direction = e), - c && d > b.threshold && e & b.direction - ); - }, - attrTest: function (a) { - return ( - aa.prototype.attrTest.call(this, a) && - (this.state & ob || (!(this.state & ob) && this.directionTest(a))) - ); - }, - emit: function (a) { - (this.pX = a.deltaX), (this.pY = a.deltaY); - var b = $(a.direction); - b && (a.additionalEvent = this.options.event + b), - this._super.emit.call(this, a); - }, - }), - i(ca, aa, { - defaults: { event: "pinch", threshold: 0, pointers: 2 }, - getTouchAction: function () { - return [jb]; - }, - attrTest: function (a) { - return ( - this._super.attrTest.call(this, a) && - (Math.abs(a.scale - 1) > this.options.threshold || this.state & ob) - ); - }, - emit: function (a) { - if (1 !== a.scale) { - var b = a.scale < 1 ? "in" : "out"; - a.additionalEvent = this.options.event + b; - } - this._super.emit.call(this, a); - }, - }), - i(da, Y, { - defaults: { event: "press", pointers: 1, time: 251, threshold: 9 }, - getTouchAction: function () { - return [hb]; - }, - process: function (a) { - var b = this.options, - c = a.pointers.length === b.pointers, - d = a.distance < b.threshold, - f = a.deltaTime > b.time; - if (((this._input = a), !d || !c || (a.eventType & (Ga | Ha) && !f))) - this.reset(); - else if (a.eventType & Ea) - this.reset(), - (this._timer = e( - function () { - (this.state = rb), this.tryEmit(); - }, - b.time, - this - )); - else if (a.eventType & Ga) return rb; - return tb; - }, - reset: function () { - clearTimeout(this._timer); - }, - emit: function (a) { - this.state === rb && - (a && a.eventType & Ga - ? this.manager.emit(this.options.event + "up", a) - : ((this._input.timeStamp = ra()), - this.manager.emit(this.options.event, this._input))); - }, - }), - i(ea, aa, { - defaults: { event: "rotate", threshold: 0, pointers: 2 }, - getTouchAction: function () { - return [jb]; - }, - attrTest: function (a) { - return ( - this._super.attrTest.call(this, a) && - (Math.abs(a.rotation) > this.options.threshold || this.state & ob) - ); - }, - }), - i(fa, aa, { - defaults: { - event: "swipe", - threshold: 10, - velocity: 0.3, - direction: Na | Oa, - pointers: 1, - }, - getTouchAction: function () { - return ba.prototype.getTouchAction.call(this); - }, - attrTest: function (a) { - var b, - c = this.options.direction; - return ( - c & (Na | Oa) - ? (b = a.overallVelocity) - : c & Na - ? (b = a.overallVelocityX) - : c & Oa && (b = a.overallVelocityY), - this._super.attrTest.call(this, a) && - c & a.offsetDirection && - a.distance > this.options.threshold && - a.maxPointers == this.options.pointers && - qa(b) > this.options.velocity && - a.eventType & Ga - ); - }, - emit: function (a) { - var b = $(a.offsetDirection); - b && this.manager.emit(this.options.event + b, a), - this.manager.emit(this.options.event, a); - }, - }), - i(ga, Y, { - defaults: { - event: "tap", - pointers: 1, - taps: 1, - interval: 300, - time: 250, - threshold: 9, - posThreshold: 10, - }, - getTouchAction: function () { - return [ib]; - }, - process: function (a) { - var b = this.options, - c = a.pointers.length === b.pointers, - d = a.distance < b.threshold, - f = a.deltaTime < b.time; - if ((this.reset(), a.eventType & Ea && 0 === this.count)) - return this.failTimeout(); - if (d && f && c) { - if (a.eventType != Ga) return this.failTimeout(); - var g = this.pTime ? a.timeStamp - this.pTime < b.interval : !0, - h = !this.pCenter || H(this.pCenter, a.center) < b.posThreshold; - (this.pTime = a.timeStamp), - (this.pCenter = a.center), - h && g ? (this.count += 1) : (this.count = 1), - (this._input = a); - var i = this.count % b.taps; - if (0 === i) - return this.hasRequireFailures() - ? ((this._timer = e( - function () { - (this.state = rb), this.tryEmit(); - }, - b.interval, - this - )), - ob) - : rb; - } - return tb; - }, - failTimeout: function () { - return ( - (this._timer = e( - function () { - this.state = tb; - }, - this.options.interval, - this - )), - tb - ); - }, - reset: function () { - clearTimeout(this._timer); - }, - emit: function () { - this.state == rb && - ((this._input.tapCount = this.count), - this.manager.emit(this.options.event, this._input)); - }, - }), - (ha.VERSION = "2.0.8"), - (ha.defaults = { - domEvents: !1, - touchAction: gb, - enable: !0, - inputTarget: null, - inputClass: null, - preset: [ - [ea, { enable: !1 }], - [ca, { enable: !1 }, ["rotate"]], - [fa, { direction: Na }], - [ba, { direction: Na }, ["swipe"]], - [ga], - [ga, { event: "doubletap", taps: 2 }, ["tap"]], - [da], - ], - cssProps: { - userSelect: "none", - touchSelect: "none", - touchCallout: "none", - contentZooming: "none", - userDrag: "none", - tapHighlightColor: "rgba(0,0,0,0)", - }, - }); - var ub = 1, - vb = 2; - (ia.prototype = { - set: function (a) { - return ( - la(this.options, a), - a.touchAction && this.touchAction.update(), - a.inputTarget && - (this.input.destroy(), - (this.input.target = a.inputTarget), - this.input.init()), - this - ); - }, - stop: function (a) { - this.session.stopped = a ? vb : ub; - }, - recognize: function (a) { - var b = this.session; - if (!b.stopped) { - this.touchAction.preventDefaults(a); - var c, - d = this.recognizers, - e = b.curRecognizer; - (!e || (e && e.state & rb)) && (e = b.curRecognizer = null); - for (var f = 0; f < d.length; ) - (c = d[f]), - b.stopped === vb || (e && c != e && !c.canRecognizeWith(e)) - ? c.reset() - : c.recognize(a), - !e && c.state & (ob | pb | qb) && (e = b.curRecognizer = c), - f++; - } - }, - get: function (a) { - if (a instanceof Y) return a; - for (var b = this.recognizers, c = 0; c < b.length; c++) - if (b[c].options.event == a) return b[c]; - return null; - }, - add: function (a) { - if (f(a, "add", this)) return this; - var b = this.get(a.options.event); - return ( - b && this.remove(b), - this.recognizers.push(a), - (a.manager = this), - this.touchAction.update(), - a - ); - }, - remove: function (a) { - if (f(a, "remove", this)) return this; - if ((a = this.get(a))) { - var b = this.recognizers, - c = r(b, a); - -1 !== c && (b.splice(c, 1), this.touchAction.update()); - } - return this; - }, - on: function (a, b) { - if (a !== d && b !== d) { - var c = this.handlers; - return ( - g(q(a), function (a) { - (c[a] = c[a] || []), c[a].push(b); - }), - this - ); - } - }, - off: function (a, b) { - if (a !== d) { - var c = this.handlers; - return ( - g(q(a), function (a) { - b ? c[a] && c[a].splice(r(c[a], b), 1) : delete c[a]; - }), - this - ); - } - }, - emit: function (a, b) { - this.options.domEvents && ka(a, b); - var c = this.handlers[a] && this.handlers[a].slice(); - if (c && c.length) { - (b.type = a), - (b.preventDefault = function () { - b.srcEvent.preventDefault(); - }); - for (var d = 0; d < c.length; ) c[d](b), d++; - } - }, - destroy: function () { - this.element && ja(this, !1), - (this.handlers = {}), - (this.session = {}), - this.input.destroy(), - (this.element = null); - }, - }), - la(ha, { - INPUT_START: Ea, - INPUT_MOVE: Fa, - INPUT_END: Ga, - INPUT_CANCEL: Ha, - STATE_POSSIBLE: nb, - STATE_BEGAN: ob, - STATE_CHANGED: pb, - STATE_ENDED: qb, - STATE_RECOGNIZED: rb, - STATE_CANCELLED: sb, - STATE_FAILED: tb, - DIRECTION_NONE: Ia, - DIRECTION_LEFT: Ja, - DIRECTION_RIGHT: Ka, - DIRECTION_UP: La, - DIRECTION_DOWN: Ma, - DIRECTION_HORIZONTAL: Na, - DIRECTION_VERTICAL: Oa, - DIRECTION_ALL: Pa, - Manager: ia, - Input: x, - TouchAction: V, - TouchInput: P, - MouseInput: L, - PointerEventInput: M, - TouchMouseInput: R, - SingleTouchInput: N, - Recognizer: Y, - AttrRecognizer: aa, - Tap: ga, - Pan: ba, - Swipe: fa, - Pinch: ca, - Rotate: ea, - Press: da, - on: m, - off: n, - each: g, - merge: ta, - extend: sa, - assign: la, - inherit: i, - bindFn: j, - prefixed: u, - }); - var wb = "undefined" != typeof a ? a : "undefined" != typeof self ? self : {}; - (wb.Hammer = ha), - "function" == typeof define && define.amd - ? define(function () { - return ha; - }) - : "undefined" != typeof module && module.exports - ? (module.exports = ha) - : (a[c] = ha); -})(window, document, "Hammer"); -//# sourceMappingURL=hammer.min.js.map diff --git a/motto/public/heart.svg b/motto/public/heart.svg deleted file mode 100644 index 52b6748..0000000 --- a/motto/public/heart.svg +++ /dev/null @@ -1 +0,0 @@ -<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#FA64C8" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" class="feather feather-heart"><path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"></path></svg> diff --git a/motto/public/index.html b/motto/public/index.html deleted file mode 100644 index 35ab894..0000000 --- a/motto/public/index.html +++ /dev/null @@ -1,39 +0,0 @@ -<!DOCTYPE html> -<!-- MIT License, Copyright (c) 2020 Marvin Borner --> -<html> - <head> - <meta charset="UTF-8" /> - <meta name="viewport" content="width=device-width, minimal-ui" /> - <link rel="stylesheet" href="style.css" type="text/css" media="all" /> - <title>Motto</title> - </head> - <body> - <div id="sebastian" class="sebastian fab" style="display: none"> - <button id="go"><img src="x.svg"></img></button> - <ul id="overview"> - </ul> - </div> - - <div class="wrapper"> - <div class="cards"> - </div> - - <div class="blabla fab"> - <button id="all" class="top_button"><img src="all.svg"></img></button> - <button id="aah" class="top_button"><img src="reload.svg"></img></button> - <button id="idc" class="top_button"><img src="shuffle.svg"></img></button> - <button id="add" class="top_button"><img src="add.svg"></img></button> - </div> - - <div class="yay_or_nay fab"> - <button id="nay"><img src="x.svg"></img></button> - <button id="hmm"><img src="skip.svg"></img></button> - <button id="yay"><img src="heart.svg"></img></button> - </div> - </div> - <!-- Well, why not :) --> - <small style="position: absolute; right: 0; bottom: 0; font-size: 9px; margin-right: 3px">Created by Marvin Borner</small> - <script charset="utf-8" src="hammer.js"></script> - <script charset="utf-8" src="script.js"></script> - </body> -</html> diff --git a/motto/public/reload.svg b/motto/public/reload.svg deleted file mode 100644 index 96647f8..0000000 --- a/motto/public/reload.svg +++ /dev/null @@ -1 +0,0 @@ -<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#424242" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-refresh-cw"><polyline points="23 4 23 10 17 10"></polyline><polyline points="1 20 1 14 7 14"></polyline><path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"></path></svg> diff --git a/motto/public/script.js b/motto/public/script.js deleted file mode 100644 index a4e75e9..0000000 --- a/motto/public/script.js +++ /dev/null @@ -1,216 +0,0 @@ -// Pretty ugly, huh? - -document.querySelector(".wrapper").style.opacity = 1; - -function send(id, vote) { - var xhp = new XMLHttpRequest(); - xhp.open("POST", "api/vote"); - xhp.setRequestHeader("Content-type", "application/json"); - xhp.onreadystatechange = () => { - if (xhp.readyState == 4 && xhp.status == 200) console.log(xhp.responseText); - }; - id = parseInt(id); - vote = parseInt(vote); - xhp.send(JSON.stringify({ id, vote })); -} - -function add(main, description) { - var xhp = new XMLHttpRequest(); - xhp.open("POST", "api/add"); - xhp.setRequestHeader("Content-type", "application/json"); - xhp.onreadystatechange = () => { - if (xhp.readyState == 4 && xhp.status == 200) console.log(xhp.responseText); - }; - xhp.send(JSON.stringify({ main, description })); -} - -function initCards() { - let newCards = document.querySelectorAll(".card:not(.removed)"); - newCards.forEach((card, index) => { - card.style.zIndex = newCards.length - index; - card.style.transform = "scale(" + (20 - index) / 20 + ") translateY(-" + 30 * index + "px)"; - card.style.opacity = (10 - index) / 10; - }); -} - -function start() { - initCards(); - - let cards = document.querySelectorAll(".card"); - cards.forEach((card) => { - let hammer = new Hammer(card); - hammer.on("pan", (event) => { - card.classList.add("moving"); - if (event.deltaX === 0) return; - if (event.center.x === 0 && event.center.y === 0) return; - - const xMulti = event.deltaX * 0.03; - const yMulti = event.deltaY / 80; - const rotate = xMulti * yMulti; - - event.target.style.transform = - "translate(" + event.deltaX + "px, " + event.deltaY + "px) rotate(" + rotate + "deg)"; - }); - - hammer.on("panend", (event) => { - card.classList.remove("moving"); - const moveOutWidth = document.body.clientWidth; - const keep = Math.abs(event.deltax) < 80 || Math.abs(event.velocityX) < 0.5; - event.target.classList.toggle("removed", !keep); - - if (keep) { - event.target.style.transform = ""; - } else { - event.target.style.opacity = 0; - const endX = Math.max(Math.abs(event.velocityX) * moveOutWidth, moveOutWidth); - const toX = event.deltaX > 0 ? endX : -endX; - const endY = Math.abs(event.velocityY) * moveOutWidth; - const toY = event.deltaY > 0 ? endY : -endY; - const xMulti = event.deltaX * 0.03; - const yMulti = event.deltaY / 80; - const rotate = xMulti * yMulti; - event.target.style.transform = - "translate(" + toX + "px, " + (toY + event.deltaY) + "px) rotate(" + rotate + "deg)"; - send(event.target.getAttribute("data-id"), toX > 0 ? 1 : -1); - initCards(); - } - }); - }); -} - -function skipCard() { - const card = document.querySelectorAll(".card:not(.removed)")[0]; - const moveOutWidth = document.body.clientWidth * 1.5; - - if (!card) return false; - - card.classList.add("removed"); - card.style.transform = "translate(" + moveOutWidth + "px, -100px) rotate(-30deg)"; - initCards(); - event.preventDefault(); -} - -function jumpTo(event) { - document.getElementById("sebastian").style.display = "none"; - const cards = document.querySelectorAll(".card:not(.removed)"); - let index = 0; - while (cards[index].getAttribute("data-id") != event.target.getAttribute("data-id")) { - index++; - skipCard(); - } -} - -function toggleOverview() { - const strange = document.getElementById("sebastian"); - const off = strange.style.display == "none"; - strange.style.display = off ? "block" : "none"; - if (!off) return; - const overview_list = document.getElementById("overview"); - overview_list.innerHTML = ""; - const cards = document.querySelectorAll(".card:not(.removed)"); - cards.forEach((element) => { - const li = document.createElement("li"); - li.setAttribute("data-id", element.getAttribute("data-id")); - li.textContent = `${element.querySelectorAll("h1")[1].innerText} - ${element.querySelector("h2").innerText} (${ - element.querySelectorAll("h2")[1].innerText - })`; - li.addEventListener("click", jumpTo); - overview_list.appendChild(li); - }); -} - -function createButtonListener(yay) { - return function (event) { - const card = document.querySelectorAll(".card:not(.removed)")[0]; - const moveOutWidth = document.body.clientWidth * 1.5; - - if (!card) return false; - - card.classList.add("removed"); - - if (yay) { - card.style.transform = "translate(" + moveOutWidth + "px, -100px) rotate(-30deg)"; - } else { - card.style.transform = "translate(-" + moveOutWidth + "px, -100px) rotate(30deg)"; - } - - send(card.getAttribute("data-id"), yay ? 1 : -1); - initCards(); - event.preventDefault(); - }; -} - -var xhp = new XMLHttpRequest(); -xhp.open("GET", "api/list"); -xhp.onreadystatechange = () => { - if (xhp.readyState == 4 && xhp.status == 200) { - let list = JSON.parse(xhp.responseText); - const cards_element = document.querySelector(".cards"); - list.forEach((element) => { - const card = document.createElement("div"); - card.setAttribute("class", "card"); - card.setAttribute("data-id", element["id"]); - const h1 = document.createElement("h1"); - h1.innerText = "Thema #" + element["id"]; - const hr1 = document.createElement("hr"); - hr1.style.marginTop = "16px"; - const h2 = document.createElement("h1"); - h2.innerText = element["main"]; - h2.style.marginTop = "16px"; - const h3 = document.createElement("h2"); - h3.innerText = element["description"]; - const hr2 = document.createElement("hr"); - hr2.style.marginTop = "16px"; - hr2.style.marginBottom = "16px"; - const h4 = document.createElement("h2"); - h4.innerText = "Votes: " + element["votes"]; - card.appendChild(h1); - card.appendChild(hr1); - card.appendChild(h2); - card.appendChild(h3); - card.appendChild(hr2); - card.appendChild(h4); - cards_element.appendChild(card); - }); - start(); - } -}; -xhp.send(); - -var yayListener = createButtonListener(true); -var nayListener = createButtonListener(false); -document.getElementById("yay").addEventListener("click", yayListener); -document.getElementById("hmm").addEventListener("click", skipCard); -document.getElementById("nay").addEventListener("click", nayListener); - -document.getElementById("add").addEventListener("click", () => { - const main = prompt("Was ist das Hauptthema (erste Teil)?", "ABI 2021"); - const secondary = prompt("Was ist der zweite Teil?", "Wir sind super toll"); - if (main && secondary) add(main, secondary); -}); - -document.getElementById("idc").addEventListener("click", () => { - const wrapper = document.querySelector(".cards"); - console.log(wrapper.children.length); - for (var i = wrapper.children.length; i >= 0; i--) wrapper.appendChild(wrapper.children[(Math.random() * i) | 0]); - initCards(); -}); - -document.getElementById("aah").addEventListener("click", () => { - const elements = document.getElementsByClassName("removed"); - for (var i = 0; i < elements.length; i++) { - elements[i].classList.remove("removed"); - } - initCards(); -}); - -document.getElementById("all").addEventListener("click", toggleOverview); -document.getElementById("go").addEventListener("click", toggleOverview); - -addEventListener( - "load", - () => { - window.scrollTo(1, 0); - }, - false, -); diff --git a/motto/public/shuffle.svg b/motto/public/shuffle.svg deleted file mode 100644 index 4a56d61..0000000 --- a/motto/public/shuffle.svg +++ /dev/null @@ -1 +0,0 @@ -<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#424242" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-shuffle"><polyline points="16 3 21 3 21 8"></polyline><line x1="4" y1="20" x2="21" y2="3"></line><polyline points="21 16 21 21 16 21"></polyline><line x1="15" y1="15" x2="21" y2="21"></line><line x1="4" y1="4" x2="9" y2="9"></line></svg> diff --git a/motto/public/skip.svg b/motto/public/skip.svg deleted file mode 100644 index 2beb5b9..0000000 --- a/motto/public/skip.svg +++ /dev/null @@ -1 +0,0 @@ -<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#424242" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-skip-forward"><polygon points="5 4 15 12 5 20 5 4"></polygon><line x1="19" y1="5" x2="19" y2="19"></line></svg> diff --git a/motto/public/style.css b/motto/public/style.css deleted file mode 100644 index 92fd0e3..0000000 --- a/motto/public/style.css +++ /dev/null @@ -1,143 +0,0 @@ -*, -*:before, -*:after { - color: #424242; - box-sizing: border-box; - user-select: none; - padding: 0; - margin: 0; -} - -html, -body { - background-color: #eec0c6; - background-image: linear-gradient(315deg, #eec0c6 0%, #7ee8fa 74%); - font-family: sans-serif; - overflow: hidden; -} - -.wrapper { - width: 100vw; - height: 100vh; - overflow: hidden; - display: flex; - flex-direction: column; - position: relative; - opacity: 0; - transition: opacity 0.5s ease-in-out; -} - -.cards { - flex-grow: 1; - padding-top: 40px; - text-align: center; - display: flex; - justify-content: center; - align-items: center; - z-index: 1; -} - -.card { - display: inline-block; - width: 90vw; - max-width: 400px; - height: 70vh; - max-height: 400px; - background: white; - padding-bottom: 40px; - border-radius: 8px; - overflow: hidden; - position: absolute; - transition: all 0.3s ease-in-out; - cursor: grab; - padding: 20px; -} - -.card * { - pointer-events: none; -} - -.moving.card { - transition: none; - cursor: grabbing; -} - -.sebastian { - display: none; - z-index: 100000; - width: 100vw; - height: 100vh; - overflow-y: auto; - overflow-x: hidden; - padding-top: 20px; - text-align: center; - transition: all 0.3s ease-in-out; -} - -.sebastian li { - margin: 10px; -} - -.sebastian button { - position: absolute; - right: 0; -} - -.yay_or_nay { - z-index: 10000; - position: absolute; - bottom: 0; - flex: 0 0 100px; - text-align: center; - padding-top: 20px; - width: 100%; -} - -.blabla { - z-index: 100000; - position: absolute; - top: 0; - right: 0; - flex: 0 0 100px; - text-align: right; - padding-top: 20px; - width: 100%; -} - -.fab button { - z-index: 100000; - border-radius: 50%; - line-height: 60px; - width: 60px; - border: 0; - background: white; - display: inline-block; - margin: 20px; -} - -.fab button:focus { - outline: 0; -} - -.fab img { - z-index: 100000; - vertical-align: middle; -} - -.top_button img { - cursor: pointer; -} - -@media only screen and (max-width: 600px) { - .fab button { - margin: 10px; - } -} - -@media only screen and (max-width: 400px) { - .fab button { - width: 50px; - height: 50px; - line-height: 30px; - } -} diff --git a/motto/public/x.svg b/motto/public/x.svg deleted file mode 100644 index 7c925b2..0000000 --- a/motto/public/x.svg +++ /dev/null @@ -1 +0,0 @@ -<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#424242" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-x"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg> diff --git a/package.json b/package.json index 6c65977..aa8849a 100644 --- a/package.json +++ b/package.json @@ -15,5 +15,10 @@ "mariadb": "^2.4.2", "nanoid": "^3.1.12", "redis": "^3.0.2" + }, + "scripts": { + "format": "prettier --write \"*.{html,css,js}\"", + "run": "node app.js", + "dev": "nodemon app.js" } } |