Spaces:
Sleeping
Sleeping
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Formeo with JSON Copy</title> | |
| <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/formeo.min.js"></script> | |
| <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/formeo.min.css" rel="stylesheet"> | |
| <style> | |
| body { | |
| background: radial-gradient(circle, #484848, #2F3031); | |
| font-family: Arial, sans-serif; | |
| margin: 20px; | |
| } | |
| button { | |
| padding: 10px 20px; | |
| margin-top: 20px; | |
| cursor: pointer; | |
| position: relative; | |
| z-index: 1000; /* Устанавливаем z-index на 1000 */ | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <h1>Formeo with JSON Copy</h1> | |
| <div id="formeo-editor-1"></div> | |
| <button id="copyJsonButton">Копировать JSON в буфер обмена</button> | |
| <script> | |
| document.addEventListener('DOMContentLoaded', function() { | |
| // Инициализация Formeo | |
| const formeoEditorInstance = new FormeoEditor({ | |
| editorContainer: '#formeo-editor-1', | |
| svgSprite: 'https://draggable.github.io/formeo/assets/img/formeo-sprite.svg' | |
| }); | |
| // Ожидание события formeo:ready | |
| formeoEditorInstance.on('formeo:ready', function() { | |
| // Добавление обработчика события для кнопки | |
| document.getElementById('copyJsonButton').addEventListener('click', function() { | |
| // Используем параметр FormeoEditor#json для получения JSON формы данных | |
| const jsonString = formeoEditorInstance.json; // <-- Используем параметр FormeoEditor#json | |
| navigator.clipboard.writeText(jsonString).then(() => { | |
| alert('JSON скопирован в буфер обмена'); | |
| }).catch(err => { | |
| alert('Не удалось скопировать JSON в буфер обмена: ' + err); | |
| }); | |
| }); | |
| }); | |
| }); | |
| </script> | |
| </body> | |
| </html> |