ATJRMN/powershell-font-wizard
0
1document.addEventListener('DOMContentLoaded', function() {2 // Copy button functionality3 const copyBtn = document.getElementById('copy-btn');4 if (copyBtn) {5 copyBtn.addEventListener('click', function() {6 const codeBlock = document.querySelector('pre code');7 navigator.clipboard.writeText(codeBlock.textContent).then(() => {8 const icon = copyBtn.querySelector('i');9 icon.setAttribute('data-feather', 'check');10 feather.replace();11 12 setTimeout(() => {13 icon.setAttribute('data-feather', 'copy');14 feather.replace();15 }, 2000);16 });17 });18 }19 20 // Run button functionality (simulated)21 const runBtn = document.getElementById('run-btn');22 const outputDiv = document.getElementById('output');23 24 if (runBtn && outputDiv) {25 runBtn.addEventListener('click', function() {26 outputDiv.innerHTML = `27 <p class="text-green-400">PS> Executing script...</p>28 <p class="text-gray-300">Handles NPM(K) PM(K) WS(K) CPU(s) Id SI ProcessName</p>29 <p class="text-gray-300">------- ------ ----- ----- ------ -- -- -----------</p>30 <p class="text-gray-300"> 387 25 10728 31088 12.23 4584 1 chrome</p>31 <p class="text-gray-300"> 231 11 2992 10120 5.67 7844 1 Code</p>32 <p class="text-gray-300"> 125 8 2704 8824 1.23 8904 1 powershell</p>33 <p class="text-green-400">PS> Script completed successfully</p>34 `;35 36 // Animate the run button37 runBtn.disabled = true;38 runBtn.innerHTML = '<i data-feather="loader" class="animate-spin"></i><span>Running...</span>';39 feather.replace();40 41 setTimeout(() => {42 runBtn.disabled = false;43 runBtn.innerHTML = '<i data-feather="play"></i><span>Execute Script</span>';44 feather.replace();45 }, 1500);46 });47 }48 49 // Command buttons functionality50 const commandButtons = document.querySelectorAll('.command-btn');51 const codeBlock = document.querySelector('pre code');52 53 commandButtons.forEach(button => {54 button.addEventListener('click', function() {55 const command = this.getAttribute('data-command');56 const currentCode = codeBlock.textContent;57 58 // Append the command to the code block59 codeBlock.textContent = currentCode + '\n' + command;60 61 // Highlight the new code62 hljs.highlightElement(codeBlock);63 64 // Show a quick notification65 const notification = document.createElement('div');66 notification.className = 'fixed bottom-4 right-4 bg-green-600 text-white px-4 py-2 rounded-lg shadow-lg';67 notification.textContent = `Added: ${command}`;68 document.body.appendChild(notification);69 70 setTimeout(() => {71 notification.classList.add('opacity-0', 'transition-opacity', 'duration-300');72 setTimeout(() => notification.remove(), 300);73 }, 1500);74 });75 });76});