Update DictionaryDataUtil to be able to be used in a sandbox frame (#1206)
This commit is contained in:
parent
3760b22a25
commit
7d706df66b
@ -84,7 +84,8 @@
|
|||||||
{
|
{
|
||||||
"files": [
|
"files": [
|
||||||
"ext/mixed/js/core.js",
|
"ext/mixed/js/core.js",
|
||||||
"ext/bg/js/template-renderer.js"
|
"ext/bg/js/template-renderer.js",
|
||||||
|
"ext/mixed/js/dictionary-data-util.js"
|
||||||
],
|
],
|
||||||
"env": {
|
"env": {
|
||||||
"webextensions": false
|
"webextensions": false
|
||||||
@ -94,7 +95,8 @@
|
|||||||
"files": ["ext/**/*.js"],
|
"files": ["ext/**/*.js"],
|
||||||
"excludedFiles": [
|
"excludedFiles": [
|
||||||
"ext/mixed/js/core.js",
|
"ext/mixed/js/core.js",
|
||||||
"ext/bg/js/template-renderer.js"
|
"ext/bg/js/template-renderer.js",
|
||||||
|
"ext/mixed/js/dictionary-data-util.js"
|
||||||
],
|
],
|
||||||
"globals": {
|
"globals": {
|
||||||
"errorToJson": "readonly",
|
"errorToJson": "readonly",
|
||||||
|
@ -52,8 +52,8 @@ class DictionaryDataUtil {
|
|||||||
const exclusiveExpressions = [];
|
const exclusiveExpressions = [];
|
||||||
const exclusiveReadings = [];
|
const exclusiveReadings = [];
|
||||||
const resultExpressions = result.expressions;
|
const resultExpressions = result.expressions;
|
||||||
if (!areSetsEqual(resultExpressions, allExpressions)) {
|
if (!this._areSetsEqual(resultExpressions, allExpressions)) {
|
||||||
exclusiveExpressions.push(...getSetIntersection(resultExpressions, allExpressions));
|
exclusiveExpressions.push(...this._getSetIntersection(resultExpressions, allExpressions));
|
||||||
}
|
}
|
||||||
if (multipleReadings) {
|
if (multipleReadings) {
|
||||||
exclusiveReadings.push(result.reading);
|
exclusiveReadings.push(result.reading);
|
||||||
@ -71,6 +71,8 @@ class DictionaryDataUtil {
|
|||||||
return results2;
|
return results2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Private
|
||||||
|
|
||||||
static _findExistingPitchAccentInfo(reading, position, tags, pitchAccentInfoList) {
|
static _findExistingPitchAccentInfo(reading, position, tags, pitchAccentInfoList) {
|
||||||
for (const pitchInfo of pitchAccentInfoList) {
|
for (const pitchInfo of pitchAccentInfoList) {
|
||||||
if (
|
if (
|
||||||
@ -98,4 +100,28 @@ class DictionaryDataUtil {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static _areSetsEqual(set1, set2) {
|
||||||
|
if (set1.size !== set2.size) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const value of set1) {
|
||||||
|
if (!set2.has(value)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static _getSetIntersection(set1, set2) {
|
||||||
|
const result = [];
|
||||||
|
for (const value of set1) {
|
||||||
|
if (set2.has(value)) {
|
||||||
|
result.push(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user