MCPcopy Create free account
hub / github.com/danja/dogalog / TutorialManager

Class TutorialManager

src/tutorial/tutorialManager.js:8–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6const STORAGE_KEY = 'dogalog_tutorial_progress';
7
8export class TutorialManager {
9 constructor() {
10 this.currentStep = 0;
11 this.completed = false;
12 this.listeners = new Map();
13 this.loadProgress();
14 }
15
16 /**
17 * Load progress from localStorage
18 */
19 loadProgress() {
20 try {
21 const saved = localStorage.getItem(STORAGE_KEY);
22 if (saved) {
23 const data = JSON.parse(saved);
24 this.currentStep = data.currentStep || 0;
25 this.completed = data.completed || false;
26 }
27 } catch (e) {
28 console.warn('Failed to load tutorial progress:', e);
29 }
30 }
31
32 /**
33 * Save progress to localStorage
34 */
35 saveProgress() {
36 try {
37 localStorage.setItem(STORAGE_KEY, JSON.stringify({
38 currentStep: this.currentStep,
39 completed: this.completed
40 }));
41 } catch (e) {
42 console.warn('Failed to save tutorial progress:', e);
43 }
44 }
45
46 /**
47 * Start or restart the tutorial
48 */
49 start() {
50 this.currentStep = 0;
51 this.completed = false;
52 this.saveProgress();
53 this.emit('start');
54 this.emit('step', this.currentStep);
55 }
56
57 /**
58 * Go to next step
59 */
60 next() {
61 this.currentStep++;
62 this.saveProgress();
63 this.emit('step', this.currentStep);
64 }
65

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected