Skip to content

Commit

Permalink
Added video function
Browse files Browse the repository at this point in the history
  • Loading branch information
chauhannaman98 committed Dec 24, 2023
1 parent 3f2e4a1 commit 34a6d9b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ <h1 class="heading">Are you a Thala Fan?</h1>
<input type="submit" id="btn" value="Click here to check">
</form>
<div class="output">
Sample Output Here
<video loop id="ThalaVid" src="/media/video.mp4"></video>
</div>
</div>
</main>
Expand Down
19 changes: 11 additions & 8 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
let form = document.getElementById('form');
let music = new Audio('/media/Thala.mp3');
let vid = document.getElementById("ThalaVid");

function checkForThala(text) {
// check if it's a number
Expand All @@ -13,7 +14,7 @@ function checkForThala(text) {
return true;
}
// check for length of text
// text = text.trim;
text = text.trim();
if(text.length === 7)
return true;
else
Expand All @@ -22,6 +23,7 @@ function checkForThala(text) {

function updateHeading(text, result) {
// update the heading
text = text.trim();
let arr = text.split('');
if (result)
outString = "Yes! Because.. " + arr[0];
Expand All @@ -40,15 +42,16 @@ form.addEventListener('submit', (event) => {
let text = document.getElementById('text').value;
result = checkForThala(text);
if(result){
console.log("Thala for a Reason!");

// play the sound/video
music.play();
// music.play();
vid.style.visibility = "visible";
vid.play();
}
else {
console.log("Better luck next time!");
music.pause();
music.currentTime = 0;
// music.pause();
// music.currentTime = 0;
vid.style.visibility = "hidden";
vid.pause();
vid.currentTime = 0;
}

updateHeading(text, result);
Expand Down
Binary file modified media/video.mp4
Binary file not shown.
10 changes: 8 additions & 2 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,21 @@ body {
}

.output {
border: 1px solid black;
height: 70vh;
width: 100vmin;
margin-top: 0.5vh;
margin-bottom: 0.5vh;
}

video {
height: 70vh;
width: 100vmin;
margin-top: 0.5vh;
margin-bottom: 0.5vh;
visibility: hidden;
}

footer {
border: 1px solid black;
background-color: #0065BC;
font-family: 'Barlow';
display: flex;
Expand Down

0 comments on commit 34a6d9b

Please sign in to comment.