flask webui looking good
This commit is contained in:
@ -1,39 +1,42 @@
|
||||
|
||||
document.getElementById('connectWallet').addEventListener('click', async () => {
|
||||
try {
|
||||
const { solana } is window;
|
||||
if (solana && solana.isPhantom) {
|
||||
const response = await solana.connect({ onlyIfTrusted: true });
|
||||
console.log('Connected with Public Key:', response.publicKey.toString());
|
||||
} else {
|
||||
alert('Phantom wallet not found. Please install it.');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
alert('Connection to Phantom Wallet failed');
|
||||
}
|
||||
});
|
||||
|
||||
document.getElementById('swapToken').addEventListener('click', () => {
|
||||
const tokenName = document.getElementById('tokenName').value;
|
||||
const amount = document.getElementById('amount').value;
|
||||
fetch('/swap', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({token_name: tokenName, amount: amount})
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => alert(data.message));
|
||||
});
|
||||
|
||||
|
||||
// Add your custom JavaScript here
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const connectWalletButton = document.getElementById('connectWallet');
|
||||
const swapTokenButton = document.getElementById('swapToken');
|
||||
const generateApiKeyButton = document.getElementById('generate-api-key');
|
||||
const apiKeyDisplay = document.getElementById('api-key-display');
|
||||
|
||||
if (connectWalletButton) {
|
||||
connectWalletButton.addEventListener('click', async () => {
|
||||
try {
|
||||
const { solana } = window;
|
||||
if (solana && solana.isPhantom) {
|
||||
const response = await solana.connect({ onlyIfTrusted: true });
|
||||
console.log('Connected with Public Key:', response.publicKey.toString());
|
||||
} else {
|
||||
alert('Phantom wallet not found. Please install it.');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
alert('Connection to Phantom Wallet failed');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (swapTokenButton) {
|
||||
swapTokenButton.addEventListener('click', () => {
|
||||
const tokenName = document.getElementById('tokenName').value;
|
||||
const amount = document.getElementById('amount').value;
|
||||
fetch('/swap', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({token_name: tokenName, amount: amount})
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => alert(data.message));
|
||||
});
|
||||
}
|
||||
|
||||
if (generateApiKeyButton) {
|
||||
generateApiKeyButton.addEventListener('click', async () => {
|
||||
const response = await fetch('/generate_api_key', { method: 'POST' });
|
||||
|
Reference in New Issue
Block a user