MCPcopy Create free account
hub / github.com/Vishal-raj-1/Awesome-JavaScript-Projects / generateMessage

Function generateMessage

assets/js/Notifications.js:34–49  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

32}
33
34function generateMessage() {
35 const delay = Math.floor(Math.random() * 1000) + 1500;
36 const timeoutID = setTimeout(() => {
37 const title = randomItem(messageTitle);
38 const text = randomItem(messageText);
39
40 const message = document.querySelector(".notification__message");
41
42 message.querySelector("h1").textContent = title;
43 message.querySelector("p").textContent = text;
44 message.className = `notification__message message--${title}`;
45
46 showMessage();
47 clearTimeout(timeoutID);
48 }, delay);
49}
50
51// immediately call the generateMessage function to kickstart the loop
52generateMessage();

Callers 2

dismissMessageFunction · 0.85
Notifications.jsFile · 0.85

Calls 2

randomItemFunction · 0.85
showMessageFunction · 0.70

Tested by

no test coverage detected