-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
243 lines (212 loc) · 9.2 KB
/
index.html
File metadata and controls
243 lines (212 loc) · 9.2 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>EBP2DOC Web</title>
<link rel="stylesheet" href="css/main.css">
<style>
</style>
</head>
<body>
<h1>
<svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path>
<polyline points="14 2 14 8 20 8"></polyline>
<line x1="16" y1="13" x2="8" y2="13"></line>
<line x1="16" y1="17" x2="8" y2="17"></line>
<polyline points="10 9 9 9 8 9"></polyline>
</svg>
EBP2DOC Web
</h1>
<div class="drop-zone" id="dropZone">
<svg width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="#666" stroke-width="2" style="margin: 0 auto 10px; display: block;">
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path>
<polyline points="17 8 12 3 7 8"></polyline>
<line x1="12" y1="3" x2="12" y2="15"></line>
</svg>
<p><strong>Drop .ebp file here or click to browse</strong></p>
<p style="font-size: 14px; color: #999;">Supports EmpirBus Project (.ebp) files</p>
<input type="file" id="fileInput" accept=".ebp">
</div>
<!-- Toolbar (hidden until file is loaded) -->
<div class="toolbar" id="toolbar">
<input type="text"
class="search-box"
id="searchBox"
placeholder="🔍 Search units or channels...">
<button class="button button-secondary" id="exportPDF">
📄 Export PDF
</button>
</div>
<!-- Tabs (hidden until file is loaded) -->
<div class="tabs hidden" id="tabs">
<button class="tab-button active" data-tab="units">Units</button>
<button class="tab-button" data-tab="components">NMEA Components</button>
<button class="tab-button" data-tab="alerts">Alerts</button>
<button class="tab-button" data-tab="memory">Memory</button>
<button class="tab-button" data-tab="modules">Modules</button>
</div>
<!-- Results container -->
<div class="results" id="results"></div>
<!-- Footer -->
<div class="footer">
<span class="footer-version">v1.1.2</span>
<span class="footer-separator">•</span>
<a href="https://github.com/remcohalman/ebp2docs" target="_blank" class="footer-link">
View on GitHub
</a>
</div>
<!-- Import modules -->
<script type="module">
import { parseUnits, parseProjectMetadata, parseAlarms, parseComponents, parseMemory, validateEBP } from './js/parser.js';
import { displayUnits, displayComponents, displayAlertsDetailed, displayMemory, displayModules, displayError } from './js/ui.js';
import { downloadPDF, filterUnitsAndChannels, debounce } from './js/utils.js';
import { MODULES, getModuleByProductNumber } from './modules.js';
// DOM elements
const dropZone = document.getElementById('dropZone');
const fileInput = document.getElementById('fileInput');
const results = document.getElementById('results');
const toolbar = document.getElementById('toolbar');
const searchBox = document.getElementById('searchBox');
const exportPDFBtn = document.getElementById('exportPDF');
const tabs = document.getElementById('tabs');
const metadataCard = document.querySelector('.metadata-card');
// Store parsed data globally
let currentUnits = [];
let allUnits = [];
let currentMetadata = null;
let currentAlarms = [];
let currentComponents = [];
let currentMemory = [];
let activeTab = 'units';
// Click to upload
dropZone.addEventListener('click', () => fileInput.click());
// File input change
fileInput.addEventListener('change', (e) => {
const file = e.target.files[0];
if (file) handleFile(file);
});
// Drag and drop
dropZone.addEventListener('dragover', (e) => {
e.preventDefault();
dropZone.classList.add('drag-over');
});
dropZone.addEventListener('dragleave', () => {
dropZone.classList.remove('drag-over');
});
dropZone.addEventListener('drop', (e) => {
e.preventDefault();
dropZone.classList.remove('drag-over');
const file = e.dataTransfer.files[0];
if (file) handleFile(file);
});
// Handle file upload
async function handleFile(file) {
const reader = new FileReader();
reader.onload = async (e) => {
try {
const content = e.target.result;
// Validate first
const validation = validateEBP(content);
if (!validation.isValid) {
displayError(`Invalid EBP file: ${validation.errors.join(', ')}`, results);
return;
}
// Parse all data
allUnits = await parseUnits(content);
// Enrich units with product numbers from modules.js
const moduleLookup = new Map();
MODULES.forEach(module => {
moduleLookup.set(module.standardUnitVariantNumber, module);
});
allUnits = allUnits.map(unit => {
const moduleInfo = moduleLookup.get(unit.standardUnitVariantNumber);
return {
...unit,
productNumber: moduleInfo ? moduleInfo.productNumber : 'Unknown'
};
});
currentUnits = allUnits;
currentMetadata = parseProjectMetadata(content);
currentAlarms = parseAlarms(content);
currentComponents = await parseComponents(content);
currentMemory = parseMemory(content);
// Display current tab
displayCurrentTab();
// Show toolbar and tabs
toolbar.style.display = 'flex';
tabs.classList.remove('hidden');
// Reset search box
searchBox.value = '';
} catch (error) {
displayError(error.message, results);
}
};
reader.readAsText(file);
}
// Display current tab
function displayCurrentTab() {
switch (activeTab) {
case 'units':
displayUnits(currentUnits, results, currentMetadata, false, currentAlarms);
break;
case 'components':
displayComponents(currentComponents, results, currentMetadata);
break;
case 'alerts':
displayAlertsDetailed(currentAlarms, results, currentMetadata);
break;
case 'memory':
displayMemory(currentMemory, results, currentMetadata);
break;
case 'modules':
displayModules(allUnits, results, currentMetadata, MODULES);
break;
}
}
// Tab switching
tabs.querySelectorAll('.tab-button').forEach(button => {
button.addEventListener('click', () => {
// Update active tab
activeTab = button.dataset.tab;
// Update button states
tabs.querySelectorAll('.tab-button').forEach(btn => {
btn.classList.remove('active');
});
button.classList.add('active');
// Display current tab
displayCurrentTab();
// Hide search for non-units tabs
if (activeTab !== 'units') {
searchBox.style.display = 'none';
} else {
searchBox.style.display = 'block';
}
// Show metadata card only for units tab
const metadataCard = document.querySelector('.metadata-card');
if (metadataCard) {
if (activeTab === 'units') {
metadataCard.style.display = 'block';
} else {
metadataCard.style.display = 'none';
}
}
});
});
// Search functionality (only for units tab)
searchBox.addEventListener('input', debounce((e) => {
if (activeTab === 'units') {
const searchTerm = e.target.value;
const { units: filtered, hasSearch } = filterUnitsAndChannels(allUnits, searchTerm);
currentUnits = filtered;
displayUnits(currentUnits, results, currentMetadata, hasSearch, currentAlarms);
}
}, 300));
// Export PDF
exportPDFBtn.addEventListener('click', () => {
downloadPDF(currentMetadata);
});
</script>
</body>
</html>