added random text generation
This commit is contained in:
parent
b25eed4cec
commit
30784f5b36
19
.VSCodeCounter/2022-11-18_12-24-29/details.md
Normal file
19
.VSCodeCounter/2022-11-18_12-24-29/details.md
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
# Details
|
||||||
|
|
||||||
|
Date : 2022-11-18 12:24:29
|
||||||
|
|
||||||
|
Directory /home/arlo/code/cs_coursework
|
||||||
|
|
||||||
|
Total : 4 files, 320 codes, 0 comments, 41 blanks, all 361 lines
|
||||||
|
|
||||||
|
[Summary](results.md) / Details / [Diff Summary](diff.md) / [Diff Details](diff-details.md)
|
||||||
|
|
||||||
|
## Files
|
||||||
|
| filename | language | code | comment | blank | total |
|
||||||
|
| :--- | :--- | ---: | ---: | ---: | ---: |
|
||||||
|
| [Cargo.toml](/Cargo.toml) | TOML | 9 | 0 | 2 | 11 |
|
||||||
|
| [Rocket.toml](/Rocket.toml) | TOML | 25 | 0 | 3 | 28 |
|
||||||
|
| [src/main.rs](/src/main.rs) | Rust | 87 | 0 | 10 | 97 |
|
||||||
|
| [src/sql.rs](/src/sql.rs) | Rust | 199 | 0 | 26 | 225 |
|
||||||
|
|
||||||
|
[Summary](results.md) / Details / [Diff Summary](diff.md) / [Diff Details](diff-details.md)
|
15
.VSCodeCounter/2022-11-18_12-24-29/diff-details.md
Normal file
15
.VSCodeCounter/2022-11-18_12-24-29/diff-details.md
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# Diff Details
|
||||||
|
|
||||||
|
Date : 2022-11-18 12:24:29
|
||||||
|
|
||||||
|
Directory /home/arlo/code/cs_coursework
|
||||||
|
|
||||||
|
Total : 0 files, 0 codes, 0 comments, 0 blanks, all 0 lines
|
||||||
|
|
||||||
|
[Summary](results.md) / [Details](details.md) / [Diff Summary](diff.md) / Diff Details
|
||||||
|
|
||||||
|
## Files
|
||||||
|
| filename | language | code | comment | blank | total |
|
||||||
|
| :--- | :--- | ---: | ---: | ---: | ---: |
|
||||||
|
|
||||||
|
[Summary](results.md) / [Details](details.md) / [Diff Summary](diff.md) / Diff Details
|
2
.VSCodeCounter/2022-11-18_12-24-29/diff.csv
Normal file
2
.VSCodeCounter/2022-11-18_12-24-29/diff.csv
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
"filename", "language", "", "comment", "blank", "total"
|
||||||
|
"Total", "-", , 0, 0, 0
|
|
19
.VSCodeCounter/2022-11-18_12-24-29/diff.md
Normal file
19
.VSCodeCounter/2022-11-18_12-24-29/diff.md
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
# Diff Summary
|
||||||
|
|
||||||
|
Date : 2022-11-18 12:24:29
|
||||||
|
|
||||||
|
Directory /home/arlo/code/cs_coursework
|
||||||
|
|
||||||
|
Total : 0 files, 0 codes, 0 comments, 0 blanks, all 0 lines
|
||||||
|
|
||||||
|
[Summary](results.md) / [Details](details.md) / Diff Summary / [Diff Details](diff-details.md)
|
||||||
|
|
||||||
|
## Languages
|
||||||
|
| language | files | code | comment | blank | total |
|
||||||
|
| :--- | ---: | ---: | ---: | ---: | ---: |
|
||||||
|
|
||||||
|
## Directories
|
||||||
|
| path | files | code | comment | blank | total |
|
||||||
|
| :--- | ---: | ---: | ---: | ---: | ---: |
|
||||||
|
|
||||||
|
[Summary](results.md) / [Details](details.md) / Diff Summary / [Diff Details](diff-details.md)
|
22
.VSCodeCounter/2022-11-18_12-24-29/diff.txt
Normal file
22
.VSCodeCounter/2022-11-18_12-24-29/diff.txt
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
Date : 2022-11-18 12:24:29
|
||||||
|
Directory : /home/arlo/code/cs_coursework
|
||||||
|
Total : 0 files, 0 codes, 0 comments, 0 blanks, all 0 lines
|
||||||
|
|
||||||
|
Languages
|
||||||
|
+----------+------------+------------+------------+------------+------------+
|
||||||
|
| language | files | code | comment | blank | total |
|
||||||
|
+----------+------------+------------+------------+------------+------------+
|
||||||
|
+----------+------------+------------+------------+------------+------------+
|
||||||
|
|
||||||
|
Directories
|
||||||
|
+------+------------+------------+------------+------------+------------+
|
||||||
|
| path | files | code | comment | blank | total |
|
||||||
|
+------+------------+------------+------------+------------+------------+
|
||||||
|
+------+------------+------------+------------+------------+------------+
|
||||||
|
|
||||||
|
Files
|
||||||
|
+----------+----------+------------+------------+------------+------------+
|
||||||
|
| filename | language | code | comment | blank | total |
|
||||||
|
+----------+----------+------------+------------+------------+------------+
|
||||||
|
| Total | | 0 | 0 | 0 | 0 |
|
||||||
|
+----------+----------+------------+------------+------------+------------+
|
6
.VSCodeCounter/2022-11-18_12-24-29/results.csv
Normal file
6
.VSCodeCounter/2022-11-18_12-24-29/results.csv
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
"filename", "language", "TOML", "Rust", "comment", "blank", "total"
|
||||||
|
"/home/arlo/code/cs_coursework/Cargo.toml", "TOML", 9, 0, 0, 2, 11
|
||||||
|
"/home/arlo/code/cs_coursework/Rocket.toml", "TOML", 25, 0, 0, 3, 28
|
||||||
|
"/home/arlo/code/cs_coursework/src/main.rs", "Rust", 0, 87, 0, 10, 97
|
||||||
|
"/home/arlo/code/cs_coursework/src/sql.rs", "Rust", 0, 199, 0, 26, 225
|
||||||
|
"Total", "-", 34, 286, 0, 41, 361
|
|
1
.VSCodeCounter/2022-11-18_12-24-29/results.json
Normal file
1
.VSCodeCounter/2022-11-18_12-24-29/results.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"file:///home/arlo/code/cs_coursework/Cargo.toml":{"language":"TOML","code":9,"comment":0,"blank":2},"file:///home/arlo/code/cs_coursework/Rocket.toml":{"language":"TOML","code":25,"comment":0,"blank":3},"file:///home/arlo/code/cs_coursework/src/sql.rs":{"language":"Rust","code":199,"comment":0,"blank":26},"file:///home/arlo/code/cs_coursework/src/main.rs":{"language":"Rust","code":87,"comment":0,"blank":10}}
|
23
.VSCodeCounter/2022-11-18_12-24-29/results.md
Normal file
23
.VSCodeCounter/2022-11-18_12-24-29/results.md
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# Summary
|
||||||
|
|
||||||
|
Date : 2022-11-18 12:24:29
|
||||||
|
|
||||||
|
Directory /home/arlo/code/cs_coursework
|
||||||
|
|
||||||
|
Total : 4 files, 320 codes, 0 comments, 41 blanks, all 361 lines
|
||||||
|
|
||||||
|
Summary / [Details](details.md) / [Diff Summary](diff.md) / [Diff Details](diff-details.md)
|
||||||
|
|
||||||
|
## Languages
|
||||||
|
| language | files | code | comment | blank | total |
|
||||||
|
| :--- | ---: | ---: | ---: | ---: | ---: |
|
||||||
|
| Rust | 2 | 286 | 0 | 36 | 322 |
|
||||||
|
| TOML | 2 | 34 | 0 | 5 | 39 |
|
||||||
|
|
||||||
|
## Directories
|
||||||
|
| path | files | code | comment | blank | total |
|
||||||
|
| :--- | ---: | ---: | ---: | ---: | ---: |
|
||||||
|
| . | 4 | 320 | 0 | 41 | 361 |
|
||||||
|
| src | 2 | 286 | 0 | 36 | 322 |
|
||||||
|
|
||||||
|
Summary / [Details](details.md) / [Diff Summary](diff.md) / [Diff Details](diff-details.md)
|
30
.VSCodeCounter/2022-11-18_12-24-29/results.txt
Normal file
30
.VSCodeCounter/2022-11-18_12-24-29/results.txt
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
Date : 2022-11-18 12:24:29
|
||||||
|
Directory : /home/arlo/code/cs_coursework
|
||||||
|
Total : 4 files, 320 codes, 0 comments, 41 blanks, all 361 lines
|
||||||
|
|
||||||
|
Languages
|
||||||
|
+----------+------------+------------+------------+------------+------------+
|
||||||
|
| language | files | code | comment | blank | total |
|
||||||
|
+----------+------------+------------+------------+------------+------------+
|
||||||
|
| Rust | 2 | 286 | 0 | 36 | 322 |
|
||||||
|
| TOML | 2 | 34 | 0 | 5 | 39 |
|
||||||
|
+----------+------------+------------+------------+------------+------------+
|
||||||
|
|
||||||
|
Directories
|
||||||
|
+-------------------------------------------+------------+------------+------------+------------+------------+
|
||||||
|
| path | files | code | comment | blank | total |
|
||||||
|
+-------------------------------------------+------------+------------+------------+------------+------------+
|
||||||
|
| . | 4 | 320 | 0 | 41 | 361 |
|
||||||
|
| src | 2 | 286 | 0 | 36 | 322 |
|
||||||
|
+-------------------------------------------+------------+------------+------------+------------+------------+
|
||||||
|
|
||||||
|
Files
|
||||||
|
+-------------------------------------------+----------+------------+------------+------------+------------+
|
||||||
|
| filename | language | code | comment | blank | total |
|
||||||
|
+-------------------------------------------+----------+------------+------------+------------+------------+
|
||||||
|
| /home/arlo/code/cs_coursework/Cargo.toml | TOML | 9 | 0 | 2 | 11 |
|
||||||
|
| /home/arlo/code/cs_coursework/Rocket.toml | TOML | 25 | 0 | 3 | 28 |
|
||||||
|
| /home/arlo/code/cs_coursework/src/main.rs | Rust | 87 | 0 | 10 | 97 |
|
||||||
|
| /home/arlo/code/cs_coursework/src/sql.rs | Rust | 199 | 0 | 26 | 225 |
|
||||||
|
| Total | | 320 | 0 | 41 | 361 |
|
||||||
|
+-------------------------------------------+----------+------------+------------+------------+------------+
|
19
.VSCodeCounter/2022-11-18_12-25-12/details.md
Normal file
19
.VSCodeCounter/2022-11-18_12-25-12/details.md
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
# Details
|
||||||
|
|
||||||
|
Date : 2022-11-18 12:25:12
|
||||||
|
|
||||||
|
Directory /home/arlo/code/cs_coursework
|
||||||
|
|
||||||
|
Total : 4 files, 315 codes, 5 comments, 41 blanks, all 361 lines
|
||||||
|
|
||||||
|
[Summary](results.md) / Details / [Diff Summary](diff.md) / [Diff Details](diff-details.md)
|
||||||
|
|
||||||
|
## Files
|
||||||
|
| filename | language | code | comment | blank | total |
|
||||||
|
| :--- | :--- | ---: | ---: | ---: | ---: |
|
||||||
|
| [Cargo.toml](/Cargo.toml) | TOML | 9 | 0 | 2 | 11 |
|
||||||
|
| [Rocket.toml](/Rocket.toml) | TOML | 21 | 4 | 3 | 28 |
|
||||||
|
| [src/main.rs](/src/main.rs) | Rust | 86 | 1 | 10 | 97 |
|
||||||
|
| [src/sql.rs](/src/sql.rs) | Rust | 199 | 0 | 26 | 225 |
|
||||||
|
|
||||||
|
[Summary](results.md) / Details / [Diff Summary](diff.md) / [Diff Details](diff-details.md)
|
17
.VSCodeCounter/2022-11-18_12-25-12/diff-details.md
Normal file
17
.VSCodeCounter/2022-11-18_12-25-12/diff-details.md
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# Diff Details
|
||||||
|
|
||||||
|
Date : 2022-11-18 12:25:12
|
||||||
|
|
||||||
|
Directory /home/arlo/code/cs_coursework
|
||||||
|
|
||||||
|
Total : 2 files, -5 codes, 5 comments, 0 blanks, all 0 lines
|
||||||
|
|
||||||
|
[Summary](results.md) / [Details](details.md) / [Diff Summary](diff.md) / Diff Details
|
||||||
|
|
||||||
|
## Files
|
||||||
|
| filename | language | code | comment | blank | total |
|
||||||
|
| :--- | :--- | ---: | ---: | ---: | ---: |
|
||||||
|
| [Rocket.toml](/Rocket.toml) | TOML | -4 | 4 | 0 | 0 |
|
||||||
|
| [src/main.rs](/src/main.rs) | Rust | -1 | 1 | 0 | 0 |
|
||||||
|
|
||||||
|
[Summary](results.md) / [Details](details.md) / [Diff Summary](diff.md) / Diff Details
|
4
.VSCodeCounter/2022-11-18_12-25-12/diff.csv
Normal file
4
.VSCodeCounter/2022-11-18_12-25-12/diff.csv
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
"filename", "language", "TOML", "Rust", "comment", "blank", "total"
|
||||||
|
"/home/arlo/code/cs_coursework/Rocket.toml", "TOML", -4, 0, 4, 0, 0
|
||||||
|
"/home/arlo/code/cs_coursework/src/main.rs", "Rust", 0, -1, 1, 0, 0
|
||||||
|
"Total", "-", -4, -1, 5, 0, 0
|
|
23
.VSCodeCounter/2022-11-18_12-25-12/diff.md
Normal file
23
.VSCodeCounter/2022-11-18_12-25-12/diff.md
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# Diff Summary
|
||||||
|
|
||||||
|
Date : 2022-11-18 12:25:12
|
||||||
|
|
||||||
|
Directory /home/arlo/code/cs_coursework
|
||||||
|
|
||||||
|
Total : 2 files, -5 codes, 5 comments, 0 blanks, all 0 lines
|
||||||
|
|
||||||
|
[Summary](results.md) / [Details](details.md) / Diff Summary / [Diff Details](diff-details.md)
|
||||||
|
|
||||||
|
## Languages
|
||||||
|
| language | files | code | comment | blank | total |
|
||||||
|
| :--- | ---: | ---: | ---: | ---: | ---: |
|
||||||
|
| Rust | 1 | -1 | 1 | 0 | 0 |
|
||||||
|
| TOML | 1 | -4 | 4 | 0 | 0 |
|
||||||
|
|
||||||
|
## Directories
|
||||||
|
| path | files | code | comment | blank | total |
|
||||||
|
| :--- | ---: | ---: | ---: | ---: | ---: |
|
||||||
|
| . | 2 | -5 | 5 | 0 | 0 |
|
||||||
|
| src | 1 | -1 | 1 | 0 | 0 |
|
||||||
|
|
||||||
|
[Summary](results.md) / [Details](details.md) / Diff Summary / [Diff Details](diff-details.md)
|
28
.VSCodeCounter/2022-11-18_12-25-12/diff.txt
Normal file
28
.VSCodeCounter/2022-11-18_12-25-12/diff.txt
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
Date : 2022-11-18 12:25:12
|
||||||
|
Directory : /home/arlo/code/cs_coursework
|
||||||
|
Total : 2 files, -5 codes, 5 comments, 0 blanks, all 0 lines
|
||||||
|
|
||||||
|
Languages
|
||||||
|
+----------+------------+------------+------------+------------+------------+
|
||||||
|
| language | files | code | comment | blank | total |
|
||||||
|
+----------+------------+------------+------------+------------+------------+
|
||||||
|
| Rust | 1 | -1 | 1 | 0 | 0 |
|
||||||
|
| TOML | 1 | -4 | 4 | 0 | 0 |
|
||||||
|
+----------+------------+------------+------------+------------+------------+
|
||||||
|
|
||||||
|
Directories
|
||||||
|
+-------------------------------------------+------------+------------+------------+------------+------------+
|
||||||
|
| path | files | code | comment | blank | total |
|
||||||
|
+-------------------------------------------+------------+------------+------------+------------+------------+
|
||||||
|
| . | 2 | -5 | 5 | 0 | 0 |
|
||||||
|
| src | 1 | -1 | 1 | 0 | 0 |
|
||||||
|
+-------------------------------------------+------------+------------+------------+------------+------------+
|
||||||
|
|
||||||
|
Files
|
||||||
|
+-------------------------------------------+----------+------------+------------+------------+------------+
|
||||||
|
| filename | language | code | comment | blank | total |
|
||||||
|
+-------------------------------------------+----------+------------+------------+------------+------------+
|
||||||
|
| /home/arlo/code/cs_coursework/Rocket.toml | TOML | -4 | 4 | 0 | 0 |
|
||||||
|
| /home/arlo/code/cs_coursework/src/main.rs | Rust | -1 | 1 | 0 | 0 |
|
||||||
|
| Total | | -5 | 5 | 0 | 0 |
|
||||||
|
+-------------------------------------------+----------+------------+------------+------------+------------+
|
6
.VSCodeCounter/2022-11-18_12-25-12/results.csv
Normal file
6
.VSCodeCounter/2022-11-18_12-25-12/results.csv
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
"filename", "language", "TOML", "Rust", "comment", "blank", "total"
|
||||||
|
"/home/arlo/code/cs_coursework/Cargo.toml", "TOML", 9, 0, 0, 2, 11
|
||||||
|
"/home/arlo/code/cs_coursework/Rocket.toml", "TOML", 21, 0, 4, 3, 28
|
||||||
|
"/home/arlo/code/cs_coursework/src/main.rs", "Rust", 0, 86, 1, 10, 97
|
||||||
|
"/home/arlo/code/cs_coursework/src/sql.rs", "Rust", 0, 199, 0, 26, 225
|
||||||
|
"Total", "-", 30, 285, 5, 41, 361
|
|
1
.VSCodeCounter/2022-11-18_12-25-12/results.json
Normal file
1
.VSCodeCounter/2022-11-18_12-25-12/results.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"file:///home/arlo/code/cs_coursework/Cargo.toml":{"language":"TOML","code":9,"comment":0,"blank":2},"file:///home/arlo/code/cs_coursework/Rocket.toml":{"language":"TOML","code":21,"comment":4,"blank":3},"file:///home/arlo/code/cs_coursework/src/sql.rs":{"language":"Rust","code":199,"comment":0,"blank":26},"file:///home/arlo/code/cs_coursework/src/main.rs":{"language":"Rust","code":86,"comment":1,"blank":10}}
|
23
.VSCodeCounter/2022-11-18_12-25-12/results.md
Normal file
23
.VSCodeCounter/2022-11-18_12-25-12/results.md
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# Summary
|
||||||
|
|
||||||
|
Date : 2022-11-18 12:25:12
|
||||||
|
|
||||||
|
Directory /home/arlo/code/cs_coursework
|
||||||
|
|
||||||
|
Total : 4 files, 315 codes, 5 comments, 41 blanks, all 361 lines
|
||||||
|
|
||||||
|
Summary / [Details](details.md) / [Diff Summary](diff.md) / [Diff Details](diff-details.md)
|
||||||
|
|
||||||
|
## Languages
|
||||||
|
| language | files | code | comment | blank | total |
|
||||||
|
| :--- | ---: | ---: | ---: | ---: | ---: |
|
||||||
|
| Rust | 2 | 285 | 1 | 36 | 322 |
|
||||||
|
| TOML | 2 | 30 | 4 | 5 | 39 |
|
||||||
|
|
||||||
|
## Directories
|
||||||
|
| path | files | code | comment | blank | total |
|
||||||
|
| :--- | ---: | ---: | ---: | ---: | ---: |
|
||||||
|
| . | 4 | 315 | 5 | 41 | 361 |
|
||||||
|
| src | 2 | 285 | 1 | 36 | 322 |
|
||||||
|
|
||||||
|
Summary / [Details](details.md) / [Diff Summary](diff.md) / [Diff Details](diff-details.md)
|
30
.VSCodeCounter/2022-11-18_12-25-12/results.txt
Normal file
30
.VSCodeCounter/2022-11-18_12-25-12/results.txt
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
Date : 2022-11-18 12:25:12
|
||||||
|
Directory : /home/arlo/code/cs_coursework
|
||||||
|
Total : 4 files, 315 codes, 5 comments, 41 blanks, all 361 lines
|
||||||
|
|
||||||
|
Languages
|
||||||
|
+----------+------------+------------+------------+------------+------------+
|
||||||
|
| language | files | code | comment | blank | total |
|
||||||
|
+----------+------------+------------+------------+------------+------------+
|
||||||
|
| Rust | 2 | 285 | 1 | 36 | 322 |
|
||||||
|
| TOML | 2 | 30 | 4 | 5 | 39 |
|
||||||
|
+----------+------------+------------+------------+------------+------------+
|
||||||
|
|
||||||
|
Directories
|
||||||
|
+-------------------------------------------+------------+------------+------------+------------+------------+
|
||||||
|
| path | files | code | comment | blank | total |
|
||||||
|
+-------------------------------------------+------------+------------+------------+------------+------------+
|
||||||
|
| . | 4 | 315 | 5 | 41 | 361 |
|
||||||
|
| src | 2 | 285 | 1 | 36 | 322 |
|
||||||
|
+-------------------------------------------+------------+------------+------------+------------+------------+
|
||||||
|
|
||||||
|
Files
|
||||||
|
+-------------------------------------------+----------+------------+------------+------------+------------+
|
||||||
|
| filename | language | code | comment | blank | total |
|
||||||
|
+-------------------------------------------+----------+------------+------------+------------+------------+
|
||||||
|
| /home/arlo/code/cs_coursework/Cargo.toml | TOML | 9 | 0 | 2 | 11 |
|
||||||
|
| /home/arlo/code/cs_coursework/Rocket.toml | TOML | 21 | 4 | 3 | 28 |
|
||||||
|
| /home/arlo/code/cs_coursework/src/main.rs | Rust | 86 | 1 | 10 | 97 |
|
||||||
|
| /home/arlo/code/cs_coursework/src/sql.rs | Rust | 199 | 0 | 26 | 225 |
|
||||||
|
| Total | | 315 | 5 | 41 | 361 |
|
||||||
|
+-------------------------------------------+----------+------------+------------+------------+------------+
|
@ -63,11 +63,19 @@ class API {
|
|||||||
let wpm;
|
let wpm;
|
||||||
const accuracy = 0;
|
const accuracy = 0;
|
||||||
const userId = Number(user.userId);
|
const userId = Number(user.userId);
|
||||||
|
let test_content = screenManager.screen.textbox.testContent;
|
||||||
|
|
||||||
|
let string = "";
|
||||||
|
for (let letter = 0; letter < test.length; letter++) {
|
||||||
|
if (test[letter] === test_content[letter]) {
|
||||||
|
string += test[letter];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// this is the wpm calculation factoring in the time of test
|
// this is the wpm calculation factoring in the time of test
|
||||||
// it assumes that all words are 5 characters long because on average
|
// it assumes that all words are 5 characters long because on average
|
||||||
// they are
|
// they are
|
||||||
wpm = Math.round((testLength / 5) * (60 / testTime));
|
wpm = Math.round((string.length / 5) * (60 / testTime));
|
||||||
|
|
||||||
// the following code is a series of if statements that checks the
|
// the following code is a series of if statements that checks the
|
||||||
// types of the variables is correct if not it errors it and returns
|
// types of the variables is correct if not it errors it and returns
|
||||||
@ -238,4 +246,18 @@ class API {
|
|||||||
user.leaderboard = JSON.parse(xhr.response);
|
user.leaderboard = JSON.parse(xhr.response);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getTest() {
|
||||||
|
let xhr = new XMLHttpRequest();
|
||||||
|
xhr.open('GET', `https://random-word-api.herokuapp.com/word?number=100`);
|
||||||
|
xhr.send();
|
||||||
|
xhr.onload = () => {
|
||||||
|
let textArr = JSON.parse(xhr.response);
|
||||||
|
let text = "";
|
||||||
|
for (let i = 0; i < textArr.length; i++) {
|
||||||
|
text += `${textArr[i]} `
|
||||||
|
}
|
||||||
|
user.nextTest = text;
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
@ -5,5 +5,6 @@ class User {
|
|||||||
this.userId = 0;
|
this.userId = 0;
|
||||||
this.tests;
|
this.tests;
|
||||||
this.leaderboard;
|
this.leaderboard;
|
||||||
|
this.nextTest = `satisfy powerful pleasant bells disastrous mean kited is gusted romantic past taste immolate productive leak close show crabby awake handsails finicky betray long-term incompetent wander show manage toys convey hop constitute number send like off ice aboard well-made vast vacuous tramp seed force divergent flower porter fire untidy soggy fetch`;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -19,6 +19,7 @@ function setup() {
|
|||||||
|
|
||||||
// will log the user in if there details are in local storage
|
// will log the user in if there details are in local storage
|
||||||
api.login();
|
api.login();
|
||||||
|
api.getTest();
|
||||||
textFont(roboto);
|
textFont(roboto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,6 +43,6 @@ class LeaderboardScreen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
fill("#000");
|
fill("#000");
|
||||||
text(`Logged in as ${user.username}`, windowWidth-100, 15);
|
text(`Logged in as ${user.username}`, windowWidth-400, 15);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,7 +8,8 @@ class LoginScreen {
|
|||||||
true,
|
true,
|
||||||
"#000",
|
"#000",
|
||||||
false, "#000",
|
false, "#000",
|
||||||
"#000"
|
"#000",
|
||||||
|
true
|
||||||
),
|
),
|
||||||
|
|
||||||
new Textbox(
|
new Textbox(
|
||||||
@ -18,7 +19,8 @@ class LoginScreen {
|
|||||||
true,
|
true,
|
||||||
"#000",
|
"#000",
|
||||||
false,"000",
|
false,"000",
|
||||||
"#000"
|
"#000",
|
||||||
|
false
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -83,9 +85,13 @@ class LoginScreen {
|
|||||||
text("Password", 110, 325);
|
text("Password", 110, 325);
|
||||||
|
|
||||||
if (this.buttons[0].isPressed()) {
|
if (this.buttons[0].isPressed()) {
|
||||||
|
this.textboxes[this.activeTextBox].line = false;
|
||||||
this.activeTextBox=0;
|
this.activeTextBox=0;
|
||||||
|
this.textboxes[this.activeTextBox].line = true;
|
||||||
} else if (this.buttons[1].isPressed()) {
|
} else if (this.buttons[1].isPressed()) {
|
||||||
|
this.textboxes[this.activeTextBox].line = false;
|
||||||
this.activeTextBox=1;
|
this.activeTextBox=1;
|
||||||
|
this.textboxes[this.activeTextBox].line = true;
|
||||||
} else if (this.buttons[2].isPressed()) {
|
} else if (this.buttons[2].isPressed()) {
|
||||||
api.login(
|
api.login(
|
||||||
this.textboxes[0].getWords(),
|
this.textboxes[0].getWords(),
|
||||||
@ -114,6 +120,22 @@ class LoginScreen {
|
|||||||
* @param {key} key
|
* @param {key} key
|
||||||
*/
|
*/
|
||||||
letterTyped(key) {
|
letterTyped(key) {
|
||||||
|
if (key === "Tab" && this.activeTextBox === 0) {
|
||||||
|
this.textboxes[this.activeTextBox].line = false;
|
||||||
|
this.activeTextBox=1;
|
||||||
|
this.textboxes[this.activeTextBox].line = true;
|
||||||
|
} else if (key === "Tab" && this.activeTextBox === 1) {
|
||||||
|
this.textboxes[this.activeTextBox].line = false;
|
||||||
|
this.activeTextBox=0;
|
||||||
|
this.textboxes[this.activeTextBox].line = true;
|
||||||
|
} else if (key === "Enter") {
|
||||||
|
api.login(
|
||||||
|
this.textboxes[0].getWords(),
|
||||||
|
this.textboxes[1].getWords()
|
||||||
|
)
|
||||||
|
screenManager.setScreen(new StartScreen());
|
||||||
|
} else {
|
||||||
this.textboxes[this.activeTextBox].letterTyped(key);
|
this.textboxes[this.activeTextBox].letterTyped(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
@ -43,6 +43,6 @@ class ProfileScreen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
fill("#000");
|
fill("#000");
|
||||||
text(`Logged in as ${user.username}`, windowWidth-100, 15);
|
text(`Logged in as ${user.username}`, windowWidth-400, 15);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,7 +8,8 @@ class SignUpScreen {
|
|||||||
true,
|
true,
|
||||||
"#000",
|
"#000",
|
||||||
false, "#000",
|
false, "#000",
|
||||||
"#000"
|
"#000",
|
||||||
|
true
|
||||||
),
|
),
|
||||||
|
|
||||||
new Textbox(
|
new Textbox(
|
||||||
@ -18,7 +19,8 @@ class SignUpScreen {
|
|||||||
true,
|
true,
|
||||||
"#000",
|
"#000",
|
||||||
false,"000",
|
false,"000",
|
||||||
"#000"
|
"#000",
|
||||||
|
false
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -83,9 +85,13 @@ class SignUpScreen {
|
|||||||
text("Password", 110, 325);
|
text("Password", 110, 325);
|
||||||
|
|
||||||
if (this.buttons[0].isPressed()) {
|
if (this.buttons[0].isPressed()) {
|
||||||
|
this.textboxes[this.activeTextBox].line = false;
|
||||||
this.activeTextBox=0;
|
this.activeTextBox=0;
|
||||||
|
this.textboxes[this.activeTextBox].line = true;
|
||||||
} else if (this.buttons[1].isPressed()) {
|
} else if (this.buttons[1].isPressed()) {
|
||||||
|
this.textboxes[this.activeTextBox].line = false;
|
||||||
this.activeTextBox=1;
|
this.activeTextBox=1;
|
||||||
|
this.textboxes[this.activeTextBox].line = true;
|
||||||
} else if (this.buttons[2].isPressed()) {
|
} else if (this.buttons[2].isPressed()) {
|
||||||
api.createUser(
|
api.createUser(
|
||||||
this.textboxes[0].getWords(),
|
this.textboxes[0].getWords(),
|
||||||
@ -102,7 +108,7 @@ class SignUpScreen {
|
|||||||
screenManager.setScreen(new ProfileScreen());
|
screenManager.setScreen(new ProfileScreen());
|
||||||
} else if (this.buttons[7].isPressed()) {
|
} else if (this.buttons[7].isPressed()) {
|
||||||
screenManager.setScreen(new TestScreen())
|
screenManager.setScreen(new TestScreen())
|
||||||
} else if (this.buttons[5].isPressed()) {
|
} else if (this.buttons[8].isPressed()) {
|
||||||
screenManager.setScreen(new LeaderboardScreen())
|
screenManager.setScreen(new LeaderboardScreen())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -112,6 +118,22 @@ class SignUpScreen {
|
|||||||
* @param {key} key
|
* @param {key} key
|
||||||
*/
|
*/
|
||||||
letterTyped(key) {
|
letterTyped(key) {
|
||||||
|
if (key === "Tab" && this.activeTextBox === 0) {
|
||||||
|
this.textboxes[this.activeTextBox].line = false;
|
||||||
|
this.activeTextBox=1;
|
||||||
|
this.textboxes[this.activeTextBox].line = true;
|
||||||
|
} else if (key === "Tab" && this.activeTextBox === 1) {
|
||||||
|
this.textboxes[this.activeTextBox].line = false;
|
||||||
|
this.activeTextBox=0;
|
||||||
|
this.textboxes[this.activeTextBox].line = true;
|
||||||
|
} else if (key === "Enter") {
|
||||||
|
api.createUser(
|
||||||
|
this.textboxes[0].getWords(),
|
||||||
|
this.textboxes[1].getWords()
|
||||||
|
)
|
||||||
|
screenManager.setScreen(new StartScreen());
|
||||||
|
} else {
|
||||||
this.textboxes[this.activeTextBox].letterTyped(key);
|
this.textboxes[this.activeTextBox].letterTyped(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
@ -35,7 +35,7 @@ class StartScreen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fill("#000");
|
fill("#000");
|
||||||
text(`${user.username}`, windowWidth-100, 15);
|
text(`Logged in as ${user.username}`, windowWidth-400, 15);
|
||||||
}
|
}
|
||||||
|
|
||||||
letterTyped(key) {
|
letterTyped(key) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
class TestScreen {
|
class TestScreen {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.textbox = new Textbox(100,100,windowWidth - 100,windowHeight,0,true,"#000", false, "#000", "#000");
|
this.textbox = new Textbox(100,100,windowWidth - 200,windowHeight,0,true,"#000", false, "#000", "#000", true, true);
|
||||||
screenManager.timer = new Timer(0,0,windowWidth,50,0,true,"#fff", true, "#000", "#666", 15, true);
|
screenManager.timer = new Timer(0,0,windowWidth,50,0,true,"#fff", true, "#000", "#666", 15, true);
|
||||||
screenManager.timer.start();
|
screenManager.timer.start();
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,15 @@ class Textbox {
|
|||||||
* @param {hexcode} pBorderColor
|
* @param {hexcode} pBorderColor
|
||||||
* @param {hexcode} pBackgroundColor
|
* @param {hexcode} pBackgroundColor
|
||||||
*/
|
*/
|
||||||
constructor(pX, pY, pWidth, pHeight, pLayer, pVisible, pTextColor, pBorder, pBorderColor, pBackgroundColor) {
|
constructor(
|
||||||
|
pX, pY,
|
||||||
|
pWidth, pHeight,
|
||||||
|
pLayer, pVisible,
|
||||||
|
pTextColor,
|
||||||
|
pBorder, pBorderColor,
|
||||||
|
pBackgroundColor,
|
||||||
|
pLine, pIsTest
|
||||||
|
) {
|
||||||
this.x = pX;
|
this.x = pX;
|
||||||
this.y = pY;
|
this.y = pY;
|
||||||
this.width = pWidth;
|
this.width = pWidth;
|
||||||
@ -31,6 +39,13 @@ class Textbox {
|
|||||||
'l', 'm','n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
|
'l', 'm','n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
|
||||||
'x', 'y', 'z', '\'', '"', ',', '.', ' '
|
'x', 'y', 'z', '\'', '"', ',', '.', ' '
|
||||||
]
|
]
|
||||||
|
|
||||||
|
this.line = pLine;
|
||||||
|
this.isTest = pIsTest;
|
||||||
|
|
||||||
|
if (this.isTest) {
|
||||||
|
this.testContent = user.nextTest;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getX() {
|
getX() {
|
||||||
@ -183,11 +198,58 @@ class Textbox {
|
|||||||
fill(this.textColor);
|
fill(this.textColor);
|
||||||
textSize(23);
|
textSize(23);
|
||||||
textAlign(LEFT);
|
textAlign(LEFT);
|
||||||
|
if (this.words.length == 0 && this.line) {
|
||||||
|
fill("#000")
|
||||||
|
rect(this.x, this.y-15, 1, 30)
|
||||||
|
}
|
||||||
|
|
||||||
// these variables allow me to use the values of x and y while updating them
|
// these variables allow me to use the values of x and y while updating them
|
||||||
let i = this.x;
|
let i = this.x;
|
||||||
let j = this.y;
|
let j = this.y;
|
||||||
|
|
||||||
|
if (this.isTest) {
|
||||||
|
let i = this.x;
|
||||||
|
let j = this.y;
|
||||||
|
|
||||||
|
// currently this loop just prints out every letter in the array, including any enter characters
|
||||||
|
for (let x = 0; x < this.testContent.length; x++) {
|
||||||
|
if (i > this.x + this.width) i = this.x, j += 30;
|
||||||
|
if (this.testContent[x] === "Enter") {
|
||||||
|
i = this.x, j+= 30;
|
||||||
|
} else {
|
||||||
|
text(this.testContent[x], i, j);
|
||||||
|
i += 13
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// these variables allow me to use the values of x and y while updating them
|
||||||
|
i = this.x;
|
||||||
|
j = this.y;
|
||||||
|
|
||||||
|
// currently this loop just prints out every letter in the array, including any enter characters
|
||||||
|
for (let x = 0; x < this.letters.length; x++) {
|
||||||
|
if (i > this.x + this.width) i = this.x, j += 30;
|
||||||
|
if (this.letters[x] === "Enter") {
|
||||||
|
i = this.x, j+= 30;
|
||||||
|
} else {
|
||||||
|
if (this.letters[x] === this.testContent[x]) {
|
||||||
|
fill('green');
|
||||||
|
} else {
|
||||||
|
fill('red');
|
||||||
|
}
|
||||||
|
text(this.testContent[x], i, j);
|
||||||
|
i += 13
|
||||||
|
}
|
||||||
|
if (this.letters.length > 0 && x == this.letters.length-1 && this.line) {
|
||||||
|
fill("black")
|
||||||
|
rect(i, j-15, 1, 30)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// these variables allow me to use the values of x and y while updating them
|
||||||
|
let i = this.x;
|
||||||
|
let j = this.y;
|
||||||
|
|
||||||
// currently this loop just prints out every letter in the array, including any enter characters
|
// currently this loop just prints out every letter in the array, including any enter characters
|
||||||
for (let x = 0; x < this.letters.length; x++) {
|
for (let x = 0; x < this.letters.length; x++) {
|
||||||
if (i > this.x + this.width) i = this.x, j += 30;
|
if (i > this.x + this.width) i = this.x, j += 30;
|
||||||
@ -197,6 +259,11 @@ class Textbox {
|
|||||||
text(this.letters[x], i, j);
|
text(this.letters[x], i, j);
|
||||||
i += 13
|
i += 13
|
||||||
}
|
}
|
||||||
|
if (this.letters.length > 0 && x == this.letters.length-1 && this.line) {
|
||||||
|
fill("black")
|
||||||
|
rect(i, j-15, 1, 30)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user