Skip to content

Commit

Permalink
Added js
Browse files Browse the repository at this point in the history
  • Loading branch information
Aayush-683 committed Feb 4, 2024
1 parent 3104dda commit aedd95e
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
* text=auto
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ <h4>Insta: @hemang_light</h4>
<h6>Creator: @aayushh.hhhh</h6>
</div>
</div>
<script src="/js/index.js"></script>
<script src="/js/script.js"></script>
</body>
</html>
60 changes: 60 additions & 0 deletions public/js/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
const answers = [
"Are you sure?",
"Are you really sure??",
"Are you really realy sure???",
"Think again?",
"Don't believe in second chances?",
"Why are you being so cold?",
"Maybe we can talk about it?",
"I am not going to ask again!",
"Ok now this is hurting my feelings!",
"You are now just being mean!",
"Why are you doing this to me?",
"Please give me a chance!",
"I am begging you to stop!",
"Ok, Lets just start over.."
]

const no_button = document.getElementById('no-button');
const yes_button = document.getElementById('yes-button');
let i = 0;
let size = 50;
let clicks = 0;

no_button.addEventListener('click', () => {
// Change banner source
let banner = document.getElementById('banner');
if (clicks === 0) banner.src = "images/no.gif";
clicks++;
// increase button height and width gradually to 250px
const sizes = [40, 50, 30, 35, 45]
const random = Math.floor(Math.random() * sizes.length);
size += sizes[random]
yes_button.style.height = `${size}px`;
yes_button.style.width = `${size}px`;
let total = answers.length;
// change button text
if (i < total - 1) {
no_button.innerHTML = answers[i];
i++;
} else if (i === total - 1) {
alert(answers[i]);
i = 0;
no_button.innerHTML = "No";
yes_button.style.height = "50px";
yes_button.style.width = "50px";
size = 50;
}
});

yes_button.addEventListener('click', () => {
// change banner gif path
let banner = document.getElementById('banner');
banner.src = "images/yes.gif";
// hide buttons div
let buttons = document.getElementsByClassName('buttons')[0];
buttons.style.display = "none";
// show message div
let message = document.getElementsByClassName('message')[0];
message.style.display = "block";
});

0 comments on commit aedd95e

Please sign in to comment.