Spaces:
Running
Running
Download index.html from DBFahrerKaterchen3/test4: direct link, hf CLI and curl.
- Browser
- Download file 15.2 kB
-
https://huggingface.co/spaces/DBFahrerKaterchen3/test4/resolve/main/index.html
- Command line
-
hf download hf://spaces/DBFahrerKaterchen3/test4/index.html
-
curl -L -o index.html https://huggingface.co/spaces/DBFahrerKaterchen3/test4/resolve/main/index.html
15.2 kB
| <html lang="de"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>ESTW Simulation - Fahrstraßensicherung</title> | |
| <style> | |
| :root { | |
| --bg-color: #0d1117; | |
| --panel-bg: #161b22; | |
| --track-gray: #484f58; | |
| --track-yellow: #f1c40f; | |
| --text-color: #c9d1d9; | |
| } | |
| body { | |
| margin: 0; | |
| padding: 15px; | |
| background-color: var(--bg-color); | |
| color: var(--text-color); | |
| font-family: 'Consolas', 'Courier New', monospace; | |
| user-select: none; | |
| } | |
| h1 { | |
| margin: 0 0 10px 0; | |
| font-size: 18px; | |
| color: #8b949e; | |
| text-transform: uppercase; | |
| } | |
| #container { | |
| display: flex; | |
| flex-direction: column; | |
| gap: 12px; | |
| max-width: 1250px; | |
| margin: 0 auto; | |
| } | |
| #canvas-container { | |
| background-color: #000; | |
| border: 2px solid #30363d; | |
| border-radius: 6px; | |
| position: relative; | |
| overflow: hidden; | |
| } | |
| canvas { | |
| display: block; | |
| cursor: pointer; | |
| } | |
| #controls { | |
| background-color: var(--panel-bg); | |
| border: 1px solid #30363d; | |
| border-radius: 6px; | |
| padding: 10px 15px; | |
| display: flex; | |
| gap: 15px; | |
| align-items: center; | |
| justify-content: space-between; | |
| } | |
| .button-group { | |
| display: flex; | |
| gap: 10px; | |
| } | |
| button { | |
| background-color: #21262d; | |
| color: #c9d1d9; | |
| border: 1px solid #30363d; | |
| padding: 8px 14px; | |
| font-family: inherit; | |
| font-size: 13px; | |
| font-weight: bold; | |
| border-radius: 4px; | |
| cursor: pointer; | |
| } | |
| button:hover { | |
| background-color: #30363d; | |
| } | |
| button.active { | |
| background-color: #d35400 ; | |
| border-color: #e67e22 ; | |
| color: #fff; | |
| } | |
| .status-box { | |
| font-size: 12px; | |
| color: #8b949e; | |
| background-color: #0d1117; | |
| padding: 6px 12px; | |
| border-radius: 4px; | |
| border: 1px solid #30363d; | |
| } | |
| #log-container { | |
| background-color: #040d06; | |
| border: 1px solid #30363d; | |
| border-radius: 6px; | |
| height: 110px; | |
| overflow-y: auto; | |
| padding: 8px; | |
| font-size: 12px; | |
| color: #2ecc71; | |
| } | |
| .log-entry { margin-bottom: 3px; } | |
| .log-time { color: #8b949e; } | |
| .log-warn { color: #e67e22; } | |
| </style> | |
| </head> | |
| <body> | |
| <div id="container"> | |
| <h1>ESTW Simulation - Fahrstraßensicherung</h1> | |
| <div id="canvas-container"> | |
| <canvas id="estwCanvas" width="1200" height="480"></canvas> | |
| </div> | |
| <div id="controls"> | |
| <div class="button-group"> | |
| <button id="btnFasha" onclick="toggleFasha()">FaSHa (Hilfsauflösung)</button> | |
| <button onclick="resetSelection()" style="background-color: #34495e;">Auswahl löschen</button> | |
| </div> | |
| <div class="status-box" id="statusText">System betriebsbereit. Zuerst Startsignal wählen.</div> | |
| </div> | |
| <div id="log-container"> | |
| <div class="log-entry"><span class="log-time">[SYSTEM]</span> Stellwerk aktiv. Fahrstraßenausschluss aktiv.</div> | |
| </div> | |
| </div> | |
| <script> | |
| const canvas = document.getElementById('estwCanvas'); | |
| const ctx = canvas.getContext('2d'); | |
| let fashaActive = false; | |
| let selectedStart = null; | |
| function log(msg, type = 'normal') { | |
| const logBox = document.getElementById('log-container'); | |
| const time = new Date().toLocaleTimeString(); | |
| const entry = document.createElement('div'); | |
| entry.className = 'log-entry ' + (type === 'warn' ? 'log-warn' : ''); | |
| entry.innerHTML = `<span class="log-time">[${time}]</span> ${msg}`; | |
| logBox.appendChild(entry); | |
| logBox.scrollTop = logBox.scrollHeight; | |
| } | |
| const buttons = { | |
| GL1: { x: 50, y: 310, radius: 10, type: 'ziel', name: 'Gl. 1' }, | |
| GL2: { x: 50, y: 210, radius: 10, type: 'ziel', name: 'Gl. 2' }, | |
| GL3: { x: 50, y: 110, radius: 10, type: 'ziel', name: 'Gl. 3' }, | |
| BP: { x: 1150, y: 60, radius: 10, type: 'ziel', name: 'BP' }, | |
| LND: { x: 1150, y: 420, radius: 10, type: 'ziel', name: 'LND' }, | |
| A: { x: 980, y: 370, radius: 12, type: 'signal', name: 'A', dir: 'west' }, | |
| F: { x: 980, y: 110, radius: 12, type: 'signal', name: 'F', dir: 'west' }, | |
| P1: { x: 320, y: 310, radius: 12, type: 'signal', name: 'P1', dir: 'east' }, | |
| P2: { x: 280, y: 210, radius: 12, type: 'signal', name: 'P2', dir: 'east' }, | |
| P3: { x: 180, y: 110, radius: 12, type: 'signal', name: 'P3', dir: 'east' } | |
| }; | |
| let activeRoutes = {}; | |
| // Fahrstraßen-Definitionen mit exakter Gleisabschnitts-Zuordnung | |
| const routesDef = { | |
| 'A->GL1': { start: 'A', ziel: 'GL1', blocks: ['STR_A', 'W_UNTEN', 'GL1'] }, | |
| 'A->GL2': { start: 'A', ziel: 'GL2', blocks: ['STR_A', 'W_MITTE', 'GL2'] }, | |
| 'A->GL3': { start: 'A', ziel: 'GL3', blocks: ['STR_A', 'W_MITTE', 'W_P3', 'GL3'] }, | |
| 'F->GL1': { start: 'F', ziel: 'GL1', blocks: ['STR_F', 'W_MITTE', 'W_UNTEN', 'GL1'] }, | |
| 'F->GL2': { start: 'F', ziel: 'GL2', blocks: ['STR_F', 'W_MITTE', 'GL2'] }, | |
| 'F->GL3': { start: 'F', ziel: 'GL3', blocks: ['STR_F', 'W_MITTE', 'W_P3', 'GL3'] }, | |
| 'P1->BP': { start: 'P1', ziel: 'BP', blocks: ['GL1', 'W_UNTEN', 'W_MITTE', 'STR_F'] }, | |
| 'P1->LND': { start: 'P1', ziel: 'LND', blocks: ['GL1', 'W_UNTEN', 'STR_A'] }, | |
| 'P2->BP': { start: 'P2', ziel: 'BP', blocks: ['GL2', 'W_MITTE', 'STR_F'] }, | |
| 'P2->LND': { start: 'P2', ziel: 'LND', blocks: ['GL2', 'W_MITTE', 'STR_A'] }, | |
| 'P3->BP': { start: 'P3', ziel: 'BP', blocks: ['GL3', 'W_P3', 'W_MITTE', 'STR_F'] }, | |
| 'P3->LND': { start: 'P3', ziel: 'LND', blocks: ['GL3', 'W_P3', 'W_MITTE', 'STR_A'] } | |
| }; | |
| // Prüft, ob mindestens ein benötigter Gleisabschnitt bereits belegt ist | |
| function checkConflict(newRouteKey) { | |
| const newBlocks = routesDef[newRouteKey].blocks; | |
| for (let rKey in activeRoutes) { | |
| const activeBlocks = activeRoutes[rKey].blocks; | |
| for (let b of newBlocks) { | |
| if (activeBlocks.includes(b)) { | |
| return { conflict: true, block: b, route: rKey }; | |
| } | |
| } | |
| } | |
| return { conflict: false }; | |
| } | |
| function toggleFasha() { | |
| fashaActive = !fashaActive; | |
| document.getElementById('btnFasha').classList.toggle('active', fashaActive); | |
| document.getElementById('statusText').innerText = fashaActive ? | |
| "FaSHa AKTIV: Klicke auf Startsignal zum Auflösen." : | |
| "System bereit."; | |
| } | |
| function resetSelection() { | |
| selectedStart = null; | |
| if (fashaActive) toggleFasha(); | |
| document.getElementById('statusText').innerText = "Auswahl zurückgesetzt."; | |
| draw(); | |
| } | |
| canvas.addEventListener('click', function(e) { | |
| const rect = canvas.getBoundingClientRect(); | |
| const x = e.clientX - rect.left; | |
| const y = e.clientY - rect.top; | |
| for (let key in buttons) { | |
| const btn = buttons[key]; | |
| if (Math.hypot(btn.x - x, btn.y - y) <= btn.radius + 6) { | |
| handleButtonClick(key, btn); | |
| return; | |
| } | |
| } | |
| }); | |
| function handleButtonClick(key, btn) { | |
| if (fashaActive) { | |
| if (btn.type === 'signal') { | |
| if (activeRoutes[key]) { | |
| log(`FaSHa: Fahrstraße ab Signal ${key} aufgelöst.`, 'warn'); | |
| delete activeRoutes[key]; | |
| toggleFasha(); | |
| } else { | |
| log(`FaSHa Fehler: Keine Fahrstraße an Signal ${key}.`, 'warn'); | |
| } | |
| } | |
| draw(); | |
| return; | |
| } | |
| if (!selectedStart) { | |
| if (btn.type === 'signal') { | |
| selectedStart = key; | |
| document.getElementById('statusText').innerText = `Start ${key} gewählt. Ziel wählen.`; | |
| } | |
| } else { | |
| if (btn.type === 'ziel') { | |
| const rKey = `${selectedStart}->${key}`; | |
| if (routesDef[rKey]) { | |
| if (!activeRoutes[selectedStart]) { | |
| // Ausschlussprüfung vor dem Einstellen | |
| const check = checkConflict(rKey); | |
| if (check.conflict) { | |
| log(`FAHRSTRASSENAUSSCHLUSS! Blockiert durch Fahrstraße '${check.route}' (Abschnitt: ${check.block})`, 'warn'); | |
| document.getElementById('statusText').innerText = "Einstellen nicht möglich: Fahrstraßenausschluss!"; | |
| } else { | |
| activeRoutes[selectedStart] = routesDef[rKey]; | |
| log(`Fahrstraße ${selectedStart} -> ${btn.name} eingestellt. Signal ${selectedStart} zeigt Hp2.`); | |
| document.getElementById('statusText').innerText = "Fahrstraße eingestellt."; | |
| } | |
| selectedStart = null; | |
| } else { | |
| log(`Fehler: Fahrstraße ab ${selectedStart} existiert bereits.`, 'warn'); | |
| selectedStart = null; | |
| } | |
| } else { | |
| log(`Ungültige Fahrstraße ${selectedStart} -> ${btn.name}`, 'warn'); | |
| selectedStart = null; | |
| } | |
| } else if (btn.type === 'signal') { | |
| selectedStart = key; | |
| } | |
| } | |
| draw(); | |
| } | |
| function drawLine(x1, y1, x2, y2, color = '#484f58', dashed = false) { | |
| ctx.beginPath(); | |
| ctx.strokeStyle = color; | |
| ctx.lineWidth = 4; | |
| if (dashed) ctx.setLineDash([8, 6]); | |
| else ctx.setLineDash([]); | |
| ctx.moveTo(x1, y1); | |
| ctx.lineTo(x2, y2); | |
| ctx.stroke(); | |
| ctx.setLineDash([]); | |
| } | |
| function draw() { | |
| ctx.clearRect(0, 0, canvas.width, canvas.height); | |
| // Grund-Gleisbild | |
| drawLine(50, 110, 200, 110); // Gl 3 | |
| drawLine(50, 210, 320, 210); // Gl 2 | |
| drawLine(50, 310, 340, 310); // Gl 1 | |
| drawLine(200, 110, 280, 210); // Weiche Gl3 -> Gl2 | |
| drawLine(320, 210, 520, 210); | |
| drawLine(340, 310, 500, 310); | |
| drawLine(500, 310, 580, 210); // Verbindung Gl1 -> Gl2 | |
| drawLine(520, 210, 680, 210); | |
| drawLine(680, 210, 780, 110); // Ast nach Signal F | |
| drawLine(780, 110, 1150, 110); | |
| drawLine(680, 210, 780, 310); // Ast nach Signal A | |
| drawLine(780, 310, 1150, 370); | |
| // Prellböcke | |
| drawBumper(40, 110); | |
| drawBumper(40, 210); | |
| drawBumper(40, 310); | |
| // Aktive Fahrstraßen | |
| for (let rKey in activeRoutes) { | |
| drawActiveRoute(activeRoutes[rKey]); | |
| } | |
| // Signale | |
| for (let sKey of ['A', 'F', 'P1', 'P2', 'P3']) { | |
| drawSignal(buttons[sKey], activeRoutes[sKey] ? 'Hp2' : 'Hp0'); | |
| } | |
| // Zielknöpfe | |
| for (let zKey of ['GL1', 'GL2', 'GL3', 'BP', 'LND']) { | |
| drawZielButton(buttons[zKey]); | |
| } | |
| if (selectedStart) { | |
| const btn = buttons[selectedStart]; | |
| ctx.strokeStyle = '#f39c12'; | |
| ctx.lineWidth = 3; | |
| ctx.beginPath(); | |
| ctx.arc(btn.x, btn.y, btn.radius + 6, 0, Math.PI * 2); | |
| ctx.stroke(); | |
| } | |
| } | |
| function drawActiveRoute(route) { | |
| const y = '#f1c40f'; | |
| const s = route.start; | |
| const z = route.ziel; | |
| if (s === 'F') { | |
| drawLine(980, 110, 780, 110, y, true); | |
| drawLine(780, 110, 680, 210, y, true); | |
| if (z === 'GL3') { | |
| drawLine(680, 210, 280, 210, y, true); | |
| drawLine(280, 210, 200, 110, y, true); | |
| drawLine(200, 110, 50, 110, y, true); | |
| } else if (z === 'GL2') { | |
| drawLine(680, 210, 50, 210, y, true); | |
| } else if (z === 'GL1') { | |
| drawLine(580, 210, 500, 310, y, true); | |
| drawLine(500, 310, 50, 310, y, true); | |
| } | |
| } else if (s === 'A') { | |
| drawLine(980, 370, 780, 310, y, true); | |
| drawLine(780, 310, 680, 210, y, true); | |
| if (z === 'GL2') { | |
| drawLine(680, 210, 50, 210, y, true); | |
| } else if (z === 'GL1') { | |
| drawLine(580, 210, 500, 310, y, true); | |
| drawLine(500, 310, 50, 310, y, true); | |
| } else if (z === 'GL3') { | |
| drawLine(680, 210, 280, 210, y, true); | |
| drawLine(280, 210, 200, 110, y, true); | |
| drawLine(200, 110, 50, 110, y, true); | |
| } | |
| } else if (s.startsWith('P')) { | |
| let sx = s === 'P1' ? 320 : (s === 'P2' ? 280 : 180); | |
| let sy = s === 'P1' ? 310 : (s === 'P2' ? 210 : 110); | |
| if (s === 'P3') { | |
| drawLine(180, 110, 200, 110, y, true); | |
| drawLine(200, 110, 280, 210, y, true); | |
| sy = 210; sx = 280; | |
| } | |
| if (z === 'BP') { | |
| if (sy === 310) { | |
| drawLine(sx, 310, 500, 310, y, true); | |
| drawLine(500, 310, 580, 210, y, true); | |
| drawLine(580, 210, 680, 210, y, true); | |
| } else { | |
| drawLine(sx, 210, 680, 210, y, true); | |
| } | |
| drawLine(680, 210, 780, 110, y, true); | |
| drawLine(780, 110, 1150, 60, y, true); | |
| } else if (z === 'LND') { | |
| if (sy === 210) { | |
| drawLine(sx, 210, 680, 210, y, true); | |
| drawLine(680, 210, 780, 310, y, true); | |
| } else { | |
| drawLine(sx, 310, 780, 310, y, true); | |
| } | |
| drawLine(780, 310, 1150, 420, y, true); | |
| } | |
| } | |
| } | |
| function drawBumper(x, y) { | |
| ctx.strokeStyle = '#e74c3c'; | |
| ctx.lineWidth = 5; | |
| ctx.beginPath(); | |
| ctx.moveTo(x, y - 10); | |
| ctx.lineTo(x, y + 10); | |
| ctx.stroke(); | |
| } | |
| function drawZielButton(btn) { | |
| ctx.fillStyle = '#2980b9'; | |
| ctx.strokeStyle = '#fff'; | |
| ctx.lineWidth = 2; | |
| ctx.beginPath(); | |
| ctx.arc(btn.x, btn.y, btn.radius, 0, Math.PI * 2); | |
| ctx.fill(); | |
| ctx.stroke(); | |
| ctx.fillStyle = '#fff'; | |
| ctx.font = 'bold 11px Consolas'; | |
| ctx.fillText(btn.name, btn.x - 12, btn.y - 15); | |
| } | |
| function drawSignal(btn, state) { | |
| const isEast = btn.dir === 'east'; | |
| ctx.strokeStyle = '#8b949e'; | |
| ctx.lineWidth = 3; | |
| ctx.beginPath(); | |
| ctx.moveTo(btn.x, btn.y); | |
| ctx.lineTo(btn.x, btn.y + (isEast ? 20 : -20)); | |
| ctx.stroke(); | |
| ctx.fillStyle = '#161b22'; | |
| ctx.strokeStyle = '#30363d'; | |
| ctx.lineWidth = 1.5; | |
| const boxX = btn.x - 10; | |
| const boxY = isEast ? btn.y + 20 : btn.y - 40; | |
| ctx.fillRect(boxX, boxY, 20, 20); | |
| ctx.strokeRect(boxX, boxY, 20, 20); | |
| if (state === 'Hp0') { | |
| ctx.fillStyle = '#e74c3c'; | |
| ctx.beginPath(); | |
| ctx.arc(btn.x, boxY + 10, 5, 0, Math.PI * 2); | |
| ctx.fill(); | |
| } else if (state === 'Hp2') { | |
| ctx.fillStyle = '#2ecc71'; | |
| ctx.beginPath(); | |
| ctx.arc(btn.x - 4, boxY + 10, 4, 0, Math.PI * 2); | |
| ctx.fill(); | |
| ctx.fillStyle = '#f1c40f'; | |
| ctx.beginPath(); | |
| ctx.arc(btn.x + 4, boxY + 10, 4, 0, Math.PI * 2); | |
| ctx.fill(); | |
| } | |
| ctx.fillStyle = '#f39c12'; | |
| ctx.font = 'bold 12px Consolas'; | |
| ctx.fillText(btn.name, btn.x - 8, isEast ? btn.y - 10 : btn.y + 20); | |
| } | |
| draw(); | |
| </script> | |
| </body> | |
| </html> |