-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnostromo.js
81 lines (67 loc) · 2.19 KB
/
nostromo.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// Create new Audio objects
const alienKeysSound = new Audio('/lib/sounds/alien_keys.mp3');
alienKeysSound.volume = 0.1;
const beepSound = new Audio('/lib/sounds/beep.wav');
beepSound.volume = 0.1;
const bootSound = new Audio('/lib/sounds/boot.mp3');
bootSound.volume = 0.1;
const loginSound = new Audio('/lib/sounds/login_alien.mp3');
loginSound.volume = 0.1;
const atmSound = new Audio('/lib/sounds/alien_atm.mp3');
atmSound.volume = 0.1;
// Function to play the beep sound
function playBeepSound() {
beepSound.play();
//add a flash to chatlog by css
document.getElementById('chatlog').classList.remove('flash');
document.getElementById('chatlog').offsetWidth;
document.getElementById('chatlog').classList.add('flash');
}
// Function to pause the beep sound
function pauseBeepSound() {
beepSound.pause();
}
// Function to play the alien keys sound
function playAlienKeysSound() {
alienKeysSound.play();
}
// Function to pause the alien keys sound
function pauseAlienKeysSound() {
alienKeysSound.pause();
}
// Function to play the boot sound
function playBootSound() {
bootSound.play();
loginSound.play();
atmSound.play();
}
// Function to pause the boot sound
function pauseBootSound() {
bootSound.pause();
}
// Select the chat log element
const chatLog = document.getElementById('chatlog');
// Create a MutationObserver to watch for changes in the chat log
const observer = new MutationObserver((mutationsList, observer) => {
for (let mutation of mutationsList) {
if (mutation.type === 'childList') {
playAlienKeysSound();
}
}
});
// Start observing the chat log for changes
observer.observe(chatLog, { childList: true, subtree: true });
playBootSound();
// Select the prompt input and send button elements
const promptInput_nos = document.getElementById('prompt');
const sendButton_nos = document.getElementById('submit');
// Add event listener to play beep sound on Enter key press
promptInput_nos.addEventListener('keydown', (event) => {
if (event.key === 'Enter') {
playBeepSound();
}
});
// Add event listener to play beep sound on button click
sendButton_nos.addEventListener('click', () => {
playBeepSound();
});