├── Age - Wizard
├── assets
│ └── AgeWizard.jpg
├── index.html
└── style.css
├── Calculator_Wizard
├── favicon_io
│ ├── about.txt
│ ├── android-chrome-192x192.png
│ ├── android-chrome-512x512.png
│ ├── apple-touch-icon.png
│ ├── favicon-16x16.png
│ ├── favicon-32x32.png
│ ├── favicon.ico
│ └── site.webmanifest
├── index.html
├── script.js
└── style.css
├── LICENSE
├── Quiz Web App
├── 1. Create Home Page and Application Styling
│ ├── app.css
│ └── index.html
├── 10. Fetch Questions from Local JSON File
│ ├── app.css
│ ├── end.html
│ ├── end.js
│ ├── game.css
│ ├── game.html
│ ├── game.js
│ ├── highscores.css
│ ├── highscores.html
│ ├── highscores.js
│ ├── index.html
│ └── questions.json
├── 11. Fetch API Questions from Open Trivia API
│ ├── app.css
│ ├── end.html
│ ├── end.js
│ ├── game.css
│ ├── game.html
│ ├── game.js
│ ├── highscores.css
│ ├── highscores.html
│ ├── highscores.js
│ ├── index.html
│ └── questions.json
├── 12. Create a Spinning Loader
│ ├── app.css
│ ├── end.html
│ ├── end.js
│ ├── game.css
│ ├── game.html
│ ├── game.js
│ ├── highscores.css
│ ├── highscores.html
│ ├── highscores.js
│ ├── index.html
│ └── questions.json
├── 2. Create and Style the Game Page
│ ├── app.css
│ ├── game.css
│ ├── game.html
│ └── index.html
├── 3. Display Hard Coded Question and Answers
│ ├── app.css
│ ├── game.css
│ ├── game.html
│ ├── game.js
│ └── index.html
├── 4. Display Feedback for Correct and Incorrect Answers
│ ├── app.css
│ ├── game.css
│ ├── game.html
│ ├── game.js
│ └── index.html
├── 5. Create a Head's Up Display
│ ├── app.css
│ ├── game.css
│ ├── game.html
│ ├── game.js
│ └── index.html
├── 6. Create a Progress Bar
│ ├── app.css
│ ├── game.css
│ ├── game.html
│ ├── game.js
│ └── index.html
├── 7. Create and Style the End Page
│ ├── app.css
│ ├── end.html
│ ├── end.js
│ ├── game.css
│ ├── game.html
│ ├── game.js
│ └── index.html
├── 8. Save High Scores in Local Storage
│ ├── app.css
│ ├── end.html
│ ├── end.js
│ ├── game.css
│ ├── game.html
│ ├── game.js
│ └── index.html
├── 9. Load and Display High Scores from Local Storage
│ ├── app.css
│ ├── end.html
│ ├── end.js
│ ├── game.css
│ ├── game.html
│ ├── game.js
│ ├── highscores.css
│ ├── highscores.html
│ ├── highscores.js
│ └── index.html
├── LICENSE
├── Quiz Qhiz Master
│ ├── app.css
│ ├── assets
│ │ ├── Congo.jpg
│ │ ├── logo.jpg
│ │ └── play.jpg
│ ├── end.html
│ ├── end.js
│ ├── game.css
│ ├── game.html
│ ├── game.js
│ ├── highscores.css
│ ├── highscores.html
│ ├── highscores.js
│ ├── index.html
│ └── questions.json
├── README.md
└── images
│ └── quizzify.png
├── ReadMe.md
├── Resume_Wizard
├── assets
│ ├── android-chrome-192x192.png
│ ├── android-chrome-512x512.png
│ ├── apple-touch-icon.png
│ ├── default-logo.png
│ ├── favicon-16x16.png
│ ├── favicon-32x32.png
│ └── favicon.ico
├── index.html
├── index.js
├── index.php
├── myfile.pdf
└── styles.css
├── Starbucks_Landing_Page
├── assets
│ ├── Favicon.png
│ ├── facebook.png
│ ├── img1.png
│ ├── img2.png
│ ├── img3.png
│ ├── instagram.png
│ ├── logo.png
│ ├── thumb1.png
│ ├── thumb2.png
│ ├── thumb3.png
│ └── twitter.png
├── index.html
├── script.js
└── style.css
├── Temperature Wizard
├── images
│ └── favicon.ico
├── index.html
├── script.js
└── style.css
├── To_Do_Express
├── 4697260.png
├── android-chrome-192x192.png
├── android-chrome-512x512.png
├── apple-touch-icon.png
├── favicon-16x16.png
├── favicon-32x32.png
├── favicon.ico
├── index.html
├── script.js
├── site.webmanifest
└── style.css
└── Tribute_Page_For_Atal_Bihar_Vajpaayee
├── favicon
├── android-chrome-192x192.png
├── android-chrome-512x512.png
├── apple-touch-icon.png
├── favicon-16x16.png
├── favicon-32x32.png
├── favicon.ico
└── site.webmanifest
├── images
├── atal-bihari-vajpayee-png-images-thumbnail-1640366759-removebg-preview.png
└── atal-bihari-vajpayee-png-images-thumbnail-1640366759.jpg
├── index.html
└── style.css
/Age - Wizard/assets/AgeWizard.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Alok-2002/web_development_project/454d34561e93c7a8e05a22baaea597f28d2a55af/Age - Wizard/assets/AgeWizard.jpg
--------------------------------------------------------------------------------
/Age - Wizard/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Age Wizard - An Age Calculator
8 |
9 |
10 |
11 |
12 |
13 |
14 |
Age Wizard
15 |
16 |
17 |
18 |
19 | Calculate Age
20 |
21 |
22 |
23 |
24 |
25 |
75 |
76 |
--------------------------------------------------------------------------------
/Age - Wizard/style.css:
--------------------------------------------------------------------------------
1 | * {
2 | margin: 0;
3 | padding: 0;
4 | font-family: 'Poppins', sans-serif;
5 | box-sizing: border-box;
6 | }
7 |
8 | .container {
9 | width: 100%;
10 | min-height: 100vh;
11 | background: linear-gradient(135deg, #4203a9, #90bafc);
12 | color: #ffff76;
13 | padding: 10px;
14 | }
15 |
16 | .calculator {
17 | width: 100%;
18 | max-width: 600px;
19 | margin: 10% auto;
20 | }
21 |
22 | .calculator h1 {
23 | font-size: 60px;
24 | }
25 |
26 | .input-box {
27 | background: rgba(255, 255, 255, 0.3);
28 | border-radius: 10px;
29 | margin: 40px 0;
30 | padding: 35px;
31 | display: flex;
32 | align-items: center;
33 | }
34 |
35 | .input-box input {
36 | flex: 1;
37 | margin-right: 20px;
38 | padding: 14px 20px;
39 | border: 0;
40 | outline: 0;
41 | font-size: 18px;
42 | border-radius: 5px;
43 | position: relative;
44 | }
45 |
46 | .input-box button {
47 | background: #ffff76;
48 | border: 0;
49 | outline: 0;
50 | padding: 15px 30px;
51 | border-radius: 5px;
52 | font-weight: bold;
53 | color: #333;
54 | cursor: pointer;
55 | transition: background-color 0.3s;
56 | }
57 |
58 | .input-box button:hover {
59 | background-color: #ffd700;
60 | }
61 |
62 | .input-box input::-webkit-calendar-picker-indicator {
63 | top: 0;
64 | left: 0;
65 | right: 0;
66 | bottom: 0;
67 | width: auto;
68 | height: auto;
69 | position: absolute;
70 | background-position: calc(100% - 10px);
71 | background-size: 30px;
72 | cursor: pointer;
73 | }
74 |
75 | #result {
76 | font: 20px;
77 | }
78 |
79 | #result span {
80 | color: #ffff76;
81 | }
82 |
83 | /* Media Queries */
84 |
85 | @media only screen and (max-width: 600px) {
86 | .calculator {
87 | margin: 20% auto;
88 | }
89 |
90 | .calculator h1 {
91 | font-size: 40px;
92 | }
93 |
94 | .input-box {
95 | flex-direction: column;
96 | align-items: flex-start;
97 | padding: 20px;
98 | }
99 |
100 | .input-box input {
101 | margin-bottom: 20px;
102 | }
103 |
104 | .input-box button {
105 | width: 100%;
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/Calculator_Wizard/favicon_io/about.txt:
--------------------------------------------------------------------------------
1 | This favicon was generated using the following font:
2 |
3 | - Font Title: Laila
4 | - Font Author: Copyright (c) 2014 Indian Type Foundry (info@indiantypefoundry.com)
5 | - Font Source: http://fonts.gstatic.com/s/laila/v13/LYjMdG_8nE8jDIRdiidIrEIu.ttf
6 | - Font License: SIL Open Font License, 1.1 (http://scripts.sil.org/OFL))
7 |
--------------------------------------------------------------------------------
/Calculator_Wizard/favicon_io/android-chrome-192x192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Alok-2002/web_development_project/454d34561e93c7a8e05a22baaea597f28d2a55af/Calculator_Wizard/favicon_io/android-chrome-192x192.png
--------------------------------------------------------------------------------
/Calculator_Wizard/favicon_io/android-chrome-512x512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Alok-2002/web_development_project/454d34561e93c7a8e05a22baaea597f28d2a55af/Calculator_Wizard/favicon_io/android-chrome-512x512.png
--------------------------------------------------------------------------------
/Calculator_Wizard/favicon_io/apple-touch-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Alok-2002/web_development_project/454d34561e93c7a8e05a22baaea597f28d2a55af/Calculator_Wizard/favicon_io/apple-touch-icon.png
--------------------------------------------------------------------------------
/Calculator_Wizard/favicon_io/favicon-16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Alok-2002/web_development_project/454d34561e93c7a8e05a22baaea597f28d2a55af/Calculator_Wizard/favicon_io/favicon-16x16.png
--------------------------------------------------------------------------------
/Calculator_Wizard/favicon_io/favicon-32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Alok-2002/web_development_project/454d34561e93c7a8e05a22baaea597f28d2a55af/Calculator_Wizard/favicon_io/favicon-32x32.png
--------------------------------------------------------------------------------
/Calculator_Wizard/favicon_io/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Alok-2002/web_development_project/454d34561e93c7a8e05a22baaea597f28d2a55af/Calculator_Wizard/favicon_io/favicon.ico
--------------------------------------------------------------------------------
/Calculator_Wizard/favicon_io/site.webmanifest:
--------------------------------------------------------------------------------
1 | {"name":"","short_name":"","icons":[{"src":"/android-chrome-192x192.png","sizes":"192x192","type":"image/png"},{"src":"/android-chrome-512x512.png","sizes":"512x512","type":"image/png"}],"theme_color":"#ffffff","background_color":"#ffffff","display":"standalone"}
--------------------------------------------------------------------------------
/Calculator_Wizard/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Calculator-Wizard
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | C
15 | Del
16 | %
17 | /
18 | 7
19 | 8
20 | 9
21 | *
22 | 4
23 | 5
24 | 6
25 | -
26 | 1
27 | 2
28 | 3
29 | +
30 | .
31 | 0
32 | =
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/Calculator_Wizard/script.js:
--------------------------------------------------------------------------------
1 | let outputScreen = document.getElementById('output-Screen')
2 |
3 | function display(num){
4 | outputScreen.value += num;
5 | }
6 |
7 | function Calculate(){
8 | try{
9 | outputScreen.value =eval(outputScreen.value);
10 | }
11 | catch(err)
12 | {
13 | alert('Invalid')
14 | }
15 | }
16 |
17 | function Clear(){
18 | outputScreen.value = "";
19 | }
20 |
21 | function del(){
22 | outputScreen.value = outputScreen.value.slice(0, -1);
23 | }
--------------------------------------------------------------------------------
/Calculator_Wizard/style.css:
--------------------------------------------------------------------------------
1 | *{
2 | margin: 0;
3 | padding: 0;
4 | box-sizing: border-box;
5 | background-color: #ecf0f3;
6 | font-family: sans-serif;
7 | outline: none;
8 |
9 | }
10 |
11 | .container{
12 | height: 100vh;
13 | display: flex;
14 | justify-content: center;
15 | align-items: center;
16 |
17 | }
18 |
19 | .calculator{
20 | background-color: #ecf0f3;
21 | padding: 15px;
22 | border-radius: 30px;
23 | box-shadow: inset 5px 5px 12px #ffffff, 5px 5px 12px rgba(0, 0, 0,.16);
24 | display: grid;
25 | grid-template-columns: repeat(4, 68px);
26 | }
27 |
28 | input{
29 | grid-column: span 4;
30 | height: 70px;
31 | width: 260px;
32 | background-color: #ecf0f3;
33 | box-shadow: inset -5px -5px 12px #ffffff,
34 | inset 5px 5px 12px rgba(0, 0, 0,.16);
35 | border:none;
36 | border-radius:30px;
37 | color: rgb(70, 70, 70);
38 | font-size: 50px;
39 | text-align: end;
40 | margin: auto;
41 | margin-top: 40px;
42 | margin-bottom: 30px;
43 | padding: 20px;
44 | }
45 |
46 | button{
47 | height: 48px;
48 | width: 48px;
49 | background-color: #ecf0f3;
50 | box-shadow: -5px -5px 12px #ffffff,
51 | 5px 5px 12px rgba(0, 0, 0,.16);
52 | border: none;
53 | border-radius: 50%;
54 | margin: 8px;
55 | font-size: 16px;
56 | }
57 |
58 | .equal{
59 | width: 115px;
60 | border-radius: 40px;
61 | background-color: #ecf0f3;
62 | box-shadow: -5px -5px 12px #ffffff,
63 | 5px 5px 12px rgba(0, 0, 0,.16);;
64 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Alok Sharma
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Quiz Web App/1. Create Home Page and Application Styling/app.css:
--------------------------------------------------------------------------------
1 | :root {
2 | background-color: #ecf5ff;
3 | font-size: 62.5%;
4 | }
5 |
6 | * {
7 | box-sizing: border-box;
8 | font-family: Arial, Helvetica, sans-serif;
9 | margin: 0;
10 | padding: 0;
11 | color: #333;
12 | }
13 |
14 | h1,
15 | h2,
16 | h3,
17 | h4 {
18 | margin-bottom: 1rem;
19 | }
20 |
21 | h1 {
22 | font-size: 5.4rem;
23 | color: #56a5eb;
24 | margin-bottom: 5rem;
25 | }
26 |
27 | h1 > span {
28 | font-size: 2.4rem;
29 | font-weight: 500;
30 | }
31 |
32 | h2 {
33 | font-size: 4.2rem;
34 | margin-bottom: 4rem;
35 | font-weight: 700;
36 | }
37 |
38 | h3 {
39 | font-size: 2.8rem;
40 | font-weight: 500;
41 | }
42 |
43 | /* UTILITIES */
44 |
45 | .container {
46 | width: 100vw;
47 | height: 100vh;
48 | display: flex;
49 | justify-content: center;
50 | align-items: center;
51 | max-width: 80rem;
52 | margin: 0 auto;
53 | }
54 |
55 | .container > * {
56 | width: 100%;
57 | }
58 |
59 | .flex-column {
60 | display: flex;
61 | flex-direction: column;
62 | }
63 |
64 | .flex-center {
65 | justify-content: center;
66 | align-items: center;
67 | }
68 |
69 | .justify-center {
70 | justify-content: center;
71 | }
72 |
73 | .text-center {
74 | text-align: center;
75 | }
76 |
77 | .hidden {
78 | display: none;
79 | }
80 |
81 | /* BUTTONS */
82 | .btn {
83 | font-size: 1.8rem;
84 | padding: 1rem 0;
85 | width: 20rem;
86 | text-align: center;
87 | border: 0.1rem solid #56a5eb;
88 | margin-bottom: 1rem;
89 | text-decoration: none;
90 | color: #56a5eb;
91 | background-color: white;
92 | }
93 |
94 | .btn:hover {
95 | cursor: pointer;
96 | box-shadow: 0 0.4rem 1.4rem 0 rgba(86, 185, 235, 0.5);
97 | transform: translateY(-0.1rem);
98 | transition: transform 150ms;
99 | }
100 |
101 | .btn[disabled]:hover {
102 | cursor: not-allowed;
103 | box-shadow: none;
104 | transform: none;
105 | }
106 |
--------------------------------------------------------------------------------
/Quiz Web App/1. Create Home Page and Application Styling/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Quick Quiz
8 |
9 |
10 |
11 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Quiz Web App/10. Fetch Questions from Local JSON File/app.css:
--------------------------------------------------------------------------------
1 | :root {
2 | background-color: #ecf5ff;
3 | font-size: 62.5%;
4 | }
5 |
6 | * {
7 | box-sizing: border-box;
8 | font-family: Arial, Helvetica, sans-serif;
9 | margin: 0;
10 | padding: 0;
11 | color: #333;
12 | }
13 |
14 | h1,
15 | h2,
16 | h3,
17 | h4 {
18 | margin-bottom: 1rem;
19 | }
20 |
21 | h1 {
22 | font-size: 5.4rem;
23 | color: #56a5eb;
24 | margin-bottom: 5rem;
25 | }
26 |
27 | h1 > span {
28 | font-size: 2.4rem;
29 | font-weight: 500;
30 | }
31 |
32 | h2 {
33 | font-size: 4.2rem;
34 | margin-bottom: 4rem;
35 | font-weight: 700;
36 | }
37 |
38 | h3 {
39 | font-size: 2.8rem;
40 | font-weight: 500;
41 | }
42 |
43 | /* UTILITIES */
44 |
45 | .container {
46 | width: 100vw;
47 | height: 100vh;
48 | display: flex;
49 | justify-content: center;
50 | align-items: center;
51 | max-width: 80rem;
52 | margin: 0 auto;
53 | padding: 2rem;
54 | }
55 |
56 | .container > * {
57 | width: 100%;
58 | }
59 |
60 | .flex-column {
61 | display: flex;
62 | flex-direction: column;
63 | }
64 |
65 | .flex-center {
66 | justify-content: center;
67 | align-items: center;
68 | }
69 |
70 | .justify-center {
71 | justify-content: center;
72 | }
73 |
74 | .text-center {
75 | text-align: center;
76 | }
77 |
78 | .hidden {
79 | display: none;
80 | }
81 |
82 | /* BUTTONS */
83 | .btn {
84 | font-size: 1.8rem;
85 | padding: 1rem 0;
86 | width: 20rem;
87 | text-align: center;
88 | border: 0.1rem solid #56a5eb;
89 | margin-bottom: 1rem;
90 | text-decoration: none;
91 | color: #56a5eb;
92 | background-color: white;
93 | }
94 |
95 | .btn:hover {
96 | cursor: pointer;
97 | box-shadow: 0 0.4rem 1.4rem 0 rgba(86, 185, 235, 0.5);
98 | transform: translateY(-0.1rem);
99 | transition: transform 150ms;
100 | }
101 |
102 | .btn[disabled]:hover {
103 | cursor: not-allowed;
104 | box-shadow: none;
105 | transform: none;
106 | }
107 |
108 | /* FORMS */
109 | form {
110 | width: 100%;
111 | display: flex;
112 | flex-direction: column;
113 | align-items: center;
114 | }
115 |
116 | input {
117 | margin-bottom: 1rem;
118 | width: 20rem;
119 | padding: 1.5rem;
120 | font-size: 1.8rem;
121 | border: none;
122 | box-shadow: 0 0.1rem 1.4rem 0 rgba(86, 185, 235, 0.5);
123 | }
124 |
125 | input::placeholder {
126 | color: #aaa;
127 | }
128 |
--------------------------------------------------------------------------------
/Quiz Web App/10. Fetch Questions from Local JSON File/end.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Congrats!
8 |
9 |
10 |
11 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/Quiz Web App/10. Fetch Questions from Local JSON File/end.js:
--------------------------------------------------------------------------------
1 | const username = document.getElementById('username');
2 | const saveScoreBtn = document.getElementById('saveScoreBtn');
3 | const finalScore = document.getElementById('finalScore');
4 | const mostRecentScore = localStorage.getItem('mostRecentScore');
5 |
6 | const highScores = JSON.parse(localStorage.getItem('highScores')) || [];
7 |
8 | const MAX_HIGH_SCORES = 5;
9 |
10 | finalScore.innerText = mostRecentScore;
11 |
12 | username.addEventListener('keyup', () => {
13 | saveScoreBtn.disabled = !username.value;
14 | });
15 |
16 | saveHighScore = (e) => {
17 | e.preventDefault();
18 |
19 | const score = {
20 | score: mostRecentScore,
21 | name: username.value,
22 | };
23 | highScores.push(score);
24 | highScores.sort((a, b) => b.score - a.score);
25 | highScores.splice(5);
26 |
27 | localStorage.setItem('highScores', JSON.stringify(highScores));
28 | window.location.assign('/');
29 | };
30 |
--------------------------------------------------------------------------------
/Quiz Web App/10. Fetch Questions from Local JSON File/game.css:
--------------------------------------------------------------------------------
1 | .choice-container {
2 | display: flex;
3 | margin-bottom: 0.5rem;
4 | width: 100%;
5 | font-size: 1.8rem;
6 | border: 0.1rem solid rgb(86, 165, 235, 0.25);
7 | background-color: white;
8 | }
9 |
10 | .choice-container:hover {
11 | cursor: pointer;
12 | box-shadow: 0 0.4rem 1.4rem 0 rgba(86, 185, 235, 0.5);
13 | transform: translateY(-0.1rem);
14 | transition: transform 150ms;
15 | }
16 |
17 | .choice-prefix {
18 | padding: 1.5rem 2.5rem;
19 | background-color: #56a5eb;
20 | color: white;
21 | }
22 |
23 | .choice-text {
24 | padding: 1.5rem;
25 | width: 100%;
26 | }
27 |
28 | .correct {
29 | background-color: #28a745;
30 | }
31 |
32 | .incorrect {
33 | background-color: #dc3545;
34 | }
35 |
36 | /* HUD */
37 |
38 | #hud {
39 | display: flex;
40 | justify-content: space-between;
41 | }
42 |
43 | .hud-prefix {
44 | text-align: center;
45 | font-size: 2rem;
46 | }
47 |
48 | .hud-main-text {
49 | text-align: center;
50 | }
51 |
52 | #progressBar {
53 | width: 20rem;
54 | height: 4rem;
55 | border: 0.3rem solid #56a5eb;
56 | margin-top: 1.5rem;
57 | }
58 |
59 | #progressBarFull {
60 | height: 3.4rem;
61 | background-color: #56a5eb;
62 | width: 0%;
63 | }
64 |
--------------------------------------------------------------------------------
/Quiz Web App/10. Fetch Questions from Local JSON File/game.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Quick Quiz - Play
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | Question
18 |
19 |
22 |
23 |
24 |
25 | Score
26 |
27 |
28 | 0
29 |
30 |
31 |
32 |
What is the answer to this questions?
33 |
34 |
A
35 |
Choice 1
36 |
37 |
38 |
B
39 |
Choice 2
40 |
41 |
42 |
C
43 |
Choice 3
44 |
45 |
46 |
D
47 |
Choice 4
48 |
49 |
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/Quiz Web App/10. Fetch Questions from Local JSON File/game.js:
--------------------------------------------------------------------------------
1 | const question = document.getElementById('question');
2 | const choices = Array.from(document.getElementsByClassName('choice-text'));
3 | const progressText = document.getElementById('progressText');
4 | const scoreText = document.getElementById('score');
5 | const progressBarFull = document.getElementById('progressBarFull');
6 | let currentQuestion = {};
7 | let acceptingAnswers = false;
8 | let score = 0;
9 | let questionCounter = 0;
10 | let availableQuesions = [];
11 |
12 | let questions = [];
13 |
14 | fetch('questions.json')
15 | .then((res) => {
16 | return res.json();
17 | })
18 | .then((loadedQuestions) => {
19 | questions = loadedQuestions;
20 | startGame();
21 | })
22 | .catch((err) => {
23 | console.error(err);
24 | });
25 |
26 | //CONSTANTS
27 | const CORRECT_BONUS = 10;
28 | const MAX_QUESTIONS = 3;
29 |
30 | startGame = () => {
31 | questionCounter = 0;
32 | score = 0;
33 | availableQuesions = [...questions];
34 | getNewQuestion();
35 | };
36 |
37 | getNewQuestion = () => {
38 | if (availableQuesions.length === 0 || questionCounter >= MAX_QUESTIONS) {
39 | localStorage.setItem('mostRecentScore', score);
40 | //go to the end page
41 | return window.location.assign('/end.html');
42 | }
43 | questionCounter++;
44 | progressText.innerText = `Question ${questionCounter}/${MAX_QUESTIONS}`;
45 | //Update the progress bar
46 | progressBarFull.style.width = `${(questionCounter / MAX_QUESTIONS) * 100}%`;
47 |
48 | const questionIndex = Math.floor(Math.random() * availableQuesions.length);
49 | currentQuestion = availableQuesions[questionIndex];
50 | question.innerText = currentQuestion.question;
51 |
52 | choices.forEach((choice) => {
53 | const number = choice.dataset['number'];
54 | choice.innerText = currentQuestion['choice' + number];
55 | });
56 |
57 | availableQuesions.splice(questionIndex, 1);
58 | acceptingAnswers = true;
59 | };
60 |
61 | choices.forEach((choice) => {
62 | choice.addEventListener('click', (e) => {
63 | if (!acceptingAnswers) return;
64 |
65 | acceptingAnswers = false;
66 | const selectedChoice = e.target;
67 | const selectedAnswer = selectedChoice.dataset['number'];
68 |
69 | const classToApply =
70 | selectedAnswer == currentQuestion.answer ? 'correct' : 'incorrect';
71 |
72 | if (classToApply === 'correct') {
73 | incrementScore(CORRECT_BONUS);
74 | }
75 |
76 | selectedChoice.parentElement.classList.add(classToApply);
77 |
78 | setTimeout(() => {
79 | selectedChoice.parentElement.classList.remove(classToApply);
80 | getNewQuestion();
81 | }, 1000);
82 | });
83 | });
84 |
85 | incrementScore = (num) => {
86 | score += num;
87 | scoreText.innerText = score;
88 | };
89 |
--------------------------------------------------------------------------------
/Quiz Web App/10. Fetch Questions from Local JSON File/highscores.css:
--------------------------------------------------------------------------------
1 | #highScoresList {
2 | list-style: none;
3 | padding-left: 0;
4 | margin-bottom: 4rem;
5 | }
6 |
7 | .high-score {
8 | font-size: 2.8rem;
9 | margin-bottom: 0.5rem;
10 | }
11 |
12 | .high-score:hover {
13 | transform: scale(1.025);
14 | }
15 |
--------------------------------------------------------------------------------
/Quiz Web App/10. Fetch Questions from Local JSON File/highscores.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | High Scores
8 |
9 |
10 |
11 |
12 |
13 |
14 |
High Scores
15 |
16 |
Go Home
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Quiz Web App/10. Fetch Questions from Local JSON File/highscores.js:
--------------------------------------------------------------------------------
1 | const highScoresList = document.getElementById("highScoresList");
2 | const highScores = JSON.parse(localStorage.getItem("highScores")) || [];
3 |
4 | highScoresList.innerHTML = highScores
5 | .map(score => {
6 | return `${score.name} - ${score.score} `;
7 | })
8 | .join("");
9 |
--------------------------------------------------------------------------------
/Quiz Web App/10. Fetch Questions from Local JSON File/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Quick Quiz
8 |
9 |
10 |
11 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Quiz Web App/10. Fetch Questions from Local JSON File/questions.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "question": "Inside which HTML element do we put the JavaScript??",
4 | "choice1": "
36 |