added prettier and some js

master
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",
"author": "Laura Liberda <laura@selfisekai.rocks>, Dominika Liberda <dominika@sdomi.pl>",
"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"
}
}

View File

@ -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);
});
});

View File

@ -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. */
}
}

View File

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

View File

@ -1,14 +1,34 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>OCW</title>
<script src="assets/index.js"></script>
</head>
<body>
<div class="package-list">
</head>
<body>
<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>
</body>
</html>
<div class="register-box">
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>