-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
145 lines (129 loc) · 4.62 KB
/
script.js
File metadata and controls
145 lines (129 loc) · 4.62 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
const charSet = "!@#$%^&*(),.:;\"'";
const diamondPattern = [150, 160, 150];
const bgElement = document.getElementById('matrix-bg');
first = true
function generateFrame() {
let frame = "";
diamondPattern.forEach(count => {
let line = "";
for (let i = 0; i < count; i++) {
line += charSet[Math.floor(Math.random() * charSet.length)];
}
frame += line + "\n";
});
bgElement.textContent = frame;
}
if (first) {
generateFrame();
first = false;
}
// Change how quickly the text updates
setInterval(generateFrame, 300);
// ---- Email copy button ----
const emailBtn = document.getElementById('email-btn');
if (emailBtn) {
emailBtn.addEventListener('click', function () {
const email = 'blakeduvallrobertson@gmail.com';
const copiedEl = emailBtn.querySelector('.email-copied');
const textEl = emailBtn.querySelector('.email-text');
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(email).then(showCopied).catch(fallbackCopy);
} else {
fallbackCopy();
}
function fallbackCopy() {
const textarea = document.createElement('textarea');
textarea.value = email;
textarea.style.position = 'fixed';
textarea.style.opacity = '0';
document.body.appendChild(textarea);
textarea.select();
document.execCommand('copy');
document.body.removeChild(textarea);
showCopied();
}
function showCopied() {
textEl.style.opacity = '0';
copiedEl.classList.add('show');
setTimeout(function () {
copiedEl.classList.remove('show');
textEl.style.opacity = '';
}, 1200);
}
});
}
// ---- Receipt hover/tap preview ----
const receiptItems = document.querySelectorAll('.receipt-item[data-preview]');
const placeholder = document.getElementById('preview-placeholder');
function isTouchDevice() {
return ('ontouchstart' in window) || (navigator.maxTouchPoints > 0);
}
function showPreview(item) {
const previewId = 'preview-' + item.getAttribute('data-preview');
document.querySelectorAll('.receipt-preview-content').forEach(el => el.style.display = 'none');
placeholder.style.display = 'none';
const target = document.getElementById(previewId);
if (target) target.style.display = 'flex';
}
function openPdf(item) {
const previewId = 'preview-' + item.getAttribute('data-preview');
const target = document.getElementById(previewId);
if (target) {
const iframe = target.querySelector('iframe');
if (iframe) {
const pdfUrl = iframe.src.split('#')[0];
window.open(pdfUrl, '_blank');
}
}
}
receiptItems.forEach(item => {
// Desktop: hover to preview
item.addEventListener('mouseenter', () => {
showPreview(item);
});
item.addEventListener('click', () => {
if (window.innerWidth <= 768) {
// Mobile: open PDF immediately since preview is hidden
openPdf(item);
} else if (isTouchDevice()) {
// Tablet or touch laptop: First tap shows preview, second tap opens PDF
const previewId = 'preview-' + item.getAttribute('data-preview');
const target = document.getElementById(previewId);
if (target && target.style.display === 'flex') {
openPdf(item);
} else {
showPreview(item);
}
} else {
openPdf(item);
}
});
});
// ---- Project Outline Hover Effect ----
const cybranceeLogo = document.getElementById('cybrancee');
const cliqueLogo = document.getElementById('clique');
const projectBoxes = document.querySelectorAll('.project-box');
function handleLogoHover(hoveredClass) {
projectBoxes.forEach(box => {
if (!box.classList.contains(hoveredClass)) {
box.style.borderColor = '#2b2b2b8b'; // Reset to default border color
}
});
}
function resetLogoHover() {
projectBoxes.forEach(box => {
box.style.borderColor = ''; // Remove inline style to restore CSS class border
});
}
if (cybranceeLogo) {
cybranceeLogo.addEventListener('mouseenter', () => {
if (window.innerWidth > 768) handleLogoHover('project-cybrancee');
});
cybranceeLogo.addEventListener('mouseleave', resetLogoHover);
}
if (cliqueLogo) {
cliqueLogo.addEventListener('mouseenter', () => {
if (window.innerWidth > 768) handleLogoHover('project-clique');
});
cliqueLogo.addEventListener('mouseleave', resetLogoHover);
}