Add free-type spell checker for students
Build and Push Docker Image / build-and-push (push) Successful in 1m5s
Build and Push Docker Image / build-and-push (push) Successful in 1m5s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
91fe38c00d
commit
a2fb3b056a
5 files changed
+106
-2
No files matched your search
@@ -2519,6 +2519,37 @@ $('#btn-test').addEventListener('click', () => {
|
||||
startTest();
|
||||
});
|
||||
|
||||
$('#btn-freetype').addEventListener('click', () => {
|
||||
backTarget = () => openKid(currentStudent.id, 'spelling');
|
||||
$('#freetype-feedback').innerHTML = '';
|
||||
$('#freetype-input').value = '';
|
||||
show('freetype');
|
||||
$('#freetype-input').focus();
|
||||
});
|
||||
|
||||
$('#freetype-form').addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
const input = $('#freetype-input');
|
||||
const typed = input.value.trim();
|
||||
if (!typed) return;
|
||||
const fb = $('#freetype-feedback');
|
||||
try {
|
||||
const r = await api(`/api/spellcheck?word=${encodeURIComponent(typed)}`);
|
||||
if (r.correct) {
|
||||
fb.innerHTML = `<div class="banner good">✅ "${esc(r.word)}" is spelled correctly!</div>`;
|
||||
} else {
|
||||
const tips = r.suggestions.length
|
||||
? ` Did you mean: ${r.suggestions.map((x) => `<strong>${esc(x)}</strong>`).join(', ')}?`
|
||||
: '';
|
||||
fb.innerHTML = `<div class="banner bad">❌ "${esc(r.word)}" is not spelled correctly.${tips}</div>`;
|
||||
alert(`"${r.word}" is spelled wrong. Try again!`);
|
||||
}
|
||||
} catch (err) {
|
||||
fb.innerHTML = `<div class="banner bad">${esc(err.message)}</div>`;
|
||||
}
|
||||
input.select();
|
||||
});
|
||||
|
||||
// ---------- docs (OnlyOffice) ----------
|
||||
|
||||
let docsEditorInstance = null;
|
||||
|
||||
Reference in new issue
Block a user