Skip to content
TheChatArchiveThe Chat Archive
Metallama-3.3-70b-instruct· MetaHugging Face LMArena Human Preference 140K

Design and develop a dynamic split-flap clock using JavaScript and CSS that mimics the…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with gpt-4.1-mini-2025-04-14’s answer.
  1. User

    Design and develop a dynamic split-flap clock using JavaScript and CSS that mimics the vintage airport departure board or metro arrival display aesthetic. The clock should feature a real-time digital face composed of individual flapping segments, each split into top, middle, and bottom parts that physically flip between numbers. Use CSS keyframe animations for smooth, staggered transitions when the time updates, incorporating a 3D rotating effect and subtle shadowing to enhance the tactile, mechanical feel. Structure the clock with modular HTML elements (e.g., containers for each digit and flap component) and employ JavaScript to parse the current time, trigger transitions, and update the displayed numbers every second. Add a retro-inspired color scheme (e.g., dark metal frames with bright LED-like numerals) and ensure responsiveness so the clock scales seamlessly across devices. Include fallback states for smooth transitions between digits like 2→3 or 9→0, and add a subtle sound effect on each flip for an immersive experience.

  2. Meta Assistant

    Dynamic Split-Flap Clock

    Overview

    This project creates a dynamic split-flap clock using JavaScript and CSS, mimicking the vintage airport departure board or metro arrival display aesthetic. The clock features a real-time digital face composed of individual flapping segments, each split into top, middle, and bottom parts that physically flip between numbers.

    HTML Structure

    <!-- index.html -->
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Dynamic Split-Flap Clock</title>
        <link rel="stylesheet" href="styles.css">
    </head>
    <body>
        <div class="clock">
            <div class="digit">
                <div class="flap top"></div>
                <div class="flap middle"></div>
                <div class="flap bottom"></div>
            </div>
            <div class="digit">
                <div class="flap top"></div>
                <div class="flap middle"></div>
                <div class="flap bottom"></div>
            </div>
            <div class="digit">
                <div class="flap top"></div>
                <div class="flap middle"></div>
                <div class="flap bottom"></div>
            </div>
            <div class="digit">
                <div class="flap top"></div>
                <div class="flap middle"></div>
                <div class="flap bottom"></div>
            </div>
            <div class="digit">
                <div class="flap top"></div>
                <div class="flap middle"></div>
                <div class="flap bottom"></div>
            </div>
            <div class="digit">
                <div class="flap top"></div>
                <div class="flap middle"></div>
                <div class="flap bottom"></div>
            </div>
        </div>
        <audio id="flip-sound" src="flip.mp3" preload="auto"></audio>
        <script src="script.js"></script>
    </body>
    </html>
    

    CSS Styles

    /* styles.css */
    body {
        background-color: #333;
        font-family: monospace;
    }
    
    .clock {
        display: flex;
        justify-content: center;
        align-items: center;
        height: 100vh;
        width: 100vw;
    }
    
    .digit {
        position: relative;
        width: 50px;
        height: 80px;
        margin: 10px;
        perspective: 1000px;
    }
    
    .flap {
        position: absolute;
        width: 100%;
        height: 33.33%;
        background-color: #444;
        border: 1px solid #666;
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 36px;
        color: #0f0;
        text-shadow: 0 0 10px #0f0;
    }
    
    .top {
        top: 0;
        transform-origin: bottom center;
    }
    
    .middle {
        top: 33.33%;
        transform-origin: center center;
    }
    
    .bottom {
        top: 66.67%;
        transform-origin: top center;
    }
    
    .flip {
        animation: flip 0.5s;
    }
    
    @keyframes flip {
        0% {
            transform: rotateX(0deg);
        }
        50% {
            transform: rotateX(90deg);
        }
        100% {
            transform: rotateX(0deg);
        }
    }
    
    .flip-top {
        animation: flip-top 0.5s;
    }
    
    @keyframes flip-top {
        0% {
            transform: rotateX(0deg);
        }
        50% {
            transform: rotateX(-90deg);
        }
        100% {
            transform: rotateX(0deg);
        }
    }
    
    .flip-bottom {
        animation: flip-bottom 0.5s;
    }
    
    @keyframes flip-bottom {
        0% {
            transform: rotateX(0deg);
        }
        50% {
            transform: rotateX(90deg);
        }
        100% {
            transform: rotateX(0deg);
        }
    }
    

    JavaScript Code

    // script.js
    const clock = document.querySelector('.clock');
    const digits = document.querySelectorAll('.digit');
    const flipSound = document.getElementById('flip-sound');
    
    let currentTime = new Date();
    let hours = currentTime.getHours();
    let minutes = currentTime.getMinutes();
    let seconds = currentTime.getSeconds();
    
    function updateClock() {
        currentTime = new Date();
        hours = currentTime.getHours();
        minutes = currentTime.getMinutes();
        seconds = currentTime.getSeconds();
    
        const hourTens = Math.floor(hours / 10);
        const hourOnes = hours % 10;
        const minuteTens = Math.floor(minutes / 10);
        const minuteOnes = minutes % 10;
        const secondTens = Math.floor(seconds / 10);
        const secondOnes = seconds % 10;
    
        const digitsArray = [
            hourTens,
            hourOnes,
            minuteTens,
            minuteOnes,
            secondTens,
            secondOnes,
        ];
    
        digits.forEach((digit, index) => {
            const currentDigit = digitsArray[index];
            const flaps = digit.querySelectorAll('.flap');
    
            flaps.forEach((flap, flapIndex) => {
                const flapValue = currentDigit.toString()[flapIndex];
                if (flapValue === undefined) {
                    flap.textContent = '0';
                } else {
                    flap.textContent = flapValue;
                }
    
                if (flapIndex === 0) {
                    flap.classList.add('top');
                    flap.classList.remove('middle', 'bottom');
                } else if (flapIndex === 1) {
                    flap.classList.add('middle');
                    flap.classList.remove('top', 'bottom');
                } else {
                    flap.classList.add('bottom');
                    flap.classList.remove('top', 'middle');
                }
    
                if (index % 2 === 0) {
                    flap.classList.add('flip-top');
                } else {
                    flap.classList.add('flip-bottom');
                }
    
                flap.addEventListener('animationend', () => {
                    flap.classList.remove('flip-top', 'flip-bottom');
                });
            });
    
            flipSound.play();
        });
    }
    
    setInterval(updateClock, 1000);
    updateClock();
    

    Explanation

    1. The HTML structure consists of a container element with six child elements, each representing a digit in the clock.
    2. The CSS styles define the layout and appearance of the clock, including the flapping effect and the retro-inspired color scheme.
    3. The JavaScript code updates the clock every second, parsing the current time and updating the displayed numbers.
    4. The updateClock function is called every second using setInterval.
    5. The function updates the current time and extracts the hour, minute, and second values.
    6. It then updates the displayed numbers by iterating through the digit elements and their child flap elements.
    7. Each flap element is updated with the corresponding digit value and animated using the flip class.
    8. The flipSound audio element is played on each update to create a subtle sound effect.

    Example Use Cases

    • Use this clock as a decorative element on a website or application.
    • Integrate this clock with other time-related features, such as scheduling or reminders.
    • Customize the clock's appearance and behavior to fit specific design or branding requirements.

    Advice

    • To ensure smooth transitions between digits, use the animationend event to remove the flip class after the animation has completed.
    • To add a subtle sound effect on each flip, use the play method on an audio element.
    • To make the clock responsive, use relative units (e.g., %, vw, vh) for sizing and positioning elements.
    • To improve accessibility, consider adding ARIA attributes to the clock elements to provide screen reader support.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.