forked from chrisreinhart/jencks-fads
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfinal.html
More file actions
398 lines (366 loc) · 13.1 KB
/
Copy pathfinal.html
File metadata and controls
398 lines (366 loc) · 13.1 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
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Interactive Jencks Diagram</title>
<script src="https://d3js.org/d3.v7.min.js"></script>
<style>
body {
text-align: center;
font-family: "Trebuchet MS", Verdana, sans-serif;
background-color: black;
color: yellow;
}
h2 {
font-size: 24px;
font-weight: bold;
color: yellow;
}
.search-bar {
position: absolute;
top: 10px;
left: 20px;
z-index: 10;
background-color: black;
padding: 5px;
}
.search-bar input,
.search-bar button {
padding: 8px;
background-color: black;
border: 2px solid yellow;
color: yellow;
font-size: 16px;
margin-right: 4px;
}
.search-bar button {
cursor: pointer;
}
#svgContainer {
display: block;
margin: auto;
width: 98%;
background-color: black;
margin-top: -20px;
position: relative;
z-index: 0;
}
input, button {
margin-top: 10px;
padding: 8px;
background-color: black;
border: 2px solid yellow;
color: yellow;
font-size: 16px;
position: relative;
z-index: 2;
}
button {
cursor: pointer;
}
.highlight {
fill: red !important;
font-weight: bold;
opacity: 1;
filter: none;
}
.blurred {
opacity: 0.3;
filter: blur(3px);
}
.popup, .popup-match {
font-size: 14px;
font-weight: bold;
display: none;
z-index: 1000;
box-shadow: 0px 0px 10px yellow;
}
.popup {
position: absolute;
background: rgba(255, 255, 0, 0.9);
color: black;
padding: 6px 12px;
border-radius: 5px;
pointer-events: none;
white-space: nowrap;
border: 1px solid black;
}
.popup-match {
position: fixed;
top: 60px;
right: 20px;
background: rgba(0, 255, 0, 0.8);
color: black;
padding: 12px 20px;
border-radius: 8px;
animation: fadeOut 3s forwards;
}
.suggestions {
position: absolute;
background: black;
border: 2px solid yellow;
color: yellow;
max-height: 150px;
overflow-y: auto;
width: 200px;
display: none;
text-align: left;
left: 50%;
transform: translateX(-50%);
z-index: 3;
}
.suggestions div {
padding: 5px;
cursor: pointer;
}
.suggestions div:hover {
background: yellow;
color: black;
}
.author-details {
position: absolute;
width: 260px;
background: black;
color: yellow;
padding: 12px;
border: 2px solid yellow;
border-radius: 5px;
font-size: 14px;
display: none;
text-align: left;
}
.author-details h3 {
margin: 5px 0;
font-size: 16px;
border-bottom: 1px solid yellow;
padding-bottom: 5px;
}
.author-details p {
margin: 5px 0;
}
.author-details button {
display: block;
width: 100%;
margin-top: 5px;
background-color: yellow;
color: black;
border: none;
padding: 5px;
font-size: 14px;
cursor: pointer;
}
.author-details button.disabled {
background-color: gray !important;
color: black;
cursor: not-allowed;
}
@keyframes fadeOut {
0% { opacity: 1; }
80% { opacity: 1; }
100% { opacity: 0; }
}
</style>
</head>
<body>
<h2>COMPARISONS BETWEEN THE BUILT ENVIRONMENT AND BIOLOGY</h2>
<div class="search-bar">
<input type="text" id="search" placeholder="Enter author name" onkeyup="showSuggestions()" />
<button onclick="highlightText()">Search</button>
<button onclick="resetPage()">Reset</button>
<div id="suggestions" class="suggestions"></div>
</div>
<div style="width: 1000px; margin: 0 auto; padding-top: 10px; text-align: left;">
<label for="dateSlider" style="color: yellow; font-weight: bold; font-size: 16px; display: block; margin-bottom: 6px;">
FILTER RESULTS BY DATE
</label>
<input type="range" id="dateSlider" min="1900" max="2000" step="10" value="2000"
style="width: 100%; height: 8px; background-color: yellow; accent-color: yellow; cursor: pointer; border-radius: 5px;"
oninput="updateSelectedYear(this.value)" />
<div style="margin-top: 6px; display: flex; justify-content: space-between; font-size: 12px; color: yellow;">
<span>1900</span>
<span>1910</span>
<span>1920</span>
<span>1930</span>
<span>1940</span>
<span>1950</span>
<span>1960</span>
<span>1970</span>
<span>1980</span>
<span>1990</span>
<span>2000</span>
</div>
<div id="selectedYearDisplay" style="margin-top: 8px; color: yellow; font-size: 14px;">
Selected Year: 2000
</div>
</div>
<div id="popup" class="popup"></div>
<div id="popupMatch" class="popup-match"></div>
<div id="svgContainer"></div>
<div class="author-details" id="author-details"></div>
<script>
const svgFilePath = "jencks_1.svg";
const suggestionCSV = "author_data1.csv";
const detailCSV = "author_editcore.csv";
let originalSVG = "";
let namesList = [];
let csvData = {};
function loadSuggestionCSV() {
fetch(suggestionCSV)
.then(response => response.text())
.then(data => {
let rows = data.split("\n").map(row => row.split(","));
namesList = rows.map(row => row[0]?.trim().toLowerCase()).filter(Boolean);
namesList = [...new Set(namesList)];
});
}
function loadDetailCSV() {
fetch(detailCSV)
.then(response => response.text())
.then(data => {
let rows = data.split("\n").map(row => row.split(","));
rows.forEach((row, index) => {
if (index === 0 || row.length < 2) return;
let name = row[1].trim().toLowerCase(); // 👈 THIS is the key
csvData[name] = { // 👈 key: "le corbusier"
Lastname: row[1],
Firstname: row[2],
Viaf: row[3],
Wikipedia: row[4],
Born: row[5],
Died: row[6],
WorksinHTRC: row[7],
Biological: row[8]
};
});
});
}
function loadSVG() {
fetch(svgFilePath)
.then(response => response.text())
.then(svgData => {
originalSVG = svgData;
document.getElementById("svgContainer").innerHTML = svgData;
attachEventHandlers();
});
}
function attachEventHandlers() {
d3.select("#svgContainer svg")
.selectAll("text")
.on("mouseover", function(event) {
let textContent = d3.select(this).text().trim();
const popup = document.getElementById("popup");
popup.style.display = "block";
popup.innerHTML = `<strong>${textContent}</strong>`;
popup.style.left = event.pageX + 10 + "px";
popup.style.top = event.pageY + 10 + "px";
})
.on("mousemove", function(event) {
const popup = document.getElementById("popup");
popup.style.left = event.pageX + 10 + "px";
popup.style.top = event.pageY + 10 + "px";
})
.on("mouseout", function() {
document.getElementById("popup").style.display = "none";
})
.on("click", function(event) {
let author = d3.select(this).text().trim().toLowerCase();
showAuthorDetails(author, event);
});
}
function showAuthorDetails(author, event) {
if (!csvData[author]) return;
const data = csvData[author];
const detailsBox = document.getElementById("author-details");
let wikipediaButton = data.Wikipedia
? `<button onclick="window.open('${data.Wikipedia}', '_blank')">Link to Wikipedia</button>`
: `<button class='disabled'>No Wikipedia Link</button>`;
let viafButton = data.Viaf
? `<button onclick="window.open('${data.Viaf}', '_blank')">Link to VIAF</button>`
: `<button class='disabled'>No VIAF Link</button>`;
detailsBox.innerHTML = `
<h3>${data.Lastname}<strong>,</strong> ${data.Firstname}</h3>
<p><strong>Born:</strong> ${data.Born}</p>
<p><strong>Died:</strong> ${data.Died}</p>
<p><strong>Works in VIAF Catalog:</strong> ${data.Viaf && data.Viaf !== "N/A" ? "Yes" : "No"}</p>
<p><strong>Works in HTRC Catalog:</strong> ${data.WorksinHTRC}</p>
<p><strong>Built/Biological Comparisons Found:</strong> ${data.Biological}</p> <!-- Displaying the new Biological field -->
${wikipediaButton}
${viafButton}
`;
const bbox = event.target.getBoundingClientRect();
detailsBox.style.left = bbox.left + window.scrollX + 20 + "px";
detailsBox.style.top = bbox.top + window.scrollY + 20 + "px";
detailsBox.style.display = "block";
}
function showSuggestions() {
const input = document.getElementById("search").value.trim().toLowerCase();
const suggestionsBox = document.getElementById("suggestions");
if (!input) return suggestionsBox.style.display = "none";
const matches = namesList.filter(name => name.startsWith(input));
if (!matches.length) return suggestionsBox.style.display = "none";
suggestionsBox.innerHTML = matches.map(name => `<div onclick="selectSuggestion('${name}')">${name}</div>`).join("");
suggestionsBox.style.display = "block";
}
function selectSuggestion(name) {
document.getElementById("search").value = name;
hideSuggestions();
highlightText();
}
function hideSuggestions() {
document.getElementById("suggestions").style.display = "none";
}
function updateSelectedYear(value) {
document.getElementById("selectedYearDisplay").innerText = "Selected Year: " + value;
}
function highlightText() {
const input = document.getElementById("search").value.trim().toLowerCase();
if (!input) return;
let found = false, count = 0;
const texts = document.querySelectorAll("#svgContainer svg text");
texts.forEach(text => {
const content = text.textContent.trim().toLowerCase();
if (content === input) {
found = true; count++;
text.classList.add("highlight");
text.classList.remove("blurred");
} else {
text.classList.remove("highlight");
text.classList.add("blurred");
}
});
if (!found) {
showPopup("No Match Found");
texts.forEach(text => text.classList.remove("blurred"));
} else {
showMatchPopup(`${count} Match(es) Found`);
}
hideSuggestions();
}
function resetPage() {
document.getElementById("svgContainer").innerHTML = originalSVG;
document.getElementById("search").value = "";
hideSuggestions();
attachEventHandlers();
document.getElementById("author-details").style.display = "none";
}
function showPopup(msg) {
const popup = document.getElementById("popup");
popup.innerText = msg;
popup.style.display = "block";
setTimeout(() => popup.style.display = "none", 3000);
}
function showMatchPopup(msg) {
const popup = document.getElementById("popupMatch");
popup.innerText = msg;
popup.style.display = "block";
setTimeout(() => popup.style.display = "none", 3000);
}
window.onload = function () {
loadSuggestionCSV();
loadDetailCSV();
loadSVG();
}
</script>
</body>
</html>