diff --git a/src/main.rs b/src/main.rs
index e37559a..c4eab88 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -20,12 +20,6 @@ use crate::sql::Test;
fn test() -> String {
sql::create_database()
.expect("couldn't create database");
-
- sql::create_user("arlo", "passwod123")
- .expect("couldn't create user");
-
- sql::create_user("arlo","password123")
- .expect("couldn't create user");
String::from("Hello World!")
}
diff --git a/src/sql.rs b/src/sql.rs
index bdde447..80cbd36 100644
--- a/src/sql.rs
+++ b/src/sql.rs
@@ -168,8 +168,6 @@ pub fn get_user_tests(
WHERE user_id=:user_id",
)?;
- let mut user_id: u32 = 0;
-
let test_iter = statement
.query_map(&[(":user_id", &user_id.to_string())], |row| {
Ok( Test {
diff --git a/website/api/api.js b/website/api/api.js
index 72b79c9..b5517ea 100644
--- a/website/api/api.js
+++ b/website/api/api.js
@@ -211,6 +211,20 @@ class API {
logout() {
user = new User();
+ user.username = "no one";
+ user.password = "none";
+ user.userId = 0;
+ user.tests = [];
localStorage.clear();
}
+
+ getUserTests() {
+ let xhr = new XMLHttpRequest();
+ let userId = Number(user.userId);
+ xhr.open('GET', `${this.url}get_user_tests/${userId}/`);
+ xhr.send();
+ xhr.onload = () => {
+ user.tests = JSON.parse(xhr.response);
+ };
+ }
}
\ No newline at end of file
diff --git a/website/api/user.js b/website/api/user.js
index c58db7d..1a0145b 100644
--- a/website/api/user.js
+++ b/website/api/user.js
@@ -3,5 +3,6 @@ class User {
this.username = "not logged in";
this.password = "there";
this.userId = 0;
+ this.tests;
}
}
\ No newline at end of file
diff --git a/website/assets/favicon/about.txt b/website/assets/favicon/about.txt
new file mode 100644
index 0000000..9bb2f0c
--- /dev/null
+++ b/website/assets/favicon/about.txt
@@ -0,0 +1,6 @@
+This favicon was generated using the following font:
+
+- Font Title: Roboto
+- Font Author: Copyright 2011 Google Inc. All Rights Reserved.
+- Font Source: http://fonts.gstatic.com/s/roboto/v30/KFOlCnqEu92Fr1MmSU5vAx05IsDqlA.ttf
+- Font License: Apache License, version 2.0 (http://www.apache.org/licenses/LICENSE-2.0.html))
diff --git a/website/assets/favicon/android-chrome-192x192.png b/website/assets/favicon/android-chrome-192x192.png
new file mode 100644
index 0000000..5505cf6
Binary files /dev/null and b/website/assets/favicon/android-chrome-192x192.png differ
diff --git a/website/assets/favicon/android-chrome-512x512.png b/website/assets/favicon/android-chrome-512x512.png
new file mode 100644
index 0000000..8cc7222
Binary files /dev/null and b/website/assets/favicon/android-chrome-512x512.png differ
diff --git a/website/assets/favicon/apple-touch-icon.png b/website/assets/favicon/apple-touch-icon.png
new file mode 100644
index 0000000..69ceb13
Binary files /dev/null and b/website/assets/favicon/apple-touch-icon.png differ
diff --git a/website/assets/favicon/favicon-16x16.png b/website/assets/favicon/favicon-16x16.png
new file mode 100644
index 0000000..3600c33
Binary files /dev/null and b/website/assets/favicon/favicon-16x16.png differ
diff --git a/website/assets/favicon/favicon-32x32.png b/website/assets/favicon/favicon-32x32.png
new file mode 100644
index 0000000..f924768
Binary files /dev/null and b/website/assets/favicon/favicon-32x32.png differ
diff --git a/website/assets/favicon/favicon.ico b/website/assets/favicon/favicon.ico
new file mode 100644
index 0000000..95c11d6
Binary files /dev/null and b/website/assets/favicon/favicon.ico differ
diff --git a/website/assets/favicon/favicon_io (1).zip b/website/assets/favicon/favicon_io (1).zip
new file mode 100644
index 0000000..7cfaf50
Binary files /dev/null and b/website/assets/favicon/favicon_io (1).zip differ
diff --git a/website/assets/favicon/site.webmanifest b/website/assets/favicon/site.webmanifest
new file mode 100644
index 0000000..45dc8a2
--- /dev/null
+++ b/website/assets/favicon/site.webmanifest
@@ -0,0 +1 @@
+{"name":"","short_name":"","icons":[{"src":"/android-chrome-192x192.png","sizes":"192x192","type":"image/png"},{"src":"/android-chrome-512x512.png","sizes":"512x512","type":"image/png"}],"theme_color":"#ffffff","background_color":"#ffffff","display":"standalone"}
\ No newline at end of file
diff --git a/website/assets/fonts/RobotoMono-Medium.ttf b/website/assets/fonts/RobotoMono-Medium.ttf
new file mode 100644
index 0000000..752d0fa
Binary files /dev/null and b/website/assets/fonts/RobotoMono-Medium.ttf differ
diff --git a/website/index.html b/website/index.html
index ed3c5dc..dfdbb45 100644
--- a/website/index.html
+++ b/website/index.html
@@ -6,6 +6,12 @@
Document
+
+
+
+
+
+
@@ -24,6 +30,7 @@
+
diff --git a/website/index.js b/website/index.js
index fe6daef..96b7794 100644
--- a/website/index.js
+++ b/website/index.js
@@ -1,5 +1,9 @@
let canvas, api, screenManager, user;
+function preload() {
+ roboto = loadFont('./assets/fonts/RobotoMono-Medium.ttf');
+}
+
function setup() {
// Creating the canvas
canvas = new Canvas();
@@ -15,6 +19,7 @@ function setup() {
// will log the user in if there details are in local storage
api.login();
+ textFont(roboto);
}
// this function is called once per frame and draws all other elements
diff --git a/website/screens/endscreen.js b/website/screens/endscreen.js
index 1df4e6f..95131fa 100644
--- a/website/screens/endscreen.js
+++ b/website/screens/endscreen.js
@@ -1,6 +1,11 @@
class EndScreen {
constructor() {
- screenManager.textbox = new Textbox(0,0,0,0,0,false,"#000", false, "#000", "#000");
+ this.buttons = [
+ new Button(0,0,100,30,0,true,"#fff",false,"#000","#000","Sign Up"),
+ new Button(110,0,100,30,0,true,"#fff",false,"#000","#000","Login"),
+ new Button(220,0,100,30,0,true,"#fff",false,"#000","#000","Logout"),
+ new Button(330,0,100,30,0,true,"#fff",false,"#000","#000","Profile")
+ ]
}
draw() {
@@ -9,6 +14,22 @@ class EndScreen {
textAlign(CENTER, CENTER);
fill(0);
text("Test Complete\nPress enter to start another test", 0, 0, windowWidth - 100, windowHeight - 100);
+ this.buttons[0].draw();
+ this.buttons[1].draw();
+ this.buttons[2].draw();
+ this.buttons[3].draw();
+ this.buttons[4].draw();
+ if (this.buttons[0].isPressed()) {
+ screenManager.setScreen(new SignUpScreen());
+ } else if (this.buttons[1].isPressed()) {
+ screenManager.setScreen(new LoginScreen());
+ } else if (this.buttons[2].isPressed()) {
+ api.logout();
+ } else if (this.buttons[3].isPressed()) {
+ screenManager.setScreen(new ProfileScreen());
+ } else if (this.buttons[4].isPressed()) {
+ screenManager.setScreen(new TestScreen())
+ }
}
letterTyped() {
diff --git a/website/screens/loginscreen.js b/website/screens/loginscreen.js
index 826ac64..c86ab12 100644
--- a/website/screens/loginscreen.js
+++ b/website/screens/loginscreen.js
@@ -52,6 +52,12 @@ class LoginScreen {
false,"#000",
"#00ff00","Login"
),
+
+ new Button(0,0,100,30,0,true,"#fff",false,"#000","#000","Sign Up"),
+ new Button(110,0,100,30,0,true,"#fff",false,"#000","#000","Login"),
+ new Button(220,0,100,30,0,true,"#fff",false,"#000","#000","Logout"),
+ new Button(330,0,100,30,0,true,"#fff",false,"#000","#000","Profile"),
+ new Button(330,0,100,30,0,true,"#fff",false,"#000","#000","Test"),
]
this.activeTextBox = 0
@@ -86,6 +92,23 @@ class LoginScreen {
)
screenManager.setScreen(new StartScreen());
}
+
+ this.buttons[3].draw();
+ this.buttons[4].draw();
+ this.buttons[5].draw();
+ this.buttons[6].draw();
+ this.buttons[7].draw();
+ if (this.buttons[3].isPressed()) {
+ screenManager.setScreen(new SignUpScreen());
+ } else if (this.buttons[4].isPressed()) {
+ screenManager.setScreen(new LoginScreen());
+ } else if (this.buttons[5].isPressed()) {
+ api.logout();
+ } else if (this.buttons[6].isPressed()) {
+ screenManager.setScreen(new ProfileScreen());
+ } else if (this.buttons[7].isPressed()) {
+ screenManager.setScreen(new TestScreen())
+ }
}
/**
diff --git a/website/screens/profilescreen.js b/website/screens/profilescreen.js
new file mode 100644
index 0000000..5e91938
--- /dev/null
+++ b/website/screens/profilescreen.js
@@ -0,0 +1,46 @@
+class ProfileScreen {
+ constructor() {
+ this.buttons = [
+ new Button(0,0,100,30,0,true,"#fff",false,"#000","#000","Sign Up"),
+ new Button(110,0,100,30,0,true,"#fff",false,"#000","#000","Login"),
+ new Button(220,0,100,30,0,true,"#fff",false,"#000","#000","Logout"),
+ new Button(330,0,100,30,0,true,"#fff",false,"#000","#000","Profile"),
+ new Button(440,0,100,30,0,true,"#fff",false,"#000","#000","Test"),
+ ];
+ api.getUserTests();
+ }
+
+ draw() {
+ background("#eeeee4");
+ textSize(100);
+ textAlign(CENTER, CENTER);
+ fill("#000");
+ text("Profile", 0, 100, windowWidth - 100, 120);
+ this.buttons[0].draw();
+ this.buttons[1].draw();
+ this.buttons[2].draw();
+ this.buttons[3].draw();
+ this.buttons[4].draw();
+ if (this.buttons[0].isPressed()) {
+ screenManager.setScreen(new SignUpScreen());
+ } else if (this.buttons[1].isPressed()) {
+ screenManager.setScreen(new LoginScreen());
+ } else if (this.buttons[2].isPressed()) {
+ api.logout();
+ } else if (this.buttons[3].isPressed()) {
+ screenManager.setScreen(new ProfileScreen());
+ } else if (this.buttons[4].isPressed()) {
+ screenManager.setScreen(new TestScreen())
+ }
+
+ textSize(20);
+ fill("#000");
+ if (user.tests != undefined) {
+ for (let i = 0; i < user.tests.length; i++) {
+ text(`Tests ${i+1}: ${user.tests[i].wpm}wpm | Type: ${user.tests[i].test_type} | Time: ${user.tests[i].test_time} | Characters Typed: ${user.tests[i].test_length}`, 0, i*30+300, windowWidth, 30);
+ }
+ }
+ fill("#000");
+ text(`Logged in as ${user.username}`, windowWidth-100, 15);
+ }
+}
\ No newline at end of file
diff --git a/website/screens/signUpScreen.js b/website/screens/signUpScreen.js
index 2d61ec1..536a286 100644
--- a/website/screens/signUpScreen.js
+++ b/website/screens/signUpScreen.js
@@ -52,6 +52,11 @@ class SignUpScreen {
false,"#000",
"#00ff00","Sign Up"
),
+ new Button(0,0,100,30,0,true,"#fff",false,"#000","#000","Sign Up"),
+ new Button(110,0,100,30,0,true,"#fff",false,"#000","#000","Login"),
+ new Button(220,0,100,30,0,true,"#fff",false,"#000","#000","Logout"),
+ new Button(330,0,100,30,0,true,"#fff",false,"#000","#000","Profile"),
+ new Button(330,0,100,30,0,true,"#fff",false,"#000","#000","Test"),
]
this.activeTextBox = 0
@@ -72,6 +77,7 @@ class SignUpScreen {
this.textboxes[i].draw();
}
+ fill("#000");
text("Username", 110, 175);
text("Password", 110, 325);
@@ -86,6 +92,23 @@ class SignUpScreen {
)
screenManager.setScreen(new StartScreen());
}
+
+ this.buttons[3].draw();
+ this.buttons[4].draw();
+ this.buttons[5].draw();
+ this.buttons[6].draw();
+ this.buttons[7].draw();
+ if (this.buttons[3].isPressed()) {
+ screenManager.setScreen(new SignUpScreen());
+ } else if (this.buttons[4].isPressed()) {
+ screenManager.setScreen(new LoginScreen());
+ } else if (this.buttons[5].isPressed()) {
+ api.logout();
+ } else if (this.buttons[6].isPressed()) {
+ screenManager.setScreen(new ProfileScreen());
+ } else if (this.buttons[7].isPressed()) {
+ screenManager.setScreen(new TestScreen())
+ }
}
/**
diff --git a/website/screens/startscreen.js b/website/screens/startscreen.js
index d9593e4..3fd9cb5 100644
--- a/website/screens/startscreen.js
+++ b/website/screens/startscreen.js
@@ -4,6 +4,7 @@ class StartScreen {
new Button(0,0,100,30,0,true,"#fff",false,"#000","#000","Sign Up"),
new Button(110,0,100,30,0,true,"#fff",false,"#000","#000","Login"),
new Button(220,0,100,30,0,true,"#fff",false,"#000","#000","Logout"),
+ new Button(330,0,100,30,0,true,"#fff",false,"#000","#000","Profile")
]
}
@@ -16,13 +17,16 @@ class StartScreen {
this.buttons[0].draw();
this.buttons[1].draw();
this.buttons[2].draw();
+ this.buttons[3].draw();
if (this.buttons[0].isPressed()) {
screenManager.setScreen(new SignUpScreen());
} else if (this.buttons[1].isPressed()) {
screenManager.setScreen(new LoginScreen());
} else if (this.buttons[2].isPressed()) {
api.logout();
- }
+ } else if (this.buttons[3].isPressed()) {
+ screenManager.setScreen(new ProfileScreen());
+ }
fill("#000");
text(`${user.username}`, windowWidth-100, 15);
}
diff --git a/website/ui_elements/textbox.js b/website/ui_elements/textbox.js
index 1e2d2f7..5746688 100644
--- a/website/ui_elements/textbox.js
+++ b/website/ui_elements/textbox.js
@@ -183,8 +183,6 @@ class Textbox {
fill(this.textColor);
textSize(23);
textAlign(LEFT);
- // font needs to be monospaced for outputting text to the screen like I do
- textFont('monospace');
// these variables allow me to use the values of x and y while updating them
let i = this.x;