-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
116 lines (101 loc) · 3.81 KB
/
script.js
File metadata and controls
116 lines (101 loc) · 3.81 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
document.addEventListener('DOMContentLoaded', () => {
// Navbar scroll effect
const navbar = document.querySelector('.navbar');
window.addEventListener('scroll', () => {
if (window.scrollY > 50) {
navbar.classList.add('scrolled');
} else {
navbar.classList.remove('scrolled');
}
});
// Smooth scrolling
document.querySelectorAll('a.nav-link[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});
// Tutorial Tabs
const tabLinks = document.querySelectorAll('.tab-link');
const tabContents = document.querySelectorAll('.tutorial-content');
tabLinks.forEach(link => {
link.addEventListener('click', () => {
const tab = link.dataset.tab;
tabLinks.forEach(l => l.classList.remove('active'));
link.classList.add('active');
tabContents.forEach(content => {
content.classList.remove('active');
if (content.id === tab) {
content.classList.add('active');
}
});
});
});
// Copy Script Button
const copyScriptButton = document.getElementById('copy-script-button');
let scriptContent = ''; // Variable to hold the fetched script text
// Fetch the script from GitHub once and store it
fetch('https://raw.githubusercontent.com/veriepicc/Serenity-Bloxd/main/dist/Serenity.js')
.then(response => {
if (!response.ok) { throw new Error('Network response was not ok'); }
return response.text();
})
.then(text => {
scriptContent = text;
})
.catch(error => {
console.error('Failed to fetch the script:', error);
copyScriptButton.innerHTML = 'Error fetching script!';
copyScriptButton.disabled = true;
});
copyScriptButton.addEventListener('click', () => {
if (!scriptContent) {
console.error('Script content not loaded yet.');
return;
}
navigator.clipboard.writeText(scriptContent).then(() => {
const originalText = copyScriptButton.innerHTML;
copyScriptButton.innerHTML = '<i class="fas fa-check"></i> Copied!';
setTimeout(() => {
copyScriptButton.innerHTML = originalText;
}, 2000);
}).catch(err => {
console.error('Failed to copy script to clipboard:', err);
});
});
// Fade-in animations on scroll
const faders = document.querySelectorAll('.fade-in');
const appearOptions = {
threshold: 0.1,
rootMargin: "0px 0px -100px 0px"
};
const appearOnScroll = new IntersectionObserver(function(entries, appearOnScroll) {
entries.forEach(entry => {
if (!entry.isIntersecting) {
return;
} else {
entry.target.classList.add('visible');
appearOnScroll.unobserve(entry.target);
}
});
}, appearOptions);
faders.forEach(fader => {
appearOnScroll.observe(fader);
});
// FAQ Accordion
const faqItems = document.querySelectorAll('.faq-item');
faqItems.forEach(item => {
const question = item.querySelector('.faq-question');
question.addEventListener('click', () => {
const isActive = item.classList.contains('active');
// Close all other items
faqItems.forEach(i => i.classList.remove('active'));
// If it wasn't active, open it
if (!isActive) {
item.classList.add('active');
}
});
});
});