-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
145 lines (125 loc) Β· 4.46 KB
/
Copy pathscript.js
File metadata and controls
145 lines (125 loc) Β· 4.46 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
const gifStages = [
"https://media.tenor.com/EBV7OT7ACfwAAAAj/u-u-qua-qua-u-quaa.gif", // 0 normal
"https://media1.tenor.com/m/uDugCXK4vI4AAAAd/chiikawa-hachiware.gif", // 1 confused
"https://media.tenor.com/f_rkpJbH1s8AAAAj/somsom1012.gif", // 2 pleading
"https://media.tenor.com/OGY9zdREsVAAAAAj/somsom1012.gif", // 3 sad
"https://media1.tenor.com/m/WGfra-Y_Ke0AAAAd/chiikawa-sad.gif", // 4 sadder
"https://media.tenor.com/CivArbX7NzQAAAAj/somsom1012.gif", // 5 devastated
"https://media.tenor.com/5_tv1HquZlcAAAAj/chiikawa.gif", // 6 very devastated
"https://media1.tenor.com/m/uDugCXK4vI4AAAAC/chiikawa-hachiware.gif" // 7 crying runaway
]
const noMessages = [
"No",
"Are you positive? π€",
"Pookie please... π₯Ί",
"If you say no, I will be really sad...",
"I will be very sad... π’",
"Please??? π",
"Don't do this to me...",
"Last chance! π",
"You can't catch me anyway π"
]
const yesTeasePokes = [
"try saying no first... I bet you want to know what happens π",
"go on, hit no... just once π",
"you're missing out π",
"click no, I dare you π"
]
let yesTeasedCount = 0
let noClickCount = 0
let runawayEnabled = false
let musicPlaying = true
const catGif = document.getElementById('cat-gif')
const yesBtn = document.getElementById('yes-btn')
const noBtn = document.getElementById('no-btn')
const music = document.getElementById('bg-music')
// Autoplay: audio starts muted (bypasses browser policy), unmute immediately
music.muted = true
music.volume = 0.3
music.play().then(() => {
music.muted = false
}).catch(() => {
// Fallback: unmute on first interaction
document.addEventListener('click', () => {
music.muted = false
music.play().catch(() => {})
}, { once: true })
})
function toggleMusic() {
if (musicPlaying) {
music.pause()
musicPlaying = false
document.getElementById('music-toggle').textContent = 'π'
} else {
music.muted = false
music.play()
musicPlaying = true
document.getElementById('music-toggle').textContent = 'π'
}
}
function handleYesClick() {
if (!runawayEnabled) {
// Tease her to try No first
const msg = yesTeasePokes[Math.min(yesTeasedCount, yesTeasePokes.length - 1)]
yesTeasedCount++
showTeaseMessage(msg)
return
}
window.location.href = 'yes.html'
}
function showTeaseMessage(msg) {
let toast = document.getElementById('tease-toast')
toast.textContent = msg
toast.classList.add('show')
clearTimeout(toast._timer)
toast._timer = setTimeout(() => toast.classList.remove('show'), 2500)
}
function handleNoClick() {
noClickCount++
// Cycle through guilt-trip messages
const msgIndex = Math.min(noClickCount, noMessages.length - 1)
noBtn.textContent = noMessages[msgIndex]
// Grow the Yes button bigger each time
const currentSize = parseFloat(window.getComputedStyle(yesBtn).fontSize)
yesBtn.style.fontSize = `${currentSize * 1.35}px`
const padY = Math.min(18 + noClickCount * 5, 60)
const padX = Math.min(45 + noClickCount * 10, 120)
yesBtn.style.padding = `${padY}px ${padX}px`
// Shrink No button to contrast
if (noClickCount >= 2) {
const noSize = parseFloat(window.getComputedStyle(noBtn).fontSize)
noBtn.style.fontSize = `${Math.max(noSize * 0.85, 10)}px`
}
// Swap cat GIF through stages
const gifIndex = Math.min(noClickCount, gifStages.length - 1)
swapGif(gifStages[gifIndex])
// Runaway starts at click 5
if (noClickCount >= 5 && !runawayEnabled) {
enableRunaway()
runawayEnabled = true
}
}
function swapGif(src) {
catGif.style.opacity = '0'
setTimeout(() => {
catGif.src = src
catGif.style.opacity = '1'
}, 200)
}
function enableRunaway() {
noBtn.addEventListener('mouseover', runAway)
noBtn.addEventListener('touchstart', runAway, { passive: true })
}
function runAway() {
const margin = 20
const btnW = noBtn.offsetWidth
const btnH = noBtn.offsetHeight
const maxX = window.innerWidth - btnW - margin
const maxY = window.innerHeight - btnH - margin
const randomX = Math.random() * maxX + margin / 2
const randomY = Math.random() * maxY + margin / 2
noBtn.style.position = 'fixed'
noBtn.style.left = `${randomX}px`
noBtn.style.top = `${randomY}px`
noBtn.style.zIndex = '50'
}