← Back to gallery
Looking Glass poster

Project walkthrough

Looking Glass

Explore the concept, hints, and starter code for this Nic Cage inspired build.

Title: Hidden Realities with Looking Glass and Page Visibility API

Description:

Inspired by Nicolas Cage’s role in Looking Glass, this project uses the Page Visibility API to create a web application that captures the eerie and suspenseful atmosphere of the film. The application detects when the user switches to another tab or window and triggers a hidden reality effect, creating an immersive and dynamic experience. This project demonstrates the practical use of the Page Visibility API to enhance user engagement and interaction.

Features:

  • Visibility Detection: Use the Page Visibility API to detect when the user switches tabs or windows.
  • Hidden Reality Effects: Trigger visual effects when the page visibility changes, reflecting the hidden truths and suspense of Looking Glass.
  • Thematic Design: Reflect the eerie and suspenseful atmosphere of Looking Glass through the application’s design and interactions.

Starting Code:

Beginner Hints:

  • Create a single index.html file.
  • Copy the full HTML code block into that file.
  • Open index.html in your browser. If something doesn’t work, try a local server like python -m http.server.
  • Open DevTools Console to spot errors and typos quickly.
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Hidden Realities with Looking Glass and Page Visibility API</title>
<style>
    body {
        font-family: Arial, sans-serif;
        background-color: #1c1c1c;
        color: #f0f0f0;
        text-align: center;
        padding: 50px;
    }
    .container {
        max-width: 800px;
        margin: 0 auto;
        padding: 20px;
        background-color: #2e2e2e;
        border: 1px solid #444;
        border-radius: 10px;
        box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    }
    h1 {
        margin-bottom: 20px;
        color: #ff6347;
    }
    .hidden-message {
        display: none;
        margin-top: 20px;
        color: #ff6347;
        font-size: 20px;
    }
</style>
</head>
<body>
    <div class="container">
        <h1>Hidden Realities</h1>
        <p>Explore hidden realities inspired by Looking Glass.</p>

        <div class="normal-message">
            This is the normal state. Switch to another tab and come back to reveal the hidden message.
        </div>
        <div class="hidden-message" id="hiddenMessage">
            You've uncovered a hidden reality!
        </div>
    </div>
<script>
    document.addEventListener('visibilitychange', () => {
        const hiddenMessage = document.getElementById('hiddenMessage');
        if (document.hidden) {
            hiddenMessage.style.display = 'none';
        } else {
            hiddenMessage.style.display = 'block';
        }
    });
</script>
</body>
</html>

References:

Project Overview:

This project captures the eerie and suspenseful atmosphere of Looking Glass using the Page Visibility API to create an immersive and dynamic experience. Users can discover hidden realities by switching tabs or windows, reflecting the film’s themes of hidden truths and suspense. The application demonstrates the practical use of the Page Visibility API for enhancing user engagement and interaction. Embrace the mystery and intensity of Nicolas Cage’s character to master the use of the Page Visibility API in web development. Praise Cage!