milwright commited on
Commit
4ea90f7
·
1 Parent(s): 8e635f8

prevent initials modal from auto-submitting on first high score

Browse files
Files changed (2) hide show
  1. README.md +15 -11
  2. src/leaderboardUI.js +18 -2
README.md CHANGED
@@ -39,13 +39,15 @@ The cloze procedure, introduced by Wilson Taylor in 1953, measures reading compr
39
 
40
  ## Running with Docker
41
 
42
- # Build the image
43
- docker build -t cloze-reader .
 
44
 
45
- # Run the container
46
- docker run -p 7860:7860 cloze-reader
47
 
48
- # Access at http://localhost:7860
 
49
 
50
  **Prerequisites:** Docker installed, port 7860 available.
51
 
@@ -53,18 +55,20 @@ The cloze procedure, introduced by Wilson Taylor in 1953, measures reading compr
53
 
54
  Run with a local LLM server instead of OpenRouter:
55
 
56
- # Start local LLM server on port 1234 (e.g., LM Studio with Gemma-3-27b)
57
- # Run development server
58
- make dev # or python3 local-server.py 8000
 
59
 
60
- # Access at http://localhost:8000/index.html?local=true
 
61
 
62
  **Features:**
63
  - No API key required
64
  - Offline operation
65
  - Automatic response cleaning for local LLM output
66
  - Compatible with LM Studio and OpenAI-compatible servers
67
- - Testing available at http://localhost:8000/test-local-llm.html?local=true
68
 
69
  ## Architecture
70
 
@@ -85,4 +89,4 @@ Recent work connects cloze assessment and masked language modeling:
85
  - Zhang & Hashimoto (2021) analyzed inductive biases in masked tokens, showing models learn statistical and syntactic dependencies that cloze tests measure in humans
86
 
87
  ---
88
- [milwright](https://huggingface.co/milwright), *Zach Muhlbauer*, CUNY Graduate Center
 
39
 
40
  ## Running with Docker
41
 
42
+ ```bash
43
+ # Build the image
44
+ docker build -t cloze-reader .
45
 
46
+ # Run the container
47
+ docker run -p 7860:7860 cloze-reader
48
 
49
+ # Access at http://localhost:7860
50
+ ```
51
 
52
  **Prerequisites:** Docker installed, port 7860 available.
53
 
 
55
 
56
  Run with a local LLM server instead of OpenRouter:
57
 
58
+ ```bash
59
+ # Start local LLM server on port 1234 (e.g., LM Studio with Gemma-3-27b)
60
+ # Run development server
61
+ make dev # or python3 local-server.py 8000
62
 
63
+ # Access at http://localhost:8000/index.html?local=true
64
+ ```
65
 
66
  **Features:**
67
  - No API key required
68
  - Offline operation
69
  - Automatic response cleaning for local LLM output
70
  - Compatible with LM Studio and OpenAI-compatible servers
71
+ - Testing available at `http://localhost:8000/test-local-llm.html?local=true`
72
 
73
  ## Architecture
74
 
 
89
  - Zhang & Hashimoto (2021) analyzed inductive biases in masked tokens, showing models learn statistical and syntactic dependencies that cloze tests measure in humans
90
 
91
  ---
92
+ [milwright](https://huggingface.co/milwright), *Zach Muhlbauer*, CUNY Graduate Center
src/leaderboardUI.js CHANGED
@@ -12,6 +12,7 @@ export class LeaderboardUI {
12
  this.currentSlot = 0;
13
  this.initials = ['A', 'A', 'A'];
14
  this.onInitialsSubmit = null;
 
15
  }
16
 
17
  /**
@@ -151,6 +152,7 @@ export class LeaderboardUI {
151
 
152
  // Reset initials state
153
  this.currentSlot = 0;
 
154
 
155
  // Get existing player initials if available
156
  const profile = this.service.getPlayerProfile();
@@ -212,8 +214,16 @@ export class LeaderboardUI {
212
  this.initialsModal.classList.add('visible');
213
  });
214
 
215
- // Add event listeners
216
- this.setupInitialsEventListeners();
 
 
 
 
 
 
 
 
217
  }
218
 
219
  /**
@@ -340,6 +350,12 @@ export class LeaderboardUI {
340
  * Submit initials and save to leaderboard
341
  */
342
  submitInitials() {
 
 
 
 
 
 
343
  const initialsString = this.initials.join('');
344
 
345
  // Save to player profile
 
12
  this.currentSlot = 0;
13
  this.initials = ['A', 'A', 'A'];
14
  this.onInitialsSubmit = null;
15
+ this.canSubmitInitials = false; // Prevent accidental immediate submission
16
  }
17
 
18
  /**
 
152
 
153
  // Reset initials state
154
  this.currentSlot = 0;
155
+ this.canSubmitInitials = false; // Disable submission until user has had time to interact
156
 
157
  // Get existing player initials if available
158
  const profile = this.service.getPlayerProfile();
 
214
  this.initialsModal.classList.add('visible');
215
  });
216
 
217
+ // Add event listeners with a delay to prevent Enter key from passage submission
218
+ // from immediately triggering the modal's submit handler
219
+ setTimeout(() => {
220
+ this.setupInitialsEventListeners();
221
+ // Enable submission after a longer delay to ensure user has time to interact
222
+ setTimeout(() => {
223
+ this.canSubmitInitials = true;
224
+ console.log('🔓 Initials submission enabled - user can now submit');
225
+ }, 300);
226
+ }, 100);
227
  }
228
 
229
  /**
 
350
  * Submit initials and save to leaderboard
351
  */
352
  submitInitials() {
353
+ // Prevent accidental immediate submission
354
+ if (!this.canSubmitInitials) {
355
+ console.log('⏸️ Initials submission blocked - too soon after modal opened');
356
+ return;
357
+ }
358
+
359
  const initialsString = this.initials.join('');
360
 
361
  // Save to player profile