ArrayBufferUtil (#2215)
* Rename StringUtil to ArrayBufferUtil * Update docs * Rename file string-util.js to array-buffer-util.js
This commit is contained in:
parent
cd0a6b60e2
commit
d3807d88ec
@ -232,7 +232,7 @@
|
|||||||
"ext/js/data/json-schema.js",
|
"ext/js/data/json-schema.js",
|
||||||
"ext/js/data/options-util.js",
|
"ext/js/data/options-util.js",
|
||||||
"ext/js/data/permissions-util.js",
|
"ext/js/data/permissions-util.js",
|
||||||
"ext/js/data/sandbox/string-util.js",
|
"ext/js/data/sandbox/array-buffer-util.js",
|
||||||
"ext/js/dom/simple-dom-parser.js",
|
"ext/js/dom/simple-dom-parser.js",
|
||||||
"ext/js/extension/environment.js",
|
"ext/js/extension/environment.js",
|
||||||
"ext/js/general/cache-map.js",
|
"ext/js/general/cache-map.js",
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
<script src="/js/data/json-schema.js"></script>
|
<script src="/js/data/json-schema.js"></script>
|
||||||
<script src="/js/data/options-util.js"></script>
|
<script src="/js/data/options-util.js"></script>
|
||||||
<script src="/js/data/permissions-util.js"></script>
|
<script src="/js/data/permissions-util.js"></script>
|
||||||
<script src="/js/data/sandbox/string-util.js"></script>
|
<script src="/js/data/sandbox/array-buffer-util.js"></script>
|
||||||
<script src="/js/dom/native-simple-dom-parser.js"></script>
|
<script src="/js/dom/native-simple-dom-parser.js"></script>
|
||||||
<script src="/js/extension/environment.js"></script>
|
<script src="/js/extension/environment.js"></script>
|
||||||
<script src="/js/general/cache-map.js"></script>
|
<script src="/js/general/cache-map.js"></script>
|
||||||
|
@ -68,7 +68,7 @@
|
|||||||
<script src="/js/comm/cross-frame-api.js"></script>
|
<script src="/js/comm/cross-frame-api.js"></script>
|
||||||
<script src="/js/data/anki-util.js"></script>
|
<script src="/js/data/anki-util.js"></script>
|
||||||
<script src="/js/data/permissions-util.js"></script>
|
<script src="/js/data/permissions-util.js"></script>
|
||||||
<script src="/js/data/sandbox/string-util.js"></script>
|
<script src="/js/data/sandbox/array-buffer-util.js"></script>
|
||||||
<script src="/js/dom/document-focus-controller.js"></script>
|
<script src="/js/dom/document-focus-controller.js"></script>
|
||||||
<script src="/js/dom/html-template-collection.js"></script>
|
<script src="/js/dom/html-template-collection.js"></script>
|
||||||
<script src="/js/pages/settings/backup-controller.js"></script>
|
<script src="/js/pages/settings/backup-controller.js"></script>
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
* AccessibilityController
|
* AccessibilityController
|
||||||
* AnkiConnect
|
* AnkiConnect
|
||||||
* AnkiUtil
|
* AnkiUtil
|
||||||
|
* ArrayBufferUtil
|
||||||
* AudioDownloader
|
* AudioDownloader
|
||||||
* ClipboardMonitor
|
* ClipboardMonitor
|
||||||
* ClipboardReader
|
* ClipboardReader
|
||||||
@ -33,7 +34,6 @@
|
|||||||
* ProfileConditionsUtil
|
* ProfileConditionsUtil
|
||||||
* RequestBuilder
|
* RequestBuilder
|
||||||
* ScriptManager
|
* ScriptManager
|
||||||
* StringUtil
|
|
||||||
* Translator
|
* Translator
|
||||||
* wanakana
|
* wanakana
|
||||||
*/
|
*/
|
||||||
@ -2223,7 +2223,7 @@ class Backend {
|
|||||||
for (const item of results) {
|
for (const item of results) {
|
||||||
const {content} = item;
|
const {content} = item;
|
||||||
if (content instanceof ArrayBuffer) {
|
if (content instanceof ArrayBuffer) {
|
||||||
item.content = StringUtil.arrayBufferToBase64(content);
|
item.content = ArrayBufferUtil.arrayBufferToBase64(content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
|
@ -16,9 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class containing generic string utility functions.
|
* Class containing generic ArrayBuffer utility functions.
|
||||||
*/
|
*/
|
||||||
class StringUtil {
|
class ArrayBufferUtil {
|
||||||
/**
|
/**
|
||||||
* Decodes the contents of an ArrayBuffer using UTF8.
|
* Decodes the contents of an ArrayBuffer using UTF8.
|
||||||
* @param {ArrayBuffer} arrayBuffer The input ArrayBuffer.
|
* @param {ArrayBuffer} arrayBuffer The input ArrayBuffer.
|
@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* global
|
/* global
|
||||||
* StringUtil
|
* ArrayBufferUtil
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -139,7 +139,7 @@ class DisplayContentManager {
|
|||||||
const token = this._token;
|
const token = this._token;
|
||||||
const data = (await yomichan.api.getMedia([{path, dictionary}]))[0];
|
const data = (await yomichan.api.getMedia([{path, dictionary}]))[0];
|
||||||
if (token === this._token && data !== null) {
|
if (token === this._token && data !== null) {
|
||||||
const buffer = StringUtil.base64ToArrayBuffer(data.content);
|
const buffer = ArrayBufferUtil.base64ToArrayBuffer(data.content);
|
||||||
const blob = new Blob([buffer], {type: data.mediaType});
|
const blob = new Blob([buffer], {type: data.mediaType});
|
||||||
const url = URL.createObjectURL(blob);
|
const url = URL.createObjectURL(blob);
|
||||||
cachedData.data = data;
|
cachedData.data = data;
|
||||||
|
@ -16,11 +16,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* global
|
/* global
|
||||||
|
* ArrayBufferUtil
|
||||||
* JsonSchema
|
* JsonSchema
|
||||||
* NativeSimpleDOMParser
|
* NativeSimpleDOMParser
|
||||||
* RequestBuilder
|
* RequestBuilder
|
||||||
* SimpleDOMParser
|
* SimpleDOMParser
|
||||||
* StringUtil
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class AudioDownloader {
|
class AudioDownloader {
|
||||||
@ -283,7 +283,7 @@ class AudioDownloader {
|
|||||||
throw new Error('Could not retrieve audio');
|
throw new Error('Could not retrieve audio');
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = StringUtil.arrayBufferToBase64(arrayBuffer);
|
const data = ArrayBufferUtil.arrayBufferToBase64(arrayBuffer);
|
||||||
const contentType = response.headers.get('Content-Type');
|
const contentType = response.headers.get('Content-Type');
|
||||||
return {data, contentType};
|
return {data, contentType};
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* global
|
/* global
|
||||||
|
* ArrayBufferUtil
|
||||||
* DictionaryController
|
* DictionaryController
|
||||||
* OptionsUtil
|
* OptionsUtil
|
||||||
* StringUtil
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class BackupController {
|
class BackupController {
|
||||||
@ -319,7 +319,7 @@ class BackupController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async _importSettingsFile(file) {
|
async _importSettingsFile(file) {
|
||||||
const dataString = StringUtil.arrayBufferUtf8Decode(await this._readFileArrayBuffer(file));
|
const dataString = ArrayBufferUtil.arrayBufferUtf8Decode(await this._readFileArrayBuffer(file));
|
||||||
const data = JSON.parse(dataString);
|
const data = JSON.parse(dataString);
|
||||||
|
|
||||||
// Type check
|
// Type check
|
||||||
|
@ -103,7 +103,7 @@
|
|||||||
<script src="/js/comm/frame-endpoint.js"></script>
|
<script src="/js/comm/frame-endpoint.js"></script>
|
||||||
<script src="/js/data/anki-note-builder.js"></script>
|
<script src="/js/data/anki-note-builder.js"></script>
|
||||||
<script src="/js/data/anki-util.js"></script>
|
<script src="/js/data/anki-util.js"></script>
|
||||||
<script src="/js/data/sandbox/string-util.js"></script>
|
<script src="/js/data/sandbox/array-buffer-util.js"></script>
|
||||||
<script src="/js/display/display.js"></script>
|
<script src="/js/display/display.js"></script>
|
||||||
<script src="/js/display/display-anki.js"></script>
|
<script src="/js/display/display-anki.js"></script>
|
||||||
<script src="/js/display/display-audio.js"></script>
|
<script src="/js/display/display-audio.js"></script>
|
||||||
|
@ -90,7 +90,7 @@
|
|||||||
<script src="/js/comm/cross-frame-api.js"></script>
|
<script src="/js/comm/cross-frame-api.js"></script>
|
||||||
<script src="/js/data/anki-note-builder.js"></script>
|
<script src="/js/data/anki-note-builder.js"></script>
|
||||||
<script src="/js/data/anki-util.js"></script>
|
<script src="/js/data/anki-util.js"></script>
|
||||||
<script src="/js/data/sandbox/string-util.js"></script>
|
<script src="/js/data/sandbox/array-buffer-util.js"></script>
|
||||||
<script src="/js/display/display.js"></script>
|
<script src="/js/display/display.js"></script>
|
||||||
<script src="/js/display/display-anki.js"></script>
|
<script src="/js/display/display-anki.js"></script>
|
||||||
<script src="/js/display/display-audio.js"></script>
|
<script src="/js/display/display-audio.js"></script>
|
||||||
|
@ -3788,7 +3788,7 @@
|
|||||||
<script src="/js/data/json-schema.js"></script>
|
<script src="/js/data/json-schema.js"></script>
|
||||||
<script src="/js/data/options-util.js"></script>
|
<script src="/js/data/options-util.js"></script>
|
||||||
<script src="/js/data/permissions-util.js"></script>
|
<script src="/js/data/permissions-util.js"></script>
|
||||||
<script src="/js/data/sandbox/string-util.js"></script>
|
<script src="/js/data/sandbox/array-buffer-util.js"></script>
|
||||||
<script src="/js/dom/document-focus-controller.js"></script>
|
<script src="/js/dom/document-focus-controller.js"></script>
|
||||||
<script src="/js/dom/document-util.js"></script>
|
<script src="/js/dom/document-util.js"></script>
|
||||||
<script src="/js/dom/dom-data-binder.js"></script>
|
<script src="/js/dom/dom-data-binder.js"></script>
|
||||||
|
@ -34,7 +34,7 @@ self.importScripts(
|
|||||||
'/js/data/json-schema.js',
|
'/js/data/json-schema.js',
|
||||||
'/js/data/options-util.js',
|
'/js/data/options-util.js',
|
||||||
'/js/data/permissions-util.js',
|
'/js/data/permissions-util.js',
|
||||||
'/js/data/sandbox/string-util.js',
|
'/js/data/sandbox/array-buffer-util.js',
|
||||||
'/js/dom/simple-dom-parser.js',
|
'/js/dom/simple-dom-parser.js',
|
||||||
'/js/extension/environment.js',
|
'/js/extension/environment.js',
|
||||||
'/js/general/cache-map.js',
|
'/js/general/cache-map.js',
|
||||||
|
Loading…
Reference in New Issue
Block a user