forked from kong0107/zhLawEasyRead
-
Notifications
You must be signed in to change notification settings - Fork 6
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
Showing
9 changed files
with
64 additions
and
26 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
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,14 +1,30 @@ | ||
"use strict"; | ||
|
||
if(!LER.loadLaws) LER.loadLaws = getData("laws").then((laws = []) => { | ||
const rules = laws.map(law => ({ | ||
pattern: law.name, | ||
replacer: () => { | ||
LER.matchedAnyLaw = true; | ||
return {type: "law", law: law}; | ||
}, | ||
minLength: law.name.length | ||
})); | ||
LER.rules.unshift(...rules); | ||
return LER.laws = laws; | ||
}); | ||
if(!LER.loadLaws) { | ||
const exTermsPromise = fetch( | ||
browser.runtime.getURL("data/exclude_terms.txt") | ||
).then(res => res.text()) | ||
.then(text => text.split(/\r?\n\r?/).filter(x => x)); | ||
|
||
LER.loadLaws = Promise.all([ | ||
getData("laws"), | ||
exTermsPromise | ||
]).then(([laws = [], exTerms = []]) => { | ||
const rules = laws.map(law => ({ | ||
pattern: law.name, | ||
replacer: () => { | ||
LER.matchedAnyLaw = true; | ||
return {type: "law", law: law}; | ||
}, | ||
minLength: law.name.length | ||
})).concat(exTerms.map(term => ({ | ||
pattern: term, | ||
replacer: () => ({type: "exclude_term", text: term}), | ||
minLength: term.length | ||
}))); | ||
|
||
rules.sort((a, b) => b.pattern.length - a.pattern.length); | ||
LER.rules.unshift(...rules); | ||
return LER.laws = laws; | ||
}); | ||
} |
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,11 @@ | ||
國民法官法庭 | ||
國民法官 | ||
大學法律系 | ||
德國憲法 | ||
德國民法 | ||
德國刑法 | ||
日本國憲法 | ||
日本憲法 | ||
日本民法 | ||
日本刑法 | ||
美國憲法 |
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
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