feat: refactor to FastAPI architecture v2.0
Some checks failed
Build & Push Docker / build (push) Has been cancelled
Some checks failed
Build & Push Docker / build (push) Has been cancelled
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
34
app/static/js/export.js
Normal file
34
app/static/js/export.js
Normal file
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* JSON import/export for Scenar Creator.
|
||||
*/
|
||||
|
||||
function exportJson() {
|
||||
if (!window.currentDocument) {
|
||||
showStatus('No document to export', 'error');
|
||||
return;
|
||||
}
|
||||
const json = JSON.stringify(window.currentDocument, null, 2);
|
||||
const blob = new Blob([json], { type: 'application/json' });
|
||||
API.downloadBlob(blob, 'scenar_export.json');
|
||||
}
|
||||
|
||||
function handleJsonImport(event) {
|
||||
const file = event.target.files[0];
|
||||
if (!file) return;
|
||||
|
||||
const reader = new FileReader();
|
||||
reader.onload = function (e) {
|
||||
try {
|
||||
const doc = JSON.parse(e.target.result);
|
||||
if (!doc.event || !doc.blocks || !doc.program_types) {
|
||||
throw new Error('Invalid ScenarioDocument format');
|
||||
}
|
||||
window.currentDocument = doc;
|
||||
showImportedDocument(doc);
|
||||
showStatus('JSON imported successfully', 'success');
|
||||
} catch (err) {
|
||||
showStatus('JSON import error: ' + err.message, 'error');
|
||||
}
|
||||
};
|
||||
reader.readAsText(file);
|
||||
}
|
||||
Reference in New Issue
Block a user