cleanup
This commit is contained in:
parent
d57c5530b7
commit
b3984ccd54
@ -35,7 +35,7 @@ class Database {
|
||||
}
|
||||
|
||||
prepare() {
|
||||
if (this.db !== null) {
|
||||
if (!this.db) {
|
||||
return Promise.reject('database already initialized');
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ class Database {
|
||||
}
|
||||
|
||||
purge() {
|
||||
if (this.db === null) {
|
||||
if (!this.db) {
|
||||
return Promise.reject('database not initialized');
|
||||
}
|
||||
|
||||
@ -66,7 +66,7 @@ class Database {
|
||||
}
|
||||
|
||||
findTerms(term, dictionaries) {
|
||||
if (this.db === null) {
|
||||
if (!this.db) {
|
||||
return Promise.reject('database not initialized');
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ class Database {
|
||||
}
|
||||
|
||||
findKanji(kanji, dictionaries) {
|
||||
if (this.db === null) {
|
||||
if (!this.db) {
|
||||
return Promise.reject('database not initialized');
|
||||
}
|
||||
|
||||
@ -124,7 +124,7 @@ class Database {
|
||||
}
|
||||
|
||||
cacheTagMeta(dictionaries) {
|
||||
if (this.db === null) {
|
||||
if (!this.db) {
|
||||
return Promise.reject('database not initialized');
|
||||
}
|
||||
|
||||
@ -148,7 +148,7 @@ class Database {
|
||||
}
|
||||
|
||||
getDictionaries() {
|
||||
if (this.db === null) {
|
||||
if (!this.db) {
|
||||
return Promise.reject('database not initialized');
|
||||
}
|
||||
|
||||
@ -156,7 +156,7 @@ class Database {
|
||||
}
|
||||
|
||||
importDictionary(archive, callback) {
|
||||
if (this.db === null) {
|
||||
if (!this.db) {
|
||||
return Promise.reject('database not initialized');
|
||||
}
|
||||
|
||||
|
@ -337,7 +337,7 @@ function ankiFieldsPopulate(element, options) {
|
||||
const container = tab.find('tbody').empty();
|
||||
|
||||
const modelName = element.val();
|
||||
if (modelName === null) {
|
||||
if (!modelName) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,7 @@ function docImposterDestroy() {
|
||||
|
||||
function docRangeFromPoint(point) {
|
||||
const element = document.elementFromPoint(point.x, point.y);
|
||||
if (element !== null) {
|
||||
if (element) {
|
||||
if (element.nodeName === 'IMG' || element.nodeName === 'BUTTON') {
|
||||
return new TextSourceElement(element);
|
||||
} else if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') {
|
||||
@ -128,23 +128,19 @@ function docRangeFromPoint(point) {
|
||||
if (!document.caretRangeFromPoint) {
|
||||
document.caretRangeFromPoint = (x, y) => {
|
||||
const position = document.caretPositionFromPoint(x,y);
|
||||
if (position === null) {
|
||||
return null;
|
||||
if (position) {
|
||||
const range = document.createRange();
|
||||
range.setStart(position.offsetNode, position.offset);
|
||||
range.setEnd(position.offsetNode, position.offset);
|
||||
return range;
|
||||
}
|
||||
|
||||
const range = document.createRange();
|
||||
range.setStart(position.offsetNode, position.offset);
|
||||
range.setEnd(position.offsetNode, position.offset);
|
||||
return range;
|
||||
};
|
||||
}
|
||||
|
||||
const range = document.caretRangeFromPoint(point.x, point.y);
|
||||
if (range !== null) {
|
||||
if (range) {
|
||||
return new TextSourceRange(range);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function docSentenceExtract(source, extent) {
|
||||
|
Loading…
Reference in New Issue
Block a user