From 87ed7c8affd3ade9d3cd2d9ed1a61dd5f224e473 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Wed, 31 Jan 2024 08:38:30 -0500 Subject: Module refactoring (#588) * Convert PronunciationGenerator into static functions * Convert DictionaryDataUtil into static functions * Convert AnkiNoteDataCreator into static functions * Convert MediaUtil into static functions * Convert RegexUtil into static functions * Convert StringUtil into static functions * Convert ArrayBufferUtil into static functions * Convert AnkiUtil into static functions * Convert PermissionsUtil into static functions * Convert ProfileConditionsUtil into static functions --- ext/js/dom/dom-text-scanner.js | 6 +++--- ext/js/dom/text-source-element.js | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'ext/js/dom') diff --git a/ext/js/dom/dom-text-scanner.js b/ext/js/dom/dom-text-scanner.js index d605aeca..5caa32f7 100644 --- a/ext/js/dom/dom-text-scanner.js +++ b/ext/js/dom/dom-text-scanner.js @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import {StringUtil} from '../data/sandbox/string-util.js'; +import {readCodePointsBackward, readCodePointsForward} from '../data/sandbox/string-util.js'; /** * A class used to scan text in a document. @@ -172,7 +172,7 @@ export class DOMTextScanner { if (resetOffset) { this._offset = 0; } while (this._offset < nodeValueLength) { - const char = StringUtil.readCodePointsForward(nodeValue, this._offset, 1); + const char = readCodePointsForward(nodeValue, this._offset, 1); this._offset += char.length; const charAttributes = DOMTextScanner.getCharacterAttributes(char, preserveNewlines, preserveWhitespace); if (this._checkCharacterForward(char, charAttributes)) { break; } @@ -201,7 +201,7 @@ export class DOMTextScanner { if (resetOffset) { this._offset = nodeValueLength; } while (this._offset > 0) { - const char = StringUtil.readCodePointsBackward(nodeValue, this._offset - 1, 1); + const char = readCodePointsBackward(nodeValue, this._offset - 1, 1); this._offset -= char.length; const charAttributes = DOMTextScanner.getCharacterAttributes(char, preserveNewlines, preserveWhitespace); if (this._checkCharacterBackward(char, charAttributes)) { break; } diff --git a/ext/js/dom/text-source-element.js b/ext/js/dom/text-source-element.js index 477295e6..8727a4e1 100644 --- a/ext/js/dom/text-source-element.js +++ b/ext/js/dom/text-source-element.js @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import {StringUtil} from '../data/sandbox/string-util.js'; +import {readCodePointsBackward, readCodePointsForward} from '../data/sandbox/string-util.js'; import {DocumentUtil} from './document-util.js'; /** @@ -118,7 +118,7 @@ export class TextSourceElement { const offset = fromEnd ? this._endOffset : this._startOffset; length = Math.min(this._fullContent.length - offset, length); if (length > 0) { - length = StringUtil.readCodePointsForward(this._fullContent, offset, length).length; + length = readCodePointsForward(this._fullContent, offset, length).length; } this._endOffset = offset + length; this._content = this._fullContent.substring(this._startOffset, this._endOffset); @@ -133,7 +133,7 @@ export class TextSourceElement { setStartOffset(length) { length = Math.min(this._startOffset, length); if (length > 0) { - length = StringUtil.readCodePointsBackward(this._fullContent, this._startOffset - 1, length).length; + length = readCodePointsBackward(this._fullContent, this._startOffset - 1, length).length; } this._startOffset -= length; this._content = this._fullContent.substring(this._startOffset, this._endOffset); -- cgit v1.2.3