Spaces:
Running
Running
Download script.js from Maximus19lol/contractkick: direct link, hf CLI and curl.
- Browser
- Download file 4.26 kB
-
https://huggingface.co/spaces/Maximus19lol/contractkick/resolve/main/script.js
- Command line
-
hf download hf://spaces/Maximus19lol/contractkick/script.js
-
curl -L -o script.js https://huggingface.co/spaces/Maximus19lol/contractkick/resolve/main/script.js
4.26 kB
| // Main JavaScript for Aziz Contracts | |
| // Initialize application | |
| document.addEventListener('DOMContentLoaded', function() { | |
| console.log('Aziz Contracts initialized'); | |
| // Check if Web3 is available | |
| if (typeof window.ethereum !== 'undefined') { | |
| console.log('MetaMask is installed!'); | |
| initializeWeb3(); | |
| } else { | |
| console.log('Please install MetaMask!'); | |
| showMetaMaskAlert(); | |
| } | |
| // Initialize any interactive elements | |
| initializeInteractiveElements(); | |
| }); | |
| // Web3 initialization | |
| async function initializeWeb3() { | |
| try { | |
| // Request account access | |
| const accounts = await window.ethereum.request({ method: 'eth_requestAccounts' }); | |
| const account = accounts[0]; | |
| console.log('Connected account:', account); | |
| // Update UI with connected account | |
| updateWalletStatus(account); | |
| // Listen for account changes | |
| window.ethereum.on('accountsChanged', function (accounts) { | |
| if (accounts.length === 0) { | |
| console.log('Please connect to MetaMask.'); | |
| updateWalletStatus(null); | |
| } else { | |
| console.log('Account changed to:', accounts[0]); | |
| updateWalletStatus(accounts[0]); | |
| } | |
| }); | |
| } catch (error) { | |
| console.error('User denied account access:', error); | |
| } | |
| } | |
| // Update wallet connection status in UI | |
| function updateWalletStatus(account) { | |
| const walletElements = document.querySelectorAll('.wallet-status'); | |
| walletElements.forEach(element => { | |
| if (account) { | |
| element.innerHTML = ` | |
| <div class="flex items-center space-x-2"> | |
| <div class="w-2 h-2 bg-green-500 rounded-full"></div> | |
| <span class="text-sm font-medium">Connected: ${account.substring(0, 6)}...${account.substring(38)}</span> | |
| </div> | |
| `; | |
| } else { | |
| element.innerHTML = ` | |
| <div class="flex items-center space-x-2"> | |
| <div class="w-2 h-2 bg-red-500 rounded-full"></div> | |
| <span class="text-sm font-medium">Not Connected</span> | |
| </div> | |
| `; | |
| } | |
| }); | |
| } | |
| // Show MetaMask installation alert | |
| function showMetaMaskAlert() { | |
| // This would typically show a modal or notification | |
| console.log('Please install MetaMask to use Aziz Contracts'); | |
| } | |
| // Initialize interactive elements | |
| function initializeInteractiveElements() { | |
| // Add click handlers for demo buttons | |
| const demoButtons = document.querySelectorAll('button'); | |
| demoButtons.forEach(button => { | |
| button.addEventListener('click', function(e) { | |
| if (!this.textContent.includes('Connect')) { | |
| e.preventDefault(); | |
| showFeatureComingSoon(); | |
| } | |
| }); | |
| }); | |
| } | |
| // Show feature coming soon message | |
| function showFeatureComingSoon() { | |
| // Create a temporary notification | |
| const notification = document.createElement('div'); | |
| notification.className = 'fixed top-4 right-4 bg-blue-500 text-white px-6 py-3 rounded-lg shadow-lg z-50'; | |
| notification.textContent = 'Feature coming soon! 🚀'; | |
| document.body.appendChild(notification); | |
| // Remove after 3 seconds | |
| setTimeout(() => { | |
| notification.remove(); | |
| }, 3000); | |
| } | |
| // Contract interaction functions (placeholder for actual implementation) | |
| class ContractManager { | |
| constructor() { | |
| this.contractAddress = null; | |
| this.provider = null; | |
| this.signer = null; | |
| this.contract = null; | |
| } | |
| async connectContract(contractAddress, abi) { | |
| // This would be implemented with ethers.js | |
| console.log('Connecting to contract at:', contractAddress); | |
| } | |
| async proposeContract(clubAddress, playerAddress, salary, startDate, endDate) { | |
| // Implementation for proposing a contract | |
| console.log('Proposing contract...'); | |
| } | |
| async signContract(contractId, isClub) { | |
| // Implementation for signing a contract | |
| console.log('Signing contract...'); | |
| } | |
| } | |
| // Initialize contract manager | |
| window.contractManager = new ContractManager(); |