jMÂ-<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Welcome to BSVGolf.com</title>
    <style>
        body, html {
            margin: 0;
            padding: 0;
            font-family: Arial, sans-serif;
            height: 100%;
            overflow: hidden;
        }
        #header {
            background-color: #4CAF50;
            color: white;
            padding: 10px;
            transition: transform 0.3s ease-in-out;
        }
        #header.retracted {
            transform: translateY(-100%);
        }
        #content {
            display: flex;
            height: calc(100% - 50px);
        }
        #mainContent {
            flex-grow: 1;
            padding: 20px;
            overflow-y: auto;
        }
        #rightPanel {
            width: 250px;
            background-color: #f1f1f1;
            padding: 20px;
            transition: transform 0.3s ease-in-out;
        }
        #rightPanel.retracted {
            transform: translateX(100%);
        }
        .menu-toggle {
            cursor: pointer;
            font-size: 24px;
            position: fixed;
            top: 10px;
            right: 10px;
        }
        footer {
            background-color: #333;
            color: white;
            padding: 10px 0;
            position: fixed;
            width: 100%;
            bottom: 0;
        }
        footer p {
            margin: 0;
            font-size: 14px;
        }
        a {
            display: inline-block;
            margin-top: 20px;
            padding: 10px 20px;
            background-color: #007bff;
            color: white;
            text-decoration: none;
            border-radius: 5px;
        }
        a:hover {
            background-color: #0056b3;
        }
    </style>
</head>
<body>
    <div id="header">
        <h1>Welcome to BsvGolf.com</h1>
        
        <!-- Add link for Solo Play -->
        <a href="#" id="soloplayLink">Solo Play</a>
        <!-- Add link for Match Play -->
        <a href="#" id="matchplayLink">Match Play</a>
        
        <!-- Add link for Tournament Play -->
        <a href="#" id="tournamentLink">Tournament</a>
    </div>
    <div id="content">
        <div id="mainContent">
            <h2>Welcome to BSV Golf</h2>
<p><em>Please note: This site is currently under development.</em></p>
<p>Our goal is to provide practical tools for golfers to enhance their day-to-day play. BSV Golf is independent of any official golf body, and the website operates entirely as a standalone service. Since we do not apply slope calculations, players must ensure they input the correct course handicap in the handicap field for accurate Stableford scoring.</p>
<h3>Available Features</h3>
<ul>
  <li><strong>Solo Play</strong>: Fully functional. Use this tool to quickly calculate your Stableford scores and gather performance data for later analysis with Golf Caddie.</li>
</ul>
<h3>Core Functionality</h3>
<p>The <strong>Golf Notepad</strong> plays a central role in our design. You can save scores and notes directly to the notepad. Additionally, our <strong>Golf Map</strong> feature lets you record individual stroke performance, linking it to your scores. This data, when analyzed by Golf Caddie, aims to recommend the optimal club and stroke for future scenarios.</p>
<h3>In Development</h3>
<ul>
  <li><strong>Tournament Play</strong></li>
  <li><strong>Match Play</strong></li>
  <li><strong>Golf Caddie</strong></li>
</ul>
<p>We hope you find the apps helpful and look forward to your feedback as we continue to enhance the platform!</p>
        </div>
        <div id="rightPanel">
            
            <button class="menu-toggle" onclick="toggleRightPanel()">☰</button>
    
        <a href="#" id="bsvmapLink">Golf Map</a>
        <a href="#" id="notepadLink">Golf Notes</a>
        <a href="#" id="golfbuddyLink">Golf Caddie</a>
            <a href="#" id="teesetLink">Set Tees</a>
        <a href="#" id="creatematchLink">Create Match</a>
        <a href="#" id="createtournament">Create Tournament</a>
        <a href="#" id="entertournament">Enter Tournament</a>
        </div>
    </div>
    <footer>
        <p>© 2024 BSVGolf.com. All rights reserved.</p>
    </footer>
    <script>
        // Toggle right panel visibility
        function toggleRightPanel() {
            document.getElementById('rightPanel').classList.toggle('retracted');
        }
        // Toggle header visibility
        function toggleHeader() {
            document.getElementById('header').classList.toggle('retracted');
        }
        // Open TXID-based content in a new page (similar to how normal links behave)
        document.getElementById("bsvmapLink").onclick = function(event) {
            event.preventDefault();
            fetchAndDisplayHtml('/public/golfmap-app.json');
        };
        // Add functionality for Teeset
        document.getElementById("teesetLink").onclick = function(event) {
            event.preventDefault();
            fetchAndDisplayHtml('/public/teeset-app.json');
        };
        // Add functionality for Tournament
        document.getElementById("tournamentLink").onclick = function(event) {
            event.preventDefault();
            fetchAndDisplayHtml('/public/tournament-app.json');
        };
        // Add functionality for Solo Play
        document.getElementById("soloplayLink").onclick = function(event) {
            event.preventDefault();
            fetchAndDisplayHtml('/public/soloplay-app.json');
        };
        // Add functionality for Match Play
        document.getElementById("matchplayLink").onclick = function(event) {
            event.preventDefault();
            fetchAndDisplayHtml('/public/matchplay-app.json');
        };
        // Add functionality for Golf Notes
        document.getElementById("notepadLink").onclick = function(event) {
            event.preventDefault();
            fetchAndDisplayHtml('/public/notepad-app.json');
        };
        
        // Add functionality for Golf Buddy
        document.getElementById("golfbuddy").onclick = function(event) {
            event.preventDefault();
            fetchAndDisplayHtml('/public/golfbuddy-app.json');
        };
 
        // Add functionality for Create Match
        document.getElementById("creatematch").onclick = function(event) {
            event.preventDefault();
            fetchAndDisplayHtml('/public/creatematch-app.json');
        };
        // Add functionality for Create Tournament
        document.getElementById("createtournament").onclick = function(event) {
            event.preventDefault();
            fetchAndDisplayHtml('/public/createtournament-app.json');
        };
        // Add functionality for Enter Tournament
        document.getElementById("entertournament").onclick = function(event) {
            event.preventDefault();
            fetchAndDisplayHtml('/public/entertournament-app.json');
        };
        async function fetchAndDisplayHtml(jsonPath) {
            try {
                // Fetch the JSON file with the TXID
                const response = await fetch(jsonPath);
                if (!response.ok) throw new Error('Failed to load the JSON file from the server');
                const jsonData = await response.json();
                const txid = jsonData.txid;  // Get the TXID from the JSON file
                // Fetch the raw transaction hex data from the blockchain (WhatsOnChain API)
                const txDataResponse = await fetch(`https://api.whatsonchain.com/v1/bsv/main/tx/${txid}/hex`);
                if (!txDataResponse.ok) throw new Error('Failed to fetch TXID content from the blockchain');
                
                const txDataHex = await txDataResponse.text();  // This is the raw hex data
                // Log the raw hex data
                console.log('Raw TXID data (hex):', txDataHex);
                // Extract OP_RETURN data and log it
                const opReturnData = extractOpReturnData(txDataHex);
                if (!opReturnData) {
                    alert('OP_RETURN data not found');
                    return;
                }
                console.log('Extracted OP_RETURN data:', opReturnData);
                // Clean the extracted data and decode it into HTML
                const cleanedDataHex = removeAppendedData(opReturnData);
                const contentBytes = hexToBytes(cleanedDataHex);
                const htmlString = new TextDecoder().decode(contentBytes);
                // Open a new window to display the decoded HTML
                const newWindow = window.open();
                newWindow.document.open();
                newWindow.document.write(htmlString);
                newWindow.document.close();
                console.log(`Opened decoded content for TXID: ${txid} in a new page.`);
            } catch (error) {
                console.error('Error fetching and displaying the HTML content:', error);
                alert('Error fetching content. Check console for details.');
            }
        }
        // Function to extract OP_RETURN data from the raw hex data
        function extractOpReturnData(dataHex) {
            const marker = 'ffffffff';  // Special marker used in BSV transactions
            const markerIndex = dataHex.indexOf(marker);
            if (markerIndex === -1) return null;
            const opReturnOpcode = '6a';  // OP_RETURN opcode
            const opReturnIndex = dataHex.indexOf(opReturnOpcode, markerIndex + marker.length);
            if (opReturnIndex === -1) return null;
            let currentIndex = opReturnIndex + 2;  // Move past '6a'
            let lengthHex = dataHex.substring(currentIndex, currentIndex + 2);
            let dataLength = parseInt(lengthHex, 16) - 4;
            // Handle extended lengths
            if (lengthHex === '4c') {
                lengthHex = dataHex.substring(currentIndex + 2, currentIndex + 4);
                dataLength = parseInt(lengthHex, 16) - 4;
                currentIndex += 4;
            } else if (lengthHex === '4d') {
                lengthHex = dataHex.substring(currentIndex + 2, currentIndex + 6);
                dataLength = parseInt(lengthHex, 16) - 4;
                currentIndex += 6;
            } else if (lengthHex === '4e') {
                lengthHex = dataHex.substring(currentIndex + 2, currentIndex + 10);
                dataLength = parseInt(lengthHex, 16) - 4;
                currentIndex += 10;
            } else {
                currentIndex += 2;
            }
            const opReturnData = dataHex.substring(currentIndex, currentIndex + dataLength * 2);
            return opReturnData;
        }
        // Function to clean the extracted data
        function removeAppendedData(dataHex) {
            return dataHex.substring(0, dataHex.length - 38 * 2);  // Remove unnecessary appended data
        }
        // Function to convert hex string to bytes
        function hexToBytes(hex) {
            const bytes = [];
            for (let c = 0; c < hex.length; c += 2) {
                bytes.push(parseInt(hex.substr(c, 2), 16));
            }
            return new Uint8Array(bytes);
        }
    </script>
</body>
</html>
https://whatsonchain.com/tx/6c8d2a639cb059340e4bd47f6ba4e54af4ba318fa834e3fe3a8152c8fe4c6329