<script>
let nouns = [];
let conjunctions = [];
let verbs = [];
function addWord(type) {
const input = document.getElementById(`${type}Input`);
if (input.value) {
if (type === 'noun') nouns.push(input.value);
else if (type === 'conj') conjunctions.push(input.value);
else verbs.push(input.value);
input.value = '';
displayWords();
}
}
function displayWords() {
document.getElementById('nounList').innerHTML = 'Nouns: ' + nouns.join(', ');
document.getElementById('conjList').innerHTML = 'Conjunctions: ' + conjunctions.join(', ');
document.getElementById('verbList').innerHTML = 'Verbs: ' + verbs.join(', ');
}
function getRandomElement(arr) {
return arr[Math.floor(Math.random() * arr.length)];
}
function outputWords() {
const randomNoun = getRandomElement(nouns);
const randomConj = getRandomElement(conjunctions);
const randomVerb = getRandomElement(verbs);
const newOutput = `${randomNoun} ${randomConj} ${randomVerb}`;
let currentOutput = document.getElementById('outputArea').textContent;
currentOutput += (currentOutput.length > 0 ? ' ' : '') + newOutput;
// 40æåããšã«æ¹è¡ãæ¿å
¥
let formattedOutput = '';
for (let i = 0; i < currentOutput.length; i += 40) {
formattedOutput += currentOutput.slice(i, i + 40) + '\n';
}
document.getElementById('outputArea').textContent = formattedOutput.trim();
}
function downloadAsText() {
const textToWrite = 'Nouns:\n' + nouns.join('\n') + '\n\nConjunctions:\n' + conjunctions.join('\n') + '\n\nVerbs:\n' + verbs.join('\n');
const textBlob = new Blob([textToWrite], { type: 'text/plain' });
const downloadLink = document.createElement('a');
downloadLink.download = 'WordList.txt';
downloadLink.href = window.URL.createObjectURL(textBlob);
downloadLink.style.display = 'none';
document.body.appendChild(downloadLink);
downloadLink.click();
document.body.removeChild(downloadLink);
}
function loadFile(event) {
const file = event.target.files[0];
if (file) {
const reader = new FileReader();
reader.onload = function(e) {
const fileContents = e.target.result;
parseFileContents(fileContents);
displayWords();
};
reader.readAsText(file);
}
}
function parseFileContents(contents) {
const lines = contents.split(/\r\n|\n|\r/);
let currentCategory = null;
lines.forEach(line => {
if (line.startsWith('Nouns:')) {
currentCategory = nouns;
} else if (line.startsWith('Conjunctions:')) {
currentCategory = conjunctions;
} else if (line.startsWith('Verbs:')) {
currentCategory = verbs;
} else if (line && currentCategory !== null) {
currentCategory.push(line);
}
});
}
function downloadOutputAsText() {
const textToWrite = document.getElementById('outputArea').textContent;
const textBlob = new Blob([textToWrite], { type: 'text/plain' });
const downloadLink = document.createElement('a');
downloadLink.download = 'Output.txt';
downloadLink.href = window.URL.createObjectURL(textBlob);
downloadLink.style.display = 'none';
document.body.appendChild(downloadLink);
downloadLink.click();
document.body.removeChild(downloadLink);
}
function loadOutputFromFile(event) {
const file = event.target.files[0];
if (file) {
const reader = new FileReader();
reader.onload = function(e) {
const fileContents = e.target.result;
document.getElementById('outputArea').textContent = fileContents;
};
reader.readAsText(file);
}
}
</script>
outputãåºåãããããããªæããªãã ãã©ãããŠã ãã?
ããããŸã㯠çªç¶ã« çŒãäžãã ããªã¯ çªç¶ã« ç ãã«ã€ãã ã¿ãã㯠çªç¶ã«
ç ãã«ã€ãã ã¿ãã㯠æã
çŒãäžãã
ã
ãª
ã¯
çª
ç¶
ã«
å®
æ
ã
ã
ã¿
ã
ã㯠çªç¶ã« 宿ã
ã
ã¿ã
ãã¯
çª
ç¶ã«
å®
æã
ã
ã¿ã
ãã¯
çª
ç¶ã«
å®
æ
ãã
ããªã¯
æã
宿
ãã
ããã
ãŸãã¯
æã
ç ã
ã«ã€ã
ã ãã
ããŸãã¯
æã
çŒãäžã
ã ã¿ã
ã㯠æ
ã
ç ã
ã«ã€ãã
ããããŸ
ã㯠æã
宿ãã
ã¿ããã¯
çªç¶ã«
宿ãã
ããªã¯
æã
ç ãã«
ã€ãã ãã
ããŸã㯠æ
ã
çŒãäžã
ã ããªã¯ çªç¶ã« ç ã
ã«ã€ãã ããª
㯠çªç¶ã« çŒ
ãäžãã ããªã¯ çªç¶ã« 宿ãã ããããŸãã¯
æã
ç ãã«ã€
ãã ã¿ãã㯠æã
ç ãã«ã€ãã