feat: lint, logo, test, anchor links
This commit is contained in:
14 files changed
+5519
-3068
No files matched your search
+32
-30
@@ -1,65 +1,67 @@
|
||||
// Function to extract array from span content
|
||||
const getItemsFromSpan = (spanId) => {
|
||||
const span = document.getElementById(spanId);
|
||||
const span = document.getElementById(spanId)
|
||||
if (span) {
|
||||
return span.textContent.split(',').map(item => item.trim());
|
||||
return span.textContent.split(',').map((item) => item.trim())
|
||||
}
|
||||
return [];
|
||||
};
|
||||
return []
|
||||
}
|
||||
|
||||
// Load actions and objects from spans
|
||||
let actions = [];
|
||||
let objects = [];
|
||||
let objectTools = [];
|
||||
let actions = []
|
||||
let objects = []
|
||||
let objectTools = []
|
||||
|
||||
// Load after DOM is ready
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
actions = getItemsFromSpan('actions');
|
||||
objects = getItemsFromSpan('objects');
|
||||
objectTools = getItemsFromSpan('object-tools');
|
||||
});
|
||||
actions = getItemsFromSpan('actions')
|
||||
objects = getItemsFromSpan('objects')
|
||||
objectTools = getItemsFromSpan('object-tools')
|
||||
})
|
||||
|
||||
// Function to get a random item from an array
|
||||
const getRandomItem = (arr) => arr[Math.floor(Math.random() * arr.length)];
|
||||
const getRandomItem = (arr) => arr[Math.floor(Math.random() * arr.length)]
|
||||
|
||||
// Function to generate random function names
|
||||
const generateFunctionName = () => {
|
||||
const action = getRandomItem(actions);
|
||||
const firstObject = getRandomItem([...objects, ...objectTools]);
|
||||
const action = getRandomItem(actions)
|
||||
const firstObject = getRandomItem([...objects, ...objectTools])
|
||||
|
||||
// Randomly decide if a compound object name should be created
|
||||
const compound = Math.random() > 0.7;
|
||||
const compound = Math.random() > 0.7
|
||||
if (compound) {
|
||||
// Only use regular objects as the second object
|
||||
const secondObject = getRandomItem(objects);
|
||||
return `${action}-${firstObject}-${secondObject}`;
|
||||
const secondObject = getRandomItem(objects)
|
||||
return `${action}-${firstObject}-${secondObject}`
|
||||
}
|
||||
|
||||
return `${action}-${firstObject}`;
|
||||
};
|
||||
return `${action}-${firstObject}`
|
||||
}
|
||||
|
||||
// Generate a list of random function names
|
||||
const generateFunctionNames = (count = 10) => {
|
||||
const names = [];
|
||||
const names = []
|
||||
for (let i = 0; i < count; i++) {
|
||||
names.push(generateFunctionName());
|
||||
names.push(generateFunctionName())
|
||||
}
|
||||
return names;
|
||||
};
|
||||
return names
|
||||
}
|
||||
|
||||
// Display the function names on the page
|
||||
const displayFunctionNames = () => {
|
||||
const container = document.getElementById('function-names');
|
||||
container.innerHTML = generateFunctionNames().map(name => `<li>${name}</li>`).join('');
|
||||
};
|
||||
const container = document.getElementById('function-names')
|
||||
container.innerHTML = generateFunctionNames()
|
||||
.map((name) => `<li>${name}</li>`)
|
||||
.join('')
|
||||
}
|
||||
|
||||
// Run on page load
|
||||
document.addEventListener('DOMContentLoaded', displayFunctionNames);
|
||||
document.addEventListener('DOMContentLoaded', displayFunctionNames)
|
||||
|
||||
// Add event listener to the button
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const button = document.getElementById('generate-function-names');
|
||||
const button = document.getElementById('generate-function-names')
|
||||
if (button) {
|
||||
button.addEventListener('click', displayFunctionNames);
|
||||
button.addEventListener('click', displayFunctionNames)
|
||||
}
|
||||
});
|
||||
})
|
||||
Reference in new issue
Block a user