Skip to content

Commit

Permalink
Update index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
p00pcvm authored Jan 5, 2025
1 parent 47be7e9 commit 6134087
Showing 1 changed file with 27 additions and 21 deletions.
48 changes: 27 additions & 21 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ <h1>Connect Your TON Wallet</h1>
<div class="loading" id="loading" style="display: none;">Connecting...</div>
</div>

<script src="https://unpkg.com/@tonconnect/ui@^0.3.0/dist/tonconnect-ui.min.js"></script>
<script src="https://unpkg.com/@tonconnect/ui@^0.3.0/dist/tonconnect-ui.min.js" onload="initTonConnect()" onerror="handleScriptError()"></script>
<script>
function handlePlayOptionChange() {
const selectedValue = document.getElementById('play-dropdown').value;
Expand All @@ -123,28 +123,34 @@ <h1>Connect Your TON Wallet</h1>
}
}

const manifestUrl = 'https://p00pcvm.github.io/cfol/tonconnect-manifest.json'; // Replace with your manifest URL
const tonConnect = new TonConnectUI({
manifestUrl: manifestUrl,
buttonRootId: 'connectButton',
});
function handleScriptError() {
document.getElementById('status').innerText = 'Failed to load TON Connect script. Please try again later.';
}

tonConnect.onStatusChange((status) => {
document.getElementById('loading').style.display = 'none';
if (status.connected) {
document.getElementById('status').innerText = `Connected to ${status.account.address}`;
} else if (status.notFound) {
document.getElementById('status').innerText = 'TON provider not found. Please install a TON wallet extension.';
} else if (status.error) {
document.getElementById('status').innerText = `Error connecting wallet: ${status.error.message}. Please ensure your TON wallet extension is up to date and properly configured.`;
}
});
function initTonConnect() {
const manifestUrl = 'https://p00pcvm.github.io/cfol/tonconnect-manifest.json'; // Replace with your manifest URL
const tonConnect = new TonConnectUI({
manifestUrl: manifestUrl,
buttonRootId: 'connectButton',
});

document.getElementById('connectButton').addEventListener('click', () => {
document.getElementById('status').innerText = '';
document.getElementById('loading').style.display = 'block';
tonConnect.connect();
});
tonConnect.onStatusChange((status) => {
document.getElementById('loading').style.display = 'none';
if (status.connected) {
document.getElementById('status').innerText = `Connected to ${status.account.address}`;
} else if (status.notFound) {
document.getElementById('status').innerText = 'TON provider not found. Please install a TON wallet extension.';
} else if (status.error) {
document.getElementById('status').innerText = `Error connecting wallet: ${status.error.message}. Please ensure your TON wallet extension is up to date and properly configured.`;
}
});

document.getElementById('connectButton').addEventListener('click', () => {
document.getElementById('status').innerText = '';
document.getElementById('loading').style.display = 'block';
tonConnect.connect();
});
}
</script>
</body>
</html>

0 comments on commit 6134087

Please sign in to comment.