-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8430c6e
commit 31237ae
Showing
7 changed files
with
131 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
{ | ||
"name": "文字置き換え" | ||
"name": "文字置き換え", | ||
"description": "文章中の文字を置き換えます" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
function createForm() { | ||
const newForm = document.createElement('div'); | ||
newForm.classList.add('form-group', 'conversion-form'); | ||
|
||
const inputText = document.createElement('input'); | ||
inputText.type = 'text'; | ||
inputText.classList.add('conversion-input'); | ||
inputText.placeholder = '変換前'; | ||
|
||
const outputText = document.createElement('input'); | ||
outputText.type = 'text'; | ||
outputText.classList.add('conversion-output'); | ||
outputText.placeholder = '変換後'; | ||
|
||
const removeButton = document.createElement('button'); | ||
removeButton.type = 'button'; | ||
removeButton.classList.add('remove-button'); | ||
removeButton.textContent = '-パターンを削除'; | ||
removeButton.addEventListener('click', function() { | ||
newForm.remove(); | ||
}); | ||
|
||
newForm.appendChild(inputText); | ||
newForm.appendChild(outputText); | ||
newForm.appendChild(removeButton); | ||
|
||
return newForm; | ||
} | ||
|
||
document.getElementById("copyBtn").addEventListener("click", function () { | ||
const textArea = document.getElementById("output-text"); | ||
navigator.clipboard.writeText(textArea.value) | ||
.then(() => alert("クリップボードにコピーしました!")) | ||
.catch(err => console.error("クリップボードへのコピーに失敗しました: ", err)); | ||
}); | ||
|
||
document.getElementById('main-form').addEventListener('submit', function(event) { | ||
event.preventDefault(); | ||
|
||
let inputText = document.getElementById('input-text').value; | ||
const conversionInputs = document.getElementsByClassName('conversion-input'); | ||
const conversionOutputs = document.getElementsByClassName('conversion-output'); | ||
|
||
for (var i = 0; i < conversionInputs.length; i++) { | ||
const input = conversionInputs[i].value; | ||
const output = conversionOutputs[i].value; | ||
const regex = new RegExp(input, 'g'); | ||
inputText = inputText.replace(regex, output); | ||
} | ||
|
||
const outputTextArea = document.getElementById('output-text'); | ||
outputTextArea.value = inputText; | ||
outputTextArea.select(); | ||
}); | ||
|
||
const conversionForms = document.getElementById('conversion-forms') | ||
const addButton = document.createElement('button'); | ||
addButton.type = 'button'; | ||
addButton.textContent = '+パターンを追加'; | ||
addButton.addEventListener('click', function() { | ||
const newForm = createForm(); | ||
conversionForms.appendChild(newForm); | ||
}); | ||
|
||
conversionForms.appendChild(addButton); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
input { | ||
font-size: 16px; | ||
height: 20px; | ||
} | ||
|
||
button { | ||
min-width: 75px; | ||
max-width: 175px; | ||
} | ||
|
||
form h2, div h2 { | ||
text-align: left; | ||
} | ||
|
||
.buttons { | ||
width: 90%; | ||
margin: 0 auto; | ||
padding: 10px; | ||
background-color: whitesmoke; | ||
border-radius: 5px; | ||
text-align: center; | ||
} | ||
|
||
.form-group { | ||
padding-top: 20px; | ||
} | ||
|
||
.remove-button { | ||
max-width: auto; | ||
width: 125px; | ||
height: 25px; | ||
margin: 5px; | ||
padding: 5px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters