- Split styles.css (1319 lines) into 6 CSS modules: - base.css, layout.css, modal.css, text-generator.css, components.css, legend.css - Split app.js (1219 lines) into 8 JS modules: - core.js, custom.js, dxf.js, export.js, legend.js, legend-export.js, path-parser.js, utils.js - Split symbols.js (870 lines) into 10 JS modules: - index.js, schaeden.js, werkzeuge.js, bauteile.js, moebel.js, sanitaer.js, vermessung.js, vermessung-infra.js, vermessung-topo.js, init.js - Updated index.html to load new modular files All files now comply with 300-line maximum rule. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
123 lines
4.0 KiB
JavaScript
123 lines
4.0 KiB
JavaScript
// ============================================
|
|
// CUSTOM - Eigene Symbole und UI
|
|
// ============================================
|
|
|
|
// Custom Symbols aus localStorage
|
|
var customSymbols = [];
|
|
|
|
// ========== TEXT-GENERATOR UI ==========
|
|
function toggleTextGenerator() {
|
|
var generator = document.querySelector('.text-generator');
|
|
generator.classList.toggle('collapsed');
|
|
}
|
|
|
|
// ========== CUSTOM SYMBOLS STORAGE ==========
|
|
function loadCustomSymbols() {
|
|
try {
|
|
var stored = localStorage.getItem('customSymbols');
|
|
if (stored) {
|
|
customSymbols = JSON.parse(stored);
|
|
}
|
|
} catch (e) {
|
|
console.error('Fehler beim Laden der eigenen Symbole:', e);
|
|
customSymbols = [];
|
|
}
|
|
}
|
|
|
|
function saveCustomSymbols() {
|
|
try {
|
|
localStorage.setItem('customSymbols', JSON.stringify(customSymbols));
|
|
} catch (e) {
|
|
console.error('Fehler beim Speichern der eigenen Symbole:', e);
|
|
}
|
|
}
|
|
|
|
function openSaveModal() {
|
|
var modal = document.getElementById('saveModal');
|
|
var nameInput = document.getElementById('symbolName');
|
|
var descInput = document.getElementById('symbolDescription');
|
|
|
|
var state = window.TextGenState ? window.TextGenState.current : {};
|
|
var suggestedName = state.text ? state.text.replace(/\n/g, ' ').substring(0, 30) : '';
|
|
nameInput.value = suggestedName;
|
|
descInput.value = '';
|
|
|
|
modal.style.display = 'flex';
|
|
nameInput.focus();
|
|
}
|
|
|
|
function closeSaveModal() {
|
|
var modal = document.getElementById('saveModal');
|
|
modal.style.display = 'none';
|
|
}
|
|
|
|
function saveCustomSymbol() {
|
|
var nameInput = document.getElementById('symbolName');
|
|
var descInput = document.getElementById('symbolDescription');
|
|
|
|
var name = nameInput.value.trim();
|
|
if (!name) {
|
|
showNotification('Bitte einen Namen eingeben!', 'error');
|
|
return;
|
|
}
|
|
|
|
var svg = window.SvgGenerator ? window.SvgGenerator.generate(window.TextGenState.current) : '';
|
|
|
|
var newSymbol = {
|
|
id: 'custom_' + Date.now(),
|
|
name: name,
|
|
description: descInput.value.trim(),
|
|
svg: svg,
|
|
category: 'custom',
|
|
tags: ['eigene', 'custom', name.toLowerCase()],
|
|
createdAt: new Date().toISOString()
|
|
};
|
|
|
|
customSymbols.push(newSymbol);
|
|
saveCustomSymbols();
|
|
|
|
closeSaveModal();
|
|
showNotification('Symbol "' + name + '" gespeichert!');
|
|
}
|
|
|
|
function deleteCustomSymbol(id) {
|
|
if (!confirm('Symbol wirklich loeschen?')) return;
|
|
|
|
customSymbols = customSymbols.filter(function(s) { return s.id !== id; });
|
|
saveCustomSymbols();
|
|
renderSymbols();
|
|
showNotification('Symbol geloescht');
|
|
}
|
|
|
|
function createCustomSymbolCard(symbol) {
|
|
var card = document.createElement('div');
|
|
card.className = 'symbol-card';
|
|
card.innerHTML =
|
|
'<button class="btn-delete" onclick="event.stopPropagation(); deleteCustomSymbol(\'' + symbol.id + '\')" title="Loeschen">X</button>' +
|
|
'<div class="symbol-preview">' + symbol.svg + '</div>' +
|
|
'<div class="symbol-name">' + escapeHtml(symbol.name) + '</div>' +
|
|
'<div class="symbol-actions">' +
|
|
'<button class="btn-action btn-copy" onclick="copySymbolAsImage(\'' + symbol.id + '\', true)" title="Kopieren">Kopieren</button>' +
|
|
'<button class="btn-action btn-svg" onclick="downloadSymbolSVG(\'' + symbol.id + '\', true)" title="SVG">SVG</button>' +
|
|
'<button class="btn-action btn-dxf" onclick="downloadSymbolDXF(\'' + symbol.id + '\', true)" title="DXF">DXF</button>' +
|
|
'<button class="btn-action btn-legend" onclick="addSymbolToLegend(\'' + symbol.id + '\', true)" title="Legende">+</button>' +
|
|
'</div>';
|
|
return card;
|
|
}
|
|
|
|
// ========== IMPRESSUM ==========
|
|
function openImpressum() {
|
|
var modal = document.getElementById('impressumModal');
|
|
if (modal) modal.style.display = 'flex';
|
|
}
|
|
|
|
function closeImpressum() {
|
|
var modal = document.getElementById('impressumModal');
|
|
if (modal) modal.style.display = 'none';
|
|
}
|
|
|
|
// Init beim Laden
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
loadCustomSymbols();
|
|
});
|