iteration 3
This commit is contained in:
parent
445344061c
commit
ed6830b39a
@ -286,7 +286,7 @@ class API {
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', `${this.url}get_test/`);
|
||||
xhr.send();
|
||||
xhr.onload = () => {
|
||||
xhr.onload = () =>{
|
||||
const effectiveWidth = (windowWidth - 200) / 13;
|
||||
let textArr = JSON.parse(xhr.response);
|
||||
let finalText = [];
|
||||
|
@ -84,8 +84,8 @@ class ProfileScreen {
|
||||
for (let i = user.tests.length-1-offset; i >= user.tests.length-13-offset && i >= 0; i--) {
|
||||
this.testButtons.push([
|
||||
new Button(400, j, 100, 30, `${i+1}`, true, true , "#000", "#000", "#fff"), // test # button
|
||||
new Button(500, j, 100, 30, `${user.tests[i].accuracy}`, true, true , "#000", "#000", "#fff"), // accuracy button
|
||||
new Button(600, j, 100, 30, `${user.tests[i].wpm}`, true, true , "#000", "#000", "#fff"), // wpm button
|
||||
new Button(500, j, 100, 30, `${user.tests[i].wpm}`, true, true , "#000", "#000", "#fff"), // accuracy button
|
||||
new Button(600, j, 100, 30, `${user.tests[i].accuracy}`, true, true , "#000", "#000", "#fff"), // wpm button
|
||||
new Button(700, j, 240, 30, `${user.tests[i].test_length}`, true, true , "#000", "#000", "#fff")
|
||||
])
|
||||
j+=30;
|
||||
|
@ -45,8 +45,9 @@ class Timer {
|
||||
this.bar = pBar;
|
||||
this.startTime;
|
||||
this.time = pTime;
|
||||
this.timeElapsed;
|
||||
this.timeElapsed = 0;
|
||||
this.ended;
|
||||
this.hasStarted = false;
|
||||
}
|
||||
|
||||
getX() {
|
||||
@ -153,6 +154,7 @@ class Timer {
|
||||
// I am using the amount of frames passed to calculate the time, assuming that the website is running at 60q frames
|
||||
// per second
|
||||
this.timeElapsed = 0;
|
||||
this.hasStarted = true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -201,12 +203,20 @@ class Timer {
|
||||
// draws a bar that move across the screen to show the time left
|
||||
if (this.bar) {
|
||||
fill(user.colorScheme.timerBar);
|
||||
rect(this.y, this.x, windowWidth - windowWidth * (this.timeElapsed / this.time), this.height);
|
||||
if (this.hasStarted) {
|
||||
rect(this.y, this.x, windowWidth - windowWidth * (this.timeElapsed / this.time), this.height);
|
||||
} else {
|
||||
rect(this.y, this.x, windowWidth, this.height);
|
||||
}
|
||||
}
|
||||
|
||||
// draws the text in the corner of the screen
|
||||
noStroke();
|
||||
fill(user.colorScheme.timerText);
|
||||
text(Math.ceil(this.time - this.timeElapsed), this.x + this.width / 6, this.y + this.height / 2)
|
||||
if (this.hasStarted) {
|
||||
text(Math.ceil(this.time - this.timeElapsed), this.x + this.width / 6, this.y + this.height / 2);
|
||||
} else {
|
||||
text("Type A Letter To Start", this.x + this.width / 6, this.y + this.height / 2);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user