-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStorageLayoutMapper.html
More file actions
697 lines (654 loc) · 32.1 KB
/
Copy pathStorageLayoutMapper.html
File metadata and controls
697 lines (654 loc) · 32.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
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
<html>
<head>
<title>Storage Layout Mapper Page</title>
<style>
body {
background-color:black;
color: white;
}
</style>
<!-- <base href="https://AvengerMoJo.github.io/" target="_blank"> -->
<meta charset="UTF-8">
<meta name="description" content="Storage Layout Mapping tool.">
<meta name="keywords" content="AvengerMoJo, Storage, Layout, Mapping">
<meta name="author" content="AvengerMoJo">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script>
function updateURL() {
//const queryString = window.location.search;
var server_name, boxtype, server_u, customx, customy,
drive_slot, drive_row, drive_col, drive_type, orientation, drives_type;
var server_info_completed = true;
const params = new URLSearchParams( window.location.search );
if( params.get("ServerModelName") != null ) {
document.getElementById("ServerModelName").value = server_name = params.get("ServerModelName");
} else {
server_info_completed = false;
}
if( params.get("BoxType") != null ) {
let shs = document.getElementById("ServerHeightDisplay");
let customxy = document.getElementById("CustomXY");
document.getElementById("BoxType").value = boxtype = params.get("BoxType");
if( boxtype == "Custom" ) {
document.getElementById("CustomX").value = customx = +params.get("CustomX");
document.getElementById("CustomY").value = customy = +params.get("CustomY");
customxy.style.display="initial";
shs.style.display = "none";
} else if( boxtype == "Rackmount" || boxtype == "Tower" ) {
if( params.get("ServerHeight") ){
document.getElementById("ServerHeight").value = document.getElementById("ServerHeightSelect").value = server_u = params.get("ServerHeight");
shs.style.display = "initial";
customxy.style.display="none";
} else {
server_info_completed = false;
}
}
} else {
server_info_completed = false;
}
if( params.get("TotalDrive") ){
document.getElementById("TotalDrive").value = document.getElementById("TotalDriveText").value = drive_slot = params.get("TotalDrive");
} else {
server_info_completed = false;
}
if( params.get("DriveRow") ){
document.getElementById("DriveRow").value = document.getElementById("DriveRowSelect").value = drive_row = params.get("DriveRow");
} else {
server_info_completed = false;
}
if( params.get("DriveCol") ){
document.getElementById("DriveCol").value = document.getElementById("DriveColSelect").value = drive_col = params.get("DriveCol");
} else {
server_info_completed = false;
}
if( params.get("DriveOrientation") ){
document.getElementById("DriveOrientation").value = orientation = params.get("DriveOrientation");
} else {
server_info_completed = false;
}
if( params.get("DriveType") ) {
document.getElementById("DriveType").value = drive_type = params.get("DriveType");
drives_type = new Array(drive_slot);
for(let i=0; i< drive_slot; i++ ){
drives_type[i]= drive_type;
}
} else {
server_info_completed = false;
}
if( server_info_completed ) {
clear(draw);
if( boxtype == "Custom" ) {
server_obj = drawDriveLayout(draw, server_name, boxtype, drive_slot, drive_row, drive_col, drives_type, orientation, undefined, customx, customy, 5, 5);
}
else if ( boxtype == "Rackmount" || boxtype == "Tower" ) {
server_obj = drawDriveLayout(draw, server_name, boxtype, drive_slot, drive_row, drive_col, drives_type, orientation, server_u, undefined, undefined,5, 5);
}
}
if (window.loadFromLocalStorage) {
setTimeout(window.loadFromLocalStorage, 500);
}
}
window.onload=updateURL;
</script>
<script type="module" crossorigin src="https://avengermojo.github.io/assets/storage.ab41ea20.js"></script>
<link rel="stylesheet" href="https://avengermojo.github.io/assets/storage.b979cde4.css">
</head>
<body>
<h1>Storage Drive Layout Configurator</h1>
<div class="setting" id="setting">
<div class="ServerModel">
<p>Server Model Name:
<input width=100% type="text" value="<name>" class="ServerModelName" id="ServerModelName"/>
</p>
</div>
<div class="BoxTypeDisplay" id="BoxTypeDisplay">
<p>Server Chassis Type:
<select name="BoxType" id="BoxType">
<option value="Rackmount">Rackmount</option>
<option value="Tower">Tower</option>
<option value="Custom">Custom</option>
</select>
</p>
<div name="CustomXY" id="CustomXY" style="display:none">
<p>Custom Width: <input type="number" class="CustomX" id="CustomX" value=40>mm (millimeter)</p>
<p>Custom Height: <input type="number" class="CustomY" id="CustomY" value=40>mm (millimeter)</p>
<script>
var server_type = document.getElementById("BoxType");
server_type.oninput = function() {
let customxy = document.getElementById("CustomXY");
let shs = document.getElementById("ServerHeightDisplay");
if( server_type.value == "Custom" ){
customxy.style.display = "initial";
shs.style.display = "none";
} else {
customxy.style.display="none";
shs.style.display ="initial";
}
}
</script>
</div>
</div>
<div class="ServerHeightDisplay" id="ServerHeightDisplay">
<p>Server Height:
<select name="ServerHeightSelect" id="ServerHeightSelect">
<option value="1">1U</option>
<option value="2">2U</option>
<option value="3">3U</option>
<option value="4">4U</option>
<option value="5">5U</option>
<option value="6">6U</option>
<option value="7">7U</option>
<option value="8">8U</option>
</select>
<input width=100% type="range" min="1" max="8" value="1" class="slider" id="ServerHeight">
<script>
var server_height_slider = document.getElementById("ServerHeight");
var server_height_select = document.getElementById("ServerHeightSelect");
server_height_select.value = server_height_slider.value;
server_height_slider.oninput = function() {
server_height_select.value = server_height_slider.value;
}
server_height_select.oninput = function() {
server_height_slider.value = server_height_select.value;
}
</script>
</p>
</div>
<div class="DriveRowDisplay">
<p>Drive Row Number:
<select name="DriveRowSelect" id="DriveRowSelect">
<option value="1">1 Row</option>
<option value="2">2 Row</option>
<option value="3">3 Row</option>
<option value="4">4 Row</option>
<option value="5">5 Row</option>
<option value="6">6 Row</option>
<option value="7">7 Row</option>
<option value="8">8 Row</option>
</select>
<input width=100% type="range" min="1" max="8" value="1" class="slider" id="DriveRow">
<script>
var drive_row_slider = document.getElementById("DriveRow");
var drive_row_select = document.getElementById("DriveRowSelect");
drive_row_select.value= drive_row_slider.value;
drive_row_slider.oninput = function() {
drive_row_select.value = drive_row_slider.value;
}
drive_row_select.oninput = function() {
drive_row_slider.value = drive_row_select.value;
}
</script>
</p>
</div>
<div class="DriveCol">
<p>Drive Column Number:
<select name="DriveColSelect" id="DriveColSelect">
<option value="1">1 Column</option>
<option value="2">2 Column</option>
<option value="3">3 Column</option>
<option value="4">4 Column</option>
<option value="5">5 Column</option>
<option value="6">6 Column</option>
<option value="7">7 Column</option>
<option value="8">8 Column</option>
<option value="9">9 Column</option>
<option value="10">10 Column</option>
<option value="11">11 Column</option>
<option value="12">12 Column</option>
<option value="13">13 Column</option>
<option value="14">14 Column</option>
<option value="15">15 Column</option>
<option value="16">16 Column</option>
<option value="17">17 Column</option>
<option value="18">18 Column</option>
<option value="19">19 Column</option>
<option value="20">20 Column</option>
<option value="21">21 Column</option>
<option value="22">22 Column</option>
<option value="23">23 Column</option>
<option value="24">24 Column</option>
</select>
<input width=100% type="range" min="1" max="24" value="1" class="slider" id="DriveCol">
<script>
var drive_col_slider = document.getElementById("DriveCol");
var drive_col_select = document.getElementById("DriveColSelect");
drive_col_select.value = drive_col_slider.value;
drive_col_slider.oninput = function() {
drive_col_select.value = drive_col_slider.value;
}
drive_col_select.oninput = function() {
drive_col_slider.value = drive_col_select.value;
}
</script>
</p>
</div>
<div class="TotalDrive">
<p>Total Drive Number:
<input type="text" class="TotalDriveText" id="TotalDriveText" value="1">
<input width=100% type="range" min="1" max="120" value="1" class="slider" id="TotalDrive">
<script>
var total_driver_slider = document.getElementById("TotalDrive");
var total_driver_text= document.getElementById("TotalDriveText");
total_driver_text.value = total_driver_slider.value;
total_driver_slider.oninput = function() {
total_driver_text.value = total_driver_slider.value;
}
total_driver_text.oninput = function() {
total_driver_slider.value = total_driver_text.value;
}
</script>
</p>
</div>
<div class="DriveType">
<p>Hard Drive Type:
<select name="DriveType" id="DriveType">
<option value="3.5' HDD">3.5' HDD</option>
<option value="2.5' HDD">2.5' HDD</option>
<option value="2.5' SSD">2.5' SSD</option>
<option value="NVMe">NVMe</option>
</select>
</p>
</div>
<div class="DriveOrientation">
<p>Hard Drive Orientation:
<select name="DriveOrientation" id="DriveOrientation">
<option value="Vertical">Vertical</option>
<option value="Horizontal">Horizontal</option>
<option value="Others">Others</option>
</select>
</p>
</div>
<div id="Draw" class="Draw">
<button onclick="window.call('SVG')">Draw</button>
<script>
function call(graphtype) {
const url = new URL( window.location );
server_name = document.getElementById("ServerModelName").value;
url.searchParams.set("ServerModelName", server_name);
boxtype = document.getElementById("BoxType").value;
url.searchParams.set("BoxType", boxtype);
if( boxtype == "Custom" ) {
customx = +document.getElementById("CustomX").value;
url.searchParams.set("CustomX", customx);
customy = +document.getElementById("CustomY").value;
url.searchParams.set("CustomY", customy);
url.searchParams.delete("ServerHeight");
} else if( boxtype == "Rackmount" || boxtype == "Tower" ) {
server_u = +document.getElementById("ServerHeight").value;
url.searchParams.set("ServerHeight", server_u);
url.searchParams.delete("CustomX");
url.searchParams.delete("CustomY");
}
drive_slot = document.getElementById("TotalDrive").value;
url.searchParams.set("TotalDrive", drive_slot);
drive_row = document.getElementById("DriveRow").value;
url.searchParams.set("DriveRow", drive_row);
drive_col = document.getElementById("DriveCol").value;
url.searchParams.set("DriveCol", drive_col);
drive_type = document.getElementById("DriveType").value;
url.searchParams.set("DriveType", drive_type);
drives_type = new Array(drive_slot);
for( i=0; i< drive_slot; i++ ){
// console.log( "TotalDrive " + drive_slot + "Drive Type =" + drive_type )
drives_type[i]= drive_type;
}
orientation = document.getElementById("DriveOrientation").value;
url.searchParams.set("DriveOrientation", orientation);
if( graphtype == "SVG" ) {
clear(draw);
if( boxtype == "Custom" ) {
server_obj = drawDriveLayout(draw, server_name, boxtype, drive_slot, drive_row, drive_col, drives_type, orientation, undefined, customx, customy, 5, 5);
} else {
server_obj = drawDriveLayout(draw, server_name, boxtype, drive_slot, drive_row, drive_col, drives_type, orientation, server_u, undefined, undefined, 5, 5);
}
} else if( graphtype == "Diagrams-Shape" ) {
if( boxtype == "Custom" ) {
server_obj = drawDriveLayout(draw, server_name, boxtype, drive_slot, drive_row, drive_col, drives_type, orientation, undefined, customx, customy, 5, 5);
diaShapeDraw(server_obj);
} else {
server_obj = drawDriveLayout(draw, server_name, boxtype, drive_slot, drive_row, drive_col, drives_type, orientation, server_u, undefined, undefined, 5, 5);
diaShapeDraw(server_obj);
}
}
window.history.pushState({}, "", url);
}
</script>
<div id="Download" class="Download">
<input width=100% type="text" min="1" max="60" value="sample.svg" class="Filename" id="Filename">
<button onclick="window.download()">Download</button>
<script>
function download() {
var filename = document.getElementById("Filename").value;
downloadString( draw.svg(), "text/csv", filename);
}
</script>
</div>
</div>
</div>
<div id="tab" class="tab">
<script>
function switchTab(theEvent, tabName) {
var i, tabview, tablinks;
tabview = document.getElementsByClassName("tabview");
for (i = 0; i < tabview.length; i++) {
tabview[i].style.display = "none";
}
tablinks = document.getElementsByClassName("tablinks");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}
document.getElementById(tabName).style.display = "block";
theEvent.currentTarget.className += " active";
}
function updateMetadataTab(){
var elements = document.getElementsByClassName('HardDrive');
for (var i = 0; i < elements.length; i++) {
var element = elements[i];
var select_hd_id = document.getElementById("HardDriveID");
select_hd_id.options[ select_hd_id.options.length ] = new Option(element.id, element.id);
}
}
</script>
<button class="tablinks" onclick="switchTab(event, 'Json')">JSON</button>
<button class="tablinks" onclick="switchTab(event, 'diagrams.net')">diagrams.net</button>
<button class="tablinks" onclick="switchTab(event, 'MetadataTab');updateMetadataTab();">Metadata</button>
<div id="Json" class="tabview">
<button onclick="window.jsonview()">JSON-View</button>
<script>
function jsonview() {
showjson( draw.svg() );
}
</script>
<div id="JsonView" class="code">
<pre><code id="jsonstring"></code></pre>
</div>
</div>
<div id="diagrams.net" class="tabview">
<button onclick="window.shapeview()">Diagrams-Shape</button>
<script>
function shapeview() {
console.log(" Object server = " +server_obj);
diaShapeDraw(server_obj);
}
</script>
<div id="DiagramsShapeView" class="code">
<pre><textarea id="diastring" rows="25" cols="80"></textarea></pre>
</div>
</div>
<div id="MetadataTab" class="tabview">
<button onclick="window.colorchangeview()">ColorChange</button>
<script>
function getOppositeColor(colorName) {
const lightColors = ['white', 'lightblue', 'lightgreen', 'lightyellow', 'lightred', 'cyan', 'lime', 'silver', 'pink'];
const darkColors = ['black', 'blue', 'green', 'red', 'orange', 'purple', 'brown', 'gray', 'teal', 'navy', 'maroon', 'olive', 'magenta'];
if (lightColors.includes(colorName)) {
return 'black';
} else {
return 'white';
}
}
function colorchangeview() {
backgroundColor = document.getElementById("HardDriveColor").value;
drive = document.getElementById("HardDriveID").value;
textColor = getOppositeColor(backgroundColor);
if( drive == "All" ) {
var elements = document.getElementsByClassName('HardDrive');
for (var i = 0; i < elements.length; i++) {
var element = elements[i];
var rect = element.querySelector('rect');
var text = element.querySelector('text');
if (rect) rect.style.fill = backgroundColor;
if (text) text.style.fill = textColor;
}
} else {
var element = document.getElementById(drive);
if (element) {
var rect = element.querySelector('rect');
var text = element.querySelector('text');
if (rect) rect.style.fill = backgroundColor;
if (text) text.style.fill = textColor;
}
}
saveToLocalStorage();
}
function updateSerialNumber() {
var serialNumber = document.getElementById("SerialNumber").value;
var driveId = document.getElementById("HardDriveID").value;
if (driveId === "All") {
updateAllSerials(serialNumber);
} else {
updateSingleSerial(driveId, serialNumber);
}
saveToLocalStorage();
}
function onDriveSelectionChange() {
var driveId = document.getElementById("HardDriveID").value;
var serialInput = document.getElementById("SerialNumber");
if (driveId === "All") {
serialInput.value = "";
serialInput.placeholder = "Enter serial for ALL drives...";
} else {
var element = document.getElementById(driveId);
if (element) {
var title = element.querySelector('title');
if (title && title.textContent) {
serialInput.value = title.textContent;
serialInput.placeholder = "e.g., SN12345";
} else {
serialInput.value = "";
serialInput.placeholder = "No serial set for " + driveId;
}
}
}
}
function updateSingleSerial(driveId, serialNumber) {
var element = document.getElementById(driveId);
if (element) {
var title = element.querySelector('title');
if (!title) {
title = SVG().title(serialNumber);
element.add(title);
} else {
title.textContent = serialNumber;
}
}
}
function updateAllSerials(serialNumber) {
var elements = document.getElementsByClassName('HardDrive');
for (var i = 0; i < elements.length; i++) {
var element = elements[i];
var title = element.querySelector('title');
if (!title) {
title = SVG().title(serialNumber);
element.add(title);
} else {
title.textContent = serialNumber;
}
}
}
</script>
<div id="ColorChangeView" class="menu">
<p>Drive Background Color:
<select name="HardDriveColor" id="HardDriveColor">
<option value="white">White</option>
<option value="black">Black</option>
<option value="blue">Blue</option>
<option value="green">Green</option>
<option value="red">Red</option>
<option value="yellow">Yellow</option>
<option value="orange">Orange</option>
<option value="purple">Purple</option>
<option value="cyan">Cyan</option>
<option value="magenta">Magenta</option>
<option value="pink">Pink</option>
<option value="brown">Brown</option>
<option value="gray">Gray</option>
<option value="lightblue">Light Blue</option>
<option value="lightgreen">Light Green</option>
<option value="lightyellow">Light Yellow</option>
<option value="lightred">Light Red</option>
<option value="teal">Teal</option>
<option value="navy">Navy</option>
<option value="lime">Lime</option>
<option value="maroon">Maroon</option>
<option value="olive">Olive</option>
<option value="silver">Silver</option>
</select>
</p>
<p>Change Color for HardDrive ID :</p>
<select name="HardDriveID" id="HardDriveID" onchange="window.onDriveSelectionChange()">
<option value="All">All</option>
</select>
<hr style="border-color: #555; margin: 20px 0;">
<p>Serial Number:
<input type="text" id="SerialNumber" placeholder="e.g., SN12345" style="margin-left: 10px; padding: 5px; width: 200px;">
</p>
<button onclick="window.updateSerialNumber()">Update Serial</button>
<p style="margin-top: 20px; font-size: 12px; color: #888;">
<strong>Tip:</strong> Select a drive ID above to see its current serial number. Each drive can have its own serial number like colors.
</p>
<hr style="border-color: #555; margin: 20px 0;">
<p style="margin-bottom: 10px;">
<small>💾 Auto-saved to browser (survives reload)</small>
</p>
<button onclick="window.exportConfiguration()">📥 Export Configuration (JSON + SVG)</button>
<button onclick="document.getElementById('importFile').click()">📤 Import Configuration</button>
<input type="file" id="importFile" accept=".json" style="display: none;" onchange="window.importConfiguration(event)">
</div>
</div>
</div>
<div id="box" class="box"></div>
<div id="serialTooltip"></div>
<script>
// LocalStorage and Export/Import functions
function saveToLocalStorage() {
const metadata = {
version: "1.0",
savedAt: new Date().toISOString(),
driveColors: {},
serialNumbers: {}
};
// Collect current state from DOM
document.querySelectorAll('.HardDrive').forEach(drive => {
const id = drive.id;
const rect = drive.querySelector('rect');
const title = drive.querySelector('title');
if (rect) {
metadata.driveColors[id] = rect.style.fill;
}
if (title && title.textContent) {
metadata.serialNumbers[id] = title.textContent;
}
});
localStorage.setItem('storageMapperMetadata', JSON.stringify(metadata));
}
function exportConfiguration() {
const metadata = {
version: "1.0",
exportedAt: new Date().toISOString(),
url: window.location.href,
svg: draw.svg(),
driveColors: {},
serialNumbers: {}
};
// Collect current state from DOM
document.querySelectorAll('.HardDrive').forEach(drive => {
const id = drive.id;
const rect = drive.querySelector('rect');
const title = drive.querySelector('title');
if (rect) {
metadata.driveColors[id] = rect.style.fill;
}
if (title && title.textContent) {
metadata.serialNumbers[id] = title.textContent;
}
});
// Download as JSON file
const blob = new Blob([JSON.stringify(metadata, null, 2)], { type: "application/json" });
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = "storage-config-" + new Date().toISOString().split('T')[0] + ".json";
a.style.display = "none";
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
setTimeout(function() { URL.revokeObjectURL(url); }, 1500);
}
function importConfiguration(event) {
const file = event.target.files[0];
if (!file) return;
const reader = new FileReader();
reader.onload = function(event) {
try {
const metadata = JSON.parse(event.target.result);
// Restore URL parameters and redraw layout if URL is present
if (metadata.url) {
const importedUrl = new URL(metadata.url);
window.history.pushState({}, "", importedUrl.pathname + importedUrl.search);
updateURL();
}
// Apply colors
Object.entries(metadata.driveColors || {}).forEach(([id, color]) => {
const drive = document.getElementById(id);
if (drive) {
const rect = drive.querySelector('rect');
const text = drive.querySelector('text');
if (rect) rect.style.fill = color;
if (text) text.style.fill = getOppositeColor(color);
}
});
// Apply serial numbers
Object.entries(metadata.serialNumbers || {}).forEach(([id, serial]) => {
const element = document.getElementById(id);
if (element) {
let title = element.querySelector('title');
if (!title) {
title = document.createElementNS("http://www.w3.org/2000/svg", "title");
element.appendChild(title);
}
title.textContent = serial;
}
});
// Save to localStorage
saveToLocalStorage();
alert('Configuration imported successfully! Layout restored and metadata saved to browser storage.');
console.log('Imported metadata:', metadata.exportedAt);
} catch (error) {
console.error('Error importing configuration:', error);
alert('Error importing configuration. Please check the file format.');
}
};
reader.readAsText(file);
// Reset file input
event.target.value = '';
}
// Custom tooltip for serial numbers
const tooltip = document.getElementById('serialTooltip');
document.addEventListener('DOMContentLoaded', function() {
document.addEventListener('mouseover', function(e) {
const target = e.target.closest('.HardDrive');
if (target) {
const title = target.querySelector('title');
if (title && title.textContent) {
tooltip.textContent = title.textContent;
tooltip.style.display = 'block';
}
}
}, true);
document.addEventListener('mouseout', function(e) {
const target = e.target.closest('.HardDrive');
if (target) {
tooltip.style.display = 'none';
}
}, true);
document.addEventListener('mousemove', function(e) {
if (tooltip.style.display === 'block') {
tooltip.style.left = (e.pageX + 15) + 'px';
tooltip.style.top = (e.pageY + 15) + 'px';
}
}, true);
});
</script>
</body>
</html>