From bfc9d971e0d7bfb9910eaf568c6cd902f38fa840 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oph=C3=A9lie?= Date: Sun, 15 Jan 2023 11:59:08 +0100 Subject: [PATCH 01/59] Init files --- .gitignore | 1 + dist/multiplication.js | 0 index.html | 17 +++++++++++++++++ package-lock.json | 31 +++++++++++++++++++++++++++++++ package.json | 5 +++++ src/multiplication.ts | 0 tsconfig.json | 9 +++++++++ 7 files changed, 63 insertions(+) create mode 100644 .gitignore create mode 100644 dist/multiplication.js create mode 100644 index.html create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 src/multiplication.ts create mode 100644 tsconfig.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..40b878d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules/ \ No newline at end of file diff --git a/dist/multiplication.js b/dist/multiplication.js new file mode 100644 index 0000000..e69de29 diff --git a/index.html b/index.html new file mode 100644 index 0000000..1b2749e --- /dev/null +++ b/index.html @@ -0,0 +1,17 @@ + + + + + + + + Calculator + + + + + + + + + \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..02d596c --- /dev/null +++ b/package-lock.json @@ -0,0 +1,31 @@ +{ + "name": "calculator", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "dependencies": { + "typescript": "^4.9.4" + } + }, + "node_modules/typescript": { + "version": "4.9.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.4.tgz", + "integrity": "sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg==", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + } + }, + "dependencies": { + "typescript": { + "version": "4.9.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.4.tgz", + "integrity": "sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg==" + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..a68b1f6 --- /dev/null +++ b/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "typescript": "^4.9.4" + } +} diff --git a/src/multiplication.ts b/src/multiplication.ts new file mode 100644 index 0000000..e69de29 diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..c56343c --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "outDir": "dist", + "target": "ES2015", + "noEmitOnError": false, + "strict": true + }, + "files": ["src/multiplication.ts"] +} \ No newline at end of file From c87a359c007e3b43cccd156039ed218ba07fae7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oph=C3=A9lie?= Date: Mon, 16 Jan 2023 18:10:14 +0100 Subject: [PATCH 02/59] add input and button --- dist/index.js | 1 + index.html | 6 ++++++ package.json | 17 ++++++++++++++--- src/index.ts | 0 tsconfig.json | 2 +- 5 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 dist/index.js create mode 100644 src/index.ts diff --git a/dist/index.js b/dist/index.js new file mode 100644 index 0000000..3918c74 --- /dev/null +++ b/dist/index.js @@ -0,0 +1 @@ +"use strict"; diff --git a/index.html b/index.html index 1b2749e..0e57423 100644 --- a/index.html +++ b/index.html @@ -10,6 +10,12 @@ + + + + + + diff --git a/package.json b/package.json index a68b1f6..6f8cb30 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,16 @@ { - "dependencies": { - "typescript": "^4.9.4" + "name": "typescript", + "version": "1.0.0", + "description": "", + "main": "src/index.js", + "type": "module", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "devDependencies": { + "typescript": "^4.8.4" } -} +} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..e69de29 diff --git a/tsconfig.json b/tsconfig.json index c56343c..e115711 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,5 +5,5 @@ "noEmitOnError": false, "strict": true }, - "files": ["src/multiplication.ts"] + "files": ["src/index.ts", "src/multiplication.ts"] } \ No newline at end of file From f1b8e4207687b34b21571f1d227298c9afe9dd88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oph=C3=A9lie?= Date: Tue, 17 Jan 2023 19:54:46 +0100 Subject: [PATCH 03/59] test ts file --- dist/multiplication.js | 14 ++++++++++++++ src/multiplication.ts | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/dist/multiplication.js b/dist/multiplication.js index e69de29..ed6700e 100644 --- a/dist/multiplication.js +++ b/dist/multiplication.js @@ -0,0 +1,14 @@ +"use strict"; +let inputA = document.querySelector('#numberA'); +let numberA = inputA.value; +let inputB = document.querySelector('#numberB'); +let numberB = inputB.value; +let button = document.querySelector('.button-multiplication'); +let resultat; +function multiplication(a, b) { + resultat = a * b; + return resultat; +} +; +button.addEventListener('click', multiplication(numberA, numberB), alert("Le résultat de votre multiplication est " + resultat)); +// button.addEventListener('click', multiplication(numberA, numberB)) diff --git a/src/multiplication.ts b/src/multiplication.ts index e69de29..94e5227 100644 --- a/src/multiplication.ts +++ b/src/multiplication.ts @@ -0,0 +1,14 @@ +let inputA = document.querySelector('#numberA') as HTMLInputElement; +let numberA = inputA.value; +let inputB = document.querySelector('#numberB') as HTMLInputElement; +let numberB = inputB.value; +let button = document.querySelector('.button-multiplication') as HTMLButtonElement; +let resultat: number + + +function multiplication(a: number, b: number): number { + resultat = a * b + return resultat +}; + +button.addEventListener('click', multiplication(numberA, numberB), alert("Le résultat de votre multiplication est " + resultat)) From 83bd3903e1471016c12d673673a3a38af101f45f Mon Sep 17 00:00:00 2001 From: Berenger Ferguenis Date: Fri, 13 Jan 2023 20:44:45 +0100 Subject: [PATCH 04/59] feat/add branch created --- index.ts | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 index.ts diff --git a/index.ts b/index.ts new file mode 100644 index 0000000..047cc25 --- /dev/null +++ b/index.ts @@ -0,0 +1,8 @@ + +// let varNumb = document.getElementById('ids') + +// varNumb?.addEventListener('click', () => { +// console.log('ok') +// }) + +//addition buttons function ===> \ No newline at end of file From 9d5b25f921571018a138e768d0f269acb3e65bed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oph=C3=A9lie?= Date: Wed, 18 Jan 2023 17:43:44 +0100 Subject: [PATCH 05/59] modify multiplication.ts --- src/multiplication.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/multiplication.ts b/src/multiplication.ts index 94e5227..6146042 100644 --- a/src/multiplication.ts +++ b/src/multiplication.ts @@ -8,7 +8,8 @@ let resultat: number function multiplication(a: number, b: number): number { resultat = a * b + alert("Le résultat de votre multiplication est " + resultat) return resultat }; -button.addEventListener('click', multiplication(numberA, numberB), alert("Le résultat de votre multiplication est " + resultat)) +button?.addEventListener('click', multiplication(numberA, numberB)) \ No newline at end of file From dc28b8625ceea826466b51db611bab39debb935a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oph=C3=A9lie?= Date: Sun, 15 Jan 2023 11:59:08 +0100 Subject: [PATCH 06/59] rebase --- dist/multiplication.js | 14 ++++++++++++++ index.html | 9 ++++++++- package-lock.json | 2 +- src/multiplication.ts | 14 ++++++++++++++ tsconfig.json | 2 +- 5 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 dist/multiplication.js create mode 100644 src/multiplication.ts diff --git a/dist/multiplication.js b/dist/multiplication.js new file mode 100644 index 0000000..de56089 --- /dev/null +++ b/dist/multiplication.js @@ -0,0 +1,14 @@ +"use strict"; +let inputA = document.querySelector('#numberA'); +let numberA = inputA.value; +let inputB = document.querySelector('#numberB'); +let numberB = inputB.value; +let button = document.querySelector('.button-multiplication'); +let resultat; +function multiplication(a, b) { + resultat = a * b; + return resultat; +} +; +button.addEventListener('click', multiplication(numberA, numberB), alert("Le résultat de votre multiplication est " + resultat)); +// button.addEventListener('click', multiplication(numberA, numberB)) \ No newline at end of file diff --git a/index.html b/index.html index 8fd5224..0e57423 100644 --- a/index.html +++ b/index.html @@ -5,12 +5,19 @@ - Document + Calculator + + + + + + + \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 8b9ecd1..4b85238 100644 --- a/package-lock.json +++ b/package-lock.json @@ -34,4 +34,4 @@ "dev": true } } -} +} \ No newline at end of file diff --git a/src/multiplication.ts b/src/multiplication.ts new file mode 100644 index 0000000..c30cc69 --- /dev/null +++ b/src/multiplication.ts @@ -0,0 +1,14 @@ +let inputA = document.querySelector('#numberA') as HTMLInputElement; +let numberA = inputA.value; +let inputB = document.querySelector('#numberB') as HTMLInputElement; +let numberB = inputB.value; +let button = document.querySelector('.button-multiplication') as HTMLButtonElement; +let resultat: number + + +function multiplication(a: number, b: number): number { + resultat = a * b + return resultat +}; + +button.addEventListener('click', multiplication(numberA, numberB), alert("Le résultat de votre multiplication est " + resultat)) \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 32b1954..e03c2ee 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,5 +5,5 @@ "noEmitOnError": false, "strict": true }, - "files": ["src/index.ts"] + "files": ["src/index.ts", "src/multiplication.ts"] } From ed1e0577a792f0cd00a9d4957ac57f8a0bbaf9c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oph=C3=A9lie?= Date: Mon, 16 Jan 2023 18:10:14 +0100 Subject: [PATCH 07/59] add input and button --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5e76502..6f8cb30 100644 --- a/package.json +++ b/package.json @@ -13,4 +13,4 @@ "devDependencies": { "typescript": "^4.8.4" } -} +} \ No newline at end of file From 4254b892f87aa2d72f292b4ec2ea3321a27689b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oph=C3=A9lie?= Date: Wed, 18 Jan 2023 18:23:39 +0100 Subject: [PATCH 08/59] rebase --- dist/multiplication.js | 1 - 1 file changed, 1 deletion(-) diff --git a/dist/multiplication.js b/dist/multiplication.js index de56089..748305b 100644 --- a/dist/multiplication.js +++ b/dist/multiplication.js @@ -11,4 +11,3 @@ function multiplication(a, b) { } ; button.addEventListener('click', multiplication(numberA, numberB), alert("Le résultat de votre multiplication est " + resultat)); -// button.addEventListener('click', multiplication(numberA, numberB)) \ No newline at end of file From 5a3a2ce5294c29b1baff1e5b3c5385c20b5621e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oph=C3=A9lie?= Date: Thu, 19 Jan 2023 21:59:35 +0100 Subject: [PATCH 09/59] Fix function --- .vscode/settings.json | 2 +- README.md | 10 ++++++++-- dist/multiplication.js | 23 ++++++++++++++++------- index.html | 3 ++- src/multiplication.ts | 31 ++++++++++++++++++++++++------- 5 files changed, 51 insertions(+), 18 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 6b665aa..4c7ff40 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,3 @@ { - "liveServer.settings.port": 5501 + "liveServer.settings.port": 5502 } diff --git a/README.md b/README.md index bfd2e48..cbf1793 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ Projet Excercice Typescript ### Langage et Package - TypeScript +- Nodejs ## Installation @@ -31,8 +32,6 @@ $ npm install ``` $ npx tsc $ npx tsc --watch (recompilation automatique) - - ``` ## Ajouter un fichier TS @@ -44,3 +43,10 @@ $ $ Exemple tsconfig apres ajout : $ "files": ["src/index.ts", "src/sin_cos.ts"] ``` + +## Tester son fichier JS + +``` +$ Dans un terminal taper la commande suivante: +$ node ./dist/.js +``` \ No newline at end of file diff --git a/dist/multiplication.js b/dist/multiplication.js index ed6700e..4bd3a09 100644 --- a/dist/multiplication.js +++ b/dist/multiplication.js @@ -1,14 +1,23 @@ "use strict"; let inputA = document.querySelector('#numberA'); -let numberA = inputA.value; +let numberA; let inputB = document.querySelector('#numberB'); -let numberB = inputB.value; +let numberB; let button = document.querySelector('.button-multiplication'); +let affichageResultat = document.querySelector('#resultat'); let resultat; + function multiplication(a, b) { - resultat = a * b; - return resultat; + if (a == null || b == null || isNaN(a) || isNaN(b)) { + affichageResultat.textContent = "Merci de renseigner uniquement des valeurs numériques"; + } + else { + resultat = a * b; + affichageResultat.textContent = "Résultat : " + resultat; + } } -; -button.addEventListener('click', multiplication(numberA, numberB), alert("Le résultat de votre multiplication est " + resultat)); -// button.addEventListener('click', multiplication(numberA, numberB)) +button.addEventListener('click', () => { + numberA = parseInt(inputA.value); + numberB = parseInt(inputB.value); + multiplication(numberA, numberB); +}); diff --git a/index.html b/index.html index 0e57423..857936b 100644 --- a/index.html +++ b/index.html @@ -15,9 +15,10 @@ +

- + \ No newline at end of file diff --git a/src/multiplication.ts b/src/multiplication.ts index 798a9b9..2bd7c00 100644 --- a/src/multiplication.ts +++ b/src/multiplication.ts @@ -1,13 +1,30 @@ let inputA = document.querySelector('#numberA') as HTMLInputElement; -let numberA = inputA.value; +let numberA: number let inputB = document.querySelector('#numberB') as HTMLInputElement; -let numberB = inputB.value; +let numberB: number let button = document.querySelector('.button-multiplication') as HTMLButtonElement; +let affichageResultat = document.querySelector('#resultat') as HTMLParagraphElement let resultat: number -function multiplication(a: number, b: number): number { - resultat = a * b - alert("Le résultat de votre multiplication est " + resultat) - return resultat -}; +function multiplication(a: number, b: number) { + + if (a == null || b == null || isNaN(a) || isNaN(b)) { + + affichageResultat.textContent = "Merci de renseigner uniquement des valeurs numériques" + + } + else { + + resultat = a * b; + affichageResultat.textContent = "Résultat : " + resultat; + + } + +} + +button.addEventListener('click', () => { + numberA = parseInt(inputA.value) + numberB = parseInt(inputB.value) + multiplication(numberA, numberB) +}) From c3a316f1cdfc45c140b37f72366cbd8f33278a2c Mon Sep 17 00:00:00 2001 From: sebastien baudet Date: Fri, 20 Jan 2023 22:40:56 +0100 Subject: [PATCH 10/59] add script to compile ==> npm run build, compile ts file and copy html/css files to dist --- .gitignore | 4 +++- README.md | 7 +++++++ dist/index.html | 17 +++++++++++++++++ dist/index.js | 1 + index.html | 1 + index.js | 43 +++++++++++++++++++++++++++++++++++++++++++ package.json | 3 ++- src/index.ts | 3 ++- style/tottoot.css | 3 +++ tsconfig.json | 4 ++-- 10 files changed, 81 insertions(+), 5 deletions(-) create mode 100644 dist/index.html create mode 100644 index.js create mode 100644 style/tottoot.css diff --git a/.gitignore b/.gitignore index 40b878d..234f9ca 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -node_modules/ \ No newline at end of file +node_modules/ +dist/ +.vscode/ \ No newline at end of file diff --git a/README.md b/README.md index e829176..3c112e2 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,13 @@ $ npx tsc $ npx tsc --watch (recompilation automatique) +``` + +## Compilation npm + +``` +$ npm run build + ``` ## Ajouter un fichier TS diff --git a/dist/index.html b/dist/index.html new file mode 100644 index 0000000..2739b0e --- /dev/null +++ b/dist/index.html @@ -0,0 +1,17 @@ + + + + + + + + Document + + + + +
+ + + + \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index b3d6ed1..af0a5c0 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,2 +1,3 @@ "use strict"; const compt = "55"; +const compt2 = "5555"; diff --git a/index.html b/index.html index 8fd5224..2739b0e 100644 --- a/index.html +++ b/index.html @@ -10,6 +10,7 @@ +
diff --git a/index.js b/index.js new file mode 100644 index 0000000..d5f228c --- /dev/null +++ b/index.js @@ -0,0 +1,43 @@ +import * as fs from "fs"; +import { execSync } from "child_process"; +import * as path from "path"; + +// example file and directory to copy +//const sourceDirectory = ["./", "./style"]; +const sourceDirectory = ["./"]; +const destinationDirectory = "dist/"; + +sourceDirectory.forEach(dir =>{ + cpyFile(dir,destinationDirectory) +}) + + +function cpyFile(directory, destination) { + fs.readdir(directory, (err, files) => { + if (err) { + console.error(err); + return; + } + + files.forEach((file) => { + if (path.extname(file) === ".html" || path.extname(file) === ".css") { + const sourceFile = path.join(directory, file); + let destinationFile = path.join(destination, directory); + + fs.mkdir(destinationFile, { recursive: true }, (err) => { + if (err) throw err; + }); + + destinationFile = path.join(destinationFile, file); + + const readStream = fs.createReadStream(sourceFile); + const writeStream = fs.createWriteStream(destinationFile); + + readStream.pipe(writeStream); + } + }); + }); +} + +//compile Ts file +execSync("npx tsc"); diff --git a/package.json b/package.json index 5e76502..5eba530 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,8 @@ "main": "src/index.js", "type": "module", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "test": "echo \"Error: no test specified\" && exit 1", + "build": "node index.js" }, "keywords": [], "author": "", diff --git a/src/index.ts b/src/index.ts index 547c72d..1cabe3d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1 +1,2 @@ -const compt:string = "55" \ No newline at end of file +const compt:string = "55" +const compt2:string = "5555" \ No newline at end of file diff --git a/style/tottoot.css b/style/tottoot.css new file mode 100644 index 0000000..883357e --- /dev/null +++ b/style/tottoot.css @@ -0,0 +1,3 @@ +*{ + font-size: ; +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 32b1954..0d1efe9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,9 +1,9 @@ { "compilerOptions": { "outDir": "dist", - "target": "ES2015", + "target": "ES2022", "noEmitOnError": false, "strict": true }, - "files": ["src/index.ts"] + "include": ["src/**/*.ts"] } From dc87164f58bcbfc8bec9e575c2de2f62ec57a33e Mon Sep 17 00:00:00 2001 From: sebastien baudet Date: Fri, 20 Jan 2023 22:41:39 +0100 Subject: [PATCH 11/59] remove directory test --- style/tottoot.css | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 style/tottoot.css diff --git a/style/tottoot.css b/style/tottoot.css deleted file mode 100644 index 883357e..0000000 --- a/style/tottoot.css +++ /dev/null @@ -1,3 +0,0 @@ -*{ - font-size: ; -} \ No newline at end of file From db17fea3062c0be7708f3475388f53556e4f3e26 Mon Sep 17 00:00:00 2001 From: Berenger Ferguenis Date: Sun, 15 Jan 2023 20:52:47 +0100 Subject: [PATCH 12/59] creat html & css calculator --- index.html | 76 ++++++++++++++++++++++++----- style.css | 138 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 201 insertions(+), 13 deletions(-) diff --git a/index.html b/index.html index 2739b0e..17f791f 100644 --- a/index.html +++ b/index.html @@ -1,17 +1,67 @@ - + + + + + + Calculator + + - - - - - Document - - + +
+
+ +
+ + + +
+ + + +
+ + + +
+ + + +
+ + + +
+
+
+
- -
- - - \ No newline at end of file + + diff --git a/style.css b/style.css index e69de29..ae9f963 100644 --- a/style.css +++ b/style.css @@ -0,0 +1,138 @@ +*{ + margin: 0; + padding: 0; + outline: none; + box-sizing: border-box; +} + +body { + display: flex; + text-align: center; + justify-content: center; + align-items: center; + min-height: 100vh; + background: linear-gradient(#9cebfc,#6ae1fb); +} + +.center { + width: 400px; + background: black; +} + +input[type="text"] { + height: 70px; + width: 250px; + margin-top: 40px; + margin-bottom: 10px; + color: white; + font-size: 22px; + font-weight: bold; + text-align: right; + padding-right: 20px; + background-color: #636363; +} + +form .buttons{ + width: 400px; + margin-bottom: 15px; + padding: 10px 0; +} + +.button_number { + width: 58px; + height: 55px; + margin-top: 6px; + background-color: #d5d5d5; + cursor: pointer; + font-weight: bold; +} + +.button_number:hover { + transition: .3s; + background-color: #616161; +} + +.button_operation { + width: 58px; + height: 55px; + background-color: #FFBB37; + color: #383838; + cursor: pointer; + font-weight: bold; +} + +.button_operation:hover { + transition: .3s; + background-color: #a87818; +} + +.button_dot { + width: 58px; + height: 55px; + background-color: #d5d5d5; + color: black; + cursor: pointer; +} + +.button_dot:hover { + transition: .3s; + background-color: #616161; +} + +.button_clear { + width: 58px; + height: 55px; + background-color: #df5c34; + color: white; + font-weight: bold; + cursor: pointer; +} + +.button_clear:hover { + transition: .3s; + background-color: #9c3f23; +} + +.button_equal { + width: 58px; + height: 55px; + color: white; + background-color: #df5c34; + cursor: pointer; + font-weight: bold; + font-size: 18px; +} + +.button_equal:hover { + transition: .3s; + background-color: #9c3f23; +} + +.button_cos { + width: 58px; + height: 55px; + border-radius: 3px; + background-color: #5A93C7; + color: black; + cursor: pointer; + font-weight: bold; +} + +.button_cos:hover { + transition: .3s; + background-color: #335575; +} + +.button_sin { + width: 58px; + height: 55px; + background-color: #5AC77F; + color: black; + cursor: pointer; + font-weight: bold; +} + +.button_sin:hover { + transition: .3s; + background-color: #337a4b; +} \ No newline at end of file From 173202e77851fb00efa551d7f428d38babe16527 Mon Sep 17 00:00:00 2001 From: Abdel Bailoul Date: Sat, 21 Jan 2023 17:24:44 +0100 Subject: [PATCH 13/59] first commit --- dist/index.html | 62 ++++++++++---- index.html | 86 ++++++++----------- index.js | 29 +++---- style.css | 214 ++++++++++++++++++++---------------------------- 4 files changed, 184 insertions(+), 207 deletions(-) diff --git a/dist/index.html b/dist/index.html index 2739b0e..ec7d87b 100644 --- a/dist/index.html +++ b/dist/index.html @@ -1,17 +1,49 @@ - - - - - - - Document - - - - -
+ + + + + + Calculator + + + + +
+
+
+
+
3+6
+
+
(
+
)
+
COS
+
SIN
+
TAN
+
7
+
8
+
9
+
/
+
C
+
4
+
5
+
6
+
x
+
=
+
1
+
2
+
3
+
-
+
+/-
+
0
+
.
+
+
+
+
+
- - - \ No newline at end of file + + diff --git a/index.html b/index.html index 17f791f..ec7d87b 100644 --- a/index.html +++ b/index.html @@ -5,63 +5,45 @@ Calculator + - -
-
- -
- - - -
- - - -
- - - -
- - - -
- - - -
+
+
+
+
+
3+6
+
+
(
+
)
+
COS
+
SIN
+
TAN
+
7
+
8
+
9
+
/
+
C
+
4
+
5
+
6
+
x
+
=
+
1
+
2
+
3
+
-
+
+/-
+
0
+
.
+
+
- +
- diff --git a/index.js b/index.js index d5f228c..3c7c799 100644 --- a/index.js +++ b/index.js @@ -1,16 +1,15 @@ -import * as fs from "fs"; -import { execSync } from "child_process"; -import * as path from "path"; +import * as fs from 'fs'; +import { execSync } from 'child_process'; +import * as path from 'path'; // example file and directory to copy //const sourceDirectory = ["./", "./style"]; -const sourceDirectory = ["./"]; -const destinationDirectory = "dist/"; - -sourceDirectory.forEach(dir =>{ - cpyFile(dir,destinationDirectory) -}) +const sourceDirectory = ['./']; +const destinationDirectory = 'dist/'; +sourceDirectory.forEach((dir) => { + cpyFile(dir, destinationDirectory); +}); function cpyFile(directory, destination) { fs.readdir(directory, (err, files) => { @@ -20,19 +19,15 @@ function cpyFile(directory, destination) { } files.forEach((file) => { - if (path.extname(file) === ".html" || path.extname(file) === ".css") { + if (path.extname(file) === '.html' || path.extname(file) === '.css') { const sourceFile = path.join(directory, file); let destinationFile = path.join(destination, directory); - fs.mkdir(destinationFile, { recursive: true }, (err) => { - if (err) throw err; - }); - + if (err) throw err; + }); destinationFile = path.join(destinationFile, file); - const readStream = fs.createReadStream(sourceFile); const writeStream = fs.createWriteStream(destinationFile); - readStream.pipe(writeStream); } }); @@ -40,4 +35,4 @@ function cpyFile(directory, destination) { } //compile Ts file -execSync("npx tsc"); +execSync('npx tsc'); diff --git a/style.css b/style.css index ae9f963..5238593 100644 --- a/style.css +++ b/style.css @@ -1,138 +1,106 @@ -*{ +* { margin: 0; padding: 0; - outline: none; box-sizing: border-box; + font-family: 'Rubik', sans-serif; } body { + background-color: #e8c055; + background: linear-gradient(45deg, #e8c055, #e9dab2); + min-height: 100vh; + width: 100%; display: flex; - text-align: center; - justify-content: center; align-items: center; - min-height: 100vh; - background: linear-gradient(#9cebfc,#6ae1fb); -} - -.center { - width: 400px; - background: black; -} - -input[type="text"] { - height: 70px; - width: 250px; - margin-top: 40px; - margin-bottom: 10px; - color: white; - font-size: 22px; - font-weight: bold; - text-align: right; - padding-right: 20px; - background-color: #636363; -} - -form .buttons{ - width: 400px; - margin-bottom: 15px; - padding: 10px 0; -} - -.button_number { - width: 58px; - height: 55px; - margin-top: 6px; - background-color: #d5d5d5; - cursor: pointer; - font-weight: bold; -} - -.button_number:hover { - transition: .3s; - background-color: #616161; -} - -.button_operation { - width: 58px; - height: 55px; - background-color: #FFBB37; - color: #383838; - cursor: pointer; - font-weight: bold; -} - -.button_operation:hover { - transition: .3s; - background-color: #a87818; -} - -.button_dot { - width: 58px; - height: 55px; - background-color: #d5d5d5; - color: black; - cursor: pointer; -} - -.button_dot:hover { - transition: .3s; - background-color: #616161; -} - -.button_clear { - width: 58px; - height: 55px; - background-color: #df5c34; - color: white; - font-weight: bold; - cursor: pointer; -} - -.button_clear:hover { - transition: .3s; - background-color: #9c3f23; -} - -.button_equal { - width: 58px; - height: 55px; - color: white; - background-color: #df5c34; - cursor: pointer; - font-weight: bold; - font-size: 18px; -} - -.button_equal:hover { - transition: .3s; - background-color: #9c3f23; + justify-content: center; + font-size: 1.75rem; + color: rgb(246, 246, 246); + text-shadow: 0 3px 3px #00000033; } -.button_cos { - width: 58px; - height: 55px; - border-radius: 3px; - background-color: #5A93C7; - color: black; - cursor: pointer; - font-weight: bold; +.calculator { + width: clamp(23rem, 80vw, 50rem); + background-color: #404f66; + border-radius: 9px; } -.button_cos:hover { - transition: .3s; - background-color: #335575; +.calculator-body { + display: grid; + border-radius: 9px; + /* height: 100%; */ + padding: 3rem; + grid-template-columns: repeat(5, 1fr); + grid-template-rows: repeat(6, 1fr); + column-gap: 1rem; + row-gap: 1rem; + box-shadow: 0 16px 16px #00000031; } -.button_sin { - width: 58px; - height: 55px; - background-color: #5AC77F; - color: black; - cursor: pointer; - font-weight: bold; +.calculator-body > div { + background-color: #e8c055; + grid-column-end: span 1; + min-height: 2rem; + display: flex; + align-items: center; + justify-content: center; + border-radius: 6px; + box-shadow: 0 4px 4px #00000033; +} + +.calculator-body .key-opt { + height: 2.8rem; + margin-top: 1.5rem; +} + +.calculator-body .screen { + position: relative; + grid-column-end: span 5; + justify-content: end; + padding-right: 1rem; + overflow: hidden; + height: 100%; + width: 100%; + z-index: 10; +} + +.calculator-body .screen::after { + position: absolute; + z-index: 5; + content: ''; + width: 800px; + height: 100px; + background: #6699b1; + transform: skew(-50deg) translateX(50%); +} +.calculator-body .result { + position: relative; + z-index: 10; +} +.calculator-body .screen, +.calculator-body .key-blue { + background-color: #709db0; +} + +.calculator-body .key-equal { + grid-row-end: span 3; +} + +@media screen and (max-width: 800px) { + body { + font-size: 1.5rem; + } + .calculator { + min-width: 100%; + } + .calculator-body { + padding: 1.5rem; + } +} +@media screen and (max-width: 500px) { + body { + font-size: 1rem; + } + .calculator-body { + padding: 1rem; + } } - -.button_sin:hover { - transition: .3s; - background-color: #337a4b; -} \ No newline at end of file From 6e0c756fd4bdaa565f29177c87c3e047ed937dc4 Mon Sep 17 00:00:00 2001 From: Abdel Bailoul Date: Sat, 21 Jan 2023 17:34:32 +0100 Subject: [PATCH 14/59] fix: issue on npm run build / remove all dist > build --- index.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/index.js b/index.js index 3c7c799..91577bf 100644 --- a/index.js +++ b/index.js @@ -7,6 +7,14 @@ import * as path from 'path'; const sourceDirectory = ['./']; const destinationDirectory = 'dist/'; +if (fs.existsSync('./dist')) { + fs.rmSync(destinationDirectory, { recursive: true }); +} + +if (!fs.existsSync('./dist')) { + fs.mkdirSync('./dist'); +} + sourceDirectory.forEach((dir) => { cpyFile(dir, destinationDirectory); }); From 87eb877311a698a88e0f187aeda31c84aaa80dc3 Mon Sep 17 00:00:00 2001 From: sebastien baudet Date: Sat, 21 Jan 2023 17:37:36 +0100 Subject: [PATCH 15/59] update index.js to build project --- index.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/index.js b/index.js index d5f228c..4635b78 100644 --- a/index.js +++ b/index.js @@ -7,10 +7,17 @@ import * as path from "path"; const sourceDirectory = ["./"]; const destinationDirectory = "dist/"; -sourceDirectory.forEach(dir =>{ - cpyFile(dir,destinationDirectory) -}) +if (fs.existsSync("./dist")) { + fs.rmSync(destinationDirectory, { recursive: true }); +} + +if (!fs.existsSync("./dist")) { + fs.mkdirSync("./dist"); +} +sourceDirectory.forEach((dir) => { + cpyFile(dir, destinationDirectory); +}); function cpyFile(directory, destination) { fs.readdir(directory, (err, files) => { @@ -23,16 +30,12 @@ function cpyFile(directory, destination) { if (path.extname(file) === ".html" || path.extname(file) === ".css") { const sourceFile = path.join(directory, file); let destinationFile = path.join(destination, directory); - fs.mkdir(destinationFile, { recursive: true }, (err) => { - if (err) throw err; - }); - + if (err) throw err; + }); destinationFile = path.join(destinationFile, file); - const readStream = fs.createReadStream(sourceFile); const writeStream = fs.createWriteStream(destinationFile); - readStream.pipe(writeStream); } }); From 20a29ff6c1c05bc118e0f2620a201a4d40a44862 Mon Sep 17 00:00:00 2001 From: Abdel Bailoul Date: Sat, 21 Jan 2023 17:42:06 +0100 Subject: [PATCH 16/59] opt: added dataset for all calculator keys --- index.html | 50 +++++++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/index.html b/index.html index ec7d87b..e7fa30d 100644 --- a/index.html +++ b/index.html @@ -18,29 +18,33 @@
3+6
-
(
-
)
-
COS
-
SIN
-
TAN
-
7
-
8
-
9
-
/
-
C
-
4
-
5
-
6
-
x
-
=
-
1
-
2
-
3
-
-
-
+/-
-
0
-
.
-
+
+
+ ( +
+
+ ) +
+
COS
+
SIN
+
TAN
+
7
+
8
+
9
+
/
+
C
+
4
+
5
+
6
+
x
+
=
+
1
+
2
+
3
+
-
+
+/-
+
0
+
.
+
+
From 16769c5c299ea0f7869e2b7aa99e221b55de0b4a Mon Sep 17 00:00:00 2001 From: Abdel Bailoul Date: Sat, 21 Jan 2023 17:51:00 +0100 Subject: [PATCH 17/59] opt: animtion btns on hover --- dist/index.html | 50 ++++++++++++++++++++++++++----------------------- style.css | 11 +++++++++++ 2 files changed, 38 insertions(+), 23 deletions(-) diff --git a/dist/index.html b/dist/index.html index ec7d87b..e7fa30d 100644 --- a/dist/index.html +++ b/dist/index.html @@ -18,29 +18,33 @@
3+6
-
(
-
)
-
COS
-
SIN
-
TAN
-
7
-
8
-
9
-
/
-
C
-
4
-
5
-
6
-
x
-
=
-
1
-
2
-
3
-
-
-
+/-
-
0
-
.
-
+
+
+ ( +
+
+ ) +
+
COS
+
SIN
+
TAN
+
7
+
8
+
9
+
/
+
C
+
4
+
5
+
6
+
x
+
=
+
1
+
2
+
3
+
-
+
+/-
+
0
+
.
+
+
diff --git a/style.css b/style.css index 5238593..b96ae7a 100644 --- a/style.css +++ b/style.css @@ -85,6 +85,17 @@ body { grid-row-end: span 3; } +.calculator-body .key { + cursor: pointer; + transition: background-color 0.3s ease-out; +} +.calculator-body .key:hover { + background-color: #c7a549; +} +.calculator-body .key-blue:hover { + background-color: #5c8191; +} + @media screen and (max-width: 800px) { body { font-size: 1.5rem; From 7c86be5b862da69df689e6335847ea24127be983 Mon Sep 17 00:00:00 2001 From: Abdel Bailoul Date: Sat, 21 Jan 2023 18:00:50 +0100 Subject: [PATCH 18/59] html: added title h1 --- index.html | 1 + style.css | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index e7fa30d..879ef8d 100644 --- a/index.html +++ b/index.html @@ -12,6 +12,7 @@ +

Project
Calculator TS

diff --git a/style.css b/style.css index b96ae7a..ee1ccde 100644 --- a/style.css +++ b/style.css @@ -1,3 +1,4 @@ +/*** Reset CSS ***/ * { margin: 0; padding: 0; @@ -13,11 +14,21 @@ body { display: flex; align-items: center; justify-content: center; + flex-direction: column; font-size: 1.75rem; color: rgb(246, 246, 246); text-shadow: 0 3px 3px #00000033; } +h1 { + text-align: center; + font-size: 3.6rem; + margin-bottom: 2.4rem; + line-height: 1.05; + text-shadow: 0 6px 6px #00000033; +} + +/*** Calculator element ***/ .calculator { width: clamp(23rem, 80vw, 50rem); background-color: #404f66; @@ -27,7 +38,6 @@ body { .calculator-body { display: grid; border-radius: 9px; - /* height: 100%; */ padding: 3rem; grid-template-columns: repeat(5, 1fr); grid-template-rows: repeat(6, 1fr); @@ -75,6 +85,7 @@ body { .calculator-body .result { position: relative; z-index: 10; + letter-spacing: 0.25rem; } .calculator-body .screen, .calculator-body .key-blue { @@ -96,10 +107,14 @@ body { background-color: #5c8191; } +/*** Media queries ***/ @media screen and (max-width: 800px) { body { font-size: 1.5rem; } + h1 { + font-size: 2.6rem; + } .calculator { min-width: 100%; } From 2e605376cb439df3828cdeb88fc88ae7ec488ed8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oph=C3=A9lie?= Date: Tue, 24 Jan 2023 18:59:56 +0100 Subject: [PATCH 19/59] Add vscode and dist in gitignore --- dist/multiplication.js | 13 ++++++------- index.html | 24 ------------------------ src/multiplication.ts | 12 ++++++------ style.css | 0 tsconfig.json | 3 ++- 5 files changed, 14 insertions(+), 38 deletions(-) delete mode 100644 index.html delete mode 100644 style.css diff --git a/dist/multiplication.js b/dist/multiplication.js index 4bd3a09..5fce5af 100644 --- a/dist/multiplication.js +++ b/dist/multiplication.js @@ -1,13 +1,12 @@ "use strict"; -let inputA = document.querySelector('#numberA'); +const inputA = document.getElementById('numberA'); +const inputB = document.getElementById('numberB'); let numberA; -let inputB = document.querySelector('#numberB'); let numberB; -let button = document.querySelector('.button-multiplication'); -let affichageResultat = document.querySelector('#resultat'); +const button = document.querySelector('.button-multiplication'); +const affichageResultat = document.getElementById('resultat'); let resultat; - -function multiplication(a, b) { +const multiplication = (a, b) => { if (a == null || b == null || isNaN(a) || isNaN(b)) { affichageResultat.textContent = "Merci de renseigner uniquement des valeurs numériques"; } @@ -15,7 +14,7 @@ function multiplication(a, b) { resultat = a * b; affichageResultat.textContent = "Résultat : " + resultat; } -} +}; button.addEventListener('click', () => { numberA = parseInt(inputA.value); numberB = parseInt(inputB.value); diff --git a/index.html b/index.html deleted file mode 100644 index 857936b..0000000 --- a/index.html +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - Calculator - - - - - - - - - -

- - - - - - \ No newline at end of file diff --git a/src/multiplication.ts b/src/multiplication.ts index 2bd7c00..3783c4f 100644 --- a/src/multiplication.ts +++ b/src/multiplication.ts @@ -1,13 +1,13 @@ -let inputA = document.querySelector('#numberA') as HTMLInputElement; -let numberA: number -let inputB = document.querySelector('#numberB') as HTMLInputElement; +const inputA = document.getElementById('numberA') +const inputB = document.getElementById('numberB') +let numberA: number let numberB: number -let button = document.querySelector('.button-multiplication') as HTMLButtonElement; -let affichageResultat = document.querySelector('#resultat') as HTMLParagraphElement +const button = document.querySelector('.button-multiplication') +const affichageResultat = document.getElementById('resultat') let resultat: number -function multiplication(a: number, b: number) { +const multiplication = (a: number, b: number) => { if (a == null || b == null || isNaN(a) || isNaN(b)) { diff --git a/style.css b/style.css deleted file mode 100644 index e69de29..0000000 diff --git a/tsconfig.json b/tsconfig.json index e03c2ee..36095ef 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,5 +5,6 @@ "noEmitOnError": false, "strict": true }, - "files": ["src/index.ts", "src/multiplication.ts"] + "include": ["src/*.ts"] + } From 6c6271e0d8d67d8456c724ea76e97ed36956beda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oph=C3=A9lie?= Date: Tue, 24 Jan 2023 19:07:52 +0100 Subject: [PATCH 20/59] add vscode and dist in gitignore --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 40b878d..2525745 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -node_modules/ \ No newline at end of file +node_modules/ +.vscode/ +dist/ \ No newline at end of file From 9145e68ec07440e1fd0264a633af55f959ae9507 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oph=C3=A9lie?= Date: Tue, 24 Jan 2023 19:14:52 +0100 Subject: [PATCH 21/59] add index.html and style.css in dist - change function to arrow function - change querySelector to getElementById --- dist/multiplication.js | 13 +++++++------ index.html | 24 ++++++++++++++++++++++++ src/multiplication.ts | 12 ++++++------ style.css | 0 tsconfig.json | 3 +-- 5 files changed, 38 insertions(+), 14 deletions(-) create mode 100644 index.html create mode 100644 style.css diff --git a/dist/multiplication.js b/dist/multiplication.js index 5fce5af..4bd3a09 100644 --- a/dist/multiplication.js +++ b/dist/multiplication.js @@ -1,12 +1,13 @@ "use strict"; -const inputA = document.getElementById('numberA'); -const inputB = document.getElementById('numberB'); +let inputA = document.querySelector('#numberA'); let numberA; +let inputB = document.querySelector('#numberB'); let numberB; -const button = document.querySelector('.button-multiplication'); -const affichageResultat = document.getElementById('resultat'); +let button = document.querySelector('.button-multiplication'); +let affichageResultat = document.querySelector('#resultat'); let resultat; -const multiplication = (a, b) => { + +function multiplication(a, b) { if (a == null || b == null || isNaN(a) || isNaN(b)) { affichageResultat.textContent = "Merci de renseigner uniquement des valeurs numériques"; } @@ -14,7 +15,7 @@ const multiplication = (a, b) => { resultat = a * b; affichageResultat.textContent = "Résultat : " + resultat; } -}; +} button.addEventListener('click', () => { numberA = parseInt(inputA.value); numberB = parseInt(inputB.value); diff --git a/index.html b/index.html new file mode 100644 index 0000000..857936b --- /dev/null +++ b/index.html @@ -0,0 +1,24 @@ + + + + + + + + Calculator + + + + + + + + + +

+ + + + + + \ No newline at end of file diff --git a/src/multiplication.ts b/src/multiplication.ts index 3783c4f..2bd7c00 100644 --- a/src/multiplication.ts +++ b/src/multiplication.ts @@ -1,13 +1,13 @@ -const inputA = document.getElementById('numberA') -const inputB = document.getElementById('numberB') -let numberA: number +let inputA = document.querySelector('#numberA') as HTMLInputElement; +let numberA: number +let inputB = document.querySelector('#numberB') as HTMLInputElement; let numberB: number -const button = document.querySelector('.button-multiplication') -const affichageResultat = document.getElementById('resultat') +let button = document.querySelector('.button-multiplication') as HTMLButtonElement; +let affichageResultat = document.querySelector('#resultat') as HTMLParagraphElement let resultat: number -const multiplication = (a: number, b: number) => { +function multiplication(a: number, b: number) { if (a == null || b == null || isNaN(a) || isNaN(b)) { diff --git a/style.css b/style.css new file mode 100644 index 0000000..e69de29 diff --git a/tsconfig.json b/tsconfig.json index 36095ef..e03c2ee 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,6 +5,5 @@ "noEmitOnError": false, "strict": true }, - "include": ["src/*.ts"] - + "files": ["src/index.ts", "src/multiplication.ts"] } From 176f9a07c7cedd674caf2e20ac99ff3fc1a5adf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oph=C3=A9lie?= Date: Tue, 24 Jan 2023 19:21:28 +0100 Subject: [PATCH 22/59] Revert "add index.html and style.css in dist - change function to arrow function - change querySelector to getElementById" This reverts commit 9145e68ec07440e1fd0264a633af55f959ae9507. --- dist/multiplication.js | 13 ++++++------- index.html | 24 ------------------------ src/multiplication.ts | 12 ++++++------ style.css | 0 tsconfig.json | 3 ++- 5 files changed, 14 insertions(+), 38 deletions(-) delete mode 100644 index.html delete mode 100644 style.css diff --git a/dist/multiplication.js b/dist/multiplication.js index 4bd3a09..5fce5af 100644 --- a/dist/multiplication.js +++ b/dist/multiplication.js @@ -1,13 +1,12 @@ "use strict"; -let inputA = document.querySelector('#numberA'); +const inputA = document.getElementById('numberA'); +const inputB = document.getElementById('numberB'); let numberA; -let inputB = document.querySelector('#numberB'); let numberB; -let button = document.querySelector('.button-multiplication'); -let affichageResultat = document.querySelector('#resultat'); +const button = document.querySelector('.button-multiplication'); +const affichageResultat = document.getElementById('resultat'); let resultat; - -function multiplication(a, b) { +const multiplication = (a, b) => { if (a == null || b == null || isNaN(a) || isNaN(b)) { affichageResultat.textContent = "Merci de renseigner uniquement des valeurs numériques"; } @@ -15,7 +14,7 @@ function multiplication(a, b) { resultat = a * b; affichageResultat.textContent = "Résultat : " + resultat; } -} +}; button.addEventListener('click', () => { numberA = parseInt(inputA.value); numberB = parseInt(inputB.value); diff --git a/index.html b/index.html deleted file mode 100644 index 857936b..0000000 --- a/index.html +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - Calculator - - - - - - - - - -

- - - - - - \ No newline at end of file diff --git a/src/multiplication.ts b/src/multiplication.ts index 2bd7c00..3783c4f 100644 --- a/src/multiplication.ts +++ b/src/multiplication.ts @@ -1,13 +1,13 @@ -let inputA = document.querySelector('#numberA') as HTMLInputElement; -let numberA: number -let inputB = document.querySelector('#numberB') as HTMLInputElement; +const inputA = document.getElementById('numberA') +const inputB = document.getElementById('numberB') +let numberA: number let numberB: number -let button = document.querySelector('.button-multiplication') as HTMLButtonElement; -let affichageResultat = document.querySelector('#resultat') as HTMLParagraphElement +const button = document.querySelector('.button-multiplication') +const affichageResultat = document.getElementById('resultat') let resultat: number -function multiplication(a: number, b: number) { +const multiplication = (a: number, b: number) => { if (a == null || b == null || isNaN(a) || isNaN(b)) { diff --git a/style.css b/style.css deleted file mode 100644 index e69de29..0000000 diff --git a/tsconfig.json b/tsconfig.json index e03c2ee..36095ef 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,5 +5,6 @@ "noEmitOnError": false, "strict": true }, - "files": ["src/index.ts", "src/multiplication.ts"] + "include": ["src/*.ts"] + } From 6ecf0d790ddfa84d212e794d7a3e91e29c32d1bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oph=C3=A9lie?= Date: Fri, 27 Jan 2023 15:23:50 +0100 Subject: [PATCH 23/59] name of variables in english --- src/multiplication.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/multiplication.ts b/src/multiplication.ts index 3783c4f..07fdff6 100644 --- a/src/multiplication.ts +++ b/src/multiplication.ts @@ -3,21 +3,21 @@ const inputB = document.getElementById('numberB') let numberA: number let numberB: number const button = document.querySelector('.button-multiplication') -const affichageResultat = document.getElementById('resultat') -let resultat: number +const showResult = document.getElementById('resultat') +let result: number const multiplication = (a: number, b: number) => { if (a == null || b == null || isNaN(a) || isNaN(b)) { - affichageResultat.textContent = "Merci de renseigner uniquement des valeurs numériques" + showResult.textContent = "Merci de renseigner uniquement des valeurs numériques" } else { - resultat = a * b; - affichageResultat.textContent = "Résultat : " + resultat; + result = a * b; + showResult.textContent = "Résultat : " + result; } @@ -28,3 +28,6 @@ button.addEventListener('click', () => { numberB = parseInt(inputB.value) multiplication(numberA, numberB) }) + + + From 26a920a3d5ca370c1b84379080fb5094aa41b37f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oph=C3=A9lie?= Date: Tue, 17 Jan 2023 19:54:46 +0100 Subject: [PATCH 24/59] test ts file --- src/multiplication.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/multiplication.ts b/src/multiplication.ts index c30cc69..84d5404 100644 --- a/src/multiplication.ts +++ b/src/multiplication.ts @@ -11,4 +11,5 @@ function multiplication(a: number, b: number): number { return resultat }; -button.addEventListener('click', multiplication(numberA, numberB), alert("Le résultat de votre multiplication est " + resultat)) \ No newline at end of file +button.addEventListener('click', multiplication(numberA, numberB), alert("Le résultat de votre multiplication est " + resultat)) + From 075b838d0d12678a832337261e513619f0d9a5c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oph=C3=A9lie?= Date: Wed, 18 Jan 2023 17:43:44 +0100 Subject: [PATCH 25/59] modify multiplication.ts --- src/multiplication.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/multiplication.ts b/src/multiplication.ts index 84d5404..01ce930 100644 --- a/src/multiplication.ts +++ b/src/multiplication.ts @@ -8,6 +8,7 @@ let resultat: number function multiplication(a: number, b: number): number { resultat = a * b + alert("Le résultat de votre multiplication est " + resultat) return resultat }; From 123b90ef4d226a8f45d468777d5365a7365aa5d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oph=C3=A9lie?= Date: Thu, 19 Jan 2023 21:59:35 +0100 Subject: [PATCH 26/59] Fix function --- .vscode/settings.json | 2 +- README.md | 10 ++++++++-- dist/multiplication.js | 22 ++++++++++++++++------ index.html | 3 ++- src/multiplication.ts | 30 ++++++++++++++++++++++-------- 5 files changed, 49 insertions(+), 18 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 6b665aa..4c7ff40 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,3 @@ { - "liveServer.settings.port": 5501 + "liveServer.settings.port": 5502 } diff --git a/README.md b/README.md index bfd2e48..cbf1793 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ Projet Excercice Typescript ### Langage et Package - TypeScript +- Nodejs ## Installation @@ -31,8 +32,6 @@ $ npm install ``` $ npx tsc $ npx tsc --watch (recompilation automatique) - - ``` ## Ajouter un fichier TS @@ -44,3 +43,10 @@ $ $ Exemple tsconfig apres ajout : $ "files": ["src/index.ts", "src/sin_cos.ts"] ``` + +## Tester son fichier JS + +``` +$ Dans un terminal taper la commande suivante: +$ node ./dist/.js +``` \ No newline at end of file diff --git a/dist/multiplication.js b/dist/multiplication.js index 748305b..4bd3a09 100644 --- a/dist/multiplication.js +++ b/dist/multiplication.js @@ -1,13 +1,23 @@ "use strict"; let inputA = document.querySelector('#numberA'); -let numberA = inputA.value; +let numberA; let inputB = document.querySelector('#numberB'); -let numberB = inputB.value; +let numberB; let button = document.querySelector('.button-multiplication'); +let affichageResultat = document.querySelector('#resultat'); let resultat; + function multiplication(a, b) { - resultat = a * b; - return resultat; + if (a == null || b == null || isNaN(a) || isNaN(b)) { + affichageResultat.textContent = "Merci de renseigner uniquement des valeurs numériques"; + } + else { + resultat = a * b; + affichageResultat.textContent = "Résultat : " + resultat; + } } -; -button.addEventListener('click', multiplication(numberA, numberB), alert("Le résultat de votre multiplication est " + resultat)); +button.addEventListener('click', () => { + numberA = parseInt(inputA.value); + numberB = parseInt(inputB.value); + multiplication(numberA, numberB); +}); diff --git a/index.html b/index.html index 0e57423..857936b 100644 --- a/index.html +++ b/index.html @@ -15,9 +15,10 @@ +

- + \ No newline at end of file diff --git a/src/multiplication.ts b/src/multiplication.ts index 01ce930..2bd7c00 100644 --- a/src/multiplication.ts +++ b/src/multiplication.ts @@ -1,16 +1,30 @@ let inputA = document.querySelector('#numberA') as HTMLInputElement; -let numberA = inputA.value; +let numberA: number let inputB = document.querySelector('#numberB') as HTMLInputElement; -let numberB = inputB.value; +let numberB: number let button = document.querySelector('.button-multiplication') as HTMLButtonElement; +let affichageResultat = document.querySelector('#resultat') as HTMLParagraphElement let resultat: number -function multiplication(a: number, b: number): number { - resultat = a * b - alert("Le résultat de votre multiplication est " + resultat) - return resultat -}; +function multiplication(a: number, b: number) { -button.addEventListener('click', multiplication(numberA, numberB), alert("Le résultat de votre multiplication est " + resultat)) + if (a == null || b == null || isNaN(a) || isNaN(b)) { + affichageResultat.textContent = "Merci de renseigner uniquement des valeurs numériques" + + } + else { + + resultat = a * b; + affichageResultat.textContent = "Résultat : " + resultat; + + } + +} + +button.addEventListener('click', () => { + numberA = parseInt(inputA.value) + numberB = parseInt(inputB.value) + multiplication(numberA, numberB) +}) From df04cd1ca25d13ffd91fdb483fb0e491de8b9aeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oph=C3=A9lie?= Date: Tue, 24 Jan 2023 18:59:56 +0100 Subject: [PATCH 27/59] Add vscode and dist in gitignore --- dist/multiplication.js | 13 ++++++------- index.html | 24 ------------------------ src/multiplication.ts | 12 ++++++------ style.css | 0 tsconfig.json | 3 ++- 5 files changed, 14 insertions(+), 38 deletions(-) delete mode 100644 index.html delete mode 100644 style.css diff --git a/dist/multiplication.js b/dist/multiplication.js index 4bd3a09..5fce5af 100644 --- a/dist/multiplication.js +++ b/dist/multiplication.js @@ -1,13 +1,12 @@ "use strict"; -let inputA = document.querySelector('#numberA'); +const inputA = document.getElementById('numberA'); +const inputB = document.getElementById('numberB'); let numberA; -let inputB = document.querySelector('#numberB'); let numberB; -let button = document.querySelector('.button-multiplication'); -let affichageResultat = document.querySelector('#resultat'); +const button = document.querySelector('.button-multiplication'); +const affichageResultat = document.getElementById('resultat'); let resultat; - -function multiplication(a, b) { +const multiplication = (a, b) => { if (a == null || b == null || isNaN(a) || isNaN(b)) { affichageResultat.textContent = "Merci de renseigner uniquement des valeurs numériques"; } @@ -15,7 +14,7 @@ function multiplication(a, b) { resultat = a * b; affichageResultat.textContent = "Résultat : " + resultat; } -} +}; button.addEventListener('click', () => { numberA = parseInt(inputA.value); numberB = parseInt(inputB.value); diff --git a/index.html b/index.html deleted file mode 100644 index 857936b..0000000 --- a/index.html +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - Calculator - - - - - - - - - -

- - - - - - \ No newline at end of file diff --git a/src/multiplication.ts b/src/multiplication.ts index 2bd7c00..3783c4f 100644 --- a/src/multiplication.ts +++ b/src/multiplication.ts @@ -1,13 +1,13 @@ -let inputA = document.querySelector('#numberA') as HTMLInputElement; -let numberA: number -let inputB = document.querySelector('#numberB') as HTMLInputElement; +const inputA = document.getElementById('numberA') +const inputB = document.getElementById('numberB') +let numberA: number let numberB: number -let button = document.querySelector('.button-multiplication') as HTMLButtonElement; -let affichageResultat = document.querySelector('#resultat') as HTMLParagraphElement +const button = document.querySelector('.button-multiplication') +const affichageResultat = document.getElementById('resultat') let resultat: number -function multiplication(a: number, b: number) { +const multiplication = (a: number, b: number) => { if (a == null || b == null || isNaN(a) || isNaN(b)) { diff --git a/style.css b/style.css deleted file mode 100644 index e69de29..0000000 diff --git a/tsconfig.json b/tsconfig.json index e03c2ee..36095ef 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,5 +5,6 @@ "noEmitOnError": false, "strict": true }, - "files": ["src/index.ts", "src/multiplication.ts"] + "include": ["src/*.ts"] + } From b2a77ed9770b987b1db7130a736b06ab8fee08e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oph=C3=A9lie?= Date: Tue, 24 Jan 2023 19:07:52 +0100 Subject: [PATCH 28/59] add vscode and dist in gitignore --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 40b878d..2525745 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -node_modules/ \ No newline at end of file +node_modules/ +.vscode/ +dist/ \ No newline at end of file From 77a2c270dd9a140ff68b24033cae2e0dff9bfb75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oph=C3=A9lie?= Date: Tue, 24 Jan 2023 19:14:52 +0100 Subject: [PATCH 29/59] add index.html and style.css in dist - change function to arrow function - change querySelector to getElementById --- dist/multiplication.js | 13 +++++++------ index.html | 24 ++++++++++++++++++++++++ src/multiplication.ts | 12 ++++++------ style.css | 0 tsconfig.json | 3 +-- 5 files changed, 38 insertions(+), 14 deletions(-) create mode 100644 index.html create mode 100644 style.css diff --git a/dist/multiplication.js b/dist/multiplication.js index 5fce5af..4bd3a09 100644 --- a/dist/multiplication.js +++ b/dist/multiplication.js @@ -1,12 +1,13 @@ "use strict"; -const inputA = document.getElementById('numberA'); -const inputB = document.getElementById('numberB'); +let inputA = document.querySelector('#numberA'); let numberA; +let inputB = document.querySelector('#numberB'); let numberB; -const button = document.querySelector('.button-multiplication'); -const affichageResultat = document.getElementById('resultat'); +let button = document.querySelector('.button-multiplication'); +let affichageResultat = document.querySelector('#resultat'); let resultat; -const multiplication = (a, b) => { + +function multiplication(a, b) { if (a == null || b == null || isNaN(a) || isNaN(b)) { affichageResultat.textContent = "Merci de renseigner uniquement des valeurs numériques"; } @@ -14,7 +15,7 @@ const multiplication = (a, b) => { resultat = a * b; affichageResultat.textContent = "Résultat : " + resultat; } -}; +} button.addEventListener('click', () => { numberA = parseInt(inputA.value); numberB = parseInt(inputB.value); diff --git a/index.html b/index.html new file mode 100644 index 0000000..857936b --- /dev/null +++ b/index.html @@ -0,0 +1,24 @@ + + + + + + + + Calculator + + + + + + + + + +

+ + + + + + \ No newline at end of file diff --git a/src/multiplication.ts b/src/multiplication.ts index 3783c4f..2bd7c00 100644 --- a/src/multiplication.ts +++ b/src/multiplication.ts @@ -1,13 +1,13 @@ -const inputA = document.getElementById('numberA') -const inputB = document.getElementById('numberB') -let numberA: number +let inputA = document.querySelector('#numberA') as HTMLInputElement; +let numberA: number +let inputB = document.querySelector('#numberB') as HTMLInputElement; let numberB: number -const button = document.querySelector('.button-multiplication') -const affichageResultat = document.getElementById('resultat') +let button = document.querySelector('.button-multiplication') as HTMLButtonElement; +let affichageResultat = document.querySelector('#resultat') as HTMLParagraphElement let resultat: number -const multiplication = (a: number, b: number) => { +function multiplication(a: number, b: number) { if (a == null || b == null || isNaN(a) || isNaN(b)) { diff --git a/style.css b/style.css new file mode 100644 index 0000000..e69de29 diff --git a/tsconfig.json b/tsconfig.json index 36095ef..e03c2ee 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,6 +5,5 @@ "noEmitOnError": false, "strict": true }, - "include": ["src/*.ts"] - + "files": ["src/index.ts", "src/multiplication.ts"] } From e7abe4446c3d509f0dbb2e5c94ca5aa94d0da457 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oph=C3=A9lie?= Date: Tue, 24 Jan 2023 19:21:28 +0100 Subject: [PATCH 30/59] Revert "add index.html and style.css in dist - change function to arrow function - change querySelector to getElementById" This reverts commit 9145e68ec07440e1fd0264a633af55f959ae9507. --- dist/multiplication.js | 13 ++++++------- index.html | 24 ------------------------ src/multiplication.ts | 12 ++++++------ style.css | 0 tsconfig.json | 3 ++- 5 files changed, 14 insertions(+), 38 deletions(-) delete mode 100644 index.html delete mode 100644 style.css diff --git a/dist/multiplication.js b/dist/multiplication.js index 4bd3a09..5fce5af 100644 --- a/dist/multiplication.js +++ b/dist/multiplication.js @@ -1,13 +1,12 @@ "use strict"; -let inputA = document.querySelector('#numberA'); +const inputA = document.getElementById('numberA'); +const inputB = document.getElementById('numberB'); let numberA; -let inputB = document.querySelector('#numberB'); let numberB; -let button = document.querySelector('.button-multiplication'); -let affichageResultat = document.querySelector('#resultat'); +const button = document.querySelector('.button-multiplication'); +const affichageResultat = document.getElementById('resultat'); let resultat; - -function multiplication(a, b) { +const multiplication = (a, b) => { if (a == null || b == null || isNaN(a) || isNaN(b)) { affichageResultat.textContent = "Merci de renseigner uniquement des valeurs numériques"; } @@ -15,7 +14,7 @@ function multiplication(a, b) { resultat = a * b; affichageResultat.textContent = "Résultat : " + resultat; } -} +}; button.addEventListener('click', () => { numberA = parseInt(inputA.value); numberB = parseInt(inputB.value); diff --git a/index.html b/index.html deleted file mode 100644 index 857936b..0000000 --- a/index.html +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - Calculator - - - - - - - - - -

- - - - - - \ No newline at end of file diff --git a/src/multiplication.ts b/src/multiplication.ts index 2bd7c00..3783c4f 100644 --- a/src/multiplication.ts +++ b/src/multiplication.ts @@ -1,13 +1,13 @@ -let inputA = document.querySelector('#numberA') as HTMLInputElement; -let numberA: number -let inputB = document.querySelector('#numberB') as HTMLInputElement; +const inputA = document.getElementById('numberA') +const inputB = document.getElementById('numberB') +let numberA: number let numberB: number -let button = document.querySelector('.button-multiplication') as HTMLButtonElement; -let affichageResultat = document.querySelector('#resultat') as HTMLParagraphElement +const button = document.querySelector('.button-multiplication') +const affichageResultat = document.getElementById('resultat') let resultat: number -function multiplication(a: number, b: number) { +const multiplication = (a: number, b: number) => { if (a == null || b == null || isNaN(a) || isNaN(b)) { diff --git a/style.css b/style.css deleted file mode 100644 index e69de29..0000000 diff --git a/tsconfig.json b/tsconfig.json index e03c2ee..36095ef 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,5 +5,6 @@ "noEmitOnError": false, "strict": true }, - "files": ["src/index.ts", "src/multiplication.ts"] + "include": ["src/*.ts"] + } From 8c533cae892b239b424121ed1f8cf744b5722094 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oph=C3=A9lie?= Date: Fri, 27 Jan 2023 15:23:50 +0100 Subject: [PATCH 31/59] name of variables in english --- src/multiplication.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/multiplication.ts b/src/multiplication.ts index 3783c4f..07fdff6 100644 --- a/src/multiplication.ts +++ b/src/multiplication.ts @@ -3,21 +3,21 @@ const inputB = document.getElementById('numberB') let numberA: number let numberB: number const button = document.querySelector('.button-multiplication') -const affichageResultat = document.getElementById('resultat') -let resultat: number +const showResult = document.getElementById('resultat') +let result: number const multiplication = (a: number, b: number) => { if (a == null || b == null || isNaN(a) || isNaN(b)) { - affichageResultat.textContent = "Merci de renseigner uniquement des valeurs numériques" + showResult.textContent = "Merci de renseigner uniquement des valeurs numériques" } else { - resultat = a * b; - affichageResultat.textContent = "Résultat : " + resultat; + result = a * b; + showResult.textContent = "Résultat : " + result; } @@ -28,3 +28,6 @@ button.addEventListener('click', () => { numberB = parseInt(inputB.value) multiplication(numberA, numberB) }) + + + From fa11dec30e5b6451de0c0672170c0df3bed6a91e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oph=C3=A9lie?= Date: Fri, 27 Jan 2023 16:48:46 +0100 Subject: [PATCH 32/59] multiplication of decimals --- dist/multiplication.js | 14 +++++++------- src/multiplication.ts | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/dist/multiplication.js b/dist/multiplication.js index 5fce5af..4059947 100644 --- a/dist/multiplication.js +++ b/dist/multiplication.js @@ -4,19 +4,19 @@ const inputB = document.getElementById('numberB'); let numberA; let numberB; const button = document.querySelector('.button-multiplication'); -const affichageResultat = document.getElementById('resultat'); -let resultat; +const showResult = document.getElementById('resultat'); +let result; const multiplication = (a, b) => { if (a == null || b == null || isNaN(a) || isNaN(b)) { - affichageResultat.textContent = "Merci de renseigner uniquement des valeurs numériques"; + showResult.textContent = "Merci de renseigner uniquement des valeurs numériques"; } else { - resultat = a * b; - affichageResultat.textContent = "Résultat : " + resultat; + result = a * b; + showResult.textContent = "Résultat : " + result.toFixed(2); } }; button.addEventListener('click', () => { - numberA = parseInt(inputA.value); - numberB = parseInt(inputB.value); + numberA = parseFloat(inputA.value); + numberB = parseFloat(inputB.value); multiplication(numberA, numberB); }); diff --git a/src/multiplication.ts b/src/multiplication.ts index 07fdff6..fb184e2 100644 --- a/src/multiplication.ts +++ b/src/multiplication.ts @@ -17,15 +17,15 @@ const multiplication = (a: number, b: number) => { else { result = a * b; - showResult.textContent = "Résultat : " + result; + showResult.textContent = "Résultat : " + result.toFixed(2); } } button.addEventListener('click', () => { - numberA = parseInt(inputA.value) - numberB = parseInt(inputB.value) + numberA = parseFloat(inputA.value) + numberB = parseFloat(inputB.value) multiplication(numberA, numberB) }) From 0843a688006ed21ef08e3d400585b77e02f827f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oph=C3=A9lie?= Date: Fri, 27 Jan 2023 19:20:17 +0100 Subject: [PATCH 33/59] add validation function and multiplication if more than 2 decimals --- dist/multiplication.js | 13 +++++++++---- package.json | 2 +- src/multiplication.ts | 19 ++++++++++++------- tsconfig.json | 2 +- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/dist/multiplication.js b/dist/multiplication.js index 4059947..86051c4 100644 --- a/dist/multiplication.js +++ b/dist/multiplication.js @@ -5,14 +5,19 @@ let numberA; let numberB; const button = document.querySelector('.button-multiplication'); const showResult = document.getElementById('resultat'); -let result; -const multiplication = (a, b) => { - if (a == null || b == null || isNaN(a) || isNaN(b)) { +let result = 1; +const multiplication = (...numbers) => { + if (numbers.includes(NaN) || numbers.includes(null)) { showResult.textContent = "Merci de renseigner uniquement des valeurs numériques"; } else { - result = a * b; + console.log("ok ce sont des nombres"); + for (const number of numbers) { + result *= number; + } + console.log(result); showResult.textContent = "Résultat : " + result.toFixed(2); + result = 1; } }; button.addEventListener('click', () => { diff --git a/package.json b/package.json index 6f8cb30..df1a1ce 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "typescript", "version": "1.0.0", "description": "", - "main": "src/index.js", + "main": "src/multiplication.js", "type": "module", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" diff --git a/src/multiplication.ts b/src/multiplication.ts index fb184e2..b47ccc5 100644 --- a/src/multiplication.ts +++ b/src/multiplication.ts @@ -4,25 +4,29 @@ let numberA: number let numberB: number const button = document.querySelector('.button-multiplication') const showResult = document.getElementById('resultat') -let result: number +let result: number = 1 -const multiplication = (a: number, b: number) => { - - if (a == null || b == null || isNaN(a) || isNaN(b)) { +const multiplication = (...numbers: any) => { + if (numbers.includes(NaN) || numbers.includes(null)) { showResult.textContent = "Merci de renseigner uniquement des valeurs numériques" } else { - - result = a * b; + console.log("ok ce sont des nombres") + + for (const number of numbers) { + result *= number; + } + console.log(result) showResult.textContent = "Résultat : " + result.toFixed(2); - + result = 1 } } + button.addEventListener('click', () => { numberA = parseFloat(inputA.value) numberB = parseFloat(inputB.value) @@ -31,3 +35,4 @@ button.addEventListener('click', () => { + diff --git a/tsconfig.json b/tsconfig.json index 36095ef..fa6a489 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,6 +5,6 @@ "noEmitOnError": false, "strict": true }, - "include": ["src/*.ts"] + "include": ["src/multiplication.ts"] } From 4beae0d6c3fbe0ccb8536f3f0f7d80979971da18 Mon Sep 17 00:00:00 2001 From: sebastien baudet Date: Fri, 20 Jan 2023 22:40:56 +0100 Subject: [PATCH 34/59] add script to compile ==> npm run build, compile ts file and copy html/css files to dist --- .gitignore | 4 +++- README.md | 7 +++++++ dist/index.html | 17 +++++++++++++++++ dist/index.js | 1 + index.html | 1 + index.js | 43 +++++++++++++++++++++++++++++++++++++++++++ package.json | 3 ++- src/index.ts | 3 ++- style/tottoot.css | 3 +++ tsconfig.json | 4 ++-- 10 files changed, 81 insertions(+), 5 deletions(-) create mode 100644 dist/index.html create mode 100644 index.js create mode 100644 style/tottoot.css diff --git a/.gitignore b/.gitignore index 40b878d..234f9ca 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -node_modules/ \ No newline at end of file +node_modules/ +dist/ +.vscode/ \ No newline at end of file diff --git a/README.md b/README.md index e829176..3c112e2 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,13 @@ $ npx tsc $ npx tsc --watch (recompilation automatique) +``` + +## Compilation npm + +``` +$ npm run build + ``` ## Ajouter un fichier TS diff --git a/dist/index.html b/dist/index.html new file mode 100644 index 0000000..2739b0e --- /dev/null +++ b/dist/index.html @@ -0,0 +1,17 @@ + + + + + + + + Document + + + + +
+ + + + \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index b3d6ed1..af0a5c0 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,2 +1,3 @@ "use strict"; const compt = "55"; +const compt2 = "5555"; diff --git a/index.html b/index.html index 8fd5224..2739b0e 100644 --- a/index.html +++ b/index.html @@ -10,6 +10,7 @@ +
diff --git a/index.js b/index.js new file mode 100644 index 0000000..d5f228c --- /dev/null +++ b/index.js @@ -0,0 +1,43 @@ +import * as fs from "fs"; +import { execSync } from "child_process"; +import * as path from "path"; + +// example file and directory to copy +//const sourceDirectory = ["./", "./style"]; +const sourceDirectory = ["./"]; +const destinationDirectory = "dist/"; + +sourceDirectory.forEach(dir =>{ + cpyFile(dir,destinationDirectory) +}) + + +function cpyFile(directory, destination) { + fs.readdir(directory, (err, files) => { + if (err) { + console.error(err); + return; + } + + files.forEach((file) => { + if (path.extname(file) === ".html" || path.extname(file) === ".css") { + const sourceFile = path.join(directory, file); + let destinationFile = path.join(destination, directory); + + fs.mkdir(destinationFile, { recursive: true }, (err) => { + if (err) throw err; + }); + + destinationFile = path.join(destinationFile, file); + + const readStream = fs.createReadStream(sourceFile); + const writeStream = fs.createWriteStream(destinationFile); + + readStream.pipe(writeStream); + } + }); + }); +} + +//compile Ts file +execSync("npx tsc"); diff --git a/package.json b/package.json index 5e76502..5eba530 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,8 @@ "main": "src/index.js", "type": "module", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "test": "echo \"Error: no test specified\" && exit 1", + "build": "node index.js" }, "keywords": [], "author": "", diff --git a/src/index.ts b/src/index.ts index 547c72d..1cabe3d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1 +1,2 @@ -const compt:string = "55" \ No newline at end of file +const compt:string = "55" +const compt2:string = "5555" \ No newline at end of file diff --git a/style/tottoot.css b/style/tottoot.css new file mode 100644 index 0000000..883357e --- /dev/null +++ b/style/tottoot.css @@ -0,0 +1,3 @@ +*{ + font-size: ; +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 32b1954..0d1efe9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,9 +1,9 @@ { "compilerOptions": { "outDir": "dist", - "target": "ES2015", + "target": "ES2022", "noEmitOnError": false, "strict": true }, - "files": ["src/index.ts"] + "include": ["src/**/*.ts"] } From 3ef57e3f8d6ed0b9ce4b03c0809d16e4dddb2b79 Mon Sep 17 00:00:00 2001 From: sebastien baudet Date: Fri, 20 Jan 2023 22:41:39 +0100 Subject: [PATCH 35/59] remove directory test --- style/tottoot.css | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 style/tottoot.css diff --git a/style/tottoot.css b/style/tottoot.css deleted file mode 100644 index 883357e..0000000 --- a/style/tottoot.css +++ /dev/null @@ -1,3 +0,0 @@ -*{ - font-size: ; -} \ No newline at end of file From 1bb50f48ce6031b88ca0daaf0d04842ac56c1207 Mon Sep 17 00:00:00 2001 From: Berenger Ferguenis Date: Sun, 15 Jan 2023 20:52:47 +0100 Subject: [PATCH 36/59] creat html & css calculator --- index.html | 76 ++++++++++++++++++++++++----- style.css | 138 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 201 insertions(+), 13 deletions(-) diff --git a/index.html b/index.html index 2739b0e..17f791f 100644 --- a/index.html +++ b/index.html @@ -1,17 +1,67 @@ - + + + + + + Calculator + + - - - - - Document - - + +
+
+ +
+ + + +
+ + + +
+ + + +
+ + + +
+ + + +
+
+
+
- -
- - - \ No newline at end of file + + diff --git a/style.css b/style.css index e69de29..ae9f963 100644 --- a/style.css +++ b/style.css @@ -0,0 +1,138 @@ +*{ + margin: 0; + padding: 0; + outline: none; + box-sizing: border-box; +} + +body { + display: flex; + text-align: center; + justify-content: center; + align-items: center; + min-height: 100vh; + background: linear-gradient(#9cebfc,#6ae1fb); +} + +.center { + width: 400px; + background: black; +} + +input[type="text"] { + height: 70px; + width: 250px; + margin-top: 40px; + margin-bottom: 10px; + color: white; + font-size: 22px; + font-weight: bold; + text-align: right; + padding-right: 20px; + background-color: #636363; +} + +form .buttons{ + width: 400px; + margin-bottom: 15px; + padding: 10px 0; +} + +.button_number { + width: 58px; + height: 55px; + margin-top: 6px; + background-color: #d5d5d5; + cursor: pointer; + font-weight: bold; +} + +.button_number:hover { + transition: .3s; + background-color: #616161; +} + +.button_operation { + width: 58px; + height: 55px; + background-color: #FFBB37; + color: #383838; + cursor: pointer; + font-weight: bold; +} + +.button_operation:hover { + transition: .3s; + background-color: #a87818; +} + +.button_dot { + width: 58px; + height: 55px; + background-color: #d5d5d5; + color: black; + cursor: pointer; +} + +.button_dot:hover { + transition: .3s; + background-color: #616161; +} + +.button_clear { + width: 58px; + height: 55px; + background-color: #df5c34; + color: white; + font-weight: bold; + cursor: pointer; +} + +.button_clear:hover { + transition: .3s; + background-color: #9c3f23; +} + +.button_equal { + width: 58px; + height: 55px; + color: white; + background-color: #df5c34; + cursor: pointer; + font-weight: bold; + font-size: 18px; +} + +.button_equal:hover { + transition: .3s; + background-color: #9c3f23; +} + +.button_cos { + width: 58px; + height: 55px; + border-radius: 3px; + background-color: #5A93C7; + color: black; + cursor: pointer; + font-weight: bold; +} + +.button_cos:hover { + transition: .3s; + background-color: #335575; +} + +.button_sin { + width: 58px; + height: 55px; + background-color: #5AC77F; + color: black; + cursor: pointer; + font-weight: bold; +} + +.button_sin:hover { + transition: .3s; + background-color: #337a4b; +} \ No newline at end of file From 1758bd8c005b54b3b13d8ec65c681a48db8a7c5d Mon Sep 17 00:00:00 2001 From: Abdel Bailoul Date: Sat, 21 Jan 2023 17:24:44 +0100 Subject: [PATCH 37/59] first commit --- dist/index.html | 62 ++++++++++---- index.html | 86 ++++++++----------- index.js | 29 +++---- style.css | 214 ++++++++++++++++++++---------------------------- 4 files changed, 184 insertions(+), 207 deletions(-) diff --git a/dist/index.html b/dist/index.html index 2739b0e..ec7d87b 100644 --- a/dist/index.html +++ b/dist/index.html @@ -1,17 +1,49 @@ - - - - - - - Document - - - - -
+ + + + + + Calculator + + + + +
+
+
+
+
3+6
+
+
(
+
)
+
COS
+
SIN
+
TAN
+
7
+
8
+
9
+
/
+
C
+
4
+
5
+
6
+
x
+
=
+
1
+
2
+
3
+
-
+
+/-
+
0
+
.
+
+
+
+
+
- - - \ No newline at end of file + + diff --git a/index.html b/index.html index 17f791f..ec7d87b 100644 --- a/index.html +++ b/index.html @@ -5,63 +5,45 @@ Calculator + - -
-
- -
- - - -
- - - -
- - - -
- - - -
- - - -
+
+
+
+
+
3+6
+
+
(
+
)
+
COS
+
SIN
+
TAN
+
7
+
8
+
9
+
/
+
C
+
4
+
5
+
6
+
x
+
=
+
1
+
2
+
3
+
-
+
+/-
+
0
+
.
+
+
- +
- diff --git a/index.js b/index.js index d5f228c..3c7c799 100644 --- a/index.js +++ b/index.js @@ -1,16 +1,15 @@ -import * as fs from "fs"; -import { execSync } from "child_process"; -import * as path from "path"; +import * as fs from 'fs'; +import { execSync } from 'child_process'; +import * as path from 'path'; // example file and directory to copy //const sourceDirectory = ["./", "./style"]; -const sourceDirectory = ["./"]; -const destinationDirectory = "dist/"; - -sourceDirectory.forEach(dir =>{ - cpyFile(dir,destinationDirectory) -}) +const sourceDirectory = ['./']; +const destinationDirectory = 'dist/'; +sourceDirectory.forEach((dir) => { + cpyFile(dir, destinationDirectory); +}); function cpyFile(directory, destination) { fs.readdir(directory, (err, files) => { @@ -20,19 +19,15 @@ function cpyFile(directory, destination) { } files.forEach((file) => { - if (path.extname(file) === ".html" || path.extname(file) === ".css") { + if (path.extname(file) === '.html' || path.extname(file) === '.css') { const sourceFile = path.join(directory, file); let destinationFile = path.join(destination, directory); - fs.mkdir(destinationFile, { recursive: true }, (err) => { - if (err) throw err; - }); - + if (err) throw err; + }); destinationFile = path.join(destinationFile, file); - const readStream = fs.createReadStream(sourceFile); const writeStream = fs.createWriteStream(destinationFile); - readStream.pipe(writeStream); } }); @@ -40,4 +35,4 @@ function cpyFile(directory, destination) { } //compile Ts file -execSync("npx tsc"); +execSync('npx tsc'); diff --git a/style.css b/style.css index ae9f963..5238593 100644 --- a/style.css +++ b/style.css @@ -1,138 +1,106 @@ -*{ +* { margin: 0; padding: 0; - outline: none; box-sizing: border-box; + font-family: 'Rubik', sans-serif; } body { + background-color: #e8c055; + background: linear-gradient(45deg, #e8c055, #e9dab2); + min-height: 100vh; + width: 100%; display: flex; - text-align: center; - justify-content: center; align-items: center; - min-height: 100vh; - background: linear-gradient(#9cebfc,#6ae1fb); -} - -.center { - width: 400px; - background: black; -} - -input[type="text"] { - height: 70px; - width: 250px; - margin-top: 40px; - margin-bottom: 10px; - color: white; - font-size: 22px; - font-weight: bold; - text-align: right; - padding-right: 20px; - background-color: #636363; -} - -form .buttons{ - width: 400px; - margin-bottom: 15px; - padding: 10px 0; -} - -.button_number { - width: 58px; - height: 55px; - margin-top: 6px; - background-color: #d5d5d5; - cursor: pointer; - font-weight: bold; -} - -.button_number:hover { - transition: .3s; - background-color: #616161; -} - -.button_operation { - width: 58px; - height: 55px; - background-color: #FFBB37; - color: #383838; - cursor: pointer; - font-weight: bold; -} - -.button_operation:hover { - transition: .3s; - background-color: #a87818; -} - -.button_dot { - width: 58px; - height: 55px; - background-color: #d5d5d5; - color: black; - cursor: pointer; -} - -.button_dot:hover { - transition: .3s; - background-color: #616161; -} - -.button_clear { - width: 58px; - height: 55px; - background-color: #df5c34; - color: white; - font-weight: bold; - cursor: pointer; -} - -.button_clear:hover { - transition: .3s; - background-color: #9c3f23; -} - -.button_equal { - width: 58px; - height: 55px; - color: white; - background-color: #df5c34; - cursor: pointer; - font-weight: bold; - font-size: 18px; -} - -.button_equal:hover { - transition: .3s; - background-color: #9c3f23; + justify-content: center; + font-size: 1.75rem; + color: rgb(246, 246, 246); + text-shadow: 0 3px 3px #00000033; } -.button_cos { - width: 58px; - height: 55px; - border-radius: 3px; - background-color: #5A93C7; - color: black; - cursor: pointer; - font-weight: bold; +.calculator { + width: clamp(23rem, 80vw, 50rem); + background-color: #404f66; + border-radius: 9px; } -.button_cos:hover { - transition: .3s; - background-color: #335575; +.calculator-body { + display: grid; + border-radius: 9px; + /* height: 100%; */ + padding: 3rem; + grid-template-columns: repeat(5, 1fr); + grid-template-rows: repeat(6, 1fr); + column-gap: 1rem; + row-gap: 1rem; + box-shadow: 0 16px 16px #00000031; } -.button_sin { - width: 58px; - height: 55px; - background-color: #5AC77F; - color: black; - cursor: pointer; - font-weight: bold; +.calculator-body > div { + background-color: #e8c055; + grid-column-end: span 1; + min-height: 2rem; + display: flex; + align-items: center; + justify-content: center; + border-radius: 6px; + box-shadow: 0 4px 4px #00000033; +} + +.calculator-body .key-opt { + height: 2.8rem; + margin-top: 1.5rem; +} + +.calculator-body .screen { + position: relative; + grid-column-end: span 5; + justify-content: end; + padding-right: 1rem; + overflow: hidden; + height: 100%; + width: 100%; + z-index: 10; +} + +.calculator-body .screen::after { + position: absolute; + z-index: 5; + content: ''; + width: 800px; + height: 100px; + background: #6699b1; + transform: skew(-50deg) translateX(50%); +} +.calculator-body .result { + position: relative; + z-index: 10; +} +.calculator-body .screen, +.calculator-body .key-blue { + background-color: #709db0; +} + +.calculator-body .key-equal { + grid-row-end: span 3; +} + +@media screen and (max-width: 800px) { + body { + font-size: 1.5rem; + } + .calculator { + min-width: 100%; + } + .calculator-body { + padding: 1.5rem; + } +} +@media screen and (max-width: 500px) { + body { + font-size: 1rem; + } + .calculator-body { + padding: 1rem; + } } - -.button_sin:hover { - transition: .3s; - background-color: #337a4b; -} \ No newline at end of file From ff0af33afc5be4c07e452bda9373bdb29b5655d2 Mon Sep 17 00:00:00 2001 From: Abdel Bailoul Date: Sat, 21 Jan 2023 17:34:32 +0100 Subject: [PATCH 38/59] fix: issue on npm run build / remove all dist > build --- index.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/index.js b/index.js index 3c7c799..91577bf 100644 --- a/index.js +++ b/index.js @@ -7,6 +7,14 @@ import * as path from 'path'; const sourceDirectory = ['./']; const destinationDirectory = 'dist/'; +if (fs.existsSync('./dist')) { + fs.rmSync(destinationDirectory, { recursive: true }); +} + +if (!fs.existsSync('./dist')) { + fs.mkdirSync('./dist'); +} + sourceDirectory.forEach((dir) => { cpyFile(dir, destinationDirectory); }); From 113ed9524562112ab631bc2842715ccc782565f7 Mon Sep 17 00:00:00 2001 From: Abdel Bailoul Date: Sat, 21 Jan 2023 17:42:06 +0100 Subject: [PATCH 39/59] opt: added dataset for all calculator keys --- index.html | 50 +++++++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/index.html b/index.html index ec7d87b..e7fa30d 100644 --- a/index.html +++ b/index.html @@ -18,29 +18,33 @@
3+6
-
(
-
)
-
COS
-
SIN
-
TAN
-
7
-
8
-
9
-
/
-
C
-
4
-
5
-
6
-
x
-
=
-
1
-
2
-
3
-
-
-
+/-
-
0
-
.
-
+
+
+ ( +
+
+ ) +
+
COS
+
SIN
+
TAN
+
7
+
8
+
9
+
/
+
C
+
4
+
5
+
6
+
x
+
=
+
1
+
2
+
3
+
-
+
+/-
+
0
+
.
+
+
From 226444680d34212a67825c34b343ae6986705055 Mon Sep 17 00:00:00 2001 From: Abdel Bailoul Date: Sat, 21 Jan 2023 17:51:00 +0100 Subject: [PATCH 40/59] opt: animtion btns on hover --- dist/index.html | 50 ++++++++++++++++++++++++++----------------------- style.css | 11 +++++++++++ 2 files changed, 38 insertions(+), 23 deletions(-) diff --git a/dist/index.html b/dist/index.html index ec7d87b..e7fa30d 100644 --- a/dist/index.html +++ b/dist/index.html @@ -18,29 +18,33 @@
3+6
-
(
-
)
-
COS
-
SIN
-
TAN
-
7
-
8
-
9
-
/
-
C
-
4
-
5
-
6
-
x
-
=
-
1
-
2
-
3
-
-
-
+/-
-
0
-
.
-
+
+
+ ( +
+
+ ) +
+
COS
+
SIN
+
TAN
+
7
+
8
+
9
+
/
+
C
+
4
+
5
+
6
+
x
+
=
+
1
+
2
+
3
+
-
+
+/-
+
0
+
.
+
+
diff --git a/style.css b/style.css index 5238593..b96ae7a 100644 --- a/style.css +++ b/style.css @@ -85,6 +85,17 @@ body { grid-row-end: span 3; } +.calculator-body .key { + cursor: pointer; + transition: background-color 0.3s ease-out; +} +.calculator-body .key:hover { + background-color: #c7a549; +} +.calculator-body .key-blue:hover { + background-color: #5c8191; +} + @media screen and (max-width: 800px) { body { font-size: 1.5rem; From 7708b994869f8450758353d0427668be202eed57 Mon Sep 17 00:00:00 2001 From: Abdel Bailoul Date: Sat, 21 Jan 2023 18:00:50 +0100 Subject: [PATCH 41/59] html: added title h1 --- index.html | 1 + style.css | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index e7fa30d..879ef8d 100644 --- a/index.html +++ b/index.html @@ -12,6 +12,7 @@ +

Project
Calculator TS

diff --git a/style.css b/style.css index b96ae7a..ee1ccde 100644 --- a/style.css +++ b/style.css @@ -1,3 +1,4 @@ +/*** Reset CSS ***/ * { margin: 0; padding: 0; @@ -13,11 +14,21 @@ body { display: flex; align-items: center; justify-content: center; + flex-direction: column; font-size: 1.75rem; color: rgb(246, 246, 246); text-shadow: 0 3px 3px #00000033; } +h1 { + text-align: center; + font-size: 3.6rem; + margin-bottom: 2.4rem; + line-height: 1.05; + text-shadow: 0 6px 6px #00000033; +} + +/*** Calculator element ***/ .calculator { width: clamp(23rem, 80vw, 50rem); background-color: #404f66; @@ -27,7 +38,6 @@ body { .calculator-body { display: grid; border-radius: 9px; - /* height: 100%; */ padding: 3rem; grid-template-columns: repeat(5, 1fr); grid-template-rows: repeat(6, 1fr); @@ -75,6 +85,7 @@ body { .calculator-body .result { position: relative; z-index: 10; + letter-spacing: 0.25rem; } .calculator-body .screen, .calculator-body .key-blue { @@ -96,10 +107,14 @@ body { background-color: #5c8191; } +/*** Media queries ***/ @media screen and (max-width: 800px) { body { font-size: 1.5rem; } + h1 { + font-size: 2.6rem; + } .calculator { min-width: 100%; } From 955fa767767ba9f1df0fe6d429f97abf68197b8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oph=C3=A9lie?= Date: Sun, 15 Jan 2023 11:59:08 +0100 Subject: [PATCH 42/59] rebase --- dist/multiplication.js | 14 ++++++++++++++ index.html | 1 + package-lock.json | 2 +- src/multiplication.ts | 14 ++++++++++++++ tsconfig.json | 2 +- 5 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 dist/multiplication.js create mode 100644 src/multiplication.ts diff --git a/dist/multiplication.js b/dist/multiplication.js new file mode 100644 index 0000000..de56089 --- /dev/null +++ b/dist/multiplication.js @@ -0,0 +1,14 @@ +"use strict"; +let inputA = document.querySelector('#numberA'); +let numberA = inputA.value; +let inputB = document.querySelector('#numberB'); +let numberB = inputB.value; +let button = document.querySelector('.button-multiplication'); +let resultat; +function multiplication(a, b) { + resultat = a * b; + return resultat; +} +; +button.addEventListener('click', multiplication(numberA, numberB), alert("Le résultat de votre multiplication est " + resultat)); +// button.addEventListener('click', multiplication(numberA, numberB)) \ No newline at end of file diff --git a/index.html b/index.html index 879ef8d..66734d6 100644 --- a/index.html +++ b/index.html @@ -52,3 +52,4 @@

Project
Calculator TS

+ diff --git a/package-lock.json b/package-lock.json index 8b9ecd1..4b85238 100644 --- a/package-lock.json +++ b/package-lock.json @@ -34,4 +34,4 @@ "dev": true } } -} +} \ No newline at end of file diff --git a/src/multiplication.ts b/src/multiplication.ts new file mode 100644 index 0000000..c30cc69 --- /dev/null +++ b/src/multiplication.ts @@ -0,0 +1,14 @@ +let inputA = document.querySelector('#numberA') as HTMLInputElement; +let numberA = inputA.value; +let inputB = document.querySelector('#numberB') as HTMLInputElement; +let numberB = inputB.value; +let button = document.querySelector('.button-multiplication') as HTMLButtonElement; +let resultat: number + + +function multiplication(a: number, b: number): number { + resultat = a * b + return resultat +}; + +button.addEventListener('click', multiplication(numberA, numberB), alert("Le résultat de votre multiplication est " + resultat)) \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 0d1efe9..db19711 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,5 +5,5 @@ "noEmitOnError": false, "strict": true }, - "include": ["src/**/*.ts"] + "files": ["src/index.ts", "src/multiplication.ts"] } From 245be99901655ecc1b371c3b48a74f8b3634b3dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oph=C3=A9lie?= Date: Mon, 16 Jan 2023 18:10:14 +0100 Subject: [PATCH 43/59] add input and button --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5eba530..4e258b9 100644 --- a/package.json +++ b/package.json @@ -14,4 +14,4 @@ "devDependencies": { "typescript": "^4.8.4" } -} +} \ No newline at end of file From d281a93fa5142869bfbe4fe6b98885d5d2508ed1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oph=C3=A9lie?= Date: Wed, 18 Jan 2023 18:23:39 +0100 Subject: [PATCH 44/59] rebase --- dist/multiplication.js | 1 - 1 file changed, 1 deletion(-) diff --git a/dist/multiplication.js b/dist/multiplication.js index de56089..748305b 100644 --- a/dist/multiplication.js +++ b/dist/multiplication.js @@ -11,4 +11,3 @@ function multiplication(a, b) { } ; button.addEventListener('click', multiplication(numberA, numberB), alert("Le résultat de votre multiplication est " + resultat)); -// button.addEventListener('click', multiplication(numberA, numberB)) \ No newline at end of file From ff8e39ca7cfc43fa4dacb52ac6f1c9cb78aa77b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oph=C3=A9lie?= Date: Tue, 17 Jan 2023 19:54:46 +0100 Subject: [PATCH 45/59] test ts file --- src/multiplication.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/multiplication.ts b/src/multiplication.ts index c30cc69..84d5404 100644 --- a/src/multiplication.ts +++ b/src/multiplication.ts @@ -11,4 +11,5 @@ function multiplication(a: number, b: number): number { return resultat }; -button.addEventListener('click', multiplication(numberA, numberB), alert("Le résultat de votre multiplication est " + resultat)) \ No newline at end of file +button.addEventListener('click', multiplication(numberA, numberB), alert("Le résultat de votre multiplication est " + resultat)) + From 59d0cffd34c7c4f9b80f3e7c78074b02d44d5ecc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oph=C3=A9lie?= Date: Wed, 18 Jan 2023 17:43:44 +0100 Subject: [PATCH 46/59] modify multiplication.ts --- src/multiplication.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/multiplication.ts b/src/multiplication.ts index 84d5404..01ce930 100644 --- a/src/multiplication.ts +++ b/src/multiplication.ts @@ -8,6 +8,7 @@ let resultat: number function multiplication(a: number, b: number): number { resultat = a * b + alert("Le résultat de votre multiplication est " + resultat) return resultat }; From 7a157d1dc8414525ec87f6be5a5b1f47b9480add Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oph=C3=A9lie?= Date: Thu, 19 Jan 2023 21:59:35 +0100 Subject: [PATCH 47/59] Fix function --- .vscode/settings.json | 2 +- README.md | 3 +-- dist/multiplication.js | 22 ++++++++++++++++------ index.html | 1 + src/multiplication.ts | 30 ++++++++++++++++++++++-------- 5 files changed, 41 insertions(+), 17 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 6b665aa..4c7ff40 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,3 @@ { - "liveServer.settings.port": 5501 + "liveServer.settings.port": 5502 } diff --git a/README.md b/README.md index 3c112e2..775003a 100644 --- a/README.md +++ b/README.md @@ -32,8 +32,6 @@ $ npm install ``` $ npx tsc $ npx tsc --watch (recompilation automatique) - - ``` ## Compilation npm @@ -59,3 +57,4 @@ $ "files": ["src/index.ts", "src/sin_cos.ts"] $ Dans un terminal taper la commande suivante: $ node ./dist/.js ``` + diff --git a/dist/multiplication.js b/dist/multiplication.js index 748305b..4bd3a09 100644 --- a/dist/multiplication.js +++ b/dist/multiplication.js @@ -1,13 +1,23 @@ "use strict"; let inputA = document.querySelector('#numberA'); -let numberA = inputA.value; +let numberA; let inputB = document.querySelector('#numberB'); -let numberB = inputB.value; +let numberB; let button = document.querySelector('.button-multiplication'); +let affichageResultat = document.querySelector('#resultat'); let resultat; + function multiplication(a, b) { - resultat = a * b; - return resultat; + if (a == null || b == null || isNaN(a) || isNaN(b)) { + affichageResultat.textContent = "Merci de renseigner uniquement des valeurs numériques"; + } + else { + resultat = a * b; + affichageResultat.textContent = "Résultat : " + resultat; + } } -; -button.addEventListener('click', multiplication(numberA, numberB), alert("Le résultat de votre multiplication est " + resultat)); +button.addEventListener('click', () => { + numberA = parseInt(inputA.value); + numberB = parseInt(inputB.value); + multiplication(numberA, numberB); +}); diff --git a/index.html b/index.html index 66734d6..80423cc 100644 --- a/index.html +++ b/index.html @@ -53,3 +53,4 @@

Project
Calculator TS

+ diff --git a/src/multiplication.ts b/src/multiplication.ts index 01ce930..2bd7c00 100644 --- a/src/multiplication.ts +++ b/src/multiplication.ts @@ -1,16 +1,30 @@ let inputA = document.querySelector('#numberA') as HTMLInputElement; -let numberA = inputA.value; +let numberA: number let inputB = document.querySelector('#numberB') as HTMLInputElement; -let numberB = inputB.value; +let numberB: number let button = document.querySelector('.button-multiplication') as HTMLButtonElement; +let affichageResultat = document.querySelector('#resultat') as HTMLParagraphElement let resultat: number -function multiplication(a: number, b: number): number { - resultat = a * b - alert("Le résultat de votre multiplication est " + resultat) - return resultat -}; +function multiplication(a: number, b: number) { -button.addEventListener('click', multiplication(numberA, numberB), alert("Le résultat de votre multiplication est " + resultat)) + if (a == null || b == null || isNaN(a) || isNaN(b)) { + affichageResultat.textContent = "Merci de renseigner uniquement des valeurs numériques" + + } + else { + + resultat = a * b; + affichageResultat.textContent = "Résultat : " + resultat; + + } + +} + +button.addEventListener('click', () => { + numberA = parseInt(inputA.value) + numberB = parseInt(inputB.value) + multiplication(numberA, numberB) +}) From d3ca44e160eb4ef40269a2375329052ce313b0eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oph=C3=A9lie?= Date: Tue, 24 Jan 2023 18:59:56 +0100 Subject: [PATCH 48/59] Add vscode and dist in gitignore --- dist/multiplication.js | 13 ++++++------- src/multiplication.ts | 12 ++++++------ tsconfig.json | 3 ++- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/dist/multiplication.js b/dist/multiplication.js index 4bd3a09..5fce5af 100644 --- a/dist/multiplication.js +++ b/dist/multiplication.js @@ -1,13 +1,12 @@ "use strict"; -let inputA = document.querySelector('#numberA'); +const inputA = document.getElementById('numberA'); +const inputB = document.getElementById('numberB'); let numberA; -let inputB = document.querySelector('#numberB'); let numberB; -let button = document.querySelector('.button-multiplication'); -let affichageResultat = document.querySelector('#resultat'); +const button = document.querySelector('.button-multiplication'); +const affichageResultat = document.getElementById('resultat'); let resultat; - -function multiplication(a, b) { +const multiplication = (a, b) => { if (a == null || b == null || isNaN(a) || isNaN(b)) { affichageResultat.textContent = "Merci de renseigner uniquement des valeurs numériques"; } @@ -15,7 +14,7 @@ function multiplication(a, b) { resultat = a * b; affichageResultat.textContent = "Résultat : " + resultat; } -} +}; button.addEventListener('click', () => { numberA = parseInt(inputA.value); numberB = parseInt(inputB.value); diff --git a/src/multiplication.ts b/src/multiplication.ts index 2bd7c00..3783c4f 100644 --- a/src/multiplication.ts +++ b/src/multiplication.ts @@ -1,13 +1,13 @@ -let inputA = document.querySelector('#numberA') as HTMLInputElement; -let numberA: number -let inputB = document.querySelector('#numberB') as HTMLInputElement; +const inputA = document.getElementById('numberA') +const inputB = document.getElementById('numberB') +let numberA: number let numberB: number -let button = document.querySelector('.button-multiplication') as HTMLButtonElement; -let affichageResultat = document.querySelector('#resultat') as HTMLParagraphElement +const button = document.querySelector('.button-multiplication') +const affichageResultat = document.getElementById('resultat') let resultat: number -function multiplication(a: number, b: number) { +const multiplication = (a: number, b: number) => { if (a == null || b == null || isNaN(a) || isNaN(b)) { diff --git a/tsconfig.json b/tsconfig.json index db19711..cc16e1c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,5 +5,6 @@ "noEmitOnError": false, "strict": true }, - "files": ["src/index.ts", "src/multiplication.ts"] + "include": ["src/*.ts"] + } From 444e0fa178850f0ad7a86a5ffb255e9a0dc8d2bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oph=C3=A9lie?= Date: Tue, 24 Jan 2023 19:07:52 +0100 Subject: [PATCH 49/59] add vscode and dist in gitignore --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 234f9ca..8617652 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ node_modules/ dist/ -.vscode/ \ No newline at end of file +.vscode/ From 1598d47652087b6b872df87d2a36245ce020ec2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oph=C3=A9lie?= Date: Tue, 24 Jan 2023 19:14:52 +0100 Subject: [PATCH 50/59] add index.html and style.css in dist - change function to arrow function - change querySelector to getElementById --- dist/multiplication.js | 13 +++++++------ src/multiplication.ts | 12 ++++++------ tsconfig.json | 3 +-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/dist/multiplication.js b/dist/multiplication.js index 5fce5af..4bd3a09 100644 --- a/dist/multiplication.js +++ b/dist/multiplication.js @@ -1,12 +1,13 @@ "use strict"; -const inputA = document.getElementById('numberA'); -const inputB = document.getElementById('numberB'); +let inputA = document.querySelector('#numberA'); let numberA; +let inputB = document.querySelector('#numberB'); let numberB; -const button = document.querySelector('.button-multiplication'); -const affichageResultat = document.getElementById('resultat'); +let button = document.querySelector('.button-multiplication'); +let affichageResultat = document.querySelector('#resultat'); let resultat; -const multiplication = (a, b) => { + +function multiplication(a, b) { if (a == null || b == null || isNaN(a) || isNaN(b)) { affichageResultat.textContent = "Merci de renseigner uniquement des valeurs numériques"; } @@ -14,7 +15,7 @@ const multiplication = (a, b) => { resultat = a * b; affichageResultat.textContent = "Résultat : " + resultat; } -}; +} button.addEventListener('click', () => { numberA = parseInt(inputA.value); numberB = parseInt(inputB.value); diff --git a/src/multiplication.ts b/src/multiplication.ts index 3783c4f..2bd7c00 100644 --- a/src/multiplication.ts +++ b/src/multiplication.ts @@ -1,13 +1,13 @@ -const inputA = document.getElementById('numberA') -const inputB = document.getElementById('numberB') -let numberA: number +let inputA = document.querySelector('#numberA') as HTMLInputElement; +let numberA: number +let inputB = document.querySelector('#numberB') as HTMLInputElement; let numberB: number -const button = document.querySelector('.button-multiplication') -const affichageResultat = document.getElementById('resultat') +let button = document.querySelector('.button-multiplication') as HTMLButtonElement; +let affichageResultat = document.querySelector('#resultat') as HTMLParagraphElement let resultat: number -const multiplication = (a: number, b: number) => { +function multiplication(a: number, b: number) { if (a == null || b == null || isNaN(a) || isNaN(b)) { diff --git a/tsconfig.json b/tsconfig.json index cc16e1c..db19711 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,6 +5,5 @@ "noEmitOnError": false, "strict": true }, - "include": ["src/*.ts"] - + "files": ["src/index.ts", "src/multiplication.ts"] } From a6a926e0abe6a3407d2dc7a9b0b2a20d163f8717 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oph=C3=A9lie?= Date: Tue, 24 Jan 2023 19:21:28 +0100 Subject: [PATCH 51/59] Revert "add index.html and style.css in dist - change function to arrow function - change querySelector to getElementById" This reverts commit 9145e68ec07440e1fd0264a633af55f959ae9507. --- dist/multiplication.js | 13 ++++++------- src/multiplication.ts | 12 ++++++------ tsconfig.json | 3 ++- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/dist/multiplication.js b/dist/multiplication.js index 4bd3a09..5fce5af 100644 --- a/dist/multiplication.js +++ b/dist/multiplication.js @@ -1,13 +1,12 @@ "use strict"; -let inputA = document.querySelector('#numberA'); +const inputA = document.getElementById('numberA'); +const inputB = document.getElementById('numberB'); let numberA; -let inputB = document.querySelector('#numberB'); let numberB; -let button = document.querySelector('.button-multiplication'); -let affichageResultat = document.querySelector('#resultat'); +const button = document.querySelector('.button-multiplication'); +const affichageResultat = document.getElementById('resultat'); let resultat; - -function multiplication(a, b) { +const multiplication = (a, b) => { if (a == null || b == null || isNaN(a) || isNaN(b)) { affichageResultat.textContent = "Merci de renseigner uniquement des valeurs numériques"; } @@ -15,7 +14,7 @@ function multiplication(a, b) { resultat = a * b; affichageResultat.textContent = "Résultat : " + resultat; } -} +}; button.addEventListener('click', () => { numberA = parseInt(inputA.value); numberB = parseInt(inputB.value); diff --git a/src/multiplication.ts b/src/multiplication.ts index 2bd7c00..3783c4f 100644 --- a/src/multiplication.ts +++ b/src/multiplication.ts @@ -1,13 +1,13 @@ -let inputA = document.querySelector('#numberA') as HTMLInputElement; -let numberA: number -let inputB = document.querySelector('#numberB') as HTMLInputElement; +const inputA = document.getElementById('numberA') +const inputB = document.getElementById('numberB') +let numberA: number let numberB: number -let button = document.querySelector('.button-multiplication') as HTMLButtonElement; -let affichageResultat = document.querySelector('#resultat') as HTMLParagraphElement +const button = document.querySelector('.button-multiplication') +const affichageResultat = document.getElementById('resultat') let resultat: number -function multiplication(a: number, b: number) { +const multiplication = (a: number, b: number) => { if (a == null || b == null || isNaN(a) || isNaN(b)) { diff --git a/tsconfig.json b/tsconfig.json index db19711..cc16e1c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,5 +5,6 @@ "noEmitOnError": false, "strict": true }, - "files": ["src/index.ts", "src/multiplication.ts"] + "include": ["src/*.ts"] + } From e5b2f7aca5bf0f964a0ae9eae836e1196d0b9da4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oph=C3=A9lie?= Date: Fri, 27 Jan 2023 15:23:50 +0100 Subject: [PATCH 52/59] name of variables in english --- src/multiplication.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/multiplication.ts b/src/multiplication.ts index 3783c4f..07fdff6 100644 --- a/src/multiplication.ts +++ b/src/multiplication.ts @@ -3,21 +3,21 @@ const inputB = document.getElementById('numberB') let numberA: number let numberB: number const button = document.querySelector('.button-multiplication') -const affichageResultat = document.getElementById('resultat') -let resultat: number +const showResult = document.getElementById('resultat') +let result: number const multiplication = (a: number, b: number) => { if (a == null || b == null || isNaN(a) || isNaN(b)) { - affichageResultat.textContent = "Merci de renseigner uniquement des valeurs numériques" + showResult.textContent = "Merci de renseigner uniquement des valeurs numériques" } else { - resultat = a * b; - affichageResultat.textContent = "Résultat : " + resultat; + result = a * b; + showResult.textContent = "Résultat : " + result; } @@ -28,3 +28,6 @@ button.addEventListener('click', () => { numberB = parseInt(inputB.value) multiplication(numberA, numberB) }) + + + From 5ba5eb4792ae4ec6d2d6d776b4eef98ef22266e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oph=C3=A9lie?= Date: Sun, 15 Jan 2023 11:59:08 +0100 Subject: [PATCH 53/59] Init files --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4b85238..8b9ecd1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -34,4 +34,4 @@ "dev": true } } -} \ No newline at end of file +} diff --git a/package.json b/package.json index 4e258b9..5eba530 100644 --- a/package.json +++ b/package.json @@ -14,4 +14,4 @@ "devDependencies": { "typescript": "^4.8.4" } -} \ No newline at end of file +} From ad2d75d8c665de40566815bb25da2f3f63574e82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oph=C3=A9lie?= Date: Mon, 16 Jan 2023 18:10:14 +0100 Subject: [PATCH 54/59] add input and button --- dist/index.js | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 dist/index.js diff --git a/dist/index.js b/dist/index.js new file mode 100644 index 0000000..3918c74 --- /dev/null +++ b/dist/index.js @@ -0,0 +1 @@ +"use strict"; diff --git a/package.json b/package.json index 5eba530..4e258b9 100644 --- a/package.json +++ b/package.json @@ -14,4 +14,4 @@ "devDependencies": { "typescript": "^4.8.4" } -} +} \ No newline at end of file From ecf72400af965e342b71e55a6440b2dfae587d49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oph=C3=A9lie?= Date: Wed, 18 Jan 2023 17:43:44 +0100 Subject: [PATCH 55/59] modify multiplication.ts --- src/multiplication.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/multiplication.ts b/src/multiplication.ts index 07fdff6..a0171ea 100644 --- a/src/multiplication.ts +++ b/src/multiplication.ts @@ -30,4 +30,3 @@ button.addEventListener('click', () => { }) - From cb199b2ee9d1799049d60bfb0abdc73362ffafe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oph=C3=A9lie?= Date: Tue, 24 Jan 2023 19:14:52 +0100 Subject: [PATCH 56/59] add index.html and style.css in dist - change function to arrow function - change querySelector to getElementById --- dist/multiplication.js | 13 +++++++------ src/multiplication.ts | 8 ++++---- tsconfig.json | 3 +-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/dist/multiplication.js b/dist/multiplication.js index 5fce5af..4bd3a09 100644 --- a/dist/multiplication.js +++ b/dist/multiplication.js @@ -1,12 +1,13 @@ "use strict"; -const inputA = document.getElementById('numberA'); -const inputB = document.getElementById('numberB'); +let inputA = document.querySelector('#numberA'); let numberA; +let inputB = document.querySelector('#numberB'); let numberB; -const button = document.querySelector('.button-multiplication'); -const affichageResultat = document.getElementById('resultat'); +let button = document.querySelector('.button-multiplication'); +let affichageResultat = document.querySelector('#resultat'); let resultat; -const multiplication = (a, b) => { + +function multiplication(a, b) { if (a == null || b == null || isNaN(a) || isNaN(b)) { affichageResultat.textContent = "Merci de renseigner uniquement des valeurs numériques"; } @@ -14,7 +15,7 @@ const multiplication = (a, b) => { resultat = a * b; affichageResultat.textContent = "Résultat : " + resultat; } -}; +} button.addEventListener('click', () => { numberA = parseInt(inputA.value); numberB = parseInt(inputB.value); diff --git a/src/multiplication.ts b/src/multiplication.ts index a0171ea..87b978e 100644 --- a/src/multiplication.ts +++ b/src/multiplication.ts @@ -1,13 +1,13 @@ -const inputA = document.getElementById('numberA') -const inputB = document.getElementById('numberB') -let numberA: number +let inputA = document.querySelector('#numberA') as HTMLInputElement; +let numberA: number +let inputB = document.querySelector('#numberB') as HTMLInputElement; let numberB: number const button = document.querySelector('.button-multiplication') const showResult = document.getElementById('resultat') let result: number -const multiplication = (a: number, b: number) => { +function multiplication(a: number, b: number) { if (a == null || b == null || isNaN(a) || isNaN(b)) { diff --git a/tsconfig.json b/tsconfig.json index cc16e1c..db19711 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,6 +5,5 @@ "noEmitOnError": false, "strict": true }, - "include": ["src/*.ts"] - + "files": ["src/index.ts", "src/multiplication.ts"] } From 9077fa787e4214711bf360360e8caf69c67645f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oph=C3=A9lie?= Date: Tue, 24 Jan 2023 19:21:28 +0100 Subject: [PATCH 57/59] Revert "add index.html and style.css in dist - change function to arrow function - change querySelector to getElementById" This reverts commit 9145e68ec07440e1fd0264a633af55f959ae9507. --- dist/multiplication.js | 13 ++++++------- src/multiplication.ts | 8 ++++---- tsconfig.json | 3 ++- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/dist/multiplication.js b/dist/multiplication.js index 4bd3a09..5fce5af 100644 --- a/dist/multiplication.js +++ b/dist/multiplication.js @@ -1,13 +1,12 @@ "use strict"; -let inputA = document.querySelector('#numberA'); +const inputA = document.getElementById('numberA'); +const inputB = document.getElementById('numberB'); let numberA; -let inputB = document.querySelector('#numberB'); let numberB; -let button = document.querySelector('.button-multiplication'); -let affichageResultat = document.querySelector('#resultat'); +const button = document.querySelector('.button-multiplication'); +const affichageResultat = document.getElementById('resultat'); let resultat; - -function multiplication(a, b) { +const multiplication = (a, b) => { if (a == null || b == null || isNaN(a) || isNaN(b)) { affichageResultat.textContent = "Merci de renseigner uniquement des valeurs numériques"; } @@ -15,7 +14,7 @@ function multiplication(a, b) { resultat = a * b; affichageResultat.textContent = "Résultat : " + resultat; } -} +}; button.addEventListener('click', () => { numberA = parseInt(inputA.value); numberB = parseInt(inputB.value); diff --git a/src/multiplication.ts b/src/multiplication.ts index 87b978e..a0171ea 100644 --- a/src/multiplication.ts +++ b/src/multiplication.ts @@ -1,13 +1,13 @@ -let inputA = document.querySelector('#numberA') as HTMLInputElement; -let numberA: number -let inputB = document.querySelector('#numberB') as HTMLInputElement; +const inputA = document.getElementById('numberA') +const inputB = document.getElementById('numberB') +let numberA: number let numberB: number const button = document.querySelector('.button-multiplication') const showResult = document.getElementById('resultat') let result: number -function multiplication(a: number, b: number) { +const multiplication = (a: number, b: number) => { if (a == null || b == null || isNaN(a) || isNaN(b)) { diff --git a/tsconfig.json b/tsconfig.json index db19711..cc16e1c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,5 +5,6 @@ "noEmitOnError": false, "strict": true }, - "files": ["src/index.ts", "src/multiplication.ts"] + "include": ["src/*.ts"] + } From 4fe3493bba081241674ccb073b3838ebcac4cecc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oph=C3=A9lie?= Date: Fri, 27 Jan 2023 16:48:46 +0100 Subject: [PATCH 58/59] multiplication of decimals --- dist/multiplication.js | 14 +++++++------- src/multiplication.ts | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/dist/multiplication.js b/dist/multiplication.js index 5fce5af..4059947 100644 --- a/dist/multiplication.js +++ b/dist/multiplication.js @@ -4,19 +4,19 @@ const inputB = document.getElementById('numberB'); let numberA; let numberB; const button = document.querySelector('.button-multiplication'); -const affichageResultat = document.getElementById('resultat'); -let resultat; +const showResult = document.getElementById('resultat'); +let result; const multiplication = (a, b) => { if (a == null || b == null || isNaN(a) || isNaN(b)) { - affichageResultat.textContent = "Merci de renseigner uniquement des valeurs numériques"; + showResult.textContent = "Merci de renseigner uniquement des valeurs numériques"; } else { - resultat = a * b; - affichageResultat.textContent = "Résultat : " + resultat; + result = a * b; + showResult.textContent = "Résultat : " + result.toFixed(2); } }; button.addEventListener('click', () => { - numberA = parseInt(inputA.value); - numberB = parseInt(inputB.value); + numberA = parseFloat(inputA.value); + numberB = parseFloat(inputB.value); multiplication(numberA, numberB); }); diff --git a/src/multiplication.ts b/src/multiplication.ts index a0171ea..2bbbaf3 100644 --- a/src/multiplication.ts +++ b/src/multiplication.ts @@ -17,15 +17,15 @@ const multiplication = (a: number, b: number) => { else { result = a * b; - showResult.textContent = "Résultat : " + result; + showResult.textContent = "Résultat : " + result.toFixed(2); } } button.addEventListener('click', () => { - numberA = parseInt(inputA.value) - numberB = parseInt(inputB.value) + numberA = parseFloat(inputA.value) + numberB = parseFloat(inputB.value) multiplication(numberA, numberB) }) From d570c3b6722e218d2b24d947dcd960398f9119fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oph=C3=A9lie?= Date: Fri, 27 Jan 2023 19:20:17 +0100 Subject: [PATCH 59/59] add validation function and multiplication if more than 2 decimals --- dist/multiplication.js | 13 +++++++++---- package.json | 2 +- src/multiplication.ts | 18 +++++++++++------- tsconfig.json | 2 +- 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/dist/multiplication.js b/dist/multiplication.js index 4059947..86051c4 100644 --- a/dist/multiplication.js +++ b/dist/multiplication.js @@ -5,14 +5,19 @@ let numberA; let numberB; const button = document.querySelector('.button-multiplication'); const showResult = document.getElementById('resultat'); -let result; -const multiplication = (a, b) => { - if (a == null || b == null || isNaN(a) || isNaN(b)) { +let result = 1; +const multiplication = (...numbers) => { + if (numbers.includes(NaN) || numbers.includes(null)) { showResult.textContent = "Merci de renseigner uniquement des valeurs numériques"; } else { - result = a * b; + console.log("ok ce sont des nombres"); + for (const number of numbers) { + result *= number; + } + console.log(result); showResult.textContent = "Résultat : " + result.toFixed(2); + result = 1; } }; button.addEventListener('click', () => { diff --git a/package.json b/package.json index 4e258b9..ccf2708 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "typescript", "version": "1.0.0", "description": "", - "main": "src/index.js", + "main": "src/multiplication.js", "type": "module", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", diff --git a/src/multiplication.ts b/src/multiplication.ts index 2bbbaf3..9deb5f3 100644 --- a/src/multiplication.ts +++ b/src/multiplication.ts @@ -4,25 +4,29 @@ let numberA: number let numberB: number const button = document.querySelector('.button-multiplication') const showResult = document.getElementById('resultat') -let result: number +let result: number = 1 -const multiplication = (a: number, b: number) => { - - if (a == null || b == null || isNaN(a) || isNaN(b)) { +const multiplication = (...numbers: any) => { + if (numbers.includes(NaN) || numbers.includes(null)) { showResult.textContent = "Merci de renseigner uniquement des valeurs numériques" } else { - - result = a * b; + console.log("ok ce sont des nombres") + + for (const number of numbers) { + result *= number; + } + console.log(result) showResult.textContent = "Résultat : " + result.toFixed(2); - + result = 1 } } + button.addEventListener('click', () => { numberA = parseFloat(inputA.value) numberB = parseFloat(inputB.value) diff --git a/tsconfig.json b/tsconfig.json index cc16e1c..ccf5278 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,6 +5,6 @@ "noEmitOnError": false, "strict": true }, - "include": ["src/*.ts"] + "include": ["src/multiplication.ts"] }