-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjavascript.js
More file actions
119 lines (95 loc) · 3.67 KB
/
Copy pathjavascript.js
File metadata and controls
119 lines (95 loc) · 3.67 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
/* ═══════════════════════════════════════════
ACTIVE NAV ON SCROLL
═══════════════════════════════════════════ */
const sections = document.querySelectorAll("section");
const navLinks = document.querySelectorAll("nav a");
window.addEventListener("scroll", () => {
let current = "";
sections.forEach(sec => {
if (scrollY >= sec.offsetTop - sec.offsetHeight / 3) {
current = sec.id;
}
});
navLinks.forEach(link => {
link.classList.toggle("active", link.getAttribute("href") === `#${current}`);
});
}, { passive: true });
/* ═══════════════════════════════════════════
Cursor PNG
═══════════════════════════════════════════
function createCursorPNG(color, size = 32) {
const canvas = document.createElement('canvas');
canvas.width = size;
canvas.height = size;
const ctx = canvas.getContext('2d');
ctx.strokeStyle = color;
ctx.lineWidth = 2;
const center = size / 2;
const offset = size / 6;
ctx.beginPath();
ctx.moveTo(center, offset);
ctx.lineTo(center, size - offset);
ctx.stroke();
ctx.beginPath();
ctx.moveTo(offset, center);
ctx.lineTo(size - offset, center);
ctx.stroke();
return canvas.toDataURL('image/png');
}
const whiteCursor = createCursorPNG('#ffffff');
const greenCursor = createCursorPNG('#00ff41');
const greenDimCursor = createCursorPNG('#00791e');
// Body et li en blanc
document.querySelectorAll('body, li').forEach(el => {
el.style.cursor = `url('${whiteCursor}') 16 16, auto`;
});
// A et button en vert
document.querySelectorAll('a, button').forEach(el => {
el.style.cursor = `url('${greenCursor}') 16 16, auto`;
});
// IMPORTANT: Remplace les curseurs "grab" et "pointer" EN TEMPS RÉEL
document.addEventListener('mouseover', (e) => {
const computedCursor = window.getComputedStyle(e.target).cursor;
// Si c'est "grab" ou "pointer", remplace par la croix verte
if (computedCursor === 'grab' || computedCursor === 'pointer') {
e.target.style.cursor = `url('${greenDimCursor}') 16 16, auto`;
}
}, true); // true = capture phase pour attraper tous les éléments
// Même chose pour mouseenter (au cas où)
document.addEventListener('mouseenter', (e) => {
const computedCursor = window.getComputedStyle(e.target).cursor;
if (computedCursor === 'grab' || computedCursor === 'pointer') {
e.target.style.cursor = `url('${greenDimCursor}') 16 16, auto`;
}
}, true);
/* ═══════════════════════════════════════════ TERMINAL TYPEWRITER (querySelector version) ═══════════════════════════════════════════
const output = document.getElementById("terminal-output");
function addLine(text) {
const div = document.createElement("div");
div.className = "line";
div.textContent = text;
output.appendChild(div);
}
/* Python code
const pythonCode = `
lines = [
"> initializing profile...",
"",
"> status : Open to opportunities",
"> interests : design, web security, reverse engineering",
"> education : BTS CIEL Option B",
"",
"> system ready_"
]
"\\n".join(lines)
`;
async function runPython() {
const pyodide = await loadPyodide();
const result = await pyodide.runPythonAsync(pythonCode);
const lines = result.split("\n");
for (const line of lines) {
addLine(line);
}
}
runPython();
*/