-
Notifications
You must be signed in to change notification settings - Fork 30
Added Time Limit #83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
n-keerthi-gayathri
wants to merge
2
commits into
KendallDoesCoding:main
Choose a base branch
from
n-keerthi-gayathri:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Added Time Limit #83
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,91 +1,107 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <link | ||
| rel="stylesheet" | ||
| href="https://use.fontawesome.com/releases/v5.15.4/css/all.css" | ||
| integrity="sha384-DyZ88mC6Up2uqS4h/KRgHuoeGwBcD4Ng9SiP4dIRy0EXTlnuz47vAwmeGwVChigm" | ||
| crossorigin="anonymous" | ||
| /> | ||
| <link rel="icon" type="image/x-icon" href="../images/Main.ico" /> | ||
| <title>Quiz Page - Main Game</title> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css" integrity="sha384-DyZ88mC6Up2uqS4h/KRgHuoeGwBcD4Ng9SiP4dIRy0EXTlnuz47vAwmeGwVChigm" crossorigin="anonymous" /> | ||
| <link rel="icon" type="image/x-icon" href="../images/Main.ico" /> | ||
| <title>Quiz Page - Main Game</title> | ||
| <link rel="stylesheet" href="../css/index.css" /> | ||
| <link rel="stylesheet" href="../css/game.css" /> | ||
| <script type="module" defer> | ||
| import { gameQA } from "../js/data/index.js"; | ||
| import { Quiz } from "../js/QuizClass.js"; | ||
|
|
||
| <link rel="stylesheet" href="../css/index.css" /> | ||
| <link rel="stylesheet" href="../css/game.css" /> | ||
| <script type="module" defer> | ||
| import { gameQA } from "../js/data/index.js"; | ||
| import { Quiz } from "../js/QuizClass.js"; | ||
| const QuizInstance = new Quiz(gameQA); | ||
| let timer; | ||
| let timeLimit = 10; // Set the initial time limit in seconds | ||
|
|
||
| const QuizInstance = new Quiz(gameQA); | ||
| document.addEventListener("click", (e) => { | ||
| if (e.target.dataset.number) { | ||
| QuizInstance.checkAnswer(+e.target.dataset.number, QuizInstance.answer); | ||
| resetTimer(); | ||
| } | ||
| }); | ||
|
|
||
| document.addEventListener("click", (e) => { | ||
| if (e.target.dataset.number) { | ||
| QuizInstance.checkAnswer( | ||
| +e.target.dataset.number, | ||
| QuizInstance.answer | ||
| ); | ||
| function updateTimerDisplay() { | ||
| document.getElementById("timer").innerText = `${timeLimit}s`; | ||
| } | ||
|
|
||
| function startTimer() { | ||
| timer = setInterval(() => { | ||
| timeLimit--; | ||
| updateTimerDisplay(); | ||
|
|
||
| if (timeLimit <= 0) { | ||
| QuizInstance.handleTimeout(); | ||
| resetTimer(); | ||
| } | ||
| }); | ||
| </script> | ||
| </head> | ||
| }, 1000); | ||
| } | ||
|
|
||
| <body> | ||
| <div class="container"> | ||
| <div id="game" class="justify-center flex-column"> | ||
| <div id="hud"> | ||
| <div class="hud-item"> | ||
| <p id="progressText" class="hud-prefix">Question</p> | ||
| <div id="progressBar"> | ||
| <div id="progressBarFull"></div> | ||
| </div> | ||
| </div> | ||
| <div class="hud-item"> | ||
| <p class="hud-prefix">Score</p> | ||
| <h1 class="hud-main-text" id="score">0</h1> | ||
| <p id="addPoints" class="hud-item"></p> | ||
| <p id="subPoints" class="hud-item">-100</p> | ||
| function resetTimer() { | ||
| clearInterval(timer); | ||
| timeLimit = 10; | ||
| updateTimerDisplay(); | ||
| startTimer(); | ||
| } | ||
|
|
||
| startTimer(); | ||
| </script> | ||
| </head> | ||
| <body> | ||
| <div class="container"> | ||
| <div id="game" class="justify-center flex-column"> | ||
| <div id="hud"> | ||
| <div class="hud-item"> | ||
| <p id="progressText" class="hud-prefix">Question</p> | ||
| <div id="progressBar"> | ||
| <div id="progressBarFull"></div> | ||
| </div> | ||
| </div> | ||
| <h1 id="question">What is the answer to this question</h1> | ||
| <div class="choice-container"> | ||
| <p class="choice-prefix">A</p> | ||
| <p class="choice-text" data-number="1">Choice</p> | ||
| </div> | ||
| <div class="choice-container"> | ||
| <p class="choice-prefix">B</p> | ||
| <p class="choice-text" data-number="2">Choice 2</p> | ||
| </div> | ||
| <div class="choice-container"> | ||
| <p class="choice-prefix">C</p> | ||
| <p class="choice-text" data-number="3">Choice 3</p> | ||
| </div> | ||
| <div class="choice-container"> | ||
| <p class="choice-prefix">D</p> | ||
| <p class="choice-text" data-number="4">Choice 4</p> | ||
| <div class="hud-item"> | ||
| <p class="hud-prefix">Score</p> | ||
| <h1 class="hud-main-text" id="score">0</h1> | ||
| <p id="addPoints" class="hud-item"></p> | ||
| <p id="subPoints" class="hud-item">-100</p> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| <div class="music"> | ||
| <audio loop="loop" id="my_audio" preload="auto" autoplay> | ||
| <source id="audio_source" src="" type="audio/mpeg" /> | ||
| </audio> | ||
|
|
||
| <div class="music-container flex-center flex-row"> | ||
| <a | ||
| onclick="toggleMusic()" | ||
| class="button1" | ||
| id="musicOnButton" | ||
| style="display: none" | ||
| > | ||
| Music On <i class="fas fa-light fa-headphones"></i | ||
| ></a> | ||
| <a onclick="pauseMusic()" class="button2"> | ||
| Music Off <i class="fas fa-light fa-volume-off"></i | ||
| ></a> | ||
| <div id="timer-container"> | ||
| <p id="timer-prefix">Time Left:</p> | ||
| <p id="timer">10s</p> | ||
| </div> | ||
| <h1 id="question">What is the answer to this question</h1> | ||
| <div class="choice-container"> | ||
| <p class="choice-prefix">A</p> | ||
| <p class="choice-text" data-number="1">Choice</p> | ||
| </div> | ||
| <div class="choice-container"> | ||
| <p class="choice-prefix">B</p> | ||
| <p class="choice-text" data-number="2">Choice 2</p> | ||
| </div> | ||
| <div class="choice-container"> | ||
| <p class="choice-prefix">C</p> | ||
| <p class="choice-text" data-number="3">Choice 3</p> | ||
| </div> | ||
| <div class="choice-container"> | ||
| <p class="choice-prefix">D</p> | ||
| <p class="choice-text" data-number="4">Choice 4</p> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| <div class="music"> | ||
| <audio loop="loop" id="my_audio" preload="auto" autoplay> | ||
| <source id="audio_source" src="" type="audio/mpeg" /> | ||
| </audio> | ||
| <div class="music-container flex-center flex-row"> | ||
| <a onclick="toggleMusic()" class="button1" id="musicOnButton" style="display: none"> | ||
| Music On <i class="fas fa-light fa-headphones"></i> | ||
| </a> | ||
| <a onclick="pauseMusic()" class="button2"> | ||
| Music Off <i class="fas fa-light fa-volume-off"></i> | ||
| </a> | ||
| </div> | ||
| </body> | ||
| <script src="/js/songs.js"></script> | ||
| </div> | ||
| </body> | ||
| <script src="/js/songs.js"></script> | ||
| </html> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
??