basic orange website

This commit is contained in:
Arlo Filley 2022-09-29 15:11:33 +01:00
parent f9581e9b3f
commit 2285ac71b5
3 changed files with 39 additions and 19 deletions

View File

@ -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>

View File

@ -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 draw() {
background(255,100,100);
}
function send() {
xhr.open("POST", url);
xhr.send(JSON.stringify(data));
function windowResized() {
canvas.resize();
canvas.center();
}

View 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);
}
}