Changed around line 1
+ document.addEventListener('DOMContentLoaded', () => {
+ const fileInput = document.getElementById('file-input');
+ const diagramSection = document.getElementById('diagram-section');
+ const diagramContainer = document.getElementById('diagram-container');
+ const prevStepButton = document.getElementById('prev-step');
+ const nextStepButton = document.getElementById('next-step');
+ const stepIndicator = document.getElementById('step-indicator');
+
+ let currentStep = 0;
+ let steps = [];
+
+ fileInput.addEventListener('change', (event) => {
+ const file = event.target.files[0];
+ if (file) {
+ const reader = new FileReader();
+ reader.onload = (e) => {
+ const content = e.target.result;
+ steps = splitPlantUML(content);
+ if (steps.length > 0) {
+ currentStep = 0;
+ updateDiagram();
+ diagramSection.classList.remove('hidden');
+ }
+ };
+ reader.readAsText(file);
+ }
+ });
+
+ prevStepButton.addEventListener('click', () => {
+ if (currentStep > 0) {
+ currentStep--;
+ updateDiagram();
+ }
+ });
+
+ nextStepButton.addEventListener('click', () => {
+ if (currentStep < steps.length - 1) {
+ currentStep++;
+ updateDiagram();
+ }
+ });
+
+ function splitPlantUML(content) {
+ // Split content based on @startuml and @enduml tags
+ const regex = /@startuml[\s\S]*?@enduml/g;
+ return content.match(regex) || [];
+ }
+
+ function updateDiagram() {
+ diagramContainer.textContent = steps[currentStep];
+ stepIndicator.textContent = `Step ${currentStep + 1} of ${steps.length}`;
+ prevStepButton.disabled = currentStep === 0;
+ nextStepButton.disabled = currentStep === steps.length - 1;
+ }
+ });