basic orange website
This commit is contained in:
parent
f9581e9b3f
commit
2285ac71b5
@ -7,7 +7,11 @@
|
||||
<title>Document</title>
|
||||
|
||||
<!-- Main Script Files -->
|
||||
<script src="./index.js" type="text/javascript" defer="true"></script>
|
||||
<script src="./lib/p5.js"></script>
|
||||
<script src="./index.js" type="text/javascript"></script>
|
||||
|
||||
<!-- Element Script Files -->
|
||||
<script src="./ui_elements/canvas.js"></script>
|
||||
|
||||
<!-- API Script Files -->
|
||||
</head>
|
||||
|
@ -1,22 +1,17 @@
|
||||
const url = "http://localhost:8000/api/post_test/"
|
||||
const data = {
|
||||
test_type: "words",
|
||||
test_length: 500,
|
||||
test_time: 100,
|
||||
test_seed: 123040004,
|
||||
quote_id: 0,
|
||||
wpm: 60,
|
||||
accuracy: 100,
|
||||
user_id: 0
|
||||
let canvas;
|
||||
function setup() {
|
||||
// Creating the canvas
|
||||
canvas = new Canvas();
|
||||
canvas.resize();
|
||||
canvas.center();
|
||||
}
|
||||
const xhr = new XMLHttpRequest();
|
||||
const button = document.getElementById("button");
|
||||
|
||||
button.addEventListener("click", (e) => {
|
||||
send();
|
||||
});
|
||||
|
||||
function send() {
|
||||
xhr.open("POST", url);
|
||||
xhr.send(JSON.stringify(data));
|
||||
function draw() {
|
||||
background(255,100,100);
|
||||
}
|
||||
|
||||
|
||||
function windowResized() {
|
||||
canvas.resize();
|
||||
canvas.center();
|
||||
}
|
21
website/ui_elements/canvas.js
Normal file
21
website/ui_elements/canvas.js
Normal file
@ -0,0 +1,21 @@
|
||||
class Canvas {
|
||||
constructor() {
|
||||
this.x = 0;
|
||||
this.y = 0;
|
||||
this.canvas = createCanvas(0, 0);
|
||||
}
|
||||
|
||||
|
||||
center() {
|
||||
this.canvas.position(this.x, this.y);
|
||||
}
|
||||
|
||||
|
||||
resize() {
|
||||
this.canvas.resize(windowWidth, windowHeight);
|
||||
}
|
||||
|
||||
disable() {
|
||||
this.canvas.resize(0, 0);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user