Skip to content

Commit

Permalink
add zipcode feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Webber committed Nov 25, 2023
1 parent 0ff4651 commit 18c6581
Show file tree
Hide file tree
Showing 7 changed files with 8,069 additions and 24 deletions.
4 changes: 4 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
<a class="nav-link" href="vlookup.html">資料查閱
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="zipcode.html">郵遞區號
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="sublime.html" target="_blank">編輯器
</a>
Expand Down
8 changes: 8 additions & 0 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,14 @@ $(document).ready(function () {
$('#raw').val(result);
});

$('#zipCodeBtn').on('click', function () {
var datas = $('#raw').val().split("\n").filter(Boolean);
var dict = $('#dictionary').val().split("\n").filter(Boolean);
var dictionary = _.fromPairs(dict.map(x => x.split(":").map(y => y.trim())));
var result = datas.map(x => x + ',' + (zipCodeDict[extractAddr(x)] || 'N/A')).join('\n');
$('#dictionary').val(result);
});

$('#swapDictBtn').on('click', function () {
var dict = _.compact($('#dictionary').val().split("\n"));

Expand Down
Loading

0 comments on commit 18c6581

Please sign in to comment.