-
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.
Merge pull request #63 from YuukiToriyama/release/v0.1.0-alpha.6
release/v0.1.0-alpha.6をmainブランチにマージ
- Loading branch information
Showing
4 changed files
with
109 additions
and
17 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
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 |
---|---|---|
@@ -1,15 +1,43 @@ | ||
import init, {Parser} from "../pkg/japanese_address_parser.js" | ||
|
||
const inputTextArea = document.getElementById("input") | ||
const outputTextArea = document.getElementById("output") | ||
|
||
init().then(() => { | ||
document.getElementById("exec").addEventListener("click", () => { | ||
const input = inputTextArea.value | ||
alert("input: " + input) | ||
const parser = new Parser() | ||
parser.parse(input).then(result => { | ||
outputTextArea.value = JSON.stringify(result, null, "\t") | ||
document.getElementById("result").appendChild( | ||
createRow(input, result) | ||
) | ||
}) | ||
}) | ||
}) | ||
}) | ||
|
||
const createRow = (input, parseResult) => { | ||
const tr = document.createElement("tr") | ||
tr.appendChild(createCell(`<p>${input}</p>`)) | ||
if (parseResult.error === undefined) { | ||
tr.appendChild(createCell("<p>成功</p>")) | ||
} else { | ||
tr.appendChild(createCell("<p>失敗</p>")) | ||
} | ||
tr.appendChild(createCell(`<p>${parseResult.address.prefecture}</p>`)) | ||
tr.appendChild(createCell(`<p>${parseResult.address.city}</p>`)) | ||
tr.appendChild(createCell(`<p>${parseResult.address.town}</p>`)) | ||
tr.appendChild(createCell(`<p>${parseResult.address.rest}</p>`)) | ||
tr.appendChild(createCell(`<code>${JSON.stringify(parseResult, null, null)}</code>`)) | ||
return tr | ||
} | ||
|
||
const createCell = (innerHtml) => { | ||
const td = document.createElement("td") | ||
td.innerHTML = innerHtml | ||
td.addEventListener("click", () => { | ||
navigator.clipboard.writeText(td.innerText).then(() => { | ||
console.log(td.innerText) | ||
}) | ||
}) | ||
return td | ||
} |
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,51 @@ | ||
.input { | ||
display: flex; | ||
} | ||
|
||
.address { | ||
border: 1px solid #ddd; | ||
border-radius: 6px; | ||
padding-left: 1em; | ||
padding-right: 1em; | ||
height: 48px; | ||
flex: 1; | ||
width: 300px; | ||
max-width: 410px; | ||
background: #eaedf2; | ||
font-size: 18px; | ||
margin-right: 10px; | ||
} | ||
|
||
.button { | ||
border-radius: 6px; | ||
height: 48px; | ||
width: 180px; | ||
display: block; | ||
letter-spacing: 0.05em; | ||
background: #5bc8ac; | ||
color: #fff; | ||
font-weight: bold; | ||
font-size: 20px; | ||
} | ||
|
||
.button:hover { | ||
background: #82dcc4; | ||
} | ||
|
||
.output thead { | ||
background: #5bc8ac; | ||
} | ||
|
||
.output thead tr th { | ||
font-weight: bold; | ||
padding: 12px 30px 12px 42px; | ||
} | ||
|
||
.output tbody tr td { | ||
background: #eaedf2; | ||
padding: 15px 10px; | ||
} | ||
|
||
.output tbody tr td:hover { | ||
background: #8eeacd; | ||
} |