diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..6f3a291 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "liveServer.settings.port": 5501 +} \ No newline at end of file diff --git a/README.md b/README.md index e310f55..05f9554 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -# pwa-quizz-game \ No newline at end of file +# pwa-quizz-game diff --git a/index.html b/index.html index dc30e5f..191c7d2 100644 --- a/index.html +++ b/index.html @@ -7,6 +7,10 @@ Document - +

hej

+ +

+ + diff --git a/js/AnswerButton.js b/js/AnswerButton.js index 35a6f77..7854285 100644 --- a/js/AnswerButton.js +++ b/js/AnswerButton.js @@ -1,3 +1 @@ -class AnswerBuron{ - -} \ No newline at end of file +class AnswerBuron {} diff --git a/js/Authentication.js b/js/Authentication.js index 49572d6..375d725 100644 --- a/js/Authentication.js +++ b/js/Authentication.js @@ -1,3 +1 @@ -class Authentication{ - -} \ No newline at end of file +class Authentication {} diff --git a/js/DataBase.js b/js/DataBase.js new file mode 100644 index 0000000..917b957 --- /dev/null +++ b/js/DataBase.js @@ -0,0 +1,27 @@ +import { createClient } from 'https://esm.sh/@supabase/supabase-js@2' + +class DataBase { + constructor() { + this.supabase = createClient( + "https://unswumzybkmeifdigbfn.supabase.co", + "KEY", + ); + + } + async GetARowFrow(table, idToRow) { + try { + const { data, error } = await this.supabase + .from(table) + .select() + .eq('id', idToRow); + console.log(table, data); + return data; + } + catch (e) { + console.log("An Error has occured: " + event); + } + + } +} + +export default DataBase; \ No newline at end of file diff --git a/js/NavigationBar.js b/js/NavigationBar.js index 512efc4..ff9009d 100644 --- a/js/NavigationBar.js +++ b/js/NavigationBar.js @@ -1 +1 @@ -class NavigationBar{} \ No newline at end of file +class NavigationBar {} diff --git a/js/ProfileSettings.js b/js/ProfileSettings.js index eaf833d..1ed2d15 100644 --- a/js/ProfileSettings.js +++ b/js/ProfileSettings.js @@ -1,3 +1 @@ -class ProfileSettings{ - -} \ No newline at end of file +class ProfileSettings {} diff --git a/js/Question.js b/js/Question.js index e12cce7..e943f7e 100644 --- a/js/Question.js +++ b/js/Question.js @@ -1,3 +1 @@ -class Question{ - -} \ No newline at end of file +class Question {} diff --git a/js/ServiceWorker.js b/js/ServiceWorker.js index aeb1959..7dcb9b5 100644 --- a/js/ServiceWorker.js +++ b/js/ServiceWorker.js @@ -1,4 +1 @@ -class ServiceWorker{ - -} - +class ServiceWorker {} diff --git a/js/Settings.js b/js/Settings.js index 9e04d77..0d648b5 100644 --- a/js/Settings.js +++ b/js/Settings.js @@ -1 +1 @@ -class Settings{} \ No newline at end of file +class Settings {} diff --git a/js/main.js b/js/main.js index 9f8ce40..18ce3ee 100644 --- a/js/main.js +++ b/js/main.js @@ -1,12 +1,35 @@ -class Main{ - RegisterServiceWorker() { - if('serviceWorker' in navigator) { - navigator.serviceWorker.register('./js/ServiceWorker.js').then((reg) => { - console.log('Registration succeeded. Scope is ' + reg.scope); - }); - } +import DataBase from "./DataBase.js"; + +class Main { + constructor() { + this.dataBase = new DataBase(); + this.btnDBRequest = document.getElementById("btnDBRequest"); + this.displayData = document.getElementById("dBData"); + } + RegisterServiceWorker() { + if ("serviceWorker" in navigator) { + navigator.serviceWorker.register("./js/ServiceWorker.js").then((reg) => { + console.log("Registration succeeded. Scope is " + reg.scope); + }); } + } + Main() { + this.RegisterServiceWorker(); + + this.btnDBRequest.addEventListener("click", async () => { + const DBData = await this.dataBase.GetARowFrow('quizz', 1); + + DBData.map(data => { + this.displayData.innerHTML = data.questions; + }); + }); + + } } + + + + const main = new Main(); -main.RegisterServiceWorker(); \ No newline at end of file +main.Main(); diff --git a/manifest.json b/manifest.json index ad227fd..2b11583 100644 --- a/manifest.json +++ b/manifest.json @@ -1 +1,25 @@ -{"theme_color":"#26a269","background_color":"#8ff0a4","icons":[{"purpose":"maskable","sizes":"512x512","src":"icon512_maskable.png","type":"image/png"},{"purpose":"any","sizes":"512x512","src":"icon512_rounded.png","type":"image/png"}],"orientation":"any","display":"standalone","dir":"auto","lang":"en-US","name":"Quizz Game","short_name":"QG","start_url":"https://joelberglund05.github.io/pwa-quizz-game/"} +{ + "theme_color": "#26a269", + "background_color": "#8ff0a4", + "icons": [ + { + "purpose": "maskable", + "sizes": "512x512", + "src": "icon512_maskable.png", + "type": "image/png" + }, + { + "purpose": "any", + "sizes": "512x512", + "src": "icon512_rounded.png", + "type": "image/png" + } + ], + "orientation": "any", + "display": "standalone", + "dir": "auto", + "lang": "en-US", + "name": "Quizz Game", + "short_name": "QG", + "start_url": "https://joelberglund05.github.io/pwa-quizz-game/" +} diff --git a/package-lock.json b/package-lock.json index 4450bed..36fb8b0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,7 +4,9 @@ "requires": true, "packages": { "": { + "name": "pwa-quizz-game", "dependencies": { + "@supabase/supabase-js": "^2.45.6", "prettier": "^3.3.3", "sass": "^1.80.3" } @@ -269,6 +271,94 @@ "url": "https://opencollective.com/parcel" } }, + "node_modules/@supabase/auth-js": { + "version": "2.65.1", + "resolved": "https://registry.npmjs.org/@supabase/auth-js/-/auth-js-2.65.1.tgz", + "integrity": "sha512-IA7i2Xq2SWNCNMKxwmPlHafBQda0qtnFr8QnyyBr+KaSxoXXqEzFCnQ1dGTy6bsZjVBgXu++o3qrDypTspaAPw==", + "dependencies": { + "@supabase/node-fetch": "^2.6.14" + } + }, + "node_modules/@supabase/functions-js": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/@supabase/functions-js/-/functions-js-2.4.3.tgz", + "integrity": "sha512-sOLXy+mWRyu4LLv1onYydq+10mNRQ4rzqQxNhbrKLTLTcdcmS9hbWif0bGz/NavmiQfPs4ZcmQJp4WqOXlR4AQ==", + "dependencies": { + "@supabase/node-fetch": "^2.6.14" + } + }, + "node_modules/@supabase/node-fetch": { + "version": "2.6.15", + "resolved": "https://registry.npmjs.org/@supabase/node-fetch/-/node-fetch-2.6.15.tgz", + "integrity": "sha512-1ibVeYUacxWYi9i0cf5efil6adJ9WRyZBLivgjs+AUpewx1F3xPi7gLgaASI2SmIQxPoCEjAsLAzKPgMJVgOUQ==", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + } + }, + "node_modules/@supabase/postgrest-js": { + "version": "1.16.3", + "resolved": "https://registry.npmjs.org/@supabase/postgrest-js/-/postgrest-js-1.16.3.tgz", + "integrity": "sha512-HI6dsbW68AKlOPofUjDTaosiDBCtW4XAm0D18pPwxoW3zKOE2Ru13Z69Wuys9fd6iTpfDViNco5sgrtnP0666A==", + "dependencies": { + "@supabase/node-fetch": "^2.6.14" + } + }, + "node_modules/@supabase/realtime-js": { + "version": "2.10.7", + "resolved": "https://registry.npmjs.org/@supabase/realtime-js/-/realtime-js-2.10.7.tgz", + "integrity": "sha512-OLI0hiSAqQSqRpGMTUwoIWo51eUivSYlaNBgxsXZE7PSoWh12wPRdVt0psUMaUzEonSB85K21wGc7W5jHnT6uA==", + "dependencies": { + "@supabase/node-fetch": "^2.6.14", + "@types/phoenix": "^1.5.4", + "@types/ws": "^8.5.10", + "ws": "^8.14.2" + } + }, + "node_modules/@supabase/storage-js": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/@supabase/storage-js/-/storage-js-2.7.1.tgz", + "integrity": "sha512-asYHcyDR1fKqrMpytAS1zjyEfvxuOIp1CIXX7ji4lHHcJKqyk+sLl/Vxgm4sN6u8zvuUtae9e4kDxQP2qrwWBA==", + "dependencies": { + "@supabase/node-fetch": "^2.6.14" + } + }, + "node_modules/@supabase/supabase-js": { + "version": "2.45.6", + "resolved": "https://registry.npmjs.org/@supabase/supabase-js/-/supabase-js-2.45.6.tgz", + "integrity": "sha512-qVXSSUhhIqdFnF2VUGgeecPvw1cDW6+avcTbRgur4LaGnzrJCbM3Rx7g81/SSZjjeqYOtmHuKWhiHzV/EN8Ktw==", + "dependencies": { + "@supabase/auth-js": "2.65.1", + "@supabase/functions-js": "2.4.3", + "@supabase/node-fetch": "2.6.15", + "@supabase/postgrest-js": "1.16.3", + "@supabase/realtime-js": "2.10.7", + "@supabase/storage-js": "2.7.1" + } + }, + "node_modules/@types/node": { + "version": "22.7.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.7.9.tgz", + "integrity": "sha512-jrTfRC7FM6nChvU7X2KqcrgquofrWLFDeYC1hKfwNWomVvrn7JIksqf344WN2X/y8xrgqBd2dJATZV4GbatBfg==", + "dependencies": { + "undici-types": "~6.19.2" + } + }, + "node_modules/@types/phoenix": { + "version": "1.6.5", + "resolved": "https://registry.npmjs.org/@types/phoenix/-/phoenix-1.6.5.tgz", + "integrity": "sha512-xegpDuR+z0UqG9fwHqNoy3rI7JDlvaPh2TY47Fl80oq6g+hXT+c/LEuE43X48clZ6lOfANl5WrPur9fYO1RJ/w==" + }, + "node_modules/@types/ws": { + "version": "8.5.12", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.12.tgz", + "integrity": "sha512-3tPRkv1EtkDpzlgyKyI8pGsGZAGPEaXeu0DOj5DI25Ja91bdAYddYHbADRYVrZMRbfW+1l5YwXVDKohDJNQxkQ==", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/braces": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", @@ -437,6 +527,50 @@ "engines": { "node": ">=8.0" } + }, + "node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" + }, + "node_modules/undici-types": { + "version": "6.19.8", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", + "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==" + }, + "node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" + }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, + "node_modules/ws": { + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz", + "integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } } } } diff --git a/package.json b/package.json index 17880cc..63c6d11 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "prettier": "prettier . --write" }, "dependencies": { + "@supabase/supabase-js": "^2.45.6", "prettier": "^3.3.3", "sass": "^1.80.3" }