Spaces:
Running
Running
| // Duck-themed spell checker for Ducky Script | |
| function duckySpellCheck(text) { | |
| const commonMisspellings = { | |
| 'delay': 'DELAY', | |
| 'string': 'STRING', | |
| 'enter': 'ENTER', | |
| 'windows': 'GUI', | |
| 'gui': 'GUI', | |
| 'menu': 'MENU', | |
| 'shift': 'SHIFT', | |
| 'alt': 'ALT', | |
| 'control': 'CTRL', | |
| 'ctrl': 'CTRL', | |
| 'arrowup': 'UPARROW', | |
| 'arrowdown': 'DOWNARROW', | |
| 'arrowleft': 'LEFTARROW', | |
| 'arrowright': 'RIGHTARROW', | |
| 'delete': 'DELETE', | |
| 'space': 'SPACE' | |
| }; | |
| let corrected = text; | |
| for (const [wrong, right] of Object.entries(commonMisspellings)) { | |
| const regex = new RegExp(`\\b${wrong}\\b`, 'gi'); | |
| corrected = corrected.replace(regex, right); | |
| } | |
| return corrected; | |
| } | |
| // Shared JavaScript across all pages | |
| document.addEventListener('DOMContentLoaded', () => { | |
| // Ducky Script spell check | |
| const duckyTextarea = document.querySelector('textarea'); | |
| if (duckyTextarea) { | |
| duckyTextarea.addEventListener('blur', (e) => { | |
| if (document.querySelector('select').value === 'Ducky Script') { | |
| e.target.value = duckySpellCheck(e.target.value); | |
| } | |
| }); | |
| } | |
| // Example functionality for the code generator | |
| const generateBtn = document.querySelector('.bg-yellow-400'); | |
| const outputCode = document.getElementById('output-code'); | |
| if (generateBtn && outputCode) { | |
| generateBtn.addEventListener('click', () => { | |
| const scriptTypes = [ | |
| `#!/bin/bash\necho "Quack! Your bash script is ready π¦"\n# This script was magically generated by Quacky Code Conjurer`, | |
| `# Python script\ndef quack():\n print("Quack! Hello from Python π¦")\n\nquack()`, | |
| `// JavaScript\nconsole.log("Quack! JavaScript magic happening π¦");\n// Try refreshing for a new ducky script!`, | |
| `REM Ducky Script\nDELAY 1000\nSTRING Quack! This is a rubber ducky script π¦\nENTER` | |
| ]; | |
| const randomScript = scriptTypes[Math.floor(Math.random() * scriptTypes.length)]; | |
| outputCode.textContent = randomScript; | |
| // Feather icons replacement for dynamically added elements | |
| feather.replace(); | |
| }); | |
| } | |
| // Copy button functionality | |
| const copyBtn = document.querySelector('.bg-blue-500'); | |
| if (copyBtn) { | |
| copyBtn.addEventListener('click', () => { | |
| const code = outputCode.textContent; | |
| navigator.clipboard.writeText(code).then(() => { | |
| const originalText = copyBtn.innerHTML; | |
| copyBtn.innerHTML = '<i data-feather="check" class="mr-2"></i> Copied!'; | |
| feather.replace(); | |
| setTimeout(() => { | |
| copyBtn.innerHTML = originalText; | |
| feather.replace(); | |
| }, 2000); | |
| }); | |
| }); | |
| } | |
| }); |