Spaces:
Running
Running
File size: 2,990 Bytes
b88ba0c 4e2df23 b88ba0c 0946b85 b88ba0c 0946b85 b88ba0c d339d89 4e2df23 d339d89 4e2df23 0946b85 b88ba0c 0946b85 b88ba0c 0946b85 8f29607 b88ba0c 0946b85 b88ba0c c463c35 b88ba0c c463c35 b88ba0c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
// Welcome overlay for first-time users
class WelcomeOverlay {
constructor() {
this.isVisible = false;
this.hasBeenShown = localStorage.getItem('cloze-reader-welcomed') === 'true';
}
show() {
// Always show overlay regardless of previous views
this.isVisible = true;
const overlay = this.createOverlay();
document.body.appendChild(overlay);
// Animate in
requestAnimationFrame(() => {
overlay.style.opacity = '1';
});
}
createOverlay() {
const overlay = document.createElement('div');
overlay.className = 'welcome-overlay';
overlay.style.opacity = '0';
const modal = document.createElement('div');
modal.className = 'welcome-modal';
modal.style.cssText = `
max-width: 500px;
margin: 20px;
text-align: center;
`;
modal.innerHTML = `
<div style="display: flex; justify-content: center; margin-bottom: 12px;">
<img src="https://raw.githubusercontent.com/zmuhls/cloze-reader/main/icon.png"
alt="Cloze Reader"
style="width: 48px; height: 48px; border-radius: 6px;">
</div>
<h1 class="welcome-title">
Cloze Reader
</h1>
<div class="welcome-content">
<p>
<strong>How to play:</strong> Read the passage, fill in the blanks, and use hints or chat help (💬) if needed. Progress through levels as you improve.
</p>
<p>
<strong>Data source:</strong> Randomly excerpted historical and literary texts from Project Gutenberg's public domain collection, processed via Hugging Face Datasets.
</p>
<p style="margin-bottom: 0;">
<strong>AI assistance:</strong> Powered by Google's Gemma 3 model via OpenRouter for intelligent word selection and contextual hints.
</p>
</div>
<button id="welcome-start-btn" class="typewriter-button">
Start Reading
</button>
`;
overlay.appendChild(modal);
// Add click handler
const startBtn = modal.querySelector('#welcome-start-btn');
startBtn.addEventListener('click', () => this.hide());
// Allow clicking outside to close
overlay.addEventListener('click', (e) => {
if (e.target === overlay) this.hide();
});
return overlay;
}
hide() {
const overlay = document.querySelector('.welcome-overlay');
if (!overlay) return;
overlay.style.opacity = '0';
setTimeout(() => {
overlay.remove();
this.isVisible = false;
// Remember that user has seen welcome
localStorage.setItem('cloze-reader-welcomed', 'true');
this.hasBeenShown = true;
}, 300);
}
// Method to reset welcome (for testing or new features)
reset() {
localStorage.removeItem('cloze-reader-welcomed');
this.hasBeenShown = false;
}
// Force show overlay (for testing)
forceShow() {
this.hasBeenShown = false;
this.show();
}
}
export default WelcomeOverlay; |