-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscripts.js
32 lines (27 loc) · 1.1 KB
/
scripts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
document.addEventListener("DOMContentLoaded", function () {
// Adds more rows to the Search TextArea as the user input grows
const textarea = document.getElementById('search-textarea');
textarea.addEventListener('input', function () {
const lineHeight = 22;
//Calculate number of rows
this.rows = Math.max(1, Math.ceil((this.scrollHeight) / lineHeight));
})
//Implenment a Simplified version of the Lucky Button Hover
const luckyButton = document.getElementById("luckyButton");
const messages = [
"I'm Feeling Lucky",
"I'm Feeling Curious",
"I'm Feeling Adventurous",
"I'm Feeling Playful",
"I'm Feeling Hungry"
];
luckyButton.addEventListener("mouseenter", () => {
// Get a random message from the array
const randomIndex = Math.floor(Math.random() * messages.length);
luckyButton.textContent = messages[randomIndex];
});
luckyButton.addEventListener("mouseleave", () => {
// Reset the button text to the original
luckyButton.textContent = "I'm Feeling Lucky";
});
})