aboutsummaryrefslogtreecommitdiff
path: root/static/bs
diff options
context:
space:
mode:
authorNat Lasseter <user@4574.co.uk>2025-04-01 11:30:16 +0100
committerNat Lasseter <user@4574.co.uk>2025-04-01 11:30:16 +0100
commit1d784fc297a3c4664814283e12cd322cadd4b242 (patch)
tree35db108a54e5ea05e33ce2ba75830f23c9e3bbe7 /static/bs
parent5d438013d2c84fcaa2aac246e1173809b19793b0 (diff)
[bracket] remove email stuff
Diffstat (limited to 'static/bs')
-rw-r--r--static/bs/bracket.css72
-rw-r--r--static/bs/bracket.js332
-rw-r--r--static/bs/tutorial/tutorial.css71
3 files changed, 8 insertions, 467 deletions
diff --git a/static/bs/bracket.css b/static/bs/bracket.css
index e630a6a..ab0285f 100644
--- a/static/bs/bracket.css
+++ b/static/bs/bracket.css
@@ -435,76 +435,6 @@
color: #1a202c;
}
- /* ===================
- Email Form Styles
- =================== */
-
- .email-signup-container {
- margin: 1rem 0.5rem 0.5rem 0.5rem;
- }
-
- .email-signup-form label {
- display: block;
- margin-bottom: 0.75rem;
- font-weight: 500;
- text-align: center;
- font-family: var(--mono-font);
- font-size: 1.1rem;
- }
-
- .email-signup-form label span
- {
- background-color: rgba(255, 255, 0, 0.2); padding: 0.2rem 0.4rem;
- }
-
- .email-input-container {
- display: flex;
- gap: 0.5rem;
- }
-
- .email-signup-form input {
- flex: 1;
- padding: 0.5rem;
- border: 1px solid #ccc;
- border-radius: 0.375rem;
- font-size: 16px;
- gap: 0.5rem
- }
-
- .email-signup-form button {
- padding: 0.5rem 1rem;
- background-color: #2563eb;
- color: white;
- border: none;
- border-radius: 0.375rem;
- cursor: pointer;
- font-weight: 500;
- font-size: 16px;
- white-space: nowrap;
- }
- .email-signup-message {
- border-radius: 0.375rem;
- margin-top: 0.75rem;
- margin-bottom: 0.75rem;
- text-align: center;
- font-family: var(--mono-font);
- }
-
- .email-signup-message .success {
- padding: 1rem;
- background-color: #ecfdf5;
- border: 1px solid #6ee7b7;
- border-radius: 0.375rem;
- color: #065f46;
- }
-
- .email-signup-message .error {
- padding: 1rem;
- background-color: #fef2f2;
- border: 1px solid #fca5a5;
- border-radius: 0.375rem;
- color: #991b1b;
- }
/* ===================
Stats & Completion
@@ -1353,4 +1283,4 @@ input:checked + .toggle-slider:before {
.announcement-modal-content {
font-size: 0.95rem;
}
-} \ No newline at end of file
+}
diff --git a/static/bs/bracket.js b/static/bs/bracket.js
index d3284b7..9028078 100644
--- a/static/bs/bracket.js
+++ b/static/bs/bracket.js
@@ -216,10 +216,6 @@ class BracketCityRank {
this.API_ENDPOINT = 'https://user.4574.co.uk/bracket-api';
this.PUZZLE_DATA = null;
- this.EMAIL_API_ENDPOINT = 'https://cgirhn3gi2.execute-api.us-east-2.amazonaws.com/emails';
- this.IDENTITY_POOL_ID = 'us-east-2:437434cd-7573-48a7-b2d7-607d88c725fe';
- this.REGION = 'us-east-2';
-
this.MODE_STORAGE_KEY = 'bracketCityInputMode';
this.inputMode = this.getInputMode();
@@ -235,9 +231,6 @@ class BracketCityRank {
// Initialize user ID
this.userId = this.initializeUserId();
- this.gaCompletionFired = false;
- this.gaStartFired = false;
-
// Initialize empty state immediately
this.state = {
displayState: '',
@@ -260,74 +253,6 @@ class BracketCityRank {
this.initializeGame();
}
- async loadAwsModules() {
- // Only load once
- if (window.AWS && window.AWS.CognitoIdentity && window.AWS.SignatureV4) {
- return;
- }
-
- // Load required modules dynamically
- await Promise.all([
- this.loadScript('https://sdk.amazonaws.com/js/aws-sdk-2.1048.0.min.js'),
- ]);
- }
-
- // Helper to load a script
- loadScript(src) {
- return new Promise((resolve, reject) => {
- const script = document.createElement('script');
- script.src = src;
- script.onload = resolve;
- script.onerror = reject;
- document.head.appendChild(script);
- });
- }
-
- async makeSignedRequest(path, options = {}) {
-
- // Load AWS modules just-in-time
- await this.loadAwsModules();
-
- // Initialize AWS configuration
- AWS.config.region = this.REGION;
- AWS.config.credentials = new AWS.CognitoIdentityCredentials({
- IdentityPoolId: this.IDENTITY_POOL_ID
- });
-
- await AWS.config.credentials.getPromise();
-
- const endpoint = new AWS.Endpoint(this.EMAIL_API_ENDPOINT);
- const request = new AWS.HttpRequest(endpoint, this.REGION);
-
- request.method = options.method || 'GET';
-
- request.path = endpoint.path + (path === '/' ? '' : path);
-
- request.headers = {
- 'Host': endpoint.host
- };
-
- if (options.body) {
- request.body = options.body;
- request.headers['Content-Type'] = 'application/json';
- }
-
- const signer = new AWS.Signers.V4(request, 'execute-api');
- signer.addAuthorization(AWS.config.credentials, AWS.util.date.getDate());
-
- const fetchOptions = {
- method: request.method,
- headers: request.headers
- };
-
- if (options.body && request.method !== 'GET') {
- fetchOptions.body = options.body;
- }
-
- return fetch(`${this.EMAIL_API_ENDPOINT}${path === '/' ? '' : path}`, fetchOptions);
-
- }
-
/**
* Initializes the game
*/
@@ -704,13 +629,6 @@ class BracketCityRank {
if (updates.megaPeekedClues) {
newState.megaPeekedClues = new Set(updates.megaPeekedClues);
}
-
- // Merge emailSignup if present
- if (updates.emailSignup) {
- newState.emailSignup = {
- ...this.state.emailSignup,
- ...updates.emailSignup
- };
}
// Update active clues if display state changes
@@ -796,13 +714,7 @@ class BracketCityRank {
inputMode: parsed.inputMode || this.getInputMode(),
// Preserve help system state properties if they exist
helpVisible: parsed.helpVisible || false,
- previousDisplay: parsed.previousDisplay || null,
- // Preserve email signup state
- emailSignup: parsed.emailSignup || {
- email: '',
- status: 'idle',
- errorMessage: ''
- }
+ previousDisplay: parsed.previousDisplay || null
};
} catch (error) {
@@ -881,12 +793,7 @@ class BracketCityRank {
megaPeekedClues: new Set(),
helpVisible: false,
previousDisplay: null,
- wrongGuesses: 0, // Reset wrong guesses
- emailSignup: {
- email: '',
- status: 'idle',
- errorMessage: ''
- }
+ wrongGuesses: 0 // Reset wrong guesses
});
// Remove any existing completion message and "completed" classes.
@@ -2404,14 +2311,7 @@ class BracketCityRank {
// Check for available adjacent puzzles
await this.checkAdjacentPuzzles(targetDate);
- // Preserve email signup state before resetting state
- const preservedEmailSignup = this.state?.emailSignup || {
- email: '',
- status: 'idle',
- errorMessage: ''
- };
-
- // Reset state to prevent leakage, but preserve things like email signup
+ // Reset state to prevent leakage
this.state = {
displayState: '',
solvedExpressions: new Set(),
@@ -2425,8 +2325,7 @@ class BracketCityRank {
megaPeekedClues: new Set(),
wrongGuesses: 0,
helpVisible: false,
- previousDisplay: null,
- emailSignup: preservedEmailSignup
+ previousDisplay: null
};
// Try to load saved state for this puzzle with explicit date parameter
@@ -2464,9 +2363,7 @@ class BracketCityRank {
megaPeekedClues: new Set(savedState.megaPeekedClues || []),
wrongGuesses: savedState.wrongGuesses || 0,
helpVisible: savedState.helpVisible || false,
- previousDisplay: savedState.previousDisplay || null,
- // Don't override the preserved email signup state unless there's a saved one
- emailSignup: savedState.emailSignup || preservedEmailSignup
+ previousDisplay: savedState.previousDisplay || null
});
} else {
console.log(`Initializing fresh state for ${targetDate}`);
@@ -2489,9 +2386,7 @@ class BracketCityRank {
megaPeekedClues: new Set(),
wrongGuesses: 0,
helpVisible: false,
- previousDisplay: null,
- // Keep the preserved email signup state
- emailSignup: preservedEmailSignup
+ previousDisplay: null
});
}
@@ -2767,7 +2662,6 @@ class BracketCityRank {
// Render stats
keystrokeStats.querySelector('.stats-content').innerHTML = `
${this.generateRankDisplay(stats)}
- ${this.generateEmailSignup()}
${this.generateStatItems(stats)}
`;
@@ -2780,7 +2674,6 @@ class BracketCityRank {
behavior: 'smooth'
});
this.setupDatePicker();
- this.trackCompletion();
}, 100);
}
@@ -2795,7 +2688,6 @@ class BracketCityRank {
keystrokeStats.style.display = 'block';
keystrokeStats.querySelector('.stats-content').innerHTML = `
${this.generateRankDisplay(stats)}
- ${this.generateEmailSignup()}
${this.generateStatItems(stats)}
`;
@@ -3131,41 +3023,6 @@ generateSpecialKeyHTML(keyItem) {
</div>
`;
}
-
-
- generateEmailSignup() {
- return `
- <div class="email-signup-container">
- <form class="email-signup-form">
- <label for="email">
- <span>
- [want to know when new puzzles are ready?]
- </span>
- </label>
- <div class="email-input-container">
- <input
- type="email"
- id="email"
- placeholder="Enter your email"
- ${this.state.emailSignup?.status === 'loading' || this.state.emailSignup?.status === 'success' ? 'disabled' : ''}
- >
- <button
- type="submit"
- ${this.state.emailSignup?.status === 'loading' || this.state.emailSignup?.status === 'success' ? 'disabled' : ''}
- >
- ${this.state.emailSignup?.status === 'loading' ? 'Signing up...' : '[sign up]'}
- </button>
- </div>
- <div class="email-signup-message"></div>
- <label for="email">
- <span>
- [emails include a fun word of the day]
- </span>
- </label>
- </form>
- </div>
- `;
- }
/**
@@ -3757,40 +3614,6 @@ generateSpecialKeyHTML(keyItem) {
}
}
- /**
- * Tracks completion analytics including the input mode
- */
- trackCompletion() {
- // Only fire once.
- if (this.gaCompletionFired) return;
- this.gaCompletionFired = true;
-
- // Compute efficiency, etc.
- const efficiency = this.state.totalKeystrokes > 0
- ? ((this.state.minimumKeystrokes / this.state.totalKeystrokes) * 100)
- : 100;
-
- const stats = this.rankCalculator.getDetailedStats(
- efficiency,
- this.state.peekedClues.size,
- this.state.megaPeekedClues.size,
- this.state.wrongGuesses || 0
- );
-
- const payload = {
- puzzle_date: this.currentPuzzleDate,
- user_id: this.userId,
- device_type: this.isMobile ? 'mobile' : 'desktop',
- final_rank: stats.rank,
- peek_count: this.state.peekedClues.size,
- mega_peek_count: this.state.megaPeekedClues.size,
- wrong_guess_count: this.state.wrongGuesses || 0,
- input_mode: this.inputMode
- };
- }
-
-
-
attachCompletionHandlers(keystrokeStats) {
// Rank display click handler
const rankDisplay = keystrokeStats.querySelector('.rank-display');
@@ -3803,18 +3626,6 @@ generateSpecialKeyHTML(keyItem) {
}
});
}
-
- // Email form handler
- const emailForm = keystrokeStats.querySelector('.email-signup-form');
- if (emailForm) {
- emailForm.addEventListener('submit', async (e) => {
- e.preventDefault();
- const emailInput = emailForm.querySelector('#email');
- const email = emailInput.value.trim();
- await this.handleEmailSignup(email);
- this.renderEmailSignupState();
- });
- }
}
setupShareButtons() {
@@ -3895,137 +3706,6 @@ generateSpecialKeyHTML(keyItem) {
});
}
- /**************************
- Email system
- ***************************/
-
- // New method for email validation
- validateEmail(email) {
- const regex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
- return regex.test(email);
- }
-
- async handleEmailSignup(email) {
- // Update state to loading immediately
- this.updateGameState({
- emailSignup: {
- ...this.state.emailSignup,
- status: 'loading',
- errorMessage: ''
- }
- });
-
- // Re-render immediately to show loading state
- this.renderEmailSignupState();
-
- // Validate email format
- if (!this.validateEmail(email)) {
- this.updateGameState({
- emailSignup: {
- ...this.state.emailSignup,
- status: 'error',
- errorMessage: 'Please enter a valid email address'
- }
- });
- this.renderEmailSignupState();
- return;
- }
-
- try {
- const response = await this.makeSignedRequest('/', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify({ email })
- });
-
- const data = await response.json();
-
- if (!response.ok) {
- if (response.status === 409) {
- throw new Error('This email is already registered!');
- }
- throw new Error(data.message || 'Failed to sign up');
- }
-
- // Update state to success
- this.updateGameState({
- emailSignup: {
- email: '',
- status: 'success',
- errorMessage: ''
- }
- });
-
- } catch (error) {
- this.updateGameState({
- emailSignup: {
- ...this.state.emailSignup,
- status: 'error',
- errorMessage: error.message || 'Failed to sign up. Please try again.'
- }
- });
-
- }
-
- // Re-render to reflect final state
- this.renderEmailSignupState();
- }
-
- renderEmailSignupState() {
- // Defensive check to ensure emailSignup is initialized
- if (!this.state.emailSignup) {
- console.warn('emailSignup is undefined, initializing to default.');
- this.updateGameState({
- emailSignup: {
- email: '',
- status: 'idle',
- errorMessage: ''
- }
- });
- return; // Exit early to allow state to update
- }
-
- const form = this.root.querySelector('.email-signup-form');
- const message = this.root.querySelector('.email-signup-message');
- const input = this.root.querySelector('#email');
- const submitButton = form?.querySelector('button[type="submit"]');
-
- if (!form || !message || !input || !submitButton) return;
-
- // Update input and button state
- input.disabled = this.state.emailSignup.status === 'loading' ||
- this.state.emailSignup.status === 'success';
- submitButton.disabled = input.disabled;
-
- // Update button text
- submitButton.textContent = this.state.emailSignup.status === 'loading'
- ? 'Signing up...'
- : 'Sign up';
-
- // Clear input on success
- if (this.state.emailSignup.status === 'success') {
- input.value = '';
- }
-
- // Update message
- if (this.state.emailSignup.status === 'success') {
- message.innerHTML = `
- <div class="success">
- Thanks for signing up! The mayor will let you know when new puzzles are available.
- </div>
- `;
- } else if (this.state.emailSignup.status === 'error') {
- message.innerHTML = `
- <div class="error">
- ${this.state.emailSignup.errorMessage}
- </div>
- `;
- } else {
- message.innerHTML = '';
- }
- }
/**************************
Share system
diff --git a/static/bs/tutorial/tutorial.css b/static/bs/tutorial/tutorial.css
index f0e9d9a..4f2aff0 100644
--- a/static/bs/tutorial/tutorial.css
+++ b/static/bs/tutorial/tutorial.css
@@ -305,75 +305,6 @@
color: #1a202c;
}
- /* ===================
- Email Form Styles
- =================== */
-
- .email-signup-container {
- margin: 1rem 0.5rem 0.5rem 0.5rem;
- }
-
- .email-signup-form label {
- display: block;
- margin-bottom: 0.75rem;
- font-weight: 500;
- text-align: center;
- font-family: var(--mono-font);
- font-size: 1.1rem;
- }
-
- .email-signup-form label span
- {
- background-color: rgba(255, 255, 0, 0.2); padding: 0.2rem 0.4rem;
- }
-
- .email-input-container {
- display: flex;
- gap: 0.5rem;
- }
-
- .email-signup-form input {
- flex: 1;
- padding: 0.5rem;
- border: 1px solid #ccc;
- border-radius: 0.375rem;
- font-size: 16px;
- gap: 0.5rem
- }
-
- .email-signup-form button {
- padding: 0.5rem 1rem;
- background-color: #2563eb;
- color: white;
- border: none;
- border-radius: 0.375rem;
- cursor: pointer;
- font-weight: 500;
- font-size: 16px;
- white-space: nowrap;
- }
- .email-signup-message {
- border-radius: 0.375rem;
- margin-top: 0.75rem;
- text-align: center;
- font-family: var(--mono-font);
- }
-
- .email-signup-message .success {
- padding: 1rem;
- background-color: #ecfdf5;
- border: 1px solid #6ee7b7;
- border-radius: 0.375rem;
- color: #065f46;
- }
-
- .email-signup-message .error {
- padding: 1rem;
- background-color: #fef2f2;
- border: 1px solid #fca5a5;
- border-radius: 0.375rem;
- color: #991b1b;
- }
/* ===================
Stats & Completion
@@ -1011,4 +942,4 @@
color: white !important;
font-size: 1rem !important;
font-weight: 500 !important;
- } \ No newline at end of file
+ }