Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
58 lines (49 loc) · 1.64 KB
/
Copy pathscript.js
File metadata and controls
58 lines (49 loc) · 1.64 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
window.onload = function() {
const frame = document.getElementById('frame');
const img = document.getElementById('skin');
function resizeFrame() {
const imgRatio = img.naturalWidth / img.naturalHeight;
const frameRatio = frame.clientWidth / frame.clientHeight;
if (imgRatio > frameRatio) {
img.style.width = '100%';
img.style.height = 'auto';
} else {
img.style.width = 'auto';
img.style.height = '100%';
}
}
resizeFrame();
window.addEventListener('resize', resizeFrame);
// Start audio playback
const audio = document.getElementById('audio');
audio.play().catch(error => {
// Autoplay was prevented
console.log('Autoplay was prevented');
});
};
// Modal functionality
const modal = document.getElementById("myModal");
const modalImg = document.getElementById("modalImage");
const closeModal = document.getElementsByClassName("close")[0];
document.querySelectorAll('.proof-section img, .mod-proof-section img').forEach(img => {
img.onclick = function() {
modal.style.display = "block";
modalImg.src = this.src;
};
});
closeModal.onclick = function() {
modal.style.display = "none";
};
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
};
// Fallback to YouTube video if audio file cannot be played
const audio = document.getElementById('audio');
audio.addEventListener('error', function() {
const youtubeIframe = document.getElementById('youtube-iframe');
youtubeIframe.style.width = '1px';
youtubeIframe.style.height = '1px';
youtubeIframe.src += "&autoplay=1";
});