Spaces:
Running
Running
File size: 2,983 Bytes
2ad4002 c3c8feb 2ad4002 c3c8feb 2ad4002 c3c8feb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
// 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);
});
});
}
}); |