JSFiddle - React, Tailwind, and code Playground

by velo_ninja

HTML

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>BBM Einstellparameter - Digital Form</title>
    <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600;700&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
    <style>
        body {
            font-family: 'Open Sans', sans-serif;
            background: #f5f5f5;
            margin: 0;
            padding: 0;
        }
        .container {
            max-width: 1000px;
            margin: 20px auto;
            background: #fff;
            border-radius: 8px;
            padding: 20px;
            box-shadow: 0 0 10px rgba(0,0,0,0.1);
        }
        .header {
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            justify-content: space-between;
        }
        .logo-section svg {
            display: block;
        }
        .company-info {
            flex: 1;
            padding-left: 20px;
        }
        .form-controls {
            display: flex;
            flex-direction: column;
            gap: 10px;
        }
        .form-group {
            display: flex;
            flex-direction: column;
        }
        .form-group label {
            font-weight: 600;
        }
        .main-content {
            margin-top: 20px;
        }
        .btn {
            padding: 8px 12px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-weight: 600;
        }
        .btn-primary {
            background-color: #004080;
            color: #fff;
        }
        .btn-danger {
            background-color:...

CSS

body {
  font-family: Arial, sans-serif;
  background: #f5f5f5;
  padding: 20px;
}
#app {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  max-width: 600px;
  margin: auto;
  box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
.data-row {
  margin-bottom: 10px;
}
button {
  margin-right: 10px;
  padding: 8px 16px;
  font-size: 14px;
}

JavaScript

let entries = [];
let currentEntryIndex = 0;
const LOCAL_STORAGE_KEY = 'bbmEinstellparameterData';
const GLOBAL_DATA_KEY = 'bbmGlobalData'; // New key for global data
const COLLAPSE_STATE_KEY_PREFIX = 'bbmCollapseState_'; // New key for collapse states
let confirmCallback = null; // Store the callback for the custom confirmation modal

// Initial setup on page load
document.addEventListener('DOMContentLoaded', () => {
    loadGlobalData();
    loadEntries();
    if (entries.length === 0) {
        addEntry(); // Add a default entry if none exist
    } else {
        renderTabs();
        showEntry(currentEntryIndex);
    }
});

// --- Data Management Functions ---

function createNewEntryData() {
    return {
        general: {
            customerProject: {
                customer: '',
                projectNumber: '',
                orderNumber: ''
            },
            articleMachine: {
                articleNumber: '',
                drawingNumber: '',
                machineType: ''
            },
            moldProduction: {
                mold: '',
                cavities: '',
                cycleTime: '',
                setupNotes: ''
            }
        },
        material: [
            { type: '', name: '', percentage: '', dryingTime: '', dryingTemperature: '' }
        ],
        temperatureZones: Array.from({ length: 6 }, (_, i) => ({
            name: `Zone ${i + 1}`,
            setpoint: '',
            actual: '',
            unit: '°C'
        })),
        extruder: {
            preplastication: {
                switchpoint: '', unit: 'mm'
            },
            holdingPressure: [
                { stage: 1, pressure: '', time: '', unitPressure: 'bar', unitTime: 's' }
            ],
            speedProfile: [
                { stage: 1, speed: '', unit: 'mm/s' }
            ],
            screwSpeed: '', unitScrewSpeed: 'U/min',
            backPressure: '',...