CS-Coursework/website/screens/profilescreen.js

42 lines
1.2 KiB
JavaScript
Raw Normal View History

2022-11-28 11:04:49 +00:00
/**
* @file This file provides the user with their profilescreen, where they can see their own tests
* @author Arlo Filley
*
* TODO:
* - change button name
* - provide filters for tests
* - implement a way to scroll through tests
* - create a way to have personal bests and track them
* - store tests in localstorage.
* - show user tests even if they are not logged in
*/
/**
* This class displays all of the test data for a given user
*/
2022-11-17 11:48:12 +00:00
class ProfileScreen {
constructor() {
2022-11-18 14:51:05 +00:00
this.menu = new Menu();
2022-11-17 11:48:12 +00:00
api.getUserTests();
}
draw() {
background("#eeeee4");
textSize(100);
textAlign(CENTER, CENTER);
fill("#000");
2022-11-17 12:10:54 +00:00
text("Profile", 0, 100, windowWidth, 120);
2022-11-18 11:33:25 +00:00
2022-11-18 14:51:05 +00:00
this.menu.draw();
2022-11-17 11:48:12 +00:00
textSize(20);
fill("#000");
if (user.tests != undefined) {
for (let i = 0; i < user.tests.length; i++) {
2022-11-18 14:51:05 +00:00
text(`Test ${i+1}: ${user.tests[i].wpm}wpm | Characters Typed: ${user.tests[i].test_length}`, 0, i*30+300, windowWidth, 30);
2022-11-17 11:48:12 +00:00
}
}
fill("#000");
2022-11-18 12:27:54 +00:00
text(`Logged in as ${user.username}`, windowWidth-400, 15);
2022-11-17 11:48:12 +00:00
}
}