Changed around line 1
+ document.addEventListener('DOMContentLoaded', () => {
+ const displayText = document.getElementById('displayText');
+ const textInput = document.getElementById('textInput');
+ const updateButton = document.getElementById('updateText');
+
+ class SplitFlapDisplay {
+ constructor(element) {
+ this.element = element;
+ this.chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ ';
+ this.currentText = '';
+ }
+
+ async animate(newText) {
+ const normalized = newText.toUpperCase();
+ const steps = 3;
+
+ for (let i = 0; i < steps; i++) {
+ let randomText = '';
+ const length = Math.max(this.currentText.length, normalized.length);
+
+ for (let j = 0; j < length; j++) {
+ randomText += this.chars[Math.floor(Math.random() * this.chars.length)];
+ }
+
+ this.element.textContent = randomText;
+ await new Promise(resolve => setTimeout(resolve, 50));
+ }
+
+ this.element.textContent = normalized;
+ this.currentText = normalized;
+ }
+ }
+
+ const display = new SplitFlapDisplay(displayText);
+
+ // Initial text
+ display.animate('SPLIT FLAP');
+
+ updateButton.addEventListener('click', () => {
+ const newText = textInput.value.trim();
+ if (newText) {
+ display.animate(newText);
+ }
+ });
+
+ textInput.addEventListener('keypress', (e) => {
+ if (e.key === 'Enter') {
+ const newText = textInput.value.trim();
+ if (newText) {
+ display.animate(newText);
+ }
+ }
+ });
+ });