Files
timeline-svg/index.html
tegwick bc756fa0cd feat: comprehensive SVG viewer enhancements with zoom and template preview
- Add interactive zoom functionality (25%-300% with Ctrl+scroll wheel)
- Fix SVG width constraints by injecting calculated dimensions into templates
- Implement template preview with theme-aware sample data
- Enhance UI layout with file reordering (Project → Template → CSS → Data)
- Add blue theme support for my-project alongside existing green theme
- Fix my-project field mapping from empty 'Übergeordnet' to 'Status'
- Improve SVG viewport handling with proper scrolling and container management
- Add visual zoom controls with percentage display and smart visibility

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-19 00:46:58 +01:00

374 lines
10 KiB
HTML

<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8" />
<title>Timeline Generator</title>
<script src="https://cdn.jsdelivr.net/npm/papaparse@5.4.1/papaparse.min.js"></script>
<link id="dynamicCss" rel="stylesheet" href="">
<style>
/* File Manager Styling */
.file-item {
background: #fff;
border: 1px solid #dee2e6;
border-radius: 8px;
padding: 12px;
transition: all 0.2s ease;
}
.file-item:hover {
border-color: #495057;
box-shadow: 0 2px 8px rgba(73, 80, 87, 0.1);
}
.file-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 8px;
}
.file-label {
font-weight: 600;
color: #495057;
font-size: 13px;
}
.upload-btn {
background: #495057;
color: white;
padding: 4px 8px;
border-radius: 4px;
font-size: 11px;
cursor: pointer;
transition: background-color 0.2s;
border: none;
user-select: none;
}
.upload-btn:hover {
background: #343a40;
}
.file-status {
border-top: 1px solid #f1f3f4;
padding-top: 8px;
}
.file-name {
font-family: 'Courier New', monospace;
font-size: 11px;
font-weight: 500;
display: block;
padding: 4px 8px;
border-radius: 4px;
background: #f8f9fa;
color: #6c757d;
font-style: italic;
transition: all 0.2s ease;
}
.file-name[style*="color: #28a745"] {
background: #d4edda;
border: 1px solid #c3e6cb;
color: #155724 !important;
font-style: normal;
font-weight: 600;
}
.file-name[style*="color: #dc3545"] {
background: #f8d7da;
border: 1px solid #f1b6bb;
color: #721c24 !important;
font-style: normal;
font-weight: 600;
}
.file-name[style*="color: #6c757d"] {
background: #f8f9fa;
border: 1px solid #e9ecef;
}
.controls {
animation: fadeInUp 0.3s ease;
}
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(10px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
#fileManager {
transition: all 0.3s ease-in-out;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
@media (max-width: 768px) {
.file-grid {
grid-template-columns: 1fr !important;
}
.file-header {
flex-direction: column;
align-items: flex-start;
gap: 6px;
}
.upload-btn {
align-self: flex-end;
}
.controls {
flex-direction: column;
}
.controls button {
width: 100%;
}
}
/* Button improvements */
button {
transition: all 0.2s ease;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
button:hover:not(:disabled) {
transform: translateY(-1px);
box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}
button:disabled {
cursor: not-allowed;
opacity: 0.6;
}
/* SVG Viewer enhancements */
#viewerContainer {
position: relative;
border: 1px solid #ccd3db;
background: white;
border-radius: 8px;
min-height: 400px;
width: 100%;
overflow: hidden;
}
#viewer {
overflow: auto;
padding: 12px;
height: 100%;
max-height: 80vh;
transform-origin: top left;
transition: transform 0.2s ease;
width: 100%;
box-sizing: border-box;
min-width: 100%;
}
#viewer svg {
max-width: none !important;
height: auto !important;
width: auto !important;
display: block;
margin: 0;
min-width: 100%;
box-sizing: content-box;
}
/* Ensure zoom doesn't get clipped */
#viewer.zoomed {
overflow: visible;
width: fit-content;
height: fit-content;
max-height: none;
}
#zoomControls {
position: absolute;
top: 8px;
right: 8px;
z-index: 10;
background: rgba(255,255,255,0.95);
border-radius: 4px;
padding: 4px;
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
display: none;
}
#zoomControls button {
padding: 4px 8px;
margin: 2px;
border: 1px solid #ccc;
border-radius: 3px;
background: white;
cursor: pointer;
font-size: 12px;
transition: all 0.2s ease;
}
#zoomControls button:hover:not(:disabled) {
background: #f0f0f0;
border-color: #999;
transform: none; /* Override global button transform */
}
#zoomControls button:disabled {
background: #f8f8f8;
color: #ccc;
cursor: not-allowed;
}
</style>
<script src="generator.js"></script>
<script src="engine.js"></script>
</head>
<body class="internal-mode" style="font-family: Inter, Arial, sans-serif; background:#f5f7fa; margin:20px;">
<h1 id="projectName" style="color:#495057; margin-bottom:8px;">Timeline Generator</h1>
<p id="projectSubtitle" style="color:#5C6B7A; margin-top:0; margin-bottom:16px;">
Lade Projektdateien um eine Timeline zu erstellen oder verwende den lokalen Server für automatisches Laden.<br>
<small style="color:#6c757d;">💡 Zoom: Verwende die Zoom-Buttons oder Strg+Scrollrad für große Timelines.</small>
</p>
<!-- Integrated File Management -->
<div id="fileManager" style="margin-bottom:16px; padding:16px; background:#f8f9fa; border:1px solid #e9ecef; border-radius:8px;">
<h3 style="margin:0 0 12px 0; font-size:14px; font-weight:600; color:#495057;">Project Files</h3>
<div class="file-grid" style="display:grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap:12px; margin-bottom:16px;">
<div class="file-item">
<div class="file-header">
<span class="file-label">Project Configuration</span>
<label class="upload-btn">
<input type="file" id="projectInput" accept=".json" style="display:none;" />
📁 Load
</label>
</div>
<div class="file-status">
<span id="projectFile" class="file-name">Not loaded</span>
</div>
</div>
<div class="file-item">
<div class="file-header">
<span class="file-label">SVG Template</span>
<label class="upload-btn">
<input type="file" id="svgInput" accept=".svg" style="display:none;" />
🖼️ Load
</label>
</div>
<div class="file-status">
<span id="svgFile" class="file-name">Not loaded</span>
</div>
</div>
<div class="file-item">
<div class="file-header">
<span class="file-label">Stylesheet</span>
<label class="upload-btn">
<input type="file" id="cssInput" accept=".css" style="display:none;" />
🎨 Load
</label>
</div>
<div class="file-status">
<span id="cssFile" class="file-name">Not loaded</span>
</div>
</div>
<div class="file-item">
<div class="file-header">
<span class="file-label">CSV Data</span>
<label class="upload-btn">
<input type="file" id="csvInput" accept=".csv" style="display:none;" />
📊 Load
</label>
</div>
<div class="file-status">
<span id="csvFile" class="file-name">Not loaded</span>
</div>
</div>
</div>
<div class="controls" style="display:flex; flex-wrap:wrap; gap:12px; justify-content:center; padding-top:12px; border-top:1px solid #dee2e6;">
<button id="toggleView" style="padding:8px 16px; background:#495057; color:white; border:none; border-radius:6px; cursor:pointer; font-size:12px;">
🔄 Switch View (Internal / External)
</button>
<button id="downloadSvg" disabled
style="padding:8px 16px; background:#495057; color:white; border:none; border-radius:6px; cursor:pointer; opacity:0.6; font-size:12px;">
💾 Download SVG
</button>
</div>
</div>
<!-- SVG Viewer with zoom and scroll capabilities -->
<div id="viewerContainer">
<!-- Zoom controls -->
<div id="zoomControls">
<button id="zoomIn">🔍+</button>
<button id="zoomOut">🔍-</button>
<button id="zoomReset">100%</button>
</div>
<!-- Scrollable viewer -->
<div id="viewer">
<div style="text-align:center; padding:40px 20px; color:#6c757d;">
<div style="font-size:48px; margin-bottom:16px;">📊</div>
<h4 style="margin:0 0 8px 0; color:#495057;">Keine Timeline verfügbar</h4>
<p style="margin:0; font-size:14px;">
Lade eine <strong>Projektkonfiguration</strong> oder <strong>CSV-Datei</strong> um zu beginnen.
</p>
</div>
</div>
</div>
<script>
document.addEventListener("DOMContentLoaded", () => {
// Setup event handlers first
if (typeof setupEventHandlers === 'function') {
setupEventHandlers();
console.log("Event handlers set up");
}
// Initialize zoom functionality
if (window.svgViewer && typeof window.svgViewer.initializeZoom === 'function') {
window.svgViewer.initializeZoom();
console.log("SVG zoom initialized");
}
// Ensure engines are loaded before auto-loading
function tryAutoLoad() {
if (window.timelineEngine && window.timelineGenerator) {
console.log("Both engines loaded, starting auto-load");
// Only try auto-load if not running from file:// protocol
if (location.protocol !== 'file:') {
window.timelineEngine.autoLoadDefaultProject();
} else {
console.log("Running from file:// protocol - auto-load disabled due to CORS");
document.getElementById("viewer").innerHTML =
"<div style='text-align:center; padding:40px 20px; color:#6c757d;'>" +
"<div style='font-size:48px; margin-bottom:16px;'>📁</div>" +
"<h4 style='margin:0 0 8px 0; color:#495057;'>Manuelle Dateien laden</h4>" +
"<p style='margin:0; font-size:14px;'>" +
"Verwende die <strong>Load</strong>-Buttons oben um Projektdateien zu laden.<br>" +
"<small>💡 Tipp: Für automatisches Laden verwende einen lokalen Server (z.B. <code>make serve</code>)</small>" +
"</p></div>";
}
} else {
console.log("Engines not ready, retrying...", {
engine: !!window.timelineEngine,
generator: !!window.timelineGenerator
});
setTimeout(tryAutoLoad, 50);
}
}
tryAutoLoad();
});
</script>
</body>
</html>