From 5a691023b1b2ea645179f05976c0171510d19e74 Mon Sep 17 00:00:00 2001 From: sam Date: Tue, 9 Jan 2024 13:42:03 +0100 Subject: [PATCH] code cleanup --- web/game.js | 20 -------------------- web/index.html | 1 + web/js/Database.js | 20 ++++++++++++++++++++ 3 files changed, 21 insertions(+), 20 deletions(-) create mode 100644 web/js/Database.js diff --git a/web/game.js b/web/game.js index f4c0b35..9a5f78a 100644 --- a/web/game.js +++ b/web/game.js @@ -710,23 +710,3 @@ function game() { } } - -function sendData(naam, score) { - const request = ( url, params = {}) => { - url += '?' + ( new URLSearchParams( params ) ).toString(); - fetch( url ); -}; - const get = ( url, params ) => request( url, params); - - get('https://oege.ie.hva.nl/~hossan/postData.php', { name: naam, score: score } ); - -} - -function getData(){ - // Fetch data from the database, put it in an array, and log it to the console - return fetch ('https://oege.ie.hva.nl/~hossan/getData.php') // Add return here - .then(response => response.json()) - .then(data => { - requesteddata = data; - }); -} diff --git a/web/index.html b/web/index.html index 59ae5bd..3934d4d 100644 --- a/web/index.html +++ b/web/index.html @@ -9,6 +9,7 @@ + diff --git a/web/js/Database.js b/web/js/Database.js new file mode 100644 index 0000000..c46eb7c --- /dev/null +++ b/web/js/Database.js @@ -0,0 +1,20 @@ + +function sendData(naam, score) { + const request = ( url, params = {}) => { + url += '?' + ( new URLSearchParams( params ) ).toString(); + fetch( url ); +}; + const get = ( url, params ) => request( url, params); + + get('https://oege.ie.hva.nl/~hossan/postData.php', { name: naam, score: score } ); + +} + +function getData(){ + // Fetch data from the database, put it in an array, and log it to the console + return fetch ('https://oege.ie.hva.nl/~hossan/getData.php') // Add return here + .then(response => response.json()) + .then(data => { + requesteddata = data; + }); +}