|
|
|
|
@ -130,6 +130,25 @@
|
|
|
|
|
function cancel() {
|
|
|
|
|
push('/');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let copied = false;
|
|
|
|
|
function copyJson() {
|
|
|
|
|
const payload = {
|
|
|
|
|
title,
|
|
|
|
|
description,
|
|
|
|
|
config,
|
|
|
|
|
questions: questions.map((q) => ({
|
|
|
|
|
prompt: q.prompt,
|
|
|
|
|
explanation: q.explanation,
|
|
|
|
|
answers: q.answers,
|
|
|
|
|
correct_answer_indices: q.correct_answer_indices,
|
|
|
|
|
})),
|
|
|
|
|
};
|
|
|
|
|
navigator.clipboard.writeText(JSON.stringify(payload, null, 2)).then(() => {
|
|
|
|
|
copied = true;
|
|
|
|
|
setTimeout(() => { copied = false; }, 2000);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<header class="page-header page-header-fixed">
|
|
|
|
|
@ -166,7 +185,10 @@
|
|
|
|
|
placeholder="Paste deck JSON (title, description, config, questions)"
|
|
|
|
|
rows="8"
|
|
|
|
|
></textarea>
|
|
|
|
|
<button type="button" class="btn btn-secondary" onclick={loadFromJson}>Load from JSON</button>
|
|
|
|
|
<div class="json-actions">
|
|
|
|
|
<button type="button" class="btn btn-secondary" onclick={loadFromJson}>Load from JSON</button>
|
|
|
|
|
<button type="button" class="btn btn-secondary" onclick={copyJson}>{copied ? 'Copied!' : 'Copy JSON'}</button>
|
|
|
|
|
</div>
|
|
|
|
|
{#if jsonError}
|
|
|
|
|
<p class="error">{jsonError}</p>
|
|
|
|
|
{/if}
|
|
|
|
|
@ -291,6 +313,12 @@
|
|
|
|
|
margin-bottom: 0.5rem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.json-actions {
|
|
|
|
|
display: flex;
|
|
|
|
|
gap: 0.5rem;
|
|
|
|
|
flex-wrap: wrap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.form-group {
|
|
|
|
|
margin-bottom: 1rem;
|
|
|
|
|
}
|
|
|
|
|
|