Spaces:
Running
Running
Add 2 files
Browse files- README.md +6 -4
- index.html +372 -19
README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
colorTo: yellow
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: ai-question-generator
|
| 3 |
+
emoji: 🐳
|
| 4 |
+
colorFrom: pink
|
| 5 |
colorTo: yellow
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite
|
| 10 |
---
|
| 11 |
|
| 12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
|
@@ -1,19 +1,372 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>AI Question Generator</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 9 |
+
<style>
|
| 10 |
+
.question-card {
|
| 11 |
+
transition: all 0.3s ease;
|
| 12 |
+
}
|
| 13 |
+
.question-card:hover {
|
| 14 |
+
transform: translateY(-3px);
|
| 15 |
+
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
|
| 16 |
+
}
|
| 17 |
+
.loading-dots::after {
|
| 18 |
+
content: '.';
|
| 19 |
+
animation: dots 1.5s steps(5, end) infinite;
|
| 20 |
+
}
|
| 21 |
+
@keyframes dots {
|
| 22 |
+
0%, 20% { content: '.'; }
|
| 23 |
+
40% { content: '..'; }
|
| 24 |
+
60% { content: '...'; }
|
| 25 |
+
80%, 100% { content: ''; }
|
| 26 |
+
}
|
| 27 |
+
.fade-in {
|
| 28 |
+
animation: fadeIn 0.5s ease-in;
|
| 29 |
+
}
|
| 30 |
+
@keyframes fadeIn {
|
| 31 |
+
from { opacity: 0; transform: translateY(10px); }
|
| 32 |
+
to { opacity: 1; transform: translateY(0); }
|
| 33 |
+
}
|
| 34 |
+
</style>
|
| 35 |
+
</head>
|
| 36 |
+
<body class="bg-gray-50 min-h-screen">
|
| 37 |
+
<div class="container mx-auto px-4 py-8">
|
| 38 |
+
<!-- Header -->
|
| 39 |
+
<header class="text-center mb-12">
|
| 40 |
+
<h1 class="text-4xl font-bold text-indigo-700 mb-2">AI Question Generator</h1>
|
| 41 |
+
<p class="text-gray-600 max-w-2xl mx-auto">Enter a topic and let our AI generate insightful questions to explore the subject deeply.</p>
|
| 42 |
+
</header>
|
| 43 |
+
|
| 44 |
+
<!-- Main Content -->
|
| 45 |
+
<div class="max-w-4xl mx-auto">
|
| 46 |
+
<!-- Input Section -->
|
| 47 |
+
<div class="bg-white rounded-xl shadow-md p-6 mb-8">
|
| 48 |
+
<div class="flex flex-col md:flex-row gap-4">
|
| 49 |
+
<div class="flex-grow">
|
| 50 |
+
<label for="topic" class="block text-sm font-medium text-gray-700 mb-1">Enter your topic</label>
|
| 51 |
+
<input
|
| 52 |
+
type="text"
|
| 53 |
+
id="topic"
|
| 54 |
+
placeholder="e.g. Artificial Intelligence, Climate Change, Renaissance Art..."
|
| 55 |
+
class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition"
|
| 56 |
+
>
|
| 57 |
+
</div>
|
| 58 |
+
<div class="flex items-end">
|
| 59 |
+
<button
|
| 60 |
+
id="generateBtn"
|
| 61 |
+
class="bg-indigo-600 hover:bg-indigo-700 text-white px-6 py-3 rounded-lg font-medium transition flex items-center justify-center w-full md:w-auto"
|
| 62 |
+
>
|
| 63 |
+
<i class="fas fa-bolt mr-2"></i> Generate Questions
|
| 64 |
+
</button>
|
| 65 |
+
</div>
|
| 66 |
+
</div>
|
| 67 |
+
|
| 68 |
+
<div class="mt-4 flex flex-wrap gap-3">
|
| 69 |
+
<div class="flex items-center">
|
| 70 |
+
<input type="checkbox" id="basicQuestions" class="h-4 w-4 text-indigo-600 rounded" checked>
|
| 71 |
+
<label for="basicQuestions" class="ml-2 text-sm text-gray-700">Basic</label>
|
| 72 |
+
</div>
|
| 73 |
+
<div class="flex items-center">
|
| 74 |
+
<input type="checkbox" id="advancedQuestions" class="h-4 w-4 text-indigo-600 rounded" checked>
|
| 75 |
+
<label for="advancedQuestions" class="ml-2 text-sm text-gray-700">Advanced</label>
|
| 76 |
+
</div>
|
| 77 |
+
<div class="flex items-center">
|
| 78 |
+
<input type="checkbox" id="criticalQuestions" class="h-4 w-4 text-indigo-600 rounded" checked>
|
| 79 |
+
<label for="criticalQuestions" class="ml-2 text-sm text-gray-700">Critical Thinking</label>
|
| 80 |
+
</div>
|
| 81 |
+
<div class="flex items-center">
|
| 82 |
+
<input type="number" id="questionCount" min="3" max="20" value="8" class="w-16 px-2 py-1 border border-gray-300 rounded text-sm">
|
| 83 |
+
<label for="questionCount" class="ml-2 text-sm text-gray-700">Questions</label>
|
| 84 |
+
</div>
|
| 85 |
+
</div>
|
| 86 |
+
</div>
|
| 87 |
+
|
| 88 |
+
<!-- Loading State -->
|
| 89 |
+
<div id="loadingState" class="hidden text-center py-12">
|
| 90 |
+
<div class="inline-block bg-white p-6 rounded-xl shadow-md">
|
| 91 |
+
<i class="fas fa-cog fa-spin text-indigo-600 text-3xl mb-3"></i>
|
| 92 |
+
<p class="text-gray-700 font-medium loading-dots">Generating questions</p>
|
| 93 |
+
</div>
|
| 94 |
+
</div>
|
| 95 |
+
|
| 96 |
+
<!-- Results Section -->
|
| 97 |
+
<div id="resultsSection" class="hidden">
|
| 98 |
+
<div class="flex justify-between items-center mb-4">
|
| 99 |
+
<h2 class="text-xl font-semibold text-gray-800">Generated Questions</h2>
|
| 100 |
+
<div class="flex gap-2">
|
| 101 |
+
<button id="exportJsonBtn" class="bg-gray-100 hover:bg-gray-200 text-gray-700 px-4 py-2 rounded-lg text-sm font-medium transition flex items-center">
|
| 102 |
+
<i class="fas fa-file-export mr-2"></i> Export JSON
|
| 103 |
+
</button>
|
| 104 |
+
<button id="copyAllBtn" class="bg-gray-100 hover:bg-gray-200 text-gray-700 px-4 py-2 rounded-lg text-sm font-medium transition flex items-center">
|
| 105 |
+
<i class="fas fa-copy mr-2"></i> Copy All
|
| 106 |
+
</button>
|
| 107 |
+
</div>
|
| 108 |
+
</div>
|
| 109 |
+
|
| 110 |
+
<div id="questionsContainer" class="grid gap-4">
|
| 111 |
+
<!-- Questions will be inserted here -->
|
| 112 |
+
</div>
|
| 113 |
+
</div>
|
| 114 |
+
|
| 115 |
+
<!-- Empty State -->
|
| 116 |
+
<div id="emptyState" class="text-center py-16 bg-white rounded-xl shadow-sm">
|
| 117 |
+
<i class="fas fa-comment-dots text-4xl text-gray-300 mb-4"></i>
|
| 118 |
+
<h3 class="text-lg font-medium text-gray-500">No questions generated yet</h3>
|
| 119 |
+
<p class="text-gray-400 mt-1">Enter a topic above and click "Generate Questions" to get started</p>
|
| 120 |
+
</div>
|
| 121 |
+
</div>
|
| 122 |
+
</div>
|
| 123 |
+
|
| 124 |
+
<!-- JSON Export Modal -->
|
| 125 |
+
<div id="jsonModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
|
| 126 |
+
<div class="bg-white rounded-xl shadow-xl w-full max-w-2xl max-h-[80vh] flex flex-col">
|
| 127 |
+
<div class="px-6 py-4 border-b flex justify-between items-center">
|
| 128 |
+
<h3 class="text-lg font-semibold">Export Questions as JSON</h3>
|
| 129 |
+
<button id="closeJsonModal" class="text-gray-500 hover:text-gray-700">
|
| 130 |
+
<i class="fas fa-times"></i>
|
| 131 |
+
</button>
|
| 132 |
+
</div>
|
| 133 |
+
<div class="p-6 overflow-auto flex-grow">
|
| 134 |
+
<pre id="jsonOutput" class="bg-gray-50 p-4 rounded text-sm overflow-auto"></pre>
|
| 135 |
+
</div>
|
| 136 |
+
<div class="px-6 py-4 border-t flex justify-end gap-3">
|
| 137 |
+
<button id="copyJsonBtn" class="bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-lg text-sm font-medium transition">
|
| 138 |
+
<i class="fas fa-copy mr-2"></i> Copy JSON
|
| 139 |
+
</button>
|
| 140 |
+
<button id="downloadJsonBtn" class="bg-gray-100 hover:bg-gray-200 text-gray-700 px-4 py-2 rounded-lg text-sm font-medium transition">
|
| 141 |
+
<i class="fas fa-download mr-2"></i> Download
|
| 142 |
+
</button>
|
| 143 |
+
</div>
|
| 144 |
+
</div>
|
| 145 |
+
</div>
|
| 146 |
+
|
| 147 |
+
<script>
|
| 148 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 149 |
+
// DOM Elements
|
| 150 |
+
const topicInput = document.getElementById('topic');
|
| 151 |
+
const generateBtn = document.getElementById('generateBtn');
|
| 152 |
+
const loadingState = document.getElementById('loadingState');
|
| 153 |
+
const resultsSection = document.getElementById('resultsSection');
|
| 154 |
+
const emptyState = document.getElementById('emptyState');
|
| 155 |
+
const questionsContainer = document.getElementById('questionsContainer');
|
| 156 |
+
const exportJsonBtn = document.getElementById('exportJsonBtn');
|
| 157 |
+
const copyAllBtn = document.getElementById('copyAllBtn');
|
| 158 |
+
const jsonModal = document.getElementById('jsonModal');
|
| 159 |
+
const closeJsonModal = document.getElementById('closeJsonModal');
|
| 160 |
+
const jsonOutput = document.getElementById('jsonOutput');
|
| 161 |
+
const copyJsonBtn = document.getElementById('copyJsonBtn');
|
| 162 |
+
const downloadJsonBtn = document.getElementById('downloadJsonBtn');
|
| 163 |
+
|
| 164 |
+
// Sample question types for the mock API
|
| 165 |
+
const questionTypes = {
|
| 166 |
+
basic: [
|
| 167 |
+
"What is {topic}?",
|
| 168 |
+
"Why is {topic} important?",
|
| 169 |
+
"How does {topic} work?",
|
| 170 |
+
"What are the main components of {topic}?",
|
| 171 |
+
"When did {topic} first emerge?"
|
| 172 |
+
],
|
| 173 |
+
advanced: [
|
| 174 |
+
"What are the current challenges in {topic}?",
|
| 175 |
+
"How has {topic} evolved over time?",
|
| 176 |
+
"What are the different approaches to {topic}?",
|
| 177 |
+
"How does {topic} compare to similar concepts?",
|
| 178 |
+
"What are the technical aspects of {topic}?"
|
| 179 |
+
],
|
| 180 |
+
critical: [
|
| 181 |
+
"What are the ethical implications of {topic}?",
|
| 182 |
+
"How might {topic} impact society in the future?",
|
| 183 |
+
"What are the limitations of current {topic} implementations?",
|
| 184 |
+
"How could {topic} be improved or innovated upon?",
|
| 185 |
+
"What controversies exist surrounding {topic}?"
|
| 186 |
+
]
|
| 187 |
+
};
|
| 188 |
+
|
| 189 |
+
// Generate questions (mock API call)
|
| 190 |
+
function generateQuestions(topic, count) {
|
| 191 |
+
const selectedTypes = [];
|
| 192 |
+
if (document.getElementById('basicQuestions').checked) selectedTypes.push('basic');
|
| 193 |
+
if (document.getElementById('advancedQuestions').checked) selectedTypes.push('advanced');
|
| 194 |
+
if (document.getElementById('criticalQuestions').checked) selectedTypes.push('critical');
|
| 195 |
+
|
| 196 |
+
// Distribute questions evenly among selected types
|
| 197 |
+
const questionsPerType = Math.ceil(count / selectedTypes.length);
|
| 198 |
+
let questions = [];
|
| 199 |
+
|
| 200 |
+
selectedTypes.forEach(type => {
|
| 201 |
+
const typeQuestions = [...questionTypes[type]];
|
| 202 |
+
// Shuffle and take needed amount
|
| 203 |
+
typeQuestions.sort(() => 0.5 - Math.random());
|
| 204 |
+
const selected = typeQuestions.slice(0, questionsPerType);
|
| 205 |
+
questions = [...questions, ...selected];
|
| 206 |
+
});
|
| 207 |
+
|
| 208 |
+
// Shuffle all questions and trim to exact count
|
| 209 |
+
questions.sort(() => 0.5 - Math.random());
|
| 210 |
+
questions = questions.slice(0, count);
|
| 211 |
+
|
| 212 |
+
// Replace {topic} with actual topic
|
| 213 |
+
return questions.map(q => ({
|
| 214 |
+
text: q.replace('{topic}', topic),
|
| 215 |
+
type: Object.keys(questionTypes).find(key => questionTypes[key].includes(q)) || 'basic'
|
| 216 |
+
}));
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
// Display questions
|
| 220 |
+
function displayQuestions(questions) {
|
| 221 |
+
questionsContainer.innerHTML = '';
|
| 222 |
+
|
| 223 |
+
questions.forEach((question, index) => {
|
| 224 |
+
const typeColors = {
|
| 225 |
+
basic: 'bg-blue-100 text-blue-800',
|
| 226 |
+
advanced: 'bg-purple-100 text-purple-800',
|
| 227 |
+
critical: 'bg-orange-100 text-orange-800'
|
| 228 |
+
};
|
| 229 |
+
|
| 230 |
+
const card = document.createElement('div');
|
| 231 |
+
card.className = `question-card bg-white rounded-xl shadow-sm p-5 border-l-4 border-indigo-500 fade-in`;
|
| 232 |
+
card.style.animationDelay = `${index * 0.05}s`;
|
| 233 |
+
|
| 234 |
+
card.innerHTML = `
|
| 235 |
+
<div class="flex justify-between items-start">
|
| 236 |
+
<div class="flex-grow">
|
| 237 |
+
<div class="flex items-center mb-2">
|
| 238 |
+
<span class="text-xs font-medium px-2 py-1 rounded-full ${typeColors[question.type]} mr-2">
|
| 239 |
+
${question.type.charAt(0).toUpperCase() + question.type.slice(1)}
|
| 240 |
+
</span>
|
| 241 |
+
</div>
|
| 242 |
+
<p class="text-gray-800 font-medium">${question.text}</p>
|
| 243 |
+
</div>
|
| 244 |
+
<button class="copy-btn text-gray-400 hover:text-indigo-600 ml-3" data-question="${question.text}">
|
| 245 |
+
<i class="fas fa-copy"></i>
|
| 246 |
+
</button>
|
| 247 |
+
</div>
|
| 248 |
+
`;
|
| 249 |
+
|
| 250 |
+
questionsContainer.appendChild(card);
|
| 251 |
+
});
|
| 252 |
+
|
| 253 |
+
// Add event listeners to copy buttons
|
| 254 |
+
document.querySelectorAll('.copy-btn').forEach(btn => {
|
| 255 |
+
btn.addEventListener('click', function() {
|
| 256 |
+
const question = this.getAttribute('data-question');
|
| 257 |
+
navigator.clipboard.writeText(question);
|
| 258 |
+
|
| 259 |
+
// Show feedback
|
| 260 |
+
const icon = this.querySelector('i');
|
| 261 |
+
icon.className = 'fas fa-check';
|
| 262 |
+
setTimeout(() => {
|
| 263 |
+
icon.className = 'fas fa-copy';
|
| 264 |
+
}, 1000);
|
| 265 |
+
});
|
| 266 |
+
});
|
| 267 |
+
}
|
| 268 |
+
|
| 269 |
+
// Generate button click handler
|
| 270 |
+
generateBtn.addEventListener('click', function() {
|
| 271 |
+
const topic = topicInput.value.trim();
|
| 272 |
+
const count = parseInt(document.getElementById('questionCount').value) || 8;
|
| 273 |
+
|
| 274 |
+
if (!topic) {
|
| 275 |
+
alert('Please enter a topic first');
|
| 276 |
+
return;
|
| 277 |
+
}
|
| 278 |
+
|
| 279 |
+
// Show loading state
|
| 280 |
+
loadingState.classList.remove('hidden');
|
| 281 |
+
resultsSection.classList.add('hidden');
|
| 282 |
+
emptyState.classList.add('hidden');
|
| 283 |
+
|
| 284 |
+
// Simulate API call with timeout
|
| 285 |
+
setTimeout(() => {
|
| 286 |
+
const questions = generateQuestions(topic, count);
|
| 287 |
+
|
| 288 |
+
// Hide loading and show results
|
| 289 |
+
loadingState.classList.add('hidden');
|
| 290 |
+
resultsSection.classList.remove('hidden');
|
| 291 |
+
displayQuestions(questions);
|
| 292 |
+
|
| 293 |
+
// Scroll to results
|
| 294 |
+
resultsSection.scrollIntoView({ behavior: 'smooth' });
|
| 295 |
+
}, 1500);
|
| 296 |
+
});
|
| 297 |
+
|
| 298 |
+
// Export JSON functionality
|
| 299 |
+
exportJsonBtn.addEventListener('click', function() {
|
| 300 |
+
const questions = Array.from(document.querySelectorAll('.question-card')).map(card => {
|
| 301 |
+
return {
|
| 302 |
+
question: card.querySelector('p').textContent,
|
| 303 |
+
type: card.querySelector('span').textContent.toLowerCase()
|
| 304 |
+
};
|
| 305 |
+
});
|
| 306 |
+
|
| 307 |
+
const jsonData = {
|
| 308 |
+
topic: topicInput.value.trim(),
|
| 309 |
+
generatedAt: new Date().toISOString(),
|
| 310 |
+
questions: questions
|
| 311 |
+
};
|
| 312 |
+
|
| 313 |
+
jsonOutput.textContent = JSON.stringify(jsonData, null, 2);
|
| 314 |
+
jsonModal.classList.remove('hidden');
|
| 315 |
+
});
|
| 316 |
+
|
| 317 |
+
// Close JSON modal
|
| 318 |
+
closeJsonModal.addEventListener('click', function() {
|
| 319 |
+
jsonModal.classList.add('hidden');
|
| 320 |
+
});
|
| 321 |
+
|
| 322 |
+
// Copy JSON to clipboard
|
| 323 |
+
copyJsonBtn.addEventListener('click', function() {
|
| 324 |
+
navigator.clipboard.writeText(jsonOutput.textContent);
|
| 325 |
+
const icon = this.querySelector('i');
|
| 326 |
+
const originalText = this.innerHTML;
|
| 327 |
+
this.innerHTML = '<i class="fas fa-check mr-2"></i> Copied!';
|
| 328 |
+
setTimeout(() => {
|
| 329 |
+
this.innerHTML = originalText;
|
| 330 |
+
}, 2000);
|
| 331 |
+
});
|
| 332 |
+
|
| 333 |
+
// Download JSON file
|
| 334 |
+
downloadJsonBtn.addEventListener('click', function() {
|
| 335 |
+
const data = jsonOutput.textContent;
|
| 336 |
+
const blob = new Blob([data], { type: 'application/json' });
|
| 337 |
+
const url = URL.createObjectURL(blob);
|
| 338 |
+
|
| 339 |
+
const a = document.createElement('a');
|
| 340 |
+
a.href = url;
|
| 341 |
+
a.download = `questions-${topicInput.value.trim().toLowerCase().replace(/\s+/g, '-')}-${new Date().toISOString().slice(0,10)}.json`;
|
| 342 |
+
document.body.appendChild(a);
|
| 343 |
+
a.click();
|
| 344 |
+
document.body.removeChild(a);
|
| 345 |
+
URL.revokeObjectURL(url);
|
| 346 |
+
});
|
| 347 |
+
|
| 348 |
+
// Copy all questions
|
| 349 |
+
copyAllBtn.addEventListener('click', function() {
|
| 350 |
+
const questions = Array.from(document.querySelectorAll('.question-card')).map(card => {
|
| 351 |
+
return card.querySelector('p').textContent;
|
| 352 |
+
}).join('\n\n');
|
| 353 |
+
|
| 354 |
+
navigator.clipboard.writeText(questions);
|
| 355 |
+
const icon = this.querySelector('i');
|
| 356 |
+
const originalText = this.innerHTML;
|
| 357 |
+
this.innerHTML = '<i class="fas fa-check mr-2"></i> Copied all!';
|
| 358 |
+
setTimeout(() => {
|
| 359 |
+
this.innerHTML = originalText;
|
| 360 |
+
}, 2000);
|
| 361 |
+
});
|
| 362 |
+
|
| 363 |
+
// Allow Enter key to trigger generation
|
| 364 |
+
topicInput.addEventListener('keypress', function(e) {
|
| 365 |
+
if (e.key === 'Enter') {
|
| 366 |
+
generateBtn.click();
|
| 367 |
+
}
|
| 368 |
+
});
|
| 369 |
+
});
|
| 370 |
+
</script>
|
| 371 |
+
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - <a href="https://enzostvs-deepsite.hf.space?remix=8421bit/ai-question-generator" style="color: #fff;text-decoration: underline;" target="_blank" >🧬 Remix</a></p></body>
|
| 372 |
+
</html>
|