-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwriting.html
More file actions
275 lines (242 loc) · 9.37 KB
/
writing.html
File metadata and controls
275 lines (242 loc) · 9.37 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
<title>Writing - Nicolas Mallinckrodt</title>
<link rel="stylesheet" href="project.css">
<link rel="stylesheet" href="https://use.typekit.net/jlz2zhe.css">
<link rel="icon" type="image/x-icon" href="util/favicon.ico">
<style>
.writing-item {
margin-bottom: 2em;
}
.writing-heading {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 0.5em;
}
.writing-title {
margin: 0;
}
.writing-date {
display: inline-block;
font-size: 0.9rem;
padding: 0.4em 1em;
border-radius: 2em;
background-color: rgba(255, 255, 255, 0.2);
white-space: nowrap;
}
.link-dot {
cursor: pointer;
flex-shrink: 0;
}
@media screen and (max-width: 768px) {
.writing-date {
font-size: 0.75rem;
padding: 0.3em 0.8em;
}
.writing-heading {
flex-direction: column;
align-items: flex-start;
}
}
</style>
</head>
<body>
<div class="header">
<div class="text-block">
<div class="top-text">
<span class="name">nicolas</span>
<span class="time" id="time">12:16</span>
</div>
<div class="divider"></div>
<div class="bottom-text">
<span class="inverted name">mallinckrodt</span>
<span class="inverted date" id="date">26.08.2024</span>
</div>
</div>
</div>
<div class="container">
<div class="heading-container">
<div class="dot smoll yellow" id="index">
<span class="spinning-text spinning-text-small">BACK</span>
</div>
<h1>Writing</h1>
</div>
<section class="project-content">
<p>Loading writing...</p>
</section>
<div class="dots">
<div class="dot red" id="yellowbook.substack.com">
<span class="spinning-text">Substack</span>
</div>
<div class="dot yellow" id="nicolas-py.github.io/portfolio-b">
<span class="spinning-text">Home</span>
</div>
</div>
</div>
<div class="dot red small" url="projects" id="projects">
<span class="spinning-text spinning-text-small">Projects</span>
</div>
<div class="dot red small" url="writing" id="writing">
<span class="spinning-text spinning-text-small">Writing</span>
</div>
<div class="dot red small" url="about" id="about">
<span class="spinning-text spinning-text-small">About</span>
</div>
<script>
function updateTime() {
const now = new Date();
const day = String(now.getDate()).padStart(2, '0');
const month = String(now.getMonth() + 1).padStart(2, '0');
const year = now.getFullYear();
const formattedDate = `${day}.${month}.${year}`;
const hours = String(now.getHours()).padStart(2, '0');
const minutes = String(now.getMinutes()).padStart(2, '0');
const seconds = String(now.getSeconds()).padStart(2, '0');
const timezoneOffset = now.getTimezoneOffset();
const timezoneHours = String(Math.abs(timezoneOffset) / 60).padStart(2, '0');
const timezoneMinutes = String(Math.abs(timezoneOffset) % 60).padStart(2, '0');
const timezoneSign = timezoneOffset > 0 ? '-' : '+';
const formattedTime = `${hours}:${minutes}:${seconds} GMT${timezoneSign}${timezoneHours}${timezoneMinutes}`;
document.getElementById("date").innerHTML = formattedDate;
document.getElementById("time").innerHTML = formattedTime;
}
setInterval(updateTime, 1000);
updateTime();
</script>
<script>
/**
* Initializes click handlers for navigation dots
*/
function initDotNavigation() {
document.querySelectorAll('.dot').forEach((dot) => {
// Skip if already has listener
if (dot.dataset.hasListener) return;
dot.dataset.hasListener = 'true';
dot.addEventListener('click', function(e) {
e.preventDefault();
e.stopPropagation();
this.classList.add('dot-big');
const route = this.id;
const url = this.getAttribute('url');
const linkUrl = this.dataset.linkUrl;
setTimeout(() => {
if (route === 'index') {
window.location.href = 'index.html';
} else if (url) {
window.location.href = `${route}.html`;
} else if (linkUrl) {
window.open(linkUrl, '_blank');
} else if (route) {
window.location.href = `https://${route}`;
}
setTimeout(() => {
this.classList.remove('dot-big');
}, 800);
}, 400);
});
});
}
// Initialize on page load
document.addEventListener('DOMContentLoaded', initDotNavigation);
// Add scroll-based spinning animation for mobile
if (window.innerWidth < 1200) {
window.addEventListener('scroll', () => {
const scrollPercentage = (window.scrollY / (document.documentElement.scrollHeight - window.innerHeight)) * 100;
const rotation = scrollPercentage * 3.6;
let multi = 1;
document.querySelectorAll('.spinning-text-small').forEach((element) => {
element.style.transform = `rotate(${rotation*multi}deg)`;
multi*=1.4;
});
});
}
</script>
<script>
const API_URL = 'https://nicolas-py.github.io/portfolio-provider/api/portfolio.json';
/**
* Converts a number to Roman numeral
* @param {number} num - Number to convert
* @returns {string} Roman numeral representation
*/
function toRoman(num) {
const romanNumerals = ["I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X",
"XI", "XII", "XIII", "XIV", "XV", "XVI", "XVII", "XVIII", "XIX", "XX"];
return romanNumerals[num - 1] || num.toString();
}
/**
* Creates a link dot element
* @param {Object} link - Link object with url and label
* @returns {HTMLElement} The dot element
*/
function createLinkDot(link) {
const dotElement = document.createElement('div');
dotElement.className = 'dot smoll red link-dot';
dotElement.dataset.linkUrl = link.url;
const span = document.createElement('span');
span.className = 'spinning-text spinning-text-small';
span.textContent = link.label;
dotElement.appendChild(span);
return dotElement;
}
/**
* Fetches writing from the API and renders them
*/
async function loadWriting() {
const container = document.querySelector('.project-content');
try {
const response = await fetch(API_URL);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
const writing = data.writing;
if (!writing || writing.length === 0) {
container.innerHTML = '<p>No writing found.</p>';
return;
}
container.innerHTML = '';
writing.forEach((item, index) => {
const writingItem = document.createElement('div');
writingItem.className = 'writing-item';
const headingContainer = document.createElement('div');
headingContainer.className = 'heading-container';
// Create the heading with title and date
const headingWrapper = document.createElement('div');
headingWrapper.className = 'writing-heading';
const h2 = document.createElement('h2');
h2.className = 'writing-title';
h2.textContent = `${toRoman(index + 1)}. ${item.title}`;
headingWrapper.appendChild(h2);
if (item.date) {
const dateBadge = document.createElement('span');
dateBadge.className = 'writing-date';
dateBadge.textContent = item.date;
headingWrapper.appendChild(dateBadge);
}
headingContainer.appendChild(headingWrapper);
// Create the link dot
if (item.link && item.link.url) {
const dotElement = createLinkDot(item.link);
headingContainer.appendChild(dotElement);
}
writingItem.appendChild(headingContainer);
const p = document.createElement('p');
p.textContent = item.description;
writingItem.appendChild(p);
container.appendChild(writingItem);
});
// Re-initialize dot navigation for dynamically added dots
initDotNavigation();
} catch (error) {
console.error('Error loading writing:', error);
container.innerHTML = '<p>Failed to load writing. Please try again later.</p>';
}
}
document.addEventListener('DOMContentLoaded', loadWriting);
</script>
</body>
</html>