<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Tracking Information</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
        }
        header, footer {
            text-align: center;
            padding: 10px;
            background-color: #f1f1f1;
        }
        .tracking-info {
            text-align: center;
            margin: 50px;
        }
        .tracking-info h1 {
            font-size: 2rem;
        }
        .tracking-info div {
            margin-top: 20px;
        }
        .error {
            color: red;
            font-size: 1.5rem;
            margin-top: 20px;
        }
        .updates {
            margin-top: 30px;
            font-size: 1rem;
        }
    </style>
</head>
<body>
    <header>
        <h1>Tracking Information</h1>
    </header>
    <div class="tracking-info" id="trackingInfo">
        <!-- Content dynamically generated -->
    </div>
    <footer id="footer"></footer>
    <script>
        document.addEventListener("DOMContentLoaded", function () {
            // Load footer content dynamically
            fetch('footer/index.html')
                .then(response => response.text())
                .then(data => {
                    document.getElementById('footer').innerHTML = data;
                });

            // Get tracking code from URL
            const params = new URLSearchParams(window.location.search);
            const code = params.get('code');

            const trackingInfoDiv = document.getElementById('trackingInfo');

            if (!code || code.length < 5) { // Invalid code condition
                trackingInfoDiv.innerHTML = `
                    <p class="error">无效的追踪码 / Invalid Shipping Code</p>
                `;
            } else if (code === "XJF939f") {
                // Specific information for tracking code XJF939f
                trackingInfoDiv.innerHTML = `
                    <h1>Package Status</h1>
                    <div>
                        <p>状态: 已发货 / Status: Pending</p>
                        <p>位置: 北京, 中国 / Location: Beijing, China</p>
                        <p>预计送达: 2024年12月10日 / Expected Delivery: Dec 28, 2024</p>
                        <div class="updates">
                            <h2>最新动态 / Recent Updates:</h2>
                            <ul>
                            <li>Dec 12, 2024: Due to Holiday demand, shipping for this package delayed.</li>
                                <li>Dec 12, 2024: Package processed at Beijing sorting center</li>
                                <li>Dec 8, 2024: Package dispatched from warehouse</li>
                                <li>Dec 7, 2024: Shipping label created</li>
                            </ul>
                        </div>
                    </div>
                `;
            } else {
                // Default invalid code message
                trackingInfoDiv.innerHTML = `
                    <p class="error">无效的追踪码 / Invalid Shipping Code</p>
                `;
            }
        });
    </script>
</body>
</html>
