-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
342 lines (293 loc) · 11.8 KB
/
script.js
File metadata and controls
342 lines (293 loc) · 11.8 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
// Wait for DOM to be fully loaded
document.addEventListener('DOMContentLoaded', function() {
// Smooth scrolling for navigation links
const navLinks = document.querySelectorAll('.nav-links a');
navLinks.forEach(link => {
link.addEventListener('click', function(e) {
e.preventDefault();
const targetId = this.getAttribute('href');
const targetSection = document.querySelector(targetId);
if (targetSection) {
const offsetTop = targetSection.offsetTop - 80; // Account for fixed header
window.scrollTo({
top: offsetTop,
behavior: 'smooth'
});
}
});
});
// Button click handlers
const tryNowBtn = document.querySelector('.btn-primary');
const learnMoreBtn = document.querySelector('.btn-secondary');
const getAllInfoBtn = document.querySelector('.btn-info');
if (tryNowBtn) {
tryNowBtn.addEventListener('click', function() {
// In a real application, this would redirect to the try-on interface
alert('Try-on feature coming soon! This would redirect to the virtual try-on interface.');
});
}
if (learnMoreBtn) {
learnMoreBtn.addEventListener('click', function() {
// Scroll to features section
const featuresSection = document.querySelector('#features');
if (featuresSection) {
const offsetTop = featuresSection.offsetTop - 80;
window.scrollTo({
top: offsetTop,
behavior: 'smooth'
});
}
});
}
if (getAllInfoBtn) {
getAllInfoBtn.addEventListener('click', function() {
displayAllInfo();
});
}
// Add active nav link highlighting
function highlightActiveNavLink() {
const sections = document.querySelectorAll('section[id]');
const scrollPos = window.scrollY + 100;
sections.forEach(section => {
const top = section.offsetTop;
const bottom = top + section.offsetHeight;
const id = section.getAttribute('id');
const navLink = document.querySelector(`.nav-links a[href="#${id}"]`);
if (scrollPos >= top && scrollPos <= bottom) {
// Remove active class from all nav links
navLinks.forEach(link => link.classList.remove('active'));
// Add active class to current nav link
if (navLink) {
navLink.classList.add('active');
}
}
});
}
// Listen for scroll events
window.addEventListener('scroll', highlightActiveNavLink);
// Header background opacity on scroll
const header = document.querySelector('header');
window.addEventListener('scroll', function() {
if (window.scrollY > 50) {
header.style.backgroundColor = 'rgba(102, 126, 234, 0.95)';
} else {
header.style.backgroundColor = '';
}
});
// Add hover effects to feature cards
const featureCards = document.querySelectorAll('.feature');
featureCards.forEach(card => {
card.addEventListener('mouseenter', function() {
this.style.transform = 'translateY(-10px) scale(1.02)';
});
card.addEventListener('mouseleave', function() {
this.style.transform = 'translateY(0) scale(1)';
});
});
// Simple form validation for future contact form
function validateEmail(email) {
const re = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
return re.test(email);
}
// Add intersection observer for animations
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -50px 0px'
};
const observer = new IntersectionObserver(function(entries) {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.opacity = '1';
entry.target.style.transform = 'translateY(0)';
}
});
}, observerOptions);
// Observe all sections for animation
const animatedElements = document.querySelectorAll('section');
animatedElements.forEach(el => {
el.style.opacity = '0';
el.style.transform = 'translateY(30px)';
el.style.transition = 'opacity 0.6s ease, transform 0.6s ease';
observer.observe(el);
});
// Console welcome message
console.log('Welcome to TryOnYou! 👔✨');
console.log('Virtual try-on technology powered by Ya-va');
// Extract all website information function
function getAllWebsiteInfo() {
const info = {
company: {
name: "TryOnYou",
tagline: "Experience Virtual Try-On",
description: "Revolutionize your shopping experience with our cutting-edge virtual try-on technology. See how clothes, accessories, and more look on you before making a purchase.",
about: "We're pioneering the future of online retail with innovative virtual try-on solutions. Our technology helps customers make better purchasing decisions while reducing returns and increasing satisfaction.",
technology: "Powered by Ya-va Technology",
copyright: "© 2024 TryOnYou. All rights reserved."
},
contact: {
email: "hello@tryonyou.app",
website: "tryonyou.app"
},
features: [],
navigation: [],
content: {
sections: []
}
};
// Extract navigation items
const navLinks = document.querySelectorAll('.nav-links a');
navLinks.forEach(link => {
info.navigation.push({
text: link.textContent.trim(),
href: link.getAttribute('href'),
target: link.getAttribute('href').replace('#', '')
});
});
// Extract features
const featureElements = document.querySelectorAll('.feature');
featureElements.forEach(feature => {
const icon = feature.querySelector('.feature-icon')?.textContent.trim();
const title = feature.querySelector('h3')?.textContent.trim();
const description = feature.querySelector('p')?.textContent.trim();
info.features.push({
icon: icon,
title: title,
description: description
});
});
// Extract all sections content
const sections = document.querySelectorAll('section[id]');
sections.forEach(section => {
const sectionId = section.getAttribute('id');
const heading = section.querySelector('h2')?.textContent.trim();
const paragraphs = Array.from(section.querySelectorAll('p')).map(p => p.textContent.trim());
const buttons = Array.from(section.querySelectorAll('button')).map(btn => btn.textContent.trim());
info.content.sections.push({
id: sectionId,
heading: heading,
paragraphs: paragraphs,
buttons: buttons
});
});
return info;
}
// Make the function globally accessible
window.getAllWebsiteInfo = getAllWebsiteInfo;
// Display all info function
function displayAllInfo() {
const allInfo = getAllWebsiteInfo();
console.log('=== ALL WEBSITE INFORMATION ===');
console.log(JSON.stringify(allInfo, null, 2));
// Create a formatted display
let infoDisplay = `
=== TryOnYou Complete Information ===
COMPANY INFORMATION:
- Name: ${allInfo.company.name}
- Tagline: ${allInfo.company.tagline}
- Description: ${allInfo.company.description}
- About: ${allInfo.company.about}
- Technology: ${allInfo.company.technology}
- Copyright: ${allInfo.company.copyright}
CONTACT INFORMATION:
- Email: ${allInfo.contact.email}
- Website: ${allInfo.contact.website}
NAVIGATION STRUCTURE:
${allInfo.navigation.map(nav => `- ${nav.text} (${nav.href})`).join('\n')}
FEATURES & BENEFITS:
${allInfo.features.map(feature => `- ${feature.icon} ${feature.title}: ${feature.description}`).join('\n')}
WEBSITE SECTIONS:
${allInfo.content.sections.map(section => {
let sectionText = `\n[${section.id.toUpperCase()}]`;
if (section.heading) sectionText += `\nHeading: ${section.heading}`;
if (section.paragraphs.length) sectionText += `\nContent: ${section.paragraphs.join(' ')}`;
if (section.buttons.length) sectionText += `\nButtons: ${section.buttons.join(', ')}`;
return sectionText;
}).join('\n')}
`;
// Create options for user
const choice = prompt(`Choose how to get the information:
1. View formatted text (type 'text')
2. Download as JSON file (type 'json')
3. Copy to clipboard (type 'copy')
4. View in console (type 'console')
Type your choice:`);
switch(choice?.toLowerCase()) {
case 'text':
alert(infoDisplay);
break;
case 'json':
downloadInfoAsJSON(allInfo);
break;
case 'copy':
copyToClipboard(infoDisplay);
break;
case 'console':
default:
console.log(infoDisplay);
alert('Information has been logged to the browser console (F12 → Console tab)');
break;
}
return allInfo;
}
// Download information as JSON file
function downloadInfoAsJSON(info) {
const dataStr = JSON.stringify(info, null, 2);
const dataUri = 'data:application/json;charset=utf-8,'+ encodeURIComponent(dataStr);
const exportFileDefaultName = 'tryonyou-website-info.json';
const linkElement = document.createElement('a');
linkElement.setAttribute('href', dataUri);
linkElement.setAttribute('download', exportFileDefaultName);
linkElement.click();
alert('Website information has been downloaded as JSON file!');
}
// Copy to clipboard function
function copyToClipboard(text) {
if (navigator.clipboard) {
navigator.clipboard.writeText(text).then(() => {
alert('Information copied to clipboard!');
}).catch(() => {
fallbackCopyTextToClipboard(text);
});
} else {
fallbackCopyTextToClipboard(text);
}
}
// Fallback copy function for older browsers
function fallbackCopyTextToClipboard(text) {
const textArea = document.createElement("textarea");
textArea.value = text;
textArea.style.top = "0";
textArea.style.left = "0";
textArea.style.position = "fixed";
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
try {
document.execCommand('copy');
alert('Information copied to clipboard!');
} catch (err) {
alert('Unable to copy to clipboard. Information is available in the console.');
console.log(text);
}
document.body.removeChild(textArea);
}
// Make display function globally accessible
window.displayAllInfo = displayAllInfo;
// Add keyboard shortcut to extract info (Ctrl+I or Cmd+I)
document.addEventListener('keydown', function(e) {
if ((e.ctrlKey || e.metaKey) && e.key === 'i') {
e.preventDefault();
displayAllInfo();
}
});
});
// Add CSS for active nav links
const style = document.createElement('style');
style.textContent = `
.nav-links a.active {
opacity: 1;
border-bottom: 2px solid white;
padding-bottom: 2px;
}
`;
document.head.appendChild(style);