added prettier and some js

This commit is contained in:
Dominika Liberda 2020-10-04 18:42:05 +02:00
parent 0ca86a7971
commit 71891d9f7d
9 changed files with 83 additions and 26 deletions

5
README.md Normal file
View file

@ -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.

6
add-git-hooks.sh Executable file
View file

@ -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"

6
front/.prettierignore Normal file
View file

@ -0,0 +1,6 @@
# Ignore artifacts:
build
node_modules
yarn.lock #idk, to be safe
package.json
tsconfig.json

1
front/.prettierrc.json Normal file
View file

@ -0,0 +1 @@
{}

View file

@ -5,10 +5,11 @@
"license": "AGPL-3.0", "license": "AGPL-3.0",
"author": "Laura Liberda <laura@selfisekai.rocks>, Dominika Liberda <dominika@sdomi.pl>", "author": "Laura Liberda <laura@selfisekai.rocks>, Dominika Liberda <dominika@sdomi.pl>",
"scripts": { "scripts": {
"build": "tsc && cp -r build ../webroot/assets" "build": "tsc && cp -rT build ../webroot/assets/"
}, },
"dependencies": {}, "dependencies": {},
"devDependencies": { "devDependencies": {
"prettier": "^2.1.2",
"typescript": "^4.0.3" "typescript": "^4.0.3"
} }
} }

View file

@ -1,11 +1,24 @@
const request = (resource: string, data: any) => fetch(`/api/${resource}.shs`, { const request = (resource: string, data: any) =>
method: 'POST', fetch(`/api/${resource}.shs`, {
method: "POST",
body: new URLSearchParams(data).toString(), body: new URLSearchParams(data).toString(),
}).then((res) => res.json()); }).then((res) => res.json());
document.addEventListener('load', () => { window.addEventListener("load", () => {
request('packages', {}) const login_submit = document.querySelector(".login-submit")!;
.then((res) => { const register_submit = document.querySelector(".register-submit")!;
console.log(res);
}); 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);
});
}); });

View file

@ -4,17 +4,17 @@
/* Basic Options */ /* Basic Options */
// "incremental": true, /* Enable incremental compilation */ // "incremental": true, /* Enable incremental compilation */
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', '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'. */ "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. */ // "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */ // "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */ // "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */ // "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each 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. */ // "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. */ // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */ // "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ // "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'). */ // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */ /* 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. */ // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */ // "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */ // "strictFunctionTypes": true, /* Enable strict checking of function types. */
@ -48,7 +48,7 @@
// "typeRoots": [], /* List of folders to include type definitions from. */ // "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */ // "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. */ // "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. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
@ -63,7 +63,7 @@
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Advanced Options */ /* Advanced Options */
"skipLibCheck": true, /* Skip type checking of declaration files. */ "skipLibCheck": true /* Skip type checking of declaration files. */,
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
} }
} }

View file

@ -2,6 +2,11 @@
# yarn lockfile v1 # 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: typescript@^4.0.3:
version "4.0.3" version "4.0.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.3.tgz#153bbd468ef07725c1df9c77e8b453f8d36abba5" resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.3.tgz#153bbd468ef07725c1df9c77e8b453f8d36abba5"

View file

@ -1,14 +1,34 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>OCW</title> <title>OCW</title>
<script src="assets/index.js"></script> <script src="assets/index.js"></script>
</head> </head>
<body> <body>
<div class="package-list"> <div class="login-box">
LOGIN
<form method="POST">
<label for="login">Login:</label>
<input type="text" name="login" />
<label for="password">Pwd:</label>
<input type="text" name="password" />
<input type="submit" class="login-submit" />
</form>
</div> </div>
</body> <div class="register-box">
</html> REGISTER
<form method="POST">
<label for="login">Login:</label>
<input type="text" name="login" />
<label for="password">Pwd:</label>
<input type="text" name="password" />
<label for="phone">Phone:</label>
<input type="phone" name="phone" />
<input type="submit" class="register-submit" />
</form>
</div>
<div class="package-list"></div>
</body>
</html>