From 71891d9f7d002784d3e33a265a4b341d2ae63665 Mon Sep 17 00:00:00 2001 From: Dominika Liberda Date: Sun, 4 Oct 2020 18:42:05 +0200 Subject: [PATCH] added prettier and some js --- README.md | 5 +++++ add-git-hooks.sh | 6 ++++++ front/.prettierignore | 6 ++++++ front/.prettierrc.json | 1 + front/package.json | 3 ++- front/src/index.ts | 29 +++++++++++++++++++++-------- front/tsconfig.json | 16 ++++++++-------- front/yarn.lock | 5 +++++ webroot/index.html | 38 +++++++++++++++++++++++++++++--------- 9 files changed, 83 insertions(+), 26 deletions(-) create mode 100644 README.md create mode 100755 add-git-hooks.sh create mode 100644 front/.prettierignore create mode 100644 front/.prettierrc.json diff --git a/README.md b/README.md new file mode 100644 index 0000000..6ec2d79 --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# OCW - Otwarty Czapkomat Webowy + +OCW is a minimalistic open-source webapp for opening InPost's package lockers. Written by [sdomi](https://sdomi.pl/) and [selfisekai](https://selfisekai.rocks/). Currently a bit WiP. + +Before contributing, remember to run `./add-git-hooks.sh`, which makes sure that your code is formatted using prettier before commit. diff --git a/add-git-hooks.sh b/add-git-hooks.sh new file mode 100755 index 0000000..7bfb227 --- /dev/null +++ b/add-git-hooks.sh @@ -0,0 +1,6 @@ +#!/bin/bash +echo "#!/bin/bash +cd front +npx prettier --write ." > .git/hooks/pre-commit +chmod +x .git/hooks/pre-commit +echo "done" diff --git a/front/.prettierignore b/front/.prettierignore new file mode 100644 index 0000000..50316f8 --- /dev/null +++ b/front/.prettierignore @@ -0,0 +1,6 @@ +# Ignore artifacts: +build +node_modules +yarn.lock #idk, to be safe +package.json +tsconfig.json diff --git a/front/.prettierrc.json b/front/.prettierrc.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/front/.prettierrc.json @@ -0,0 +1 @@ +{} diff --git a/front/package.json b/front/package.json index 7d57aee..6a17fcb 100644 --- a/front/package.json +++ b/front/package.json @@ -5,10 +5,11 @@ "license": "AGPL-3.0", "author": "Laura Liberda , Dominika Liberda ", "scripts": { - "build": "tsc && cp -r build ../webroot/assets" + "build": "tsc && cp -rT build ../webroot/assets/" }, "dependencies": {}, "devDependencies": { + "prettier": "^2.1.2", "typescript": "^4.0.3" } } diff --git a/front/src/index.ts b/front/src/index.ts index 07d036b..a7eb80d 100644 --- a/front/src/index.ts +++ b/front/src/index.ts @@ -1,11 +1,24 @@ -const request = (resource: string, data: any) => fetch(`/api/${resource}.shs`, { - method: 'POST', +const request = (resource: string, data: any) => + fetch(`/api/${resource}.shs`, { + method: "POST", body: new URLSearchParams(data).toString(), -}).then((res) => res.json()); + }).then((res) => res.json()); -document.addEventListener('load', () => { - request('packages', {}) - .then((res) => { - console.log(res); - }); +window.addEventListener("load", () => { + const login_submit = document.querySelector(".login-submit")!; + const register_submit = document.querySelector(".register-submit")!; + + login_submit.addEventListener("click", function (event) { + event.preventDefault(); + document.write("lauraiscute"); + }); + + register_submit.addEventListener("click", function (event) { + event.preventDefault(); + document.write("lauraisverycute"); + }); + + request("packages", {}).then((res) => { + console.log(res); + }); }); diff --git a/front/tsconfig.json b/front/tsconfig.json index a120a7f..ace927d 100644 --- a/front/tsconfig.json +++ b/front/tsconfig.json @@ -4,17 +4,17 @@ /* Basic Options */ // "incremental": true, /* Enable incremental compilation */ - "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ - "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ + "target": "es5" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */, + "module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */, // "lib": [], /* Specify library files to be included in the compilation. */ // "allowJs": true, /* Allow javascript files to be compiled. */ // "checkJs": true, /* Report errors in .js files. */ // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ // "declaration": true, /* Generates corresponding '.d.ts' file. */ // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ - "sourceMap": true, /* Generates corresponding '.map' file. */ + "sourceMap": true /* Generates corresponding '.map' file. */, // "outFile": "./", /* Concatenate and emit output to single file. */ - "outDir": "./build", /* Redirect output structure to the directory. */ + "outDir": "./build" /* Redirect output structure to the directory. */, // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ // "composite": true, /* Enable project compilation */ // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ @@ -25,7 +25,7 @@ // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ /* Strict Type-Checking Options */ - "strict": true, /* Enable all strict type-checking options. */ + "strict": true /* Enable all strict type-checking options. */, // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ // "strictNullChecks": true, /* Enable strict null checks. */ // "strictFunctionTypes": true, /* Enable strict checking of function types. */ @@ -48,7 +48,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ + "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */, // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ @@ -63,7 +63,7 @@ // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ /* Advanced Options */ - "skipLibCheck": true, /* Skip type checking of declaration files. */ - "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ + "skipLibCheck": true /* Skip type checking of declaration files. */, + "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ } } diff --git a/front/yarn.lock b/front/yarn.lock index 624eb8a..95dffa4 100644 --- a/front/yarn.lock +++ b/front/yarn.lock @@ -2,6 +2,11 @@ # yarn lockfile v1 +prettier@^2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.1.2.tgz#3050700dae2e4c8b67c4c3f666cdb8af405e1ce5" + integrity sha512-16c7K+x4qVlJg9rEbXl7HEGmQyZlG4R9AgP+oHKRMsMsuk8s+ATStlf1NpDqyBI1HpVyfjLOeMhH2LvuNvV5Vg== + typescript@^4.0.3: version "4.0.3" resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.3.tgz#153bbd468ef07725c1df9c77e8b453f8d36abba5" diff --git a/webroot/index.html b/webroot/index.html index 6d54a66..0b3e483 100644 --- a/webroot/index.html +++ b/webroot/index.html @@ -1,14 +1,34 @@ - - - + + + OCW - - -
- + + + - - \ No newline at end of file +
+ REGISTER +
+ + + + + + + +
+
+
+ +