-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
111 lines (94 loc) · 4.34 KB
/
script.js
File metadata and controls
111 lines (94 loc) · 4.34 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
// T3Token Website JavaScript
document.addEventListener('DOMContentLoaded', function() {
// Smooth scrolling for navigation links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function(e) {
e.preventDefault();
const targetId = this.getAttribute('href');
const targetElement = document.querySelector(targetId);
if (targetElement) {
window.scrollTo({
top: targetElement.offsetTop - 70,
behavior: 'smooth'
});
// Close mobile menu if open
const navbarCollapse = document.querySelector('.navbar-collapse');
if (navbarCollapse.classList.contains('show')) {
document.querySelector('.navbar-toggler').click();
}
}
});
});
// Active navigation link highlighting
const sections = document.querySelectorAll('section');
const navLinks = document.querySelectorAll('.navbar-nav .nav-link');
window.addEventListener('scroll', function() {
let current = '';
sections.forEach(section => {
const sectionTop = section.offsetTop;
const sectionHeight = section.clientHeight;
if (pageYOffset >= sectionTop - 100) {
current = section.getAttribute('id');
}
});
navLinks.forEach(link => {
link.classList.remove('active');
if (link.getAttribute('href') === '#' + current) {
link.classList.add('active');
}
});
});
// Form submission handling (prevent default for demo)
const contactForm = document.querySelector('.contact-form');
if (contactForm) {
contactForm.addEventListener('submit', function(e) {
e.preventDefault();
alert('This is a demo form. In a real implementation, this would submit your message.');
this.reset();
});
}
// Newsletter signup handling (prevent default for demo)
const newsletterForm = document.querySelector('.newsletter-signup .input-group');
if (newsletterForm) {
const subscribeButton = newsletterForm.querySelector('button');
subscribeButton.addEventListener('click', function() {
const emailInput = newsletterForm.querySelector('input[type="email"]');
if (emailInput.value.trim() !== '') {
alert('This is a demo signup. In a real implementation, you would be subscribed to the newsletter.');
emailInput.value = '';
} else {
alert('Please enter a valid email address.');
}
});
}
// Syntax highlighting simulation for code blocks
document.querySelectorAll('.code-block code').forEach(block => {
const text = block.innerHTML;
// Simple syntax highlighting
const highlighted = text
.replace(/\/\/(.*)/g, '<span style="color: #6a9955;">$&</span>') // Comments
.replace(/\b(function|return|if|else|require|const|let|var|new|async|await|for|while)\b/g, '<span style="color: #c586c0;">$&</span>') // Keywords
.replace(/\b(uint256|address|bytes32|bool|string|struct|mapping)\b/g, '<span style="color: #4ec9b0;">$&</span>') // Types
.replace(/\b(public|private|external|internal|override|memory|storage)\b/g, '<span style="color: #569cd6;">$&</span>') // Modifiers
.replace(/(".*?")/g, '<span style="color: #ce9178;">$&</span>') // Strings
.replace(/\b(true|false|null|undefined)\b/g, '<span style="color: #569cd6;">$&</span>'); // Constants
block.innerHTML = highlighted;
});
// Animation for feature cards
const observerOptions = {
root: null,
rootMargin: '0px',
threshold: 0.1
};
const observer = new IntersectionObserver((entries, observer) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('animated');
observer.unobserve(entry.target);
}
});
}, observerOptions);
document.querySelectorAll('.feature-card').forEach(card => {
observer.observe(card);
});
});