← Back to gallery
Astro Boy poster

Project walkthrough

Astro Boy

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

Project Title: “Astro Boy: Secure Data Storage with Storage Access API”

Description:

In this project, we integrate the futuristic and high-tech world of Astro Boy with the capabilities of the Storage Access API. Astro Boy tells the story of a young robot navigating a technologically advanced world. Similarly, this project will enable users to securely manage access to storage data, enhancing privacy and control over stored information.

Features:

  1. Secure Data Storage: Use the Storage Access API to manage access to storage data securely.
  2. User Interaction: Allow users to grant or deny access to storage, providing control over their data.
  3. Thematic Design: Implement a futuristic design reflecting the technological advancements in Astro Boy.

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.

Here’s a basic setup to get you started. This includes the initial HTML, CSS, and JavaScript to integrate the Storage Access API and create a secure data storage system.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Astro Boy: Secure Data Storage</title>
<style>
    body {
        font-family: Arial, sans-serif;
        background-color: #111;
        color: #fff;
        text-align: center;
        padding: 20px;
    }

    h1 {
        color: #ff4500;
    }

    button {
        background-color: #ff4500;
        color: white;
        border: none;
        padding: 10px 20px;
        font-size: 16px;
        cursor: pointer;
        margin: 5px;
    }

    #output {
        margin-top: 20px;
        font-size: 18px;
        white-space: pre-wrap;
        text-align: left;
    }
</style>
</head>
<body>
    <h1>Astro Boy: Secure Data Storage</h1>
    <p>Manage access to your data securely with the Storage Access API!</p>
    <button id="requestAccessBtn">Request Storage Access</button>
    <button id="checkAccessBtn">Check Storage Access</button>
    <div id="output"></div>
<script>
    document.getElementById('requestAccessBtn').addEventListener('click', async () => {
        if ('hasStorageAccess' in document && 'requestStorageAccess' in document) {
            try {
                const hasAccess = await document.hasStorageAccess();
                if (hasAccess) {
                    document.getElementById('output').innerText = 'You already have storage access.';
                } else {
                    await document.requestStorageAccess();
                    document.getElementById('output').innerText = 'Storage access granted!';
                }
            } catch (error) {
                document.getElementById('output').innerText = `Storage access request failed: ${error.message}`;
            }
        } else {
            document.getElementById('output').innerText = 'Storage Access API is not supported in this browser.';
        }
    });

    document.getElementById('checkAccessBtn').addEventListener('click', async () => {
        if ('hasStorageAccess' in document) {
            try {
                const hasAccess = await document.hasStorageAccess();
                document.getElementById('output').innerText = hasAccess ? 'You have storage access.' : 'You do not have storage access.';
            } catch (error) {
                document.getElementById('output').innerText = `Error checking storage access: ${error.message}`;
            }
        } else {
            document.getElementById('output').innerText = 'Storage Access API is not supported in this browser.';
        }
    });
</script>
</body>
</html>

References:

Praise Cage! Embark on this coding adventure and create a secure data storage system that leverages the Storage Access API, inspired by the futuristic world of Astro Boy.