Skip to content

Commit 5d3b18b

Browse files
Merge pull request #7 from PeaceFounder/redesign
minify bug on javascript
2 parents c58ea11 + 45a271f commit 5d3b18b

3 files changed

Lines changed: 193 additions & 197 deletions

File tree

_assets/scripts/script.js

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
// Smooth scrolling for navigation links
2+
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
3+
anchor.addEventListener('click', function (e) {
4+
e.preventDefault();
5+
const target = document.querySelector(this.getAttribute('href'));
6+
if (target) {
7+
target.scrollIntoView({
8+
behavior: 'smooth',
9+
block: 'start'
10+
});
11+
}
12+
});
13+
});
14+
15+
// Add scroll effect to navigation
16+
window.addEventListener('scroll', function() {
17+
const nav = document.querySelector('nav');
18+
if (window.scrollY > 100) {
19+
nav.style.background = 'rgba(255, 255, 255, 0.98)';
20+
} else {
21+
nav.style.background = 'rgba(255, 255, 255, 0.95)';
22+
}
23+
});
24+
25+
// Intersection Observer for animation triggers
26+
const observerOptions = {
27+
threshold: 0.1,
28+
rootMargin: '0px 0px -50px 0px'
29+
};
30+
31+
const observer = new IntersectionObserver(function(entries) {
32+
entries.forEach(entry => {
33+
if (entry.isIntersecting) {
34+
entry.target.style.opacity = '1';
35+
entry.target.style.transform = 'translateY(0)';
36+
}
37+
});
38+
}, observerOptions);
39+
40+
// Observe elements for animation
41+
document.querySelectorAll('.innovation-card, .step, .solution-item, .problem-item').forEach(el => {
42+
el.style.opacity = '0';
43+
el.style.transform = 'translateY(20px)';
44+
el.style.transition = 'opacity 0.6s ease, transform 0.6s ease';
45+
observer.observe(el);
46+
});
47+
48+
// Demo Modal Functions
49+
function openDemoModal() {
50+
const modal = document.getElementById('demoModal');
51+
const video = document.getElementById('demoVideo');
52+
video.src = 'https://www.youtube.com/embed/3asNuNMlHhY?autoplay=1';
53+
modal.style.display = 'flex';
54+
document.body.style.overflow = 'hidden';
55+
}
56+
57+
function closeDemoModal() {
58+
const modal = document.getElementById('demoModal');
59+
const video = document.getElementById('demoVideo');
60+
video.src = '';
61+
modal.style.display = 'none';
62+
document.body.style.overflow = 'auto';
63+
}
64+
65+
// Close modal when pressing Escape key
66+
document.addEventListener('keydown', function(e) {
67+
if (e.key === 'Escape') {
68+
closeDemoModal();
69+
}
70+
});
71+
72+
// Copy to clipboard functionality
73+
function copyToClipboard(text) {
74+
navigator.clipboard.writeText(text).then(function() {
75+
// Find the clicked icon and add subtle click animation
76+
const icons = document.querySelectorAll('.copy-icon');
77+
icons.forEach(icon => {
78+
if (icon.onclick.toString().includes(text.substring(0, 20))) {
79+
icon.style.transform = 'scale(0.95)';
80+
setTimeout(() => {
81+
icon.style.transform = 'scale(1)';
82+
}, 100);
83+
}
84+
});
85+
}).catch(function(err) {
86+
console.error('Failed to copy: ', err);
87+
});
88+
}
89+
90+
function initializeCopyButtons() {
91+
const codeBlocks = document.querySelectorAll('.code-block');
92+
93+
codeBlocks.forEach(block => {
94+
// Skip if copy button already exists
95+
if (block.querySelector('.copy-icon')) return;
96+
97+
const codeElement = block.querySelector('code');
98+
if (!codeElement) return;
99+
100+
const codeText = codeElement.textContent;
101+
102+
// Create copy span exactly like your current format
103+
const copySpan = document.createElement('span');
104+
copySpan.className = 'copy-icon';
105+
copySpan.setAttribute('onclick', `copyToClipboard('${codeText.replace(/'/g, "\\'")}')`);
106+
copySpan.title = 'Copy to clipboard';
107+
copySpan.textContent = 'Copy';
108+
109+
// Insert the span before the code element (same position as your HTML)
110+
block.insertBefore(copySpan, codeElement);
111+
});
112+
}
113+
// Initialize when page loads
114+
document.addEventListener('DOMContentLoaded', initializeCopyButtons);
115+
116+
// Also provide a function to reinitialize if you add code blocks dynamically
117+
window.reinitializeCopyButtons = initializeCopyButtons;
118+
119+
120+
121+
let slideIndex = 3;
122+
let slideInterval;
123+
const SLIDE_DURATION = 5000; // 3 seconds
124+
125+
function showSlides(n) {
126+
const slides = document.getElementsByClassName("screenshot-slide");
127+
const dots = document.getElementsByClassName("dot");
128+
129+
// Bounds checking
130+
if (n > slides.length) {
131+
slideIndex = 1;
132+
} else if (n < 1) {
133+
slideIndex = slides.length;
134+
} else {
135+
slideIndex = n;
136+
}
137+
138+
// Remove active class from all
139+
for (let i = 0; i < slides.length; i++) {
140+
slides[i].classList.remove("active");
141+
}
142+
143+
for (let i = 0; i < dots.length; i++) {
144+
dots[i].classList.remove("active");
145+
}
146+
147+
// Add active class to current
148+
if (slides[slideIndex - 1] && dots[slideIndex - 1]) {
149+
slides[slideIndex - 1].classList.add("active");
150+
dots[slideIndex - 1].classList.add("active");
151+
}
152+
}
153+
154+
function currentSlide(n) {
155+
stopAutoSlide(); // Always stop first
156+
showSlides(n);
157+
startAutoSlide(); // Then restart
158+
}
159+
160+
function nextSlide() {
161+
slideIndex++;
162+
showSlides(slideIndex);
163+
}
164+
165+
function startAutoSlide() {
166+
stopAutoSlide(); // Prevent multiple intervals
167+
slideInterval = setInterval(nextSlide, SLIDE_DURATION);
168+
}
169+
170+
function stopAutoSlide() {
171+
if (slideInterval) {
172+
clearInterval(slideInterval);
173+
slideInterval = null;
174+
}
175+
}
176+
177+
// Initialize slideshow
178+
document.addEventListener('DOMContentLoaded', function() {
179+
showSlides(slideIndex);
180+
startAutoSlide();
181+
182+
// Pause on hover
183+
const slideshow = document.querySelector('.screenshot-slideshow');
184+
if (slideshow) {
185+
slideshow.addEventListener('mouseenter', stopAutoSlide);
186+
slideshow.addEventListener('mouseleave', startAutoSlide);
187+
}
188+
});
189+
190+
// Cleanup on page unload
191+
window.addEventListener('beforeunload', stopAutoSlide);

_layout/foot.html

Lines changed: 0 additions & 197 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11

2-
3-
42
<!-- CONTENT ENDS HERE -->
53
{{ if hasmath }}
64
{{ insert foot_katex.html }}
@@ -31,198 +29,3 @@ <h3>PeaceFounder Demo</h3>
3129

3230
</body>
3331
</html>
34-
35-
<script>
36-
// Smooth scrolling for navigation links
37-
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
38-
anchor.addEventListener('click', function (e) {
39-
e.preventDefault();
40-
const target = document.querySelector(this.getAttribute('href'));
41-
if (target) {
42-
target.scrollIntoView({
43-
behavior: 'smooth',
44-
block: 'start'
45-
});
46-
}
47-
});
48-
});
49-
50-
// Add scroll effect to navigation
51-
window.addEventListener('scroll', function() {
52-
const nav = document.querySelector('nav');
53-
if (window.scrollY > 100) {
54-
nav.style.background = 'rgba(255, 255, 255, 0.98)';
55-
} else {
56-
nav.style.background = 'rgba(255, 255, 255, 0.95)';
57-
}
58-
});
59-
60-
// Intersection Observer for animation triggers
61-
const observerOptions = {
62-
threshold: 0.1,
63-
rootMargin: '0px 0px -50px 0px'
64-
};
65-
66-
const observer = new IntersectionObserver(function(entries) {
67-
entries.forEach(entry => {
68-
if (entry.isIntersecting) {
69-
entry.target.style.opacity = '1';
70-
entry.target.style.transform = 'translateY(0)';
71-
}
72-
});
73-
}, observerOptions);
74-
75-
// Observe elements for animation
76-
document.querySelectorAll('.innovation-card, .step, .solution-item, .problem-item').forEach(el => {
77-
el.style.opacity = '0';
78-
el.style.transform = 'translateY(20px)';
79-
el.style.transition = 'opacity 0.6s ease, transform 0.6s ease';
80-
observer.observe(el);
81-
});
82-
83-
// Demo Modal Functions
84-
function openDemoModal() {
85-
const modal = document.getElementById('demoModal');
86-
const video = document.getElementById('demoVideo');
87-
video.src = 'https://www.youtube.com/embed/3asNuNMlHhY?autoplay=1';
88-
modal.style.display = 'flex';
89-
document.body.style.overflow = 'hidden';
90-
}
91-
92-
function closeDemoModal() {
93-
const modal = document.getElementById('demoModal');
94-
const video = document.getElementById('demoVideo');
95-
video.src = '';
96-
modal.style.display = 'none';
97-
document.body.style.overflow = 'auto';
98-
}
99-
100-
// Close modal when pressing Escape key
101-
document.addEventListener('keydown', function(e) {
102-
if (e.key === 'Escape') {
103-
closeDemoModal();
104-
}
105-
});
106-
107-
// Copy to clipboard functionality
108-
function copyToClipboard(text) {
109-
navigator.clipboard.writeText(text).then(function() {
110-
// Find the clicked icon and add subtle click animation
111-
const icons = document.querySelectorAll('.copy-icon');
112-
icons.forEach(icon => {
113-
if (icon.onclick.toString().includes(text.substring(0, 20))) {
114-
icon.style.transform = 'scale(0.95)';
115-
setTimeout(() => {
116-
icon.style.transform = 'scale(1)';
117-
}, 100);
118-
}
119-
});
120-
}).catch(function(err) {
121-
console.error('Failed to copy: ', err);
122-
});
123-
}
124-
125-
function initializeCopyButtons() {
126-
const codeBlocks = document.querySelectorAll('.code-block');
127-
128-
codeBlocks.forEach(block => {
129-
// Skip if copy button already exists
130-
if (block.querySelector('.copy-icon')) return;
131-
132-
const codeElement = block.querySelector('code');
133-
if (!codeElement) return;
134-
135-
const codeText = codeElement.textContent;
136-
137-
// Create copy span exactly like your current format
138-
const copySpan = document.createElement('span');
139-
copySpan.className = 'copy-icon';
140-
copySpan.setAttribute('onclick', `copyToClipboard('${codeText.replace(/'/g, "\\'")}')`);
141-
copySpan.title = 'Copy to clipboard';
142-
copySpan.textContent = 'Copy';
143-
144-
// Insert the span before the code element (same position as your HTML)
145-
block.insertBefore(copySpan, codeElement);
146-
});
147-
}
148-
// Initialize when page loads
149-
document.addEventListener('DOMContentLoaded', initializeCopyButtons);
150-
151-
// Also provide a function to reinitialize if you add code blocks dynamically
152-
window.reinitializeCopyButtons = initializeCopyButtons;
153-
154-
155-
156-
let slideIndex = 3;
157-
let slideInterval;
158-
const SLIDE_DURATION = 5000; // 3 seconds
159-
160-
function showSlides(n) {
161-
const slides = document.getElementsByClassName("screenshot-slide");
162-
const dots = document.getElementsByClassName("dot");
163-
164-
// Bounds checking
165-
if (n > slides.length) {
166-
slideIndex = 1;
167-
} else if (n < 1) {
168-
slideIndex = slides.length;
169-
} else {
170-
slideIndex = n;
171-
}
172-
173-
// Remove active class from all
174-
for (let i = 0; i < slides.length; i++) {
175-
slides[i].classList.remove("active");
176-
}
177-
178-
for (let i = 0; i < dots.length; i++) {
179-
dots[i].classList.remove("active");
180-
}
181-
182-
// Add active class to current
183-
if (slides[slideIndex - 1] && dots[slideIndex - 1]) {
184-
slides[slideIndex - 1].classList.add("active");
185-
dots[slideIndex - 1].classList.add("active");
186-
}
187-
}
188-
189-
function currentSlide(n) {
190-
stopAutoSlide(); // Always stop first
191-
showSlides(n);
192-
startAutoSlide(); // Then restart
193-
}
194-
195-
function nextSlide() {
196-
slideIndex++;
197-
showSlides(slideIndex);
198-
}
199-
200-
function startAutoSlide() {
201-
stopAutoSlide(); // Prevent multiple intervals
202-
slideInterval = setInterval(nextSlide, SLIDE_DURATION);
203-
}
204-
205-
function stopAutoSlide() {
206-
if (slideInterval) {
207-
clearInterval(slideInterval);
208-
slideInterval = null;
209-
}
210-
}
211-
212-
// Initialize slideshow
213-
document.addEventListener('DOMContentLoaded', function() {
214-
showSlides(slideIndex);
215-
startAutoSlide();
216-
217-
// Pause on hover
218-
const slideshow = document.querySelector('.screenshot-slideshow');
219-
if (slideshow) {
220-
slideshow.addEventListener('mouseenter', stopAutoSlide);
221-
slideshow.addEventListener('mouseleave', startAutoSlide);
222-
}
223-
});
224-
225-
// Cleanup on page unload
226-
window.addEventListener('beforeunload', stopAutoSlide);
227-
228-
</script>

0 commit comments

Comments
 (0)