| 1440 | } |
| 1441 | |
| 1442 | class NetworkInfoPanel { |
| 1443 | constructor(container) { |
| 1444 | this.container = container; |
| 1445 | if (!this.container) { |
| 1446 | throw new Error("Netzwerkinfo-Container nicht gefunden."); |
| 1447 | } |
| 1448 | this.numberFormatter = new Intl.NumberFormat("de-DE"); |
| 1449 | this.build(); |
| 1450 | } |
| 1451 | |
| 1452 | build() { |
| 1453 | this.container.innerHTML = ""; |
| 1454 | if (!this.container.classList.contains("network-info-panel")) { |
| 1455 | this.container.classList.add("network-info-panel"); |
| 1456 | } |
| 1457 | this.titleElement = document.createElement("h3"); |
| 1458 | this.titleElement.className = "network-info-panel__title"; |
| 1459 | this.titleElement.textContent = "Netzwerkübersicht"; |
| 1460 | |
| 1461 | this.summaryElement = document.createElement("div"); |
| 1462 | this.summaryElement.className = "network-info-panel__summary"; |
| 1463 | |
| 1464 | this.layersElement = document.createElement("div"); |
| 1465 | this.layersElement.className = "network-info-panel__layers"; |
| 1466 | |
| 1467 | this.emptyElement = document.createElement("div"); |
| 1468 | this.emptyElement.className = "network-info-panel__empty"; |
| 1469 | this.emptyElement.textContent = "Keine Netzwerkdaten verfügbar."; |
| 1470 | |
| 1471 | this.container.appendChild(this.titleElement); |
| 1472 | this.container.appendChild(this.summaryElement); |
| 1473 | this.container.appendChild(this.layersElement); |
| 1474 | this.container.appendChild(this.emptyElement); |
| 1475 | |
| 1476 | this.summaryElement.style.display = "none"; |
| 1477 | this.layersElement.style.display = "none"; |
| 1478 | this.emptyElement.style.display = "block"; |
| 1479 | } |
| 1480 | |
| 1481 | formatNumber(value) { |
| 1482 | if (!Number.isFinite(value)) return "—"; |
| 1483 | return this.numberFormatter.format(Math.round(value)); |
| 1484 | } |
| 1485 | |
| 1486 | buildMetric(label, value) { |
| 1487 | const wrapper = document.createElement("span"); |
| 1488 | wrapper.className = "network-info-panel__metric"; |
| 1489 | const labelElement = document.createElement("span"); |
| 1490 | labelElement.className = "network-info-panel__metric-label"; |
| 1491 | labelElement.textContent = `${label}:`; |
| 1492 | const valueElement = document.createElement("span"); |
| 1493 | valueElement.textContent = this.formatNumber(value); |
| 1494 | wrapper.appendChild(labelElement); |
| 1495 | wrapper.appendChild(valueElement); |
| 1496 | return wrapper; |
| 1497 | } |
| 1498 | |
| 1499 | buildSummaryLine(label, value) { |
nothing calls this directly
no outgoing calls
no test coverage detected