Skip to content

Commit

Permalink
Merge pull request #56 from hideki0403/develop
Browse files Browse the repository at this point in the history
release: v1.4.2
  • Loading branch information
hideki0403 authored Jul 9, 2022
2 parents c818ac1 + ef8de31 commit 8eb36e8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "better-japanese",
"version": "1.4.1",
"version": "1.4.2",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
12 changes: 12 additions & 0 deletions src/common/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const betterJapanese = {
},
tmpIgnoreList: {},
tmpCategoryList: {},
currentIgnoreList: [],
isRegisteredHook: false,

init: function() {
Expand Down Expand Up @@ -611,6 +612,8 @@ const betterJapanese = {
<h4>単語を個別に選択</h4>
<p>単語の左にあるチェックボックスにチェックを付けるとその単語の置き換えを無効化します。</p>
<input id="ignorelist-search" type="search" placeholder="単語を検索" onchange="betterJapanese.createIgnoreWordList()">
<button type="button" onclick="betterJapanese.changeAllIgnoreList(true)">全選択</button>
<button type="button" onclick="betterJapanese.changeAllIgnoreList(false)">全解除</button>
<div id="ignorelist-content" style="height: 50vh; overflow-y: scroll; text-align: left;">読み込み中</div>
</div>
</div>
Expand Down Expand Up @@ -706,6 +709,7 @@ const betterJapanese = {
let searchWord = document.getElementById('ignorelist-search')?.value || ''
let translateList = await betterJapanese.getJSON(betterJapanese.api.endpoints.TRANSLATE)
let ignoreList = betterJapanese.processIgnoreList()
betterJapanese.currentIgnoreList = []

let translateListHtml = []
for (let key of Object.keys(translateList)) {
Expand All @@ -717,6 +721,7 @@ const betterJapanese = {

if (searchWord && !value.match(searchWord)) continue

betterJapanese.currentIgnoreList.push(key)
key = key.replace(/"/g, '\\$1')

translateListHtml.push(`<div><label><input type="checkbox" name="word:${key}" ${isChecked ? 'checked' : ''}>${value.replace(/<("[^"]*"|'[^']*'|[^'">])*>/g, '')}</label></div>`)
Expand Down Expand Up @@ -759,6 +764,13 @@ const betterJapanese = {
document.getElementById('ignorelist-category').innerHTML = categoryListHtml
},

changeAllIgnoreList: function(state) {
betterJapanese.currentIgnoreList.forEach(key => {
betterJapanese.tmpIgnoreList[key] = state
})
betterJapanese.createIgnoreWordList()
},

processIgnoreList: function() {
let array = betterJapanese.config.ignoreList.concat()

Expand Down

0 comments on commit 8eb36e8

Please sign in to comment.