-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
151 lines (130 loc) · 4.68 KB
/
Copy pathscript.js
File metadata and controls
151 lines (130 loc) · 4.68 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
/**
* Smart File Sync - Interactive Landing Page Logic
* Vanilla JavaScript (Zero External Dependencies)
*/
document.addEventListener('DOMContentLoaded', () => {
// ── 1. INTERACTIVE DELTA TRANSFER SIMULATOR ──
const blockGrid = document.getElementById('blockGrid');
const btnSimulate = document.getElementById('btnSimulateEdit');
const simBytesTransferred = document.getElementById('simBytesTransferred');
const simSavings = document.getElementById('simSavings');
const TOTAL_BLOCKS = 120; // 120 blocks representing a 2MB file
const BLOCK_SIZE_BYTES = 4096; // 4KB per block
function initBlockGrid() {
if (!blockGrid) return;
blockGrid.innerHTML = '';
for (let i = 0; i < TOTAL_BLOCKS; i++) {
const block = document.createElement('div');
block.className = 'block-unit';
block.id = `block-${i}`;
blockGrid.appendChild(block);
}
}
function simulateEdit() {
if (!blockGrid) return;
// Reset all blocks
const allBlocks = blockGrid.querySelectorAll('.block-unit');
allBlocks.forEach(b => b.classList.remove('modified'));
// Pick 1 random block to modify
const randomIndex = Math.floor(Math.random() * TOTAL_BLOCKS);
const targetBlock = document.getElementById(`block-${randomIndex}`);
if (targetBlock) {
targetBlock.classList.add('modified');
}
// Animate stats counter
if (simBytesTransferred) {
simBytesTransferred.textContent = `${BLOCK_SIZE_BYTES.toLocaleString()} Bytes (4.0 KB)`;
}
if (simSavings) {
simSavings.textContent = '99.8% Time & Bandwidth Saved (1 of 120 blocks)';
}
}
initBlockGrid();
simulateEdit();
if (btnSimulate) {
btnSimulate.addEventListener('click', simulateEdit);
}
// ── 3. ONE-CLICK CLI CODE COPY ──
const btnCopyCLI = document.getElementById('btnCopyCLI');
const copyBtnText = document.getElementById('copyBtnText');
if (btnCopyCLI) {
btnCopyCLI.addEventListener('click', async () => {
const commandText = 'python -m smart_sync --src "D:\\Photos" --dst "E:\\Backup" --mode mirror --threads 8 --verify';
try {
await navigator.clipboard.writeText(commandText);
if (copyBtnText) {
copyBtnText.textContent = 'Copied to Clipboard!';
setTimeout(() => {
copyBtnText.textContent = 'Copy Command';
}, 2200);
}
} catch (err) {
// Fallback for older browsers
const tempInput = document.createElement('textarea');
tempInput.value = commandText;
document.body.appendChild(tempInput);
tempInput.select();
document.execCommand('copy');
document.body.removeChild(tempInput);
if (copyBtnText) {
copyBtnText.textContent = 'Copied!';
setTimeout(() => {
copyBtnText.textContent = 'Copy Command';
}, 2200);
}
}
});
}
// ── 4. FAQ ACCORDION INTERACTION ──
const faqItems = document.querySelectorAll('.faq-item');
faqItems.forEach(item => {
const questionBtn = item.querySelector('.faq-question');
if (questionBtn) {
questionBtn.addEventListener('click', () => {
const isActive = item.classList.contains('active');
// Close all other items
faqItems.forEach(other => other.classList.remove('active'));
// Toggle current item
if (!isActive) {
item.classList.add('active');
}
});
}
});
// ── 5. SMOOTH SCROLL FOR NAV LINKS & MOBILE MENU CLOSE ──
const navToggle = document.getElementById('navToggle');
const navMenu = document.getElementById('navMenu');
if (navToggle && navMenu) {
navToggle.addEventListener('click', (e) => {
e.stopPropagation();
navToggle.classList.toggle('active');
navMenu.classList.toggle('mobile-open');
});
// Close when clicking outside
document.addEventListener('click', (e) => {
if (!navMenu.contains(e.target) && !navToggle.contains(e.target)) {
navToggle.classList.remove('active');
navMenu.classList.remove('mobile-open');
}
});
}
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function(e) {
const targetId = this.getAttribute('href');
if (targetId === '#') return;
const targetElem = document.querySelector(targetId);
if (targetElem) {
e.preventDefault();
// Auto-close mobile menu if open
if (navToggle && navMenu) {
navToggle.classList.remove('active');
navMenu.classList.remove('mobile-open');
}
targetElem.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
});
});
});