summaryrefslogtreecommitdiff
path: root/ext/bg/js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-04-11 15:23:32 -0400
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-04-11 15:25:21 -0400
commitcdd817a0e1c573b24114836a389236f49dd9b279 (patch)
treec9a579085d288afe81455a5e4f09d8da279a43a1 /ext/bg/js
parent51e17b35e3a855c0db6c4be94a8cb416b14c8ad7 (diff)
Move and rename utilStringHashCode
options.js is the only place it's used.
Diffstat (limited to 'ext/bg/js')
-rw-r--r--ext/bg/js/options.js23
-rw-r--r--ext/bg/js/util.js13
2 files changed, 16 insertions, 20 deletions
diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js
index 20df2a68..d36b2bab 100644
--- a/ext/bg/js/options.js
+++ b/ext/bg/js/options.js
@@ -15,14 +15,23 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-/* global
- * utilStringHashCode
- */
-
/*
* Generic options functions
*/
+function optionsGetStringHashCode(string) {
+ let hashCode = 0;
+
+ if (typeof string !== 'string') { return hashCode; }
+
+ for (let i = 0, charCode = string.charCodeAt(i); i < string.length; charCode = string.charCodeAt(++i)) {
+ hashCode = ((hashCode << 5) - hashCode) + charCode;
+ hashCode |= 0;
+ }
+
+ return hashCode;
+}
+
function optionsGenericApplyUpdates(options, updates) {
const targetVersion = updates.length;
const currentVersion = options.version;
@@ -63,12 +72,12 @@ const profileOptionsVersionUpdates = [
options.anki.fieldTemplates = null;
},
(options) => {
- if (utilStringHashCode(options.anki.fieldTemplates) === 1285806040) {
+ if (optionsGetStringHashCode(options.anki.fieldTemplates) === 1285806040) {
options.anki.fieldTemplates = null;
}
},
(options) => {
- if (utilStringHashCode(options.anki.fieldTemplates) === -250091611) {
+ if (optionsGetStringHashCode(options.anki.fieldTemplates) === -250091611) {
options.anki.fieldTemplates = null;
}
},
@@ -87,7 +96,7 @@ const profileOptionsVersionUpdates = [
(options) => {
// Version 12 changes:
// The preferred default value of options.anki.fieldTemplates has been changed to null.
- if (utilStringHashCode(options.anki.fieldTemplates) === 1444379824) {
+ if (optionsGetStringHashCode(options.anki.fieldTemplates) === 1444379824) {
options.anki.fieldTemplates = null;
}
},
diff --git a/ext/bg/js/util.js b/ext/bg/js/util.js
index 106365ac..5edcc193 100644
--- a/ext/bg/js/util.js
+++ b/ext/bg/js/util.js
@@ -58,19 +58,6 @@ function utilBackgroundFunctionIsolate(func) {
return backgroundPage.utilFunctionIsolate(func);
}
-function utilStringHashCode(string) {
- let hashCode = 0;
-
- if (typeof string !== 'string') { return hashCode; }
-
- for (let i = 0, charCode = string.charCodeAt(i); i < string.length; charCode = string.charCodeAt(++i)) {
- hashCode = ((hashCode << 5) - hashCode) + charCode;
- hashCode |= 0;
- }
-
- return hashCode;
-}
-
function utilBackend() {
const backend = chrome.extension.getBackgroundPage().yomichanBackend;
if (!backend.isPrepared) {