Implements a significantly more stable architecture for the library.

This commit is contained in:
Llewellyn van der Merwe 2023-11-28 13:05:57 +02:00
parent ad64c762a8
commit 57482a2b48
Signed by: Llewellyn
GPG Key ID: A9201372263741E7
33 changed files with 2458 additions and 1641 deletions

View File

@ -2,7 +2,7 @@
## Overview
GetBible loader is an intuitive and lightweight JavaScript solution for embedding Bible scripture into your website. By simply adding the `getBible` class to any element that has a scripture reference on your webpage, you can enable users to see the full scripture text as inline text, a tooltip or a modal.
GetBible loader is an intuitive and lightweight JavaScript solution for embedding Reference scripture into your website. By simply adding the `getBible` class to any element that has a scripture reference on your webpage, you can enable users to see the full scripture text as inline text, a tooltip or a modal.
## How to Add GetBible Tooltips to Your Website
@ -12,7 +12,7 @@ GetBible loader is an intuitive and lightweight JavaScript solution for embeddin
```html
<!-- Include the GetBible tooltips script from jsDelivr CDN -->
<script src="https://cdn.jsdelivr.net/gh/getbible/loader@3.0.0/dist/js/getBible.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/getbible/loader@3.0.1/dist/js/getBible.min.js"></script>
```
2. **Markup Your Scripture References:**
@ -34,7 +34,7 @@ GetBible loader is an intuitive and lightweight JavaScript solution for embeddin
Data attributes allow you to customize the behavior and display of the scripture.
- `data-format`: Specify the format you would like to load (e.g., `modal`). There are three options `modal`, `inline`, and `tooltip` you can just select one at a time.
- `data-translation`: Specify the Bible translations to use, separated by semicolons (e.g., `kjv;aov`). The tooltip will fetch the scripture from each translation listed.
- `data-translation`: Specify the Reference translations to use, separated by semicolons (e.g., `kjv;aov`). The tooltip will fetch the scripture from each translation listed.
- `data-show-translation`: Set to `1` to display the translation name in the tooltip.
- `data-show-abbreviation`: Set to `1` to display the abbreviation of the translation in the tooltip.
- `data-show-language`: Set to `1` to display the language of the translation in the tooltip.
@ -57,12 +57,12 @@ Should you see room for improvement to these, please open an issue at our [suppo
### Some Guidelines
- **Chapter and Verse**: Follow the book name with the chapter number, a colon, and the verse number(s) (e.g., "Jn3:16").
- **Reference and Verse**: Follow the book name with the chapter number, a colon, and the verse number(s) (e.g., "Jn3:16").
- **Multiple Verses**: Separate multiple verses with commas (e.g., "Jn 3:16,17").
- **Verse Ranges**: Indicate a range of verses using a hyphen (e.g., "John 3:16-19").
- **Multiple References**: Separate different scripture references with semicolons (e.g., "Joh 3:16-17; 1 Jo3:16-19").
- **One Chapter Per/Reference**: Each reference should only target one chapter.
- **Missing Chapter**: All references that does not have a chapter will **default to chapter 1** (e.g., "Jhn :16-19").
- **One Reference Per/Reference**: Each reference should only target one chapter.
- **Missing Reference**: All references that does not have a chapter will **default to chapter 1** (e.g., "Jhn :16-19").
- **Missing Verses**: All references that does not have verses will **default to verse 1** (e.g., "Jn3").
## Copyright and License

2127
dist/js/getBible.js vendored

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

561
package-lock.json generated
View File

@ -1,23 +1,23 @@
{
"name": "getbible.loader",
"version": "3.0.0",
"version": "3.0.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "getbible.loader",
"version": "3.0.0",
"version": "3.0.1",
"license": "MIT",
"devDependencies": {
"@babel/core": "^7.15.0",
"@babel/preset-env": "^7.15.0",
"@rollup/plugin-babel": "^5.3.0",
"@rollup/plugin-commonjs": "^21.0.0",
"@rollup/plugin-node-resolve": "^13.0.0",
"@rollup/plugin-replace": "^5.0.5",
"rollup": "^2.60.0",
"rollup-plugin-license": "^2.3.0",
"rollup-plugin-terser": "^7.0.0"
"@babel/core": "latest",
"@babel/preset-env": "latest",
"@rollup/plugin-babel": "latest",
"@rollup/plugin-commonjs": "latest",
"@rollup/plugin-node-resolve": "latest",
"@rollup/plugin-replace": "latest",
"rollup": "latest",
"rollup-plugin-license": "latest",
"rollup-plugin-terser": "latest"
}
},
"node_modules/@ampproject/remapping": {
@ -34,12 +34,12 @@
}
},
"node_modules/@babel/code-frame": {
"version": "7.22.13",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.22.13.tgz",
"integrity": "sha512-XktuhWlJ5g+3TJXc5upd9Ks1HutSArik6jf2eAjYFyIOf4ej3RN+184cZbzDvbPnuTJIUhPKKJE3cIsYTiAT3w==",
"version": "7.23.4",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.23.4.tgz",
"integrity": "sha512-r1IONyb6Ia+jYR2vvIDhdWdlTGhqbBoFqLTQidzZ4kepUFH15ejXvFHxCVbtl7BOXIudsIubf4E81xeA3h3IXA==",
"dev": true,
"dependencies": {
"@babel/highlight": "^7.22.13",
"@babel/highlight": "^7.23.4",
"chalk": "^2.4.2"
},
"engines": {
@ -86,12 +86,12 @@
}
},
"node_modules/@babel/generator": {
"version": "7.23.3",
"resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.23.3.tgz",
"integrity": "sha512-keeZWAV4LU3tW0qRi19HRpabC/ilM0HRBBzf9/k8FFiG4KVpiv0FIy4hHfLfFQZNhziCTPTmd59zoyv6DNISzg==",
"version": "7.23.4",
"resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.23.4.tgz",
"integrity": "sha512-esuS49Cga3HcThFNebGhlgsrVLkvhqvYDTzgjfFFlHJcIfLe5jFmRRfCQ1KuBfc4Jrtn3ndLgKWAKjBE+IraYQ==",
"dev": true,
"dependencies": {
"@babel/types": "^7.23.3",
"@babel/types": "^7.23.4",
"@jridgewell/gen-mapping": "^0.3.2",
"@jridgewell/trace-mapping": "^0.3.17",
"jsesc": "^2.5.1"
@ -365,9 +365,9 @@
}
},
"node_modules/@babel/helper-string-parser": {
"version": "7.22.5",
"resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.22.5.tgz",
"integrity": "sha512-mM4COjgZox8U+JcXQwPijIZLElkgEpO5rsERVDJTc2qfCDfERyob6k5WegS14SX18IIjv+XD+GrqNumY5JRCDw==",
"version": "7.23.4",
"resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.23.4.tgz",
"integrity": "sha512-803gmbQdqwdf4olxrX4AJyFBV/RTr3rSmOj0rKwesmzlfhYNDEs+/iOcznzpNWlJlIlTJC2QfPFcHB6DlzdVLQ==",
"dev": true,
"engines": {
"node": ">=6.9.0"
@ -406,23 +406,23 @@
}
},
"node_modules/@babel/helpers": {
"version": "7.23.2",
"resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.23.2.tgz",
"integrity": "sha512-lzchcp8SjTSVe/fPmLwtWVBFC7+Tbn8LGHDVfDp9JGxpAY5opSaEFgt8UQvrnECWOTdji2mOWMz1rOhkHscmGQ==",
"version": "7.23.4",
"resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.23.4.tgz",
"integrity": "sha512-HfcMizYz10cr3h29VqyfGL6ZWIjTwWfvYBMsBVGwpcbhNGe3wQ1ZXZRPzZoAHhd9OqHadHqjQ89iVKINXnbzuw==",
"dev": true,
"dependencies": {
"@babel/template": "^7.22.15",
"@babel/traverse": "^7.23.2",
"@babel/types": "^7.23.0"
"@babel/traverse": "^7.23.4",
"@babel/types": "^7.23.4"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/highlight": {
"version": "7.22.20",
"resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.22.20.tgz",
"integrity": "sha512-dkdMCN3py0+ksCgYmGG8jKeGA/8Tk+gJwSYYlFGxG5lmhfKNoAy004YpLxpS1W2J8m/EK2Ew+yOs9pVRwO89mg==",
"version": "7.23.4",
"resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.23.4.tgz",
"integrity": "sha512-acGdbYSfp2WheJoJm/EBBBLh/ID8KDc64ISZ9DYtBmC8/Q204PZJLHyzeB5qMzJ5trcOkybd78M4x2KWsUq++A==",
"dev": true,
"dependencies": {
"@babel/helper-validator-identifier": "^7.22.20",
@ -434,9 +434,9 @@
}
},
"node_modules/@babel/parser": {
"version": "7.23.3",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.3.tgz",
"integrity": "sha512-uVsWNvlVsIninV2prNz/3lHCb+5CJ+e+IUBfbjToAHODtfGYLfCFuY4AU7TskI+dAKk+njsPiBjq1gKTvZOBaw==",
"version": "7.23.4",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.4.tgz",
"integrity": "sha512-vf3Xna6UEprW+7t6EtOmFpHNAuxw3xqPZghy+brsnusscJRW5BMUzzHZc5ICjULee81WeUV2jjakG09MDglJXQ==",
"dev": true,
"bin": {
"parser": "bin/babel-parser.js"
@ -756,9 +756,9 @@
}
},
"node_modules/@babel/plugin-transform-async-generator-functions": {
"version": "7.23.3",
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-async-generator-functions/-/plugin-transform-async-generator-functions-7.23.3.tgz",
"integrity": "sha512-59GsVNavGxAXCDDbakWSMJhajASb4kBCqDjqJsv+p5nKdbz7istmZ3HrX3L2LuiI80+zsOADCvooqQH3qGCucQ==",
"version": "7.23.4",
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-async-generator-functions/-/plugin-transform-async-generator-functions-7.23.4.tgz",
"integrity": "sha512-efdkfPhHYTtn0G6n2ddrESE91fgXxjlqLsnUtPWnJs4a4mZIbUaK7ffqKIIUKXSHwcDvaCVX6GXkaJJFqtX7jw==",
"dev": true,
"dependencies": {
"@babel/helper-environment-visitor": "^7.22.20",
@ -806,9 +806,9 @@
}
},
"node_modules/@babel/plugin-transform-block-scoping": {
"version": "7.23.3",
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.23.3.tgz",
"integrity": "sha512-QPZxHrThbQia7UdvfpaRRlq/J9ciz1J4go0k+lPBXbgaNeY7IQrBj/9ceWjvMMI07/ZBzHl/F0R/2K0qH7jCVw==",
"version": "7.23.4",
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.23.4.tgz",
"integrity": "sha512-0QqbP6B6HOh7/8iNR4CQU2Th/bbRtBp4KS9vcaZd1fZ0wSh5Fyssg0UCIHwxh+ka+pNDREbVLQnHCMHKZfPwfw==",
"dev": true,
"dependencies": {
"@babel/helper-plugin-utils": "^7.22.5"
@ -837,9 +837,9 @@
}
},
"node_modules/@babel/plugin-transform-class-static-block": {
"version": "7.23.3",
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-class-static-block/-/plugin-transform-class-static-block-7.23.3.tgz",
"integrity": "sha512-PENDVxdr7ZxKPyi5Ffc0LjXdnJyrJxyqF5T5YjlVg4a0VFfQHW0r8iAtRiDXkfHlu1wwcvdtnndGYIeJLSuRMQ==",
"version": "7.23.4",
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-class-static-block/-/plugin-transform-class-static-block-7.23.4.tgz",
"integrity": "sha512-nsWu/1M+ggti1SOALj3hfx5FXzAY06fwPJsUZD4/A5e1bWi46VUIWtD+kOX6/IdhXGsXBWllLFDSnqSCdUNydQ==",
"dev": true,
"dependencies": {
"@babel/helper-create-class-features-plugin": "^7.22.15",
@ -939,9 +939,9 @@
}
},
"node_modules/@babel/plugin-transform-dynamic-import": {
"version": "7.23.3",
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-dynamic-import/-/plugin-transform-dynamic-import-7.23.3.tgz",
"integrity": "sha512-vTG+cTGxPFou12Rj7ll+eD5yWeNl5/8xvQvF08y5Gv3v4mZQoyFf8/n9zg4q5vvCWt5jmgymfzMAldO7orBn7A==",
"version": "7.23.4",
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-dynamic-import/-/plugin-transform-dynamic-import-7.23.4.tgz",
"integrity": "sha512-V6jIbLhdJK86MaLh4Jpghi8ho5fGzt3imHOBu/x0jlBaPYqDoWz4RDXjmMOfnh+JWNaQleEAByZLV0QzBT4YQQ==",
"dev": true,
"dependencies": {
"@babel/helper-plugin-utils": "^7.22.5",
@ -971,9 +971,9 @@
}
},
"node_modules/@babel/plugin-transform-export-namespace-from": {
"version": "7.23.3",
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-export-namespace-from/-/plugin-transform-export-namespace-from-7.23.3.tgz",
"integrity": "sha512-yCLhW34wpJWRdTxxWtFZASJisihrfyMOTOQexhVzA78jlU+dH7Dw+zQgcPepQ5F3C6bAIiblZZ+qBggJdHiBAg==",
"version": "7.23.4",
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-export-namespace-from/-/plugin-transform-export-namespace-from-7.23.4.tgz",
"integrity": "sha512-GzuSBcKkx62dGzZI1WVgTWvkkz84FZO5TC5T8dl/Tht/rAla6Dg/Mz9Yhypg+ezVACf/rgDuQt3kbWEv7LdUDQ==",
"dev": true,
"dependencies": {
"@babel/helper-plugin-utils": "^7.22.5",
@ -1019,9 +1019,9 @@
}
},
"node_modules/@babel/plugin-transform-json-strings": {
"version": "7.23.3",
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-json-strings/-/plugin-transform-json-strings-7.23.3.tgz",
"integrity": "sha512-H9Ej2OiISIZowZHaBwF0tsJOih1PftXJtE8EWqlEIwpc7LMTGq0rPOrywKLQ4nefzx8/HMR0D3JGXoMHYvhi0A==",
"version": "7.23.4",
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-json-strings/-/plugin-transform-json-strings-7.23.4.tgz",
"integrity": "sha512-81nTOqM1dMwZ/aRXQ59zVubN9wHGqk6UtqRK+/q+ciXmRy8fSolhGVvG09HHRGo4l6fr/c4ZhXUQH0uFW7PZbg==",
"dev": true,
"dependencies": {
"@babel/helper-plugin-utils": "^7.22.5",
@ -1050,9 +1050,9 @@
}
},
"node_modules/@babel/plugin-transform-logical-assignment-operators": {
"version": "7.23.3",
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-logical-assignment-operators/-/plugin-transform-logical-assignment-operators-7.23.3.tgz",
"integrity": "sha512-+pD5ZbxofyOygEp+zZAfujY2ShNCXRpDRIPOiBmTO693hhyOEteZgl876Xs9SAHPQpcV0vz8LvA/T+w8AzyX8A==",
"version": "7.23.4",
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-logical-assignment-operators/-/plugin-transform-logical-assignment-operators-7.23.4.tgz",
"integrity": "sha512-Mc/ALf1rmZTP4JKKEhUwiORU+vcfarFVLfcFiolKUo6sewoxSEgl36ak5t+4WamRsNr6nzjZXQjM35WsU+9vbg==",
"dev": true,
"dependencies": {
"@babel/helper-plugin-utils": "^7.22.5",
@ -1179,9 +1179,9 @@
}
},
"node_modules/@babel/plugin-transform-nullish-coalescing-operator": {
"version": "7.23.3",
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-nullish-coalescing-operator/-/plugin-transform-nullish-coalescing-operator-7.23.3.tgz",
"integrity": "sha512-xzg24Lnld4DYIdysyf07zJ1P+iIfJpxtVFOzX4g+bsJ3Ng5Le7rXx9KwqKzuyaUeRnt+I1EICwQITqc0E2PmpA==",
"version": "7.23.4",
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-nullish-coalescing-operator/-/plugin-transform-nullish-coalescing-operator-7.23.4.tgz",
"integrity": "sha512-jHE9EVVqHKAQx+VePv5LLGHjmHSJR76vawFPTdlxR/LVJPfOEGxREQwQfjuZEOPTwG92X3LINSh3M40Rv4zpVA==",
"dev": true,
"dependencies": {
"@babel/helper-plugin-utils": "^7.22.5",
@ -1195,9 +1195,9 @@
}
},
"node_modules/@babel/plugin-transform-numeric-separator": {
"version": "7.23.3",
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-numeric-separator/-/plugin-transform-numeric-separator-7.23.3.tgz",
"integrity": "sha512-s9GO7fIBi/BLsZ0v3Rftr6Oe4t0ctJ8h4CCXfPoEJwmvAPMyNrfkOOJzm6b9PX9YXcCJWWQd/sBF/N26eBiMVw==",
"version": "7.23.4",
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-numeric-separator/-/plugin-transform-numeric-separator-7.23.4.tgz",
"integrity": "sha512-mps6auzgwjRrwKEZA05cOwuDc9FAzoyFS4ZsG/8F43bTLf/TgkJg7QXOrPO1JO599iA3qgK9MXdMGOEC8O1h6Q==",
"dev": true,
"dependencies": {
"@babel/helper-plugin-utils": "^7.22.5",
@ -1211,9 +1211,9 @@
}
},
"node_modules/@babel/plugin-transform-object-rest-spread": {
"version": "7.23.3",
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-object-rest-spread/-/plugin-transform-object-rest-spread-7.23.3.tgz",
"integrity": "sha512-VxHt0ANkDmu8TANdE9Kc0rndo/ccsmfe2Cx2y5sI4hu3AukHQ5wAu4cM7j3ba8B9548ijVyclBU+nuDQftZsog==",
"version": "7.23.4",
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-object-rest-spread/-/plugin-transform-object-rest-spread-7.23.4.tgz",
"integrity": "sha512-9x9K1YyeQVw0iOXJlIzwm8ltobIIv7j2iLyP2jIhEbqPRQ7ScNgwQufU2I0Gq11VjyG4gI4yMXt2VFags+1N3g==",
"dev": true,
"dependencies": {
"@babel/compat-data": "^7.23.3",
@ -1246,9 +1246,9 @@
}
},
"node_modules/@babel/plugin-transform-optional-catch-binding": {
"version": "7.23.3",
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-optional-catch-binding/-/plugin-transform-optional-catch-binding-7.23.3.tgz",
"integrity": "sha512-LxYSb0iLjUamfm7f1D7GpiS4j0UAC8AOiehnsGAP8BEsIX8EOi3qV6bbctw8M7ZvLtcoZfZX5Z7rN9PlWk0m5A==",
"version": "7.23.4",
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-optional-catch-binding/-/plugin-transform-optional-catch-binding-7.23.4.tgz",
"integrity": "sha512-XIq8t0rJPHf6Wvmbn9nFxU6ao4c7WhghTR5WyV8SrJfUFzyxhCm4nhC+iAp3HFhbAKLfYpgzhJ6t4XCtVwqO5A==",
"dev": true,
"dependencies": {
"@babel/helper-plugin-utils": "^7.22.5",
@ -1262,9 +1262,9 @@
}
},
"node_modules/@babel/plugin-transform-optional-chaining": {
"version": "7.23.3",
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-optional-chaining/-/plugin-transform-optional-chaining-7.23.3.tgz",
"integrity": "sha512-zvL8vIfIUgMccIAK1lxjvNv572JHFJIKb4MWBz5OGdBQA0fB0Xluix5rmOby48exiJc987neOmP/m9Fnpkz3Tg==",
"version": "7.23.4",
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-optional-chaining/-/plugin-transform-optional-chaining-7.23.4.tgz",
"integrity": "sha512-ZU8y5zWOfjM5vZ+asjgAPwDaBjJzgufjES89Rs4Lpq63O300R/kOz30WCLo6BxxX6QVEilwSlpClnG5cZaikTA==",
"dev": true,
"dependencies": {
"@babel/helper-plugin-utils": "^7.22.5",
@ -1310,9 +1310,9 @@
}
},
"node_modules/@babel/plugin-transform-private-property-in-object": {
"version": "7.23.3",
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-private-property-in-object/-/plugin-transform-private-property-in-object-7.23.3.tgz",
"integrity": "sha512-a5m2oLNFyje2e/rGKjVfAELTVI5mbA0FeZpBnkOWWV7eSmKQ+T/XW0Vf+29ScLzSxX+rnsarvU0oie/4m6hkxA==",
"version": "7.23.4",
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-private-property-in-object/-/plugin-transform-private-property-in-object-7.23.4.tgz",
"integrity": "sha512-9G3K1YqTq3F4Vt88Djx1UZ79PDyj+yKRnUy7cZGSMe+a7jkwD259uKKuUzQlPkGam7R+8RJwh5z4xO27fA1o2A==",
"dev": true,
"dependencies": {
"@babel/helper-annotate-as-pure": "^7.22.5",
@ -1627,9 +1627,9 @@
"dev": true
},
"node_modules/@babel/runtime": {
"version": "7.23.2",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.23.2.tgz",
"integrity": "sha512-mM8eg4yl5D6i3lu2QKPuPH4FArvJ8KhTofbE7jwMUv9KX5mBvwPAqnV3MlyBNqdp9RyRKP6Yck8TrfYrPvX3bg==",
"version": "7.23.4",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.23.4.tgz",
"integrity": "sha512-2Yv65nlWnWlSpe3fXEyX5i7fx5kIKo4Qbcj+hMO0odwaneFjfXw5fdum+4yL20O0QiaHpia0cYQ9xpNMqrBwHg==",
"dev": true,
"dependencies": {
"regenerator-runtime": "^0.14.0"
@ -1653,19 +1653,19 @@
}
},
"node_modules/@babel/traverse": {
"version": "7.23.3",
"resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.3.tgz",
"integrity": "sha512-+K0yF1/9yR0oHdE0StHuEj3uTPzwwbrLGfNOndVJVV2TqA5+j3oljJUb4nmB954FLGjNem976+B+eDuLIjesiQ==",
"version": "7.23.4",
"resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.4.tgz",
"integrity": "sha512-IYM8wSUwunWTB6tFC2dkKZhxbIjHoWemdK+3f8/wq8aKhbUscxD5MX72ubd90fxvFknaLPeGw5ycU84V1obHJg==",
"dev": true,
"dependencies": {
"@babel/code-frame": "^7.22.13",
"@babel/generator": "^7.23.3",
"@babel/code-frame": "^7.23.4",
"@babel/generator": "^7.23.4",
"@babel/helper-environment-visitor": "^7.22.20",
"@babel/helper-function-name": "^7.23.0",
"@babel/helper-hoist-variables": "^7.22.5",
"@babel/helper-split-export-declaration": "^7.22.6",
"@babel/parser": "^7.23.3",
"@babel/types": "^7.23.3",
"@babel/parser": "^7.23.4",
"@babel/types": "^7.23.4",
"debug": "^4.1.0",
"globals": "^11.1.0"
},
@ -1674,12 +1674,12 @@
}
},
"node_modules/@babel/types": {
"version": "7.23.3",
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.3.tgz",
"integrity": "sha512-OZnvoH2l8PK5eUvEcUyCt/sXgr/h+UWpVuBbOljwcrAgUl6lpchoQ++PHGyQy1AtYnVA6CEq3y5xeEI10brpXw==",
"version": "7.23.4",
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.4.tgz",
"integrity": "sha512-7uIFwVYpoplT5jp/kVv6EF93VaJ8H+Yn5IczYiaAi98ajzjfoZfslet/e0sLh+wVBjb2qqIut1b0S26VSafsSQ==",
"dev": true,
"dependencies": {
"@babel/helper-string-parser": "^7.22.5",
"@babel/helper-string-parser": "^7.23.4",
"@babel/helper-validator-identifier": "^7.22.20",
"to-fast-properties": "^2.0.0"
},
@ -1746,67 +1746,79 @@
}
},
"node_modules/@rollup/plugin-babel": {
"version": "5.3.1",
"resolved": "https://registry.npmjs.org/@rollup/plugin-babel/-/plugin-babel-5.3.1.tgz",
"integrity": "sha512-WFfdLWU/xVWKeRQnKmIAQULUI7Il0gZnBIH/ZFO069wYIfPu+8zrfp/KMW0atmELoRDq8FbiP3VCss9MhCut7Q==",
"version": "6.0.4",
"resolved": "https://registry.npmjs.org/@rollup/plugin-babel/-/plugin-babel-6.0.4.tgz",
"integrity": "sha512-YF7Y52kFdFT/xVSuVdjkV5ZdX/3YtmX0QulG+x0taQOtJdHYzVU61aSSkAgVJ7NOv6qPkIYiJSgSWWN/DM5sGw==",
"dev": true,
"dependencies": {
"@babel/helper-module-imports": "^7.10.4",
"@rollup/pluginutils": "^3.1.0"
"@babel/helper-module-imports": "^7.18.6",
"@rollup/pluginutils": "^5.0.1"
},
"engines": {
"node": ">= 10.0.0"
"node": ">=14.0.0"
},
"peerDependencies": {
"@babel/core": "^7.0.0",
"@types/babel__core": "^7.1.9",
"rollup": "^1.20.0||^2.0.0"
"rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0"
},
"peerDependenciesMeta": {
"@types/babel__core": {
"optional": true
},
"rollup": {
"optional": true
}
}
},
"node_modules/@rollup/plugin-commonjs": {
"version": "21.1.0",
"resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-21.1.0.tgz",
"integrity": "sha512-6ZtHx3VHIp2ReNNDxHjuUml6ur+WcQ28N1yHgCQwsbNkQg2suhxGMDQGJOn/KuDxKtd1xuZP5xSTwBA4GQ8hbA==",
"version": "25.0.7",
"resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-25.0.7.tgz",
"integrity": "sha512-nEvcR+LRjEjsaSsc4x3XZfCCvZIaSMenZu/OiwOKGN2UhQpAYI7ru7czFvyWbErlpoGjnSX3D5Ch5FcMA3kRWQ==",
"dev": true,
"dependencies": {
"@rollup/pluginutils": "^3.1.0",
"@rollup/pluginutils": "^5.0.1",
"commondir": "^1.0.1",
"estree-walker": "^2.0.1",
"glob": "^7.1.6",
"is-reference": "^1.2.1",
"magic-string": "^0.25.7",
"resolve": "^1.17.0"
"estree-walker": "^2.0.2",
"glob": "^8.0.3",
"is-reference": "1.2.1",
"magic-string": "^0.30.3"
},
"engines": {
"node": ">= 8.0.0"
"node": ">=14.0.0"
},
"peerDependencies": {
"rollup": "^2.38.3"
"rollup": "^2.68.0||^3.0.0||^4.0.0"
},
"peerDependenciesMeta": {
"rollup": {
"optional": true
}
}
},
"node_modules/@rollup/plugin-node-resolve": {
"version": "13.3.0",
"resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-13.3.0.tgz",
"integrity": "sha512-Lus8rbUo1eEcnS4yTFKLZrVumLPY+YayBdWXgFSHYhTT2iJbMhoaaBL3xl5NCdeRytErGr8tZ0L71BMRmnlwSw==",
"version": "15.2.3",
"resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-15.2.3.tgz",
"integrity": "sha512-j/lym8nf5E21LwBT4Df1VD6hRO2L2iwUeUmP7litikRsVp1H6NWx20NEp0Y7su+7XGc476GnXXc4kFeZNGmaSQ==",
"dev": true,
"dependencies": {
"@rollup/pluginutils": "^3.1.0",
"@types/resolve": "1.17.1",
"@rollup/pluginutils": "^5.0.1",
"@types/resolve": "1.20.2",
"deepmerge": "^4.2.2",
"is-builtin-module": "^3.1.0",
"is-builtin-module": "^3.2.1",
"is-module": "^1.0.0",
"resolve": "^1.19.0"
"resolve": "^1.22.1"
},
"engines": {
"node": ">= 10.0.0"
"node": ">=14.0.0"
},
"peerDependencies": {
"rollup": "^2.42.0"
"rollup": "^2.78.0||^3.0.0||^4.0.0"
},
"peerDependenciesMeta": {
"rollup": {
"optional": true
}
}
},
"node_modules/@rollup/plugin-replace": {
@ -1830,7 +1842,7 @@
}
}
},
"node_modules/@rollup/plugin-replace/node_modules/@rollup/pluginutils": {
"node_modules/@rollup/pluginutils": {
"version": "5.0.5",
"resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.0.5.tgz",
"integrity": "sha512-6aEYR910NyP73oHiJglti74iRyOwgFU4x3meH/H8OJx6Ry0j6cOVZ5X/wTvub7G7Ao6qaHBEaNsV3GLJkSsF+Q==",
@ -1852,47 +1864,6 @@
}
}
},
"node_modules/@rollup/plugin-replace/node_modules/magic-string": {
"version": "0.30.5",
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.5.tgz",
"integrity": "sha512-7xlpfBaQaP/T6Vh8MO/EqXSW5En6INHEvEXQiuff7Gku0PWjU3uf6w/j9o7O+SpB5fOAkrI5HeoNgwjEO0pFsA==",
"dev": true,
"dependencies": {
"@jridgewell/sourcemap-codec": "^1.4.15"
},
"engines": {
"node": ">=12"
}
},
"node_modules/@rollup/pluginutils": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.1.0.tgz",
"integrity": "sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==",
"dev": true,
"dependencies": {
"@types/estree": "0.0.39",
"estree-walker": "^1.0.1",
"picomatch": "^2.2.2"
},
"engines": {
"node": ">= 8.0.0"
},
"peerDependencies": {
"rollup": "^1.20.0||^2.0.0"
}
},
"node_modules/@rollup/pluginutils/node_modules/@types/estree": {
"version": "0.0.39",
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz",
"integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==",
"dev": true
},
"node_modules/@rollup/pluginutils/node_modules/estree-walker": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz",
"integrity": "sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==",
"dev": true
},
"node_modules/@types/estree": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz",
@ -1900,22 +1871,19 @@
"dev": true
},
"node_modules/@types/node": {
"version": "20.9.2",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.9.2.tgz",
"integrity": "sha512-WHZXKFCEyIUJzAwh3NyyTHYSR35SevJ6mZ1nWwJafKtiQbqRTIKSRcw3Ma3acqgsent3RRDqeVwpHntMk+9irg==",
"version": "20.10.0",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.0.tgz",
"integrity": "sha512-D0WfRmU9TQ8I9PFx9Yc+EBHw+vSpIub4IDvQivcp26PtPrdMGAq5SDcpXEo/epqa/DXotVpekHiLNTg3iaKXBQ==",
"dev": true,
"dependencies": {
"undici-types": "~5.26.4"
}
},
"node_modules/@types/resolve": {
"version": "1.17.1",
"resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.17.1.tgz",
"integrity": "sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw==",
"dev": true,
"dependencies": {
"@types/node": "*"
}
"version": "1.20.2",
"resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.20.2.tgz",
"integrity": "sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==",
"dev": true
},
"node_modules/acorn": {
"version": "8.11.2",
@ -1996,13 +1964,12 @@
"dev": true
},
"node_modules/brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
"integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
"dev": true,
"dependencies": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
"balanced-match": "^1.0.0"
}
},
"node_modules/browserslist": {
@ -2056,9 +2023,9 @@
}
},
"node_modules/caniuse-lite": {
"version": "1.0.30001563",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001563.tgz",
"integrity": "sha512-na2WUmOxnwIZtwnFI2CZ/3er0wdNzU7hN+cPYz/z2ajHThnkWjNBOpEPP4n+4r2WPM847JaMotaJE3bnfzjyKw==",
"version": "1.0.30001565",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001565.tgz",
"integrity": "sha512-xrE//a3O7TP0vaJ8ikzkD2c2NgcVUvsEe2IvFTntV4Yd1Z9FVzh+gW+enX96L0psrbaFMcVcH2l90xNuGDWc8w==",
"dev": true,
"funding": [
{
@ -2089,27 +2056,6 @@
"node": ">=4"
}
},
"node_modules/chalk/node_modules/has-flag": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
"integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==",
"dev": true,
"engines": {
"node": ">=4"
}
},
"node_modules/chalk/node_modules/supports-color": {
"version": "5.5.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
"integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
"dev": true,
"dependencies": {
"has-flag": "^3.0.0"
},
"engines": {
"node": ">=4"
}
},
"node_modules/color-convert": {
"version": "1.9.3",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
@ -2195,9 +2141,9 @@
}
},
"node_modules/electron-to-chromium": {
"version": "1.4.588",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.588.tgz",
"integrity": "sha512-soytjxwbgcCu7nh5Pf4S2/4wa6UIu+A3p03U2yVr53qGxi1/VTR3ENI+p50v+UxqqZAfl48j3z55ud7VHIOr9w==",
"version": "1.4.595",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.595.tgz",
"integrity": "sha512-+ozvXuamBhDOKvMNUQvecxfbyICmIAwS4GpLmR0bsiSBlGnLaOcs2Cj7J8XSbW+YEaN3Xl3ffgpm+srTUWFwFQ==",
"dev": true
},
"node_modules/escalade": {
@ -2272,20 +2218,19 @@
}
},
"node_modules/glob": {
"version": "7.2.3",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz",
"integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==",
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz",
"integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==",
"dev": true,
"dependencies": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
"inherits": "2",
"minimatch": "^3.1.1",
"once": "^1.3.0",
"path-is-absolute": "^1.0.0"
"minimatch": "^5.0.1",
"once": "^1.3.0"
},
"engines": {
"node": "*"
"node": ">=12"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
@ -2301,12 +2246,12 @@
}
},
"node_modules/has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
"integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==",
"dev": true,
"engines": {
"node": ">=8"
"node": ">=4"
}
},
"node_modules/hasown": {
@ -2379,6 +2324,41 @@
"@types/estree": "*"
}
},
"node_modules/jest-worker": {
"version": "26.6.2",
"resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-26.6.2.tgz",
"integrity": "sha512-KWYVV1c4i+jbMpaBC+U++4Va0cp8OisU185o73T1vo99hqi7w8tSJfUXYswwqqrjzwxa6KpRK54WhPvwf5w6PQ==",
"dev": true,
"dependencies": {
"@types/node": "*",
"merge-stream": "^2.0.0",
"supports-color": "^7.0.0"
},
"engines": {
"node": ">= 10.13.0"
}
},
"node_modules/jest-worker/node_modules/has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"dev": true,
"engines": {
"node": ">=8"
}
},
"node_modules/jest-worker/node_modules/supports-color": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"dev": true,
"dependencies": {
"has-flag": "^4.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/js-tokens": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
@ -2431,12 +2411,15 @@
}
},
"node_modules/magic-string": {
"version": "0.25.9",
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.9.tgz",
"integrity": "sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ==",
"version": "0.30.5",
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.5.tgz",
"integrity": "sha512-7xlpfBaQaP/T6Vh8MO/EqXSW5En6INHEvEXQiuff7Gku0PWjU3uf6w/j9o7O+SpB5fOAkrI5HeoNgwjEO0pFsA==",
"dev": true,
"dependencies": {
"sourcemap-codec": "^1.4.8"
"@jridgewell/sourcemap-codec": "^1.4.15"
},
"engines": {
"node": ">=12"
}
},
"node_modules/merge-stream": {
@ -2446,29 +2429,32 @@
"dev": true
},
"node_modules/minimatch": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
"integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
"version": "5.1.6",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz",
"integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==",
"dev": true,
"dependencies": {
"brace-expansion": "^1.1.7"
},
"engines": {
"node": "*"
}
},
"node_modules/mkdirp": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz",
"integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==",
"dev": true,
"bin": {
"mkdirp": "bin/cmd.js"
"brace-expansion": "^2.0.1"
},
"engines": {
"node": ">=10"
}
},
"node_modules/mkdirp": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-3.0.1.tgz",
"integrity": "sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg==",
"dev": true,
"bin": {
"mkdirp": "dist/cjs/src/bin.js"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/moment": {
"version": "2.29.4",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz",
@ -2657,38 +2643,68 @@
}
},
"node_modules/rollup-plugin-license": {
"version": "2.9.1",
"resolved": "https://registry.npmjs.org/rollup-plugin-license/-/rollup-plugin-license-2.9.1.tgz",
"integrity": "sha512-C26f/bFXR52tzpBMllDnf5m2ETqRuyrrj3m8i3YY4imDwbXtunop+Lj1mO9mn/sZF8gKknOycN1Sm+kMGBd6RA==",
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/rollup-plugin-license/-/rollup-plugin-license-3.2.0.tgz",
"integrity": "sha512-gLtSOTE3hZ/mDgxg1HvYz87timTpLlyWXnV7OTyYMhn+Esek+xKxAOjtTsYnfMFGtsBWX+hvqC4b2Ct5ABpE6A==",
"dev": true,
"dependencies": {
"commenting": "~1.1.0",
"glob": "~7.2.0",
"lodash": "~4.17.21",
"magic-string": "~0.26.2",
"mkdirp": "~1.0.4",
"magic-string": "~0.30.0",
"mkdirp": "~3.0.0",
"moment": "~2.29.3",
"package-name-regex": "~2.0.6",
"spdx-expression-validate": "~2.0.0",
"spdx-satisfies": "~5.0.1"
},
"engines": {
"node": ">=10.0.0"
"node": ">=14.0.0"
},
"peerDependencies": {
"rollup": "^1.0.0 || ^2.0.0"
"rollup": "^1.0.0 || ^2.0.0 || ^3.0.0 || ^4.0.0"
}
},
"node_modules/rollup-plugin-license/node_modules/magic-string": {
"version": "0.26.7",
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.26.7.tgz",
"integrity": "sha512-hX9XH3ziStPoPhJxLq1syWuZMxbDvGNbVchfrdCtanC7D13888bMFow61x8axrx+GfHLtVeAx2kxL7tTGRl+Ow==",
"node_modules/rollup-plugin-license/node_modules/brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"dev": true,
"dependencies": {
"sourcemap-codec": "^1.4.8"
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
}
},
"node_modules/rollup-plugin-license/node_modules/glob": {
"version": "7.2.3",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz",
"integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==",
"dev": true,
"dependencies": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
"inherits": "2",
"minimatch": "^3.1.1",
"once": "^1.3.0",
"path-is-absolute": "^1.0.0"
},
"engines": {
"node": ">=12"
"node": "*"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/rollup-plugin-license/node_modules/minimatch": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
"integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
"dev": true,
"dependencies": {
"brace-expansion": "^1.1.7"
},
"engines": {
"node": "*"
}
},
"node_modules/rollup-plugin-terser": {
@ -2707,41 +2723,6 @@
"rollup": "^2.0.0"
}
},
"node_modules/rollup-plugin-terser/node_modules/jest-worker": {
"version": "26.6.2",
"resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-26.6.2.tgz",
"integrity": "sha512-KWYVV1c4i+jbMpaBC+U++4Va0cp8OisU185o73T1vo99hqi7w8tSJfUXYswwqqrjzwxa6KpRK54WhPvwf5w6PQ==",
"dev": true,
"dependencies": {
"@types/node": "*",
"merge-stream": "^2.0.0",
"supports-color": "^7.0.0"
},
"engines": {
"node": ">= 10.13.0"
}
},
"node_modules/rollup-plugin-terser/node_modules/serialize-javascript": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-4.0.0.tgz",
"integrity": "sha512-GaNA54380uFefWghODBWEGisLZFj00nS5ACs6yHa9nLqlLpVLO8ChDGeKRjZnV4Nh4n0Qi7nhYZD/9fCPzEqkw==",
"dev": true,
"dependencies": {
"randombytes": "^2.1.0"
}
},
"node_modules/rollup-plugin-terser/node_modules/supports-color": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"dev": true,
"dependencies": {
"has-flag": "^4.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
@ -2771,6 +2752,15 @@
"semver": "bin/semver.js"
}
},
"node_modules/serialize-javascript": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-4.0.0.tgz",
"integrity": "sha512-GaNA54380uFefWghODBWEGisLZFj00nS5ACs6yHa9nLqlLpVLO8ChDGeKRjZnV4Nh4n0Qi7nhYZD/9fCPzEqkw==",
"dev": true,
"dependencies": {
"randombytes": "^2.1.0"
}
},
"node_modules/source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
@ -2790,13 +2780,6 @@
"source-map": "^0.6.0"
}
},
"node_modules/sourcemap-codec": {
"version": "1.4.8",
"resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz",
"integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==",
"deprecated": "Please use @jridgewell/sourcemap-codec instead",
"dev": true
},
"node_modules/spdx-compare": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/spdx-compare/-/spdx-compare-1.0.0.tgz",
@ -2856,6 +2839,18 @@
"spdx-ranges": "^2.0.0"
}
},
"node_modules/supports-color": {
"version": "5.5.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
"integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
"dev": true,
"dependencies": {
"has-flag": "^3.0.0"
},
"engines": {
"node": ">=4"
}
},
"node_modules/supports-preserve-symlinks-flag": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz",

View File

@ -2,7 +2,7 @@
"name": "getbible.loader",
"title": "getBible",
"description": "GetBible is an intuitive and lightweight JavaScript solution for embedding Bible scripture into your website.",
"version": "3.0.0",
"version": "3.0.1",
"main": "dist/js/getBible.min.js",
"scripts": {
"build": "rollup -c"
@ -19,14 +19,14 @@
"dependencies": {
},
"devDependencies": {
"@babel/core": "^7.15.0",
"@babel/preset-env": "^7.15.0",
"@rollup/plugin-babel": "^5.3.0",
"@rollup/plugin-commonjs": "^21.0.0",
"@rollup/plugin-node-resolve": "^13.0.0",
"rollup": "^2.60.0",
"rollup-plugin-terser": "^7.0.0",
"rollup-plugin-license": "^2.3.0",
"@rollup/plugin-replace": "^5.0.5"
"@babel/core": "latest",
"@babel/preset-env": "latest",
"@rollup/plugin-babel": "latest",
"@rollup/plugin-commonjs": "latest",
"@rollup/plugin-node-resolve": "latest",
"rollup": "latest",
"rollup-plugin-terser": "latest",
"rollup-plugin-license": "latest",
"@rollup/plugin-replace": "latest"
}
}

106
src/js/core/Action.js Normal file
View File

@ -0,0 +1,106 @@
/**
* Class for managing actions based on element data attributes.
*/
export class Action {
#element;
#format;
#translations;
#showBookName;
#showReference;
#showTranslation;
#showAbbreviation;
#showLanguage;
/**
* Initializes the Actions object with a DOM element and its data attributes.
*
* @param {HTMLElement} element - The DOM element containing data attributes.
*/
constructor(element) {
if (!(element instanceof HTMLElement)) {
throw new Error("triggerElement must be an instance of HTMLElement.");
}
this.#element = element;
this.#format = (element.dataset.format || 'inline').toLowerCase();
this.#translations = (element.dataset.translation || 'kjv').toLowerCase().split(';').map(translation => translation.trim());
this.#showBookName = element.dataset.showBookName ? parseInt(element.dataset.showBookName, 10) : 0;
this.#showReference = element.dataset.showReference ? parseInt(element.dataset.showReference, 10) : 1;
this.#showTranslation = element.dataset.showTranslation ? parseInt(element.dataset.showTranslation, 10) : 0;
this.#showAbbreviation = element.dataset.showAbbreviation ? parseInt(element.dataset.showAbbreviation, 10) : 0;
this.#showLanguage = element.dataset.showLanguage ? parseInt(element.dataset.showLanguage, 10) : 0;
}
/**
* Retrieves the translations.
*
* @returns {Array<string>} An array of translation strings.
*/
getTranslations() {
return this.#translations;
}
/**
* Retrieves the show book name flag.
*
* @returns {number} The show book name flag (0 or 1).
*/
showBookName() {
return this.#showBookName;
}
/**
* Retrieves the show reference flag.
*
* @returns {number} The show reference flag (0 or 1).
*/
showReference() {
return this.#showReference;
}
/**
* Retrieves the show translation flag.
*
* @returns {number} The show translation flag (0 or 1).
*/
showTranslation() {
return this.#showTranslation;
}
/**
* Retrieves the show abbreviation flag.
*
* @returns {number} The show abbreviation flag (0 or 1).
*/
showAbbreviation() {
return this.#showAbbreviation;
}
/**
* Retrieves the show language flag.
*
* @returns {number} The show language flag (0 or 1).
*/
showLanguage() {
return this.#showLanguage;
}
/**
* Retrieves the element format.
*
* @returns {string} The element format.
*/
getFormat() {
return this.#format;
}
/**
* Retrieves the DOM element.
*
* @returns {HTMLElement} The DOM element associated with this object.
*/
getElement() {
return this.#element;
}
}

View File

@ -1,4 +1,4 @@
import { Memory } from './Memory.js';
import {Memory} from './Memory.js';
/**
* Class for handling API calls to fetch scripture data.

View File

@ -1,72 +1,110 @@
import { Api } from './Api.js';
import { Format } from '../formats/Format.js';
import { Element } from '../elements/Element.js';
import {Api} from './Api.js';
import {Scripture} from './Scripture.js';
import {Action} from './Action.js';
import {Format} from '../formats/Format.js';
import {Element} from '../elements/Element.js';
/**
* Loader class responsible for handling the loading of Bible references.
* Loader class responsible for handling the loading of Reference references.
* It initializes necessary components and loads data into a specified HTML element.
*/
export class Loader {
/**
* Constructs a Loader instance.
*/
constructor() {
this.api = new Api();
#api;
#action;
#element;
#format;
#pattern = /^(?=.*\p{Letter})(?=.*\d)(?=.*:).{1,30}$/u;
/**
* Constructs a Loader instance.
* Allows for dependency injection of the Api class for easier testing and flexibility.
* @param {Api} api - Instance of Api class for making API calls.
*/
constructor(api = new Api()) {
this.#api = api;
}
/**
* Load the Reference references into the specified HTML element.
* This method extracts references from the element, validates them, and loads each valid reference.
* @param {HTMLElement} element - The element to load Reference references into.
*/
async load(element) {
const references = element.innerHTML.split(';').map(ref => ref.trim());
if (references.length === 0) {
console.error("No references found in the getBible tagged class.");
return;
}
/**
* Load the Bible references into the specified HTML element.
*
* @param {HTMLElement} element - The element to load Bible references into.
*/
load(element) {
const references = element.innerHTML.split(';');
if (references) {
this.#init(element);
const translations = (element.dataset.translation || 'kjv').toLowerCase().split(';');
this.showBookName = element.dataset.showBookName ? parseInt(element.dataset.showBookName, 10) : 1;
this.showTranslation = element.dataset.showTranslation ? parseInt(element.dataset.showTranslation, 10) : 0;
this.showAbbreviation = element.dataset.showAbbreviation ? parseInt(element.dataset.showAbbreviation, 10) : 0;
this.showLanguage = element.dataset.showLanguage ? parseInt(element.dataset.showLanguage, 10) : 0;
const validReferences = this.#validateReferences(references);
if (validReferences.length === 0) {
console.error("No valid references found in the getBible tagged class.");
return;
}
references.forEach(reference => {
translations.forEach(translation => {
this.api.get(reference.trim(), translation.trim()).then(scripture => {
if (scripture) {
this.#load(scripture);
}
}).catch(error => console.error(error));
});
});
this.#init(element);
await this.#processReferences(validReferences);
}
/**
* Validates a list of references against the specified pattern.
* Invalid references are logged and excluded from the return value.
* @param {string[]} references - The array of references to validate.
* @returns {string[]} A filtered array of valid references.
* @private
*/
#validateReferences(references) {
return references.filter(reference => {
if (!this.#pattern.test(reference)) {
console.error(`Invalid getBible reference: ${reference}`);
return false;
}
return true;
});
}
/**
* Processes each valid reference by fetching translations and loading the scripture.
* This method handles the asynchronous nature of API calls.
* @param {string[]} validReferences - Array of valid references to be processed.
* @private
*/
async #processReferences(validReferences) {
for (const reference of validReferences) {
for (const translation of this.#action.getTranslations()) {
try {
const scripture = await this.#api.get(reference, translation);
if (scripture) {
this.#load(scripture);
}
} catch (error) {
console.error(`Error loading reference ${reference}:`, error);
}
}
}
}
/**
* Initialize the target format and element for loading the Bible.
*
* @param {HTMLElement} element - The element to be initialized.
* @private
*/
#init(element) {
const format = (element.dataset.format || 'inline').toLowerCase();
this.element = new Element(element, format);
this.format = new Format(format);
}
/**
* Initializes components necessary for loading references.
* This includes action, element, and format components.
* @param {HTMLElement} element - The element to be initialized for loading.
* @private
*/
#init(element) {
this.#action = new Action(element);
this.#element = new Element(this.#action);
this.#format = new Format(this.#action);
}
/**
* Load the Bible data in the target format into the initialized element.
*
* @param {Object} data - The data containing verses and their details.
* @private
*/
#load(data) {
this.element.load(
this.format.get(
data,
this.showBookName,
this.showTranslation,
this.showAbbreviation,
this.showLanguage
)
);
}
/**
* Loads the scripture data into the initialized element in the specified format.
* This method is responsible for the final rendering of scripture data.
* @param {Object} scripture - The data containing verses and their details.
* @private
*/
#load(scripture) {
this.#element.load(this.#format.get(new Scripture(scripture)));
}
}

View File

@ -2,77 +2,77 @@
* Class for managing local storage of scripture data.
*/
export class Memory {
// Constant representing one month in milliseconds.
static ONE_MONTH_IN_MILLISECONDS = 30 * 24 * 60 * 60 * 1000;
// Constant representing one month in milliseconds.
static ONE_MONTH_IN_MILLISECONDS = 30 * 24 * 60 * 60 * 1000;
/**
* Stores scripture data in local storage.
*
* @param {string} reference - The scripture reference.
* @param {string} translation - The translation.
* @param {Object} data - The scripture data to be stored.
* @throws {Error} If storing data fails.
*/
static set(reference, translation, data) {
const key = this.#key(reference, translation);
const item = {
data,
timestamp: Date.now(),
};
try {
localStorage.setItem(key, JSON.stringify(item));
} catch (error) {
console.error('Error storing data in local storage:', error);
throw error;
/**
* Stores scripture data in local storage.
*
* @param {string} reference - The scripture reference.
* @param {string} translation - The translation.
* @param {Object} data - The scripture data to be stored.
* @throws {Error} If storing data fails.
*/
static set(reference, translation, data) {
const key = this.#key(reference, translation);
const item = {
data,
timestamp: Date.now(),
};
try {
localStorage.setItem(key, JSON.stringify(item));
} catch (error) {
console.error('Error storing data in local storage:', error);
throw error;
}
}
/**
* Retrieves scripture data from local storage.
*
* @param {string} reference - The scripture reference.
* @param {string} translation - The translation.
* @returns {Promise<Object|null>} The scripture data or null if not found.
*/
static async get(reference, translation) {
return this.#get(reference, translation);
}
/**
* Internal method to check local storage for scripture data.
*
* @param {string} reference - The scripture reference.
* @param {string} translation - The translation.
* @returns {Object|null} The stored data or null if not found.
* @throws {Error} If parsing or retrieval from local storage fails.
* @private
*/
static #get(reference, translation) {
const key = this.#key(reference, translation);
try {
const storedItem = localStorage.getItem(key);
if (storedItem) {
const {data, timestamp} = JSON.parse(storedItem);
if (timestamp > Date.now() - Memory.ONE_MONTH_IN_MILLISECONDS) {
return data;
}
}
return null;
} catch (error) {
console.error('Error parsing or retrieving data from local storage:', error);
throw error;
}
}
/**
* Retrieves scripture data from local storage.
*
* @param {string} reference - The scripture reference.
* @param {string} translation - The translation.
* @returns {Promise<Object|null>} The scripture data or null if not found.
*/
static async get(reference, translation) {
return this.#get(reference, translation);
}
/**
* Internal method to check local storage for scripture data.
*
* @param {string} reference - The scripture reference.
* @param {string} translation - The translation.
* @returns {Object|null} The stored data or null if not found.
* @throws {Error} If parsing or retrieval from local storage fails.
* @private
*/
static #get(reference, translation) {
const key = this.#key(reference, translation);
try {
const storedItem = localStorage.getItem(key);
if (storedItem) {
const { data, timestamp } = JSON.parse(storedItem);
if (timestamp > Date.now() - Memory.ONE_MONTH_IN_MILLISECONDS) {
return data;
}
}
return null;
} catch (error) {
console.error('Error parsing or retrieving data from local storage:', error);
throw error;
}
}
/**
* Generates a key for scripture data storage.
*
* @param {string} reference - The scripture reference.
* @param {string} translation - The translation.
* @returns {string} A unique key for local storage.
* @private
*/
static #key(reference, translation) {
return `getBible-${translation}-${reference}`;
}
/**
* Generates a key for scripture data storage.
*
* @param {string} reference - The scripture reference.
* @param {string} translation - The translation.
* @returns {string} A unique key for local storage.
* @private
*/
static #key(reference, translation) {
return `getBible-${translation}-${reference}`;
}
}

170
src/js/core/Reference.js Normal file
View File

@ -0,0 +1,170 @@
/**
* Class for handling chapter data.
*/
export class Reference {
#data; // Private data member
/**
* Initializes the BibleVerse object with verse data.
*
* @param {Object} data - The JSON data containing verse information.
*/
constructor(data) {
this.#data = data;
}
/**
* Retrieves the translation name.
*
* @returns {string} The name of the translation.
*/
getTranslation() {
return this.#data.translation;
}
/**
* Retrieves the abbreviation of the translation.
*
* @returns {string} The abbreviation of the translation.
*/
getAbbreviation() {
return this.#data.abbreviation;
}
/**
* Retrieves the language code.
*
* @returns {string} The language code.
*/
getLanguage() {
return this.#data.lang;
}
/**
* Retrieves the full language name.
*
* @returns {string} The full name of the language.
*/
getLanguageName() {
return this.#data.language;
}
/**
* Retrieves the text direction.
*
* @returns {string} The direction of the text (LTR or RTL).
*/
getTextDirection() {
return this.#data.direction;
}
/**
* Retrieves the encoding format.
*
* @returns {string} The encoding format (e.g., UTF-8).
*/
getEncoding() {
return this.#data.encoding;
}
/**
* Retrieves the book number.
*
* @returns {number} The book number.
*/
getBookNumber() {
return this.#data.book_nr;
}
/**
* Retrieves the name of the book.
*
* @returns {string} The name of the book.
*/
getBookName() {
return this.#data.book_name;
}
/**
* Retrieves the chapter number.
*
* @returns {number} The chapter number.
*/
getChapter() {
return this.#data.chapter;
}
/**
* Retrieves the name of the chapter.
*
* @returns {string} The name of the chapter.
*/
getChapterName() {
return this.#data.name;
}
/**
* Retrieves all verses of the chapter.
*
* @returns {Array<Object>} An array of objects representing each verse.
*/
getVerses() {
return this.#data.verses;
}
/**
* Retrieves a specific verse by its number.
*
* @param {number} verseNumber - The number of the verse to retrieve.
* @returns {Object|null} The verse object if found, or null if not.
*/
getVerse(verseNumber) {
return this.#data.verses.find(verse => verse.verse === verseNumber);
}
/**
* Retrieves a range of verses.
*
* @param {number} startVerse - The starting verse number.
* @param {number} endVerse - The ending verse number.
* @returns {Array<Object>} An array of verse objects within the range.
*/
getVersesInRange(startVerse, endVerse) {
return this.#data.verses.filter(verse => verse.verse >= startVerse && verse.verse <= endVerse);
}
/**
* Generates a reference string for the verses.
*
* @returns {string} The reference string.
*/
getReference() {
const verseNumbers = this.#data.verses.map(verse => verse.verse).sort((a, b) => a - b);
let refString = `${this.#data.name}:`;
let ranges = {};
let rangeStart = null;
let rangeEnd = null;
let previousVerse = null;
verseNumbers.forEach(verse => {
if (rangeStart === null) {
rangeStart = verse;
} else if (verse === previousVerse + 1) {
rangeEnd = verse;
} else {
ranges[rangeStart] = (rangeEnd !== null) ? `${rangeStart}-${rangeEnd}` : `${rangeStart}`;
rangeStart = verse;
rangeEnd = null;
}
previousVerse = verse;
});
// Handling the case for the last verse or a single-verse range
if (rangeStart !== null) {
ranges[rangeStart] = (rangeEnd !== null) ? `${rangeStart}-${rangeEnd}` : `${rangeStart}`;
}
// Join the range strings with commas
return refString + Object.values(ranges).join(',');
}
}

46
src/js/core/Scripture.js Normal file
View File

@ -0,0 +1,46 @@
import {Reference} from './Reference.js';
/**
* Class for handling Scripture.
*/
export class Scripture {
#references; // Private array for storing references
/**
* Initializes the Bible translations, books, and chapters.
*
* @param {Object} data - An object with references data keyed by identifiers.
*/
constructor(data) {
this.#references = Object.values(data).map(reference => new Reference(reference));
}
/**
* Gets a reference by its numerical index.
*
* @param {number} index - The index of the reference.
* @returns {Reference|null} The Reference instance or null if out of bounds.
*/
getReference(index) {
return (index >= 0 && index < this.#references.length) ? this.#references[index] : null;
}
/**
* Gets the translation.
*
* @param {number} index - The index of the reference.
* @returns {Reference|null} The Reference instance or null if out of bounds.
*/
getReference(index) {
return (index >= 0 && index < this.#references.length) ? this.#references[index] : null;
}
/**
* Iterates over all references and performs a callback function.
*
* @param {Function} callback - The callback function to execute for each chapter.
*/
forEachReference(callback) {
this.#references.forEach(callback);
}
}

View File

@ -1,43 +1,40 @@
import { ModalElement } from './ModalElement.js';
import { InlineElement } from './InlineElement.js';
import { TooltipElement } from './TooltipElement.js';
import {Action} from '../core/Action.js';
import {ModalElement} from './ModalElement.js';
import {InlineElement} from './InlineElement.js';
import {TooltipElement} from './TooltipElement.js';
/**
* Element class responsible for creating and managing different types of elements
* based on the specified format.
*/
export class Element {
/**
* Constructs an Element instance based on the given format.
*
* @param {HTMLElement} triggerElement - The trigger element.
* @param {string} format - The format type.
*/
constructor(triggerElement, format = 'tooltip') {
if (!(triggerElement instanceof HTMLElement)) {
throw new Error("triggerElement must be an instance of HTMLElement.");
}
/**
* Constructs an Element instance based on the given format.
*
* @param {Action} action - The action element that triggers the inline display.
*/
constructor(action) {
const elementTypes = {
'modal': ModalElement,
'inline': InlineElement,
'tooltip': TooltipElement
};
const elementTypes = {
'modal': ModalElement,
'inline': InlineElement,
'tooltip': TooltipElement
};
const format = action.getFormat();
const ElementType = elementTypes[format] || InlineElement;
this.element = new ElementType(action);
const ElementType = elementTypes[format] || TooltipElement;
this.element = new ElementType(triggerElement);
if (process.env.DEBUG) {
console.log(`${format} element selected`);
}
if (process.env.DEBUG) {
console.log(`${format} element selected`);
}
}
/**
* Load the content into the element.
*
* @param {string} content - The content to load.
*/
load(content) {
this.element.load(content);
}
/**
* Load the content into the element.
*
* @param {string} content - The content to load.
*/
load(content) {
this.element.load(content);
}
}

View File

@ -1,28 +1,38 @@
import {Action} from '../core/Action.js';
/**
* InlineElement class responsible for adding inline elements.
*/
export class InlineElement {
/**
* Creates an instance of InlineElement.
*
* @param {HTMLElement} triggerElement - The element that triggers the inline display.
*/
constructor(triggerElement) {
if (!(triggerElement instanceof HTMLElement)) {
throw new Error("triggerElement must be an instance of HTMLElement.");
}
this.triggerElement = triggerElement;
// Clear initial content
this.triggerElement.innerHTML = '';
}
#action;
/**
* Loads content into the trigger element. Appends new content if existing content is present.
*
* @param {string} content - The content to load into the trigger element.
*/
load(content) {
const existingContent = this.triggerElement.innerHTML;
this.triggerElement.innerHTML = existingContent ? `${existingContent}\n ${content}` : content;
}
/**
* Creates an instance of InlineElement.
*
* @param {Action} action - The action element that triggers the inline display.
*/
constructor(action) {
this.#action = action;
// Clear initial content
this.getElement().innerHTML = '';
}
/**
* Loads content into the trigger element. Appends new content if existing content is present.
*
* @param {string} content - The content to load into the trigger element.
*/
load(content) {
const existingContent = this.getElement().innerHTML;
this.getElement().innerHTML = existingContent ? `${existingContent}\n ${content}` : content;
}
/**
* Get the action element
*
* @returns {HTMLElement} - The DOM element being worked with.
*/
getElement() {
return this.#action.getElement();
}
}

View File

@ -1,8 +1,9 @@
import { BaseModal } from './modals/BaseModal.js';
import { UikitModal } from './modals/UikitModal.js';
import { BootstrapModal } from './modals/BootstrapModal.js';
import { FoundationModal } from './modals/FoundationModal.js';
import { TailwindModal } from './modals/TailwindModal.js';
import {Action} from '../core/Action.js';
import {BaseModal} from './modals/BaseModal.js';
import {UikitModal} from './modals/UikitModal.js';
import {BootstrapModal} from './modals/BootstrapModal.js';
import {FoundationModal} from './modals/FoundationModal.js';
import {TailwindModal} from './modals/TailwindModal.js';
/**
* ModalElement class responsible for creating and managing modal elements.
@ -13,10 +14,10 @@ export class ModalElement {
* Constructs an instance of ModalElement with the appropriate modal type
* based on the detected UI framework.
*
* @param {HTMLElement} triggerElement - The element that triggers the modal.
* @param {Action} action - The action element that triggers the modal.
*/
constructor(triggerElement) {
this.modal = ModalElement.framework(triggerElement);
constructor(action) {
this.modal = ModalElement.framework(action);
}
/**
@ -31,10 +32,10 @@ export class ModalElement {
/**
* Determines the appropriate modal implementation based on the available UI framework.
*
* @param {HTMLElement} triggerElement - The element triggering the modal.
* @param {Action} action - The action element triggering the modal.
* @returns {BaseModal|BootstrapModal|UikitModal|FoundationModal|TailwindModal} The modal instance.
*/
static framework(triggerElement) {
static framework(action) {
const frameworks = {
'UIkit': UikitModal,
'bootstrap': BootstrapModal,
@ -47,13 +48,13 @@ export class ModalElement {
if (process.env.DEBUG) {
console.log(`${key} modal selected`);
}
return new ModalType(triggerElement);
return new ModalType(action);
}
}
if (process.env.DEBUG) {
console.log(`base modal selected`);
}
return new BaseModal(triggerElement);
return new BaseModal(action);
}
}

View File

@ -1,8 +1,9 @@
import { BaseTooltip } from './tooltip/BaseTooltip.js';
import { BootstrapTooltip } from './tooltip/BootstrapTooltip.js';
import { UikitTooltip } from './tooltip/UikitTooltip.js';
import { FoundationTooltip } from './tooltip/FoundationTooltip.js';
import { TailwindTooltip } from './tooltip/TailwindTooltip.js';
import {Action} from '../core/Action.js';
import {BaseTooltip} from './tooltip/BaseTooltip.js';
import {BootstrapTooltip} from './tooltip/BootstrapTooltip.js';
import {UikitTooltip} from './tooltip/UikitTooltip.js';
import {FoundationTooltip} from './tooltip/FoundationTooltip.js';
import {TailwindTooltip} from './tooltip/TailwindTooltip.js';
/**
* TooltipElement class responsible for creating and managing tooltip elements.
@ -13,10 +14,10 @@ export class TooltipElement {
* Constructs an instance of TooltipElement with the appropriate tooltip type
* based on the detected UI framework.
*
* @param {HTMLElement} triggerElement - The element that triggers the tooltip.
* @param {Action} action - The action element that triggers the tooltip.
*/
constructor(triggerElement) {
this.tooltip = TooltipElement.framework(triggerElement);
constructor(action) {
this.tooltip = TooltipElement.framework(action);
}
/**
@ -31,11 +32,11 @@ export class TooltipElement {
/**
* Determines the appropriate tooltip implementation based on the available UI framework.
*
* @param {HTMLElement} triggerElement - The element triggering the tooltip.
* @param {Action} action - The action element triggering the tooltip.
* @returns {BaseTooltip|BootstrapTooltip|UikitTooltip|FoundationTooltip|TailwindTooltip} The tooltip instance.
* @param debug
*/
static framework(triggerElement) {
static framework(action) {
const frameworks = {
'UIkit': UikitTooltip,
'bootstrap': BootstrapTooltip,
@ -48,13 +49,13 @@ export class TooltipElement {
if (process.env.DEBUG) {
console.log(`${key} tooltip selected`);
}
return new TooltipType(triggerElement);
return new TooltipType(action);
}
}
if (process.env.DEBUG) {
console.log(`base tooltip selected`);
}
return new BaseTooltip(triggerElement);
return new BaseTooltip(action);
}
}

View File

@ -1,13 +1,18 @@
import {Action} from '../../core/Action.js';
export class BaseModal {
#modalId;
#action;
/**
* Creates a new BaseModal instance.
*
* @param {HTMLElement} triggerElement - The elements that triggers the modal.
* @param {Action} action - The action element triggering the modal.
*/
constructor(triggerElement) {
this.modalId = `modal-${Math.random().toString(36).slice(2, 11)}`;
this.triggerElement = triggerElement;
this.triggerElement.style.cursor = 'pointer';
constructor(action) {
this.#modalId = `modal-${Math.random().toString(36).slice(2, 11)}`;
this.#action = action;
this.getElement().style.cursor = 'pointer';
this.initializeTrigger();
}
@ -17,11 +22,11 @@ export class BaseModal {
* @param {string} content - The content to load into the modal.
*/
load(content) {
const existingModal = document.getElementById(this.modalId);
const existingModal = document.getElementById(this.getModalId());
// Check if modal already exists
if (existingModal) {
// Update the content of the existing modal
const contentDiv = document.getElementById(`${this.modalId}-content`);
const contentDiv = document.getElementById(`${this.getModalId()}-content`);
if (contentDiv) {
contentDiv.innerHTML += content;
}
@ -47,17 +52,17 @@ export class BaseModal {
*/
create(content) {
const modalHtml = `
<div id="${this.modalId}" style="display:none; position:fixed; top:0; left:0; width:100%; height:100%; background-color:rgba(0, 0, 0, 0.5); justify-content:center; align-items:center;">
<div id="${this.getModalId()}" style="display:none; position:fixed; top:0; left:0; width:100%; height:100%; background-color:rgba(0, 0, 0, 0.5); justify-content:center; align-items:center;">
<div style="position:relative; background-color:white; padding:20px; border-radius:5px; max-width:300px;">
<button class="getbible-modal-close" type="button" onclick="document.getElementById('${this.modalId}').style.display='none'" style="position:absolute; top:10px; right:10px; border:none; background:transparent; font-size:24px; cursor:pointer;"></button>
<div id="${this.modalId}-content">
<button class="getbible-modal-close" type="button" onclick="document.getElementById('${this.getModalId()}').style.display='none'" style="position:absolute; top:7px; right:7px; border:none; background:transparent; font-size:20px; cursor:pointer;"></button>
<div id="${this.getModalId()}-content">
${content}
</div>
</div>
</div>`;
this.insertIntoDOM(modalHtml);
const modalElement = document.getElementById(this.modalId);
const modalElement = document.getElementById(this.getModalId());
modalElement.addEventListener('click', (event) => {
if (event.target === modalElement) {
modalElement.style.display = 'none';
@ -70,8 +75,26 @@ export class BaseModal {
*
*/
initializeTrigger() {
this.triggerElement.addEventListener('click', () => {
document.getElementById(this.modalId).style.display = 'flex';
this.getElement().addEventListener('click', () => {
document.getElementById(this.getModalId()).style.display = 'flex';
});
}
/**
* Get the modal ID
*
* @returns {string} - The modal ID
*/
getModalId() {
return this.#modalId;
}
/**
* Get the action element
*
* @returns {HTMLElement} - The DOM element being worked with.
*/
getElement() {
return this.#action.getElement();
}
}

View File

@ -1,17 +1,17 @@
import { BaseModal } from './BaseModal.js';
import {BaseModal} from './BaseModal.js';
export class BootstrapModal extends BaseModal {
constructor(triggerElement) {
super(triggerElement);
constructor(action) {
super(action);
}
show() {
const modal = new bootstrap.Modal(document.getElementById(this.modalId));
const modal = new bootstrap.Modal(document.getElementById(this.getModalId()));
modal.show();
}
hide() {
const modal = bootstrap.Modal.getInstance(document.getElementById(this.modalId));
const modal = bootstrap.Modal.getInstance(document.getElementById(this.getModalId()));
if (modal) {
modal.hide();
}
@ -19,13 +19,13 @@ export class BootstrapModal extends BaseModal {
create(content) {
const modalHtml = `
<div class="modal fade" id="${this.modalId}" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal fade" id="${this.getModalId()}" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content p-3">
<div class="modal-header">
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div id="${this.modalId}-content" class="modal-body">
<div id="${this.getModalId()}-content" class="modal-body">
${content}
</div>
</div>
@ -35,7 +35,7 @@ export class BootstrapModal extends BaseModal {
}
initializeTrigger() {
this.triggerElement.setAttribute('data-bs-toggle', 'modal');
this.triggerElement.setAttribute('data-bs-target', `#${this.modalId}`);
this.getElement().setAttribute('data-bs-toggle', 'modal');
this.getElement().setAttribute('data-bs-target', `#${this.getModalId()}`);
}
}

View File

@ -1,8 +1,8 @@
import { BaseModal } from './BaseModal.js';
import {BaseModal} from './BaseModal.js';
export class FoundationModal extends BaseModal {
constructor(triggerElement) {
super(triggerElement);
constructor(action) {
super(action);
this.modalElement = null;
}
@ -20,8 +20,8 @@ export class FoundationModal extends BaseModal {
create(content) {
const modalHtml = `
<div class="reveal" id="${this.modalId}" data-reveal>
<div id="${this.modalId}-content">
<div class="reveal" id="${this.getModalId()}" data-reveal>
<div id="${this.getModalId()}-content">
${content}
</div>
<button class="close-button" data-close aria-label="Close modal" type="button">
@ -29,10 +29,10 @@ export class FoundationModal extends BaseModal {
</button>
</div>`;
this.insertIntoDOM(modalHtml);
this.modalElement = new Foundation.Reveal(document.getElementById(this.modalId));
this.modalElement = new Foundation.Reveal(document.getElementById(this.getModalId()));
}
initializeTrigger() {
this.triggerElement.setAttribute('data-open', this.modalId);
this.getElement().setAttribute('data-open', this.getModalId());
}
}

View File

@ -1,34 +1,34 @@
import { BaseModal } from './BaseModal.js';
import {BaseModal} from './BaseModal.js';
export class TailwindModal extends BaseModal {
constructor(triggerElement) {
super(triggerElement);
constructor(action) {
super(action);
}
show() {
document.getElementById(this.modalId).classList.remove('hidden');
document.getElementById(this.getModalId()).classList.remove('hidden');
}
hide() {
document.getElementById(this.modalId).classList.add('hidden');
document.getElementById(this.getModalId()).classList.add('hidden');
}
create(content) {
const modalHtml = `
<div class="modal hidden fixed inset-0 bg-gray-600 bg-opacity-50 overflow-y-auto h-full w-full" id="${this.modalId}">
<div class="modal hidden fixed inset-0 bg-gray-600 bg-opacity-50 overflow-y-auto h-full w-full" id="${this.getModalId()}">
<div class="modal-content container mx-auto p-5 bg-white">
<div id="${this.modalId}-content">
<div id="${this.getModalId()}-content">
${content}
</div>
<button class="close-button" onclick="document.getElementById('${this.modalId}').classList.add('hidden')">Close</button>
<button class="close-button" onclick="document.getElementById('${this.getModalId()}').classList.add('hidden')">Close</button>
</div>
</div>`;
this.insertIntoDOM(modalHtml);
}
initializeTrigger(triggerElement) {
this.triggerElement.addEventListener('click', () => {
document.getElementById(this.modalId).classList.remove('hidden');
initializeTrigger() {
this.getElement().addEventListener('click', () => {
document.getElementById(this.getModalId()).classList.remove('hidden');
});
}
}

View File

@ -1,24 +1,24 @@
import { BaseModal } from './BaseModal.js';
import {BaseModal} from './BaseModal.js';
export class UikitModal extends BaseModal {
constructor(triggerElement) {
super(triggerElement);
constructor(action) {
super(action);
}
show() {
UIkit.modal(`#${this.modalId}`).show();
UIkit.modal(`#${this.getModalId()}`).show();
}
hide() {
UIkit.modal(`#${this.modalId}`).hide();
UIkit.modal(`#${this.getModalId()}`).hide();
}
create(content) {
const modalHtml = `
<div id="${this.modalId}" uk-modal>
<div id="${this.getModalId()}" uk-modal>
<div class="uk-modal-dialog uk-modal-body">
<button class="uk-modal-close-default" type="button" uk-close></button>
<div id="${this.modalId}-content">
<div id="${this.getModalId()}-content">
${content}
</div>
</div>
@ -27,7 +27,7 @@ export class UikitModal extends BaseModal {
}
initializeTrigger() {
this.triggerElement.setAttribute('uk-toggle', `target: #${this.modalId}`);
this.getElement().setAttribute('uk-toggle', `target: #${this.getModalId()}`);
}
}

View File

@ -1,12 +1,16 @@
import {Action} from '../../core/Action.js';
export class BaseTooltip {
#action;
/**
* Creates a new BaseTooltip instance.
*
* @param {HTMLElement} triggerElement - The elements that triggers the tooltip.
* @param {Action} action - The action elements that triggers the tooltip.
*/
constructor(triggerElement) {
this.triggerElement = triggerElement;
this.triggerElement.style.cursor = 'help';
constructor(action) {
this.#action = action;
this.getElement().style.cursor = 'help';
}
/**
@ -17,8 +21,17 @@ export class BaseTooltip {
* @throws {Error} Throws an error if the trigger elements is not valid.
*/
load(content) {
const existingTitle = this.triggerElement.getAttribute('title');
const existingTitle = this.getElement().getAttribute('title');
const newTitle = existingTitle ? existingTitle + "\n" + content : content;
this.triggerElement.setAttribute('title', newTitle);
this.getElement().setAttribute('title', newTitle);
}
/**
* Get the action element
*
* @returns {HTMLElement} - The DOM element being worked with.
*/
getElement() {
return this.#action.getElement();
}
}

View File

@ -1,8 +1,8 @@
import { BaseTooltip } from './BaseTooltip.js';
import {BaseTooltip} from './BaseTooltip.js';
export class BootstrapTooltip extends BaseTooltip {
constructor(triggerElement) {
super(triggerElement);
constructor(action) {
super(action);
}
load(content) {

View File

@ -1,24 +1,24 @@
import { BaseTooltip } from './BaseTooltip.js';
import {BaseTooltip} from './BaseTooltip.js';
export class FoundationTooltip extends BaseTooltip {
constructor(triggerElement) {
super(triggerElement);
constructor(action) {
super(action);
}
load(content) {
try {
this.triggerElement.setAttribute('data-tooltip', '');
this.getElement().setAttribute('data-tooltip', '');
super.load(content);
this.triggerElement.classList.add('has-tip');
this.getElement().classList.add('has-tip');
new Foundation.Tooltip(this.triggerElement, {
new Foundation.Tooltip(this.getElement(), {
// Default options
disableHover: false, // Allows tooltip to be hoverable
fadeOutDuration: 150, // Duration of fade out animation in milliseconds
fadeInDuration: 150, // Duration of fade in animation in milliseconds
showOn: 'all', // Can be 'all', 'large', 'medium', 'small'
templateClasses: '', // Custom class(es) to be added to the tooltip template
tipText: () => this.triggerElement.getAttribute('title'), // Function to define tooltip text
tipText: () => this.getElement().getAttribute('title'), // Function to define tooltip text
triggerClass: 'has-tip', // Class to be added on the trigger elements
touchCloseText: 'tap to close', // Text for close button on touch devices
positionClass: 'top', // Position of tooltip, can be 'top', 'bottom', 'left', 'right', etc.

View File

@ -1,4 +1,4 @@
import { BaseTooltip } from './BaseTooltip.js';
import {BaseTooltip} from './BaseTooltip.js';
export class TailwindTooltip extends BaseTooltip {
constructor(triggerElement) {
@ -20,25 +20,25 @@ export class TailwindTooltip extends BaseTooltip {
this.tooltipElement.id = this.tooltipId;
this.tooltipElement.className = 'absolute invisible bg-gray-800 text-white text-xs px-2 py-1 rounded-md';
this.tooltipElement.style.transition = 'visibility 0.3s linear, opacity 0.3s linear';
this.tooltipElement.textContent = this.triggerElement.getAttribute('title');
this.tooltipElement.textContent = this.getElement().getAttribute('title');
document.body.appendChild(this.tooltipElement);
}
_initializeEvents() {
this.triggerElement.addEventListener('mouseenter', () => {
const rect = this.triggerElement.getBoundingClientRect();
this._title = this.triggerElement.getAttribute('title');
this.getElement().addEventListener('mouseenter', () => {
const rect = this.getElement().getBoundingClientRect();
this._title = this.getElement().getAttribute('title');
this.tooltipElement.style.left = `${rect.left + window.scrollX}px`;
this.tooltipElement.style.top = `${rect.bottom + 5 + window.scrollY}px`;
this.tooltipElement.classList.remove('invisible');
this.tooltipElement.classList.add('opacity-100');
this.triggerElement.setAttribute('title', '');
this.getElement().setAttribute('title', '');
});
this.triggerElement.addEventListener('mouseleave', () => {
this.getElement().addEventListener('mouseleave', () => {
this.tooltipElement.classList.add('invisible');
this.tooltipElement.classList.remove('opacity-100');
this.triggerElement.setAttribute('title', this._title);
this.getElement().setAttribute('title', this._title);
});
}
}

View File

@ -1,4 +1,4 @@
import { BaseTooltip } from './BaseTooltip.js';
import {BaseTooltip} from './BaseTooltip.js';
export class UikitTooltip extends BaseTooltip {
constructor(triggerElement) {

View File

@ -1,16 +1,35 @@
import {Scripture} from '../core/Scripture.js';
import {Action} from '../core/Action.js';
export class BaseFormat {
#action;
/**
* Creates a new BaseTooltip instance.
*
* @param {Action} action - The action elements that triggers the tooltip.
*/
constructor(action) {
this.#action = action;
}
/**
* Get action.
*
* @returns {Action} The current actions.
*/
action() {
return this.#action;
}
/**
* Get formats the verses.
*
* @param {Object} data - The data containing verses and their details.
* @param {boolean} showBook - Whether to show book names.
* @param {boolean} showTrans - Whether to show translations.
* @param {boolean} showAbbr - Whether to show abbreviations.
* @param {boolean} showLang - Whether to show languages.
* @param {Scripture} scripture - The data containing verses and their details.
* @returns {string} The formatted verses.
* @abstract
*/
get(data, showBook, showTrans, showAbbr, showLang) {
get(scripture) {
throw new Error("The 'get' method must be implemented in BaseFormat subclass.");
}
}

View File

@ -1,56 +1,48 @@
import { BaseFormat } from './BaseFormat.js';
import {BaseFormat} from './BaseFormat.js';
import {Scripture} from '../core/Scripture.js';
export class BlockFormat extends BaseFormat {
/**
* Formats the verses for HTML block elements.
*
* @param {Object} data - The data containing verses and their details.
* @param {boolean} showBook - Whether to show book names.
* @param {boolean} showTrans - Whether to show translations.
* @param {boolean} showAbbr - Whether to show abbreviations.
* @param {boolean} showLang - Whether to show languages.
* @returns {string} The formatted HTML string.
*/
get(data, showBook, showTrans, showAbbr, showLang) {
let formattedHtml = '';
let setBookName = new Set();
let setTranslation = new Set();
let setAbbreviation = new Set();
let setLanguage = new Set();
constructor(action) {
super(action);
}
for (const key in data) {
if (!data.hasOwnProperty(key)) continue;
/**
* Formats the verses for HTML block elements.
*
* @param {Scripture} scripture - The data containing verses and their details.
* @returns {string} The formatted verses.
*/
get(scripture) {
let display = [];
scripture.forEachReference((reference) => {
let header = [];
display.push(`<div dir="${reference.getTextDirection().toUpperCase()}" class="getbible-reference-block">`);
if (this.action().showBookName()) {
header.push(`<span class="getbible-book-name">${reference.getBookName()}</span>`);
}
if (this.action().showReference()) {
header.push(`<span class="getbible-reference">${reference.getReference()}</span>`);
}
if (this.action().showTranslation()) {
header.push(`<span class="getbible-translation">${reference.getTranslation()}</span>`);
}
if (this.action().showAbbreviation()) {
header.push(`<span class="getbible-abbreviation">${reference.getAbbreviation()}</span>`);
}
if (this.action().showLanguage()) {
header.push(`<span class="getbible-language">${reference.getLanguage()}</span>`);
}
// Construct the header
if (header.length > 0) {
display.push(`<b class="getbible-header">${header.join(' - ')}</b>`);
}
const verses = reference.getVerses()
.map(verse => `<div class="getbible-verse">${verse.verse}. ${verse.text}</div>`)
.join("\n");
display.push(`<div class="getbible-verses">${verses}</div>`);
display.push(`</div>`);
});
let headerParts = [];
if (showTrans && !setTranslation.has(key)) {
headerParts.push(`<span class="getbible-translation">${data[key].translation}</span>`);
setTranslation.add(key);
}
if (showAbbr && !setAbbreviation.has(key)) {
headerParts.push(`<span class="getbible-abbreviation">${data[key].abbreviation}</span>`);
setAbbreviation.add(key);
}
if (showBook && !setBookName.has(key)) {
headerParts.push(`<span class="getbible-book-name">${data[key].name}</span>`);
setBookName.add(key);
}
if (showLang && !setLanguage.has(key)) {
headerParts.push(`<span class="getbible-language">${data[key].language}</span>`);
setLanguage.add(key);
}
// Construct the header
if (headerParts.length > 0) {
formattedHtml += `<div class="getbible-header">[${headerParts.join(' - ')}]</div>\n`;
}
// Add verses
const verses = data[key].verses
.map(verse => `<span class="getbible-verse">${verse.verse}. ${verse.text}</span>`)
.join("<br />");
formattedHtml += `<div class="getbible-verses">${verses}</div><br />`;
}
return `<div class="getbible-element getbible-block">${formattedHtml}</div>`;
}
return `<div class="getbible-element getbible-block">${display.join("\n")}</div><br />`;
}
}

View File

@ -1,39 +1,38 @@
import { BlockFormat } from './BlockFormat.js';
import { InlineFormat } from './InlineFormat.js';
import { PlainFormat } from './PlainFormat.js';
import {BlockFormat} from './BlockFormat.js';
import {InlineFormat} from './InlineFormat.js';
import {PlainFormat} from './PlainFormat.js';
import {Scripture} from '../core/Scripture.js';
import {Action} from '../core/Action.js';
/**
* Format class responsible for creating and managing different types of formats
* based on the specified type.
*/
export class Format {
/**
* Constructs a Format instance based on the given type.
*
* @param {string} formatType - The format type.
*/
constructor(formatType = 'tooltip') {
const formatTypes = {
'modal': BlockFormat,
'inline': InlineFormat,
'tooltip': PlainFormat
};
/**
* Constructs a Format instance based on the given type.
*
* @param {Action} action - The action details for this element
*/
constructor(action) {
const formatTypes = {
'modal': BlockFormat,
'inline': InlineFormat,
'tooltip': PlainFormat
};
const FormatType = formatTypes[formatType] || PlainFormat;
this.format = new FormatType();
}
const format = action.getFormat();
const FormatType = formatTypes[format] || InlineFormat;
this.format = new FormatType(action);
}
/**
* Get the formatted verses.
*
* @param {Object} data - The data containing verses and their details.
* @param {boolean} showBook - Whether to show book names.
* @param {boolean} showTrans - Whether to show translations.
* @param {boolean} showAbbr - Whether to show abbreviations.
* @param {boolean} showLang - Whether to show languages.
* @returns {string} The formatted verses.
*/
get(data, showBook, showTrans, showAbbr, showLang) {
return this.format.get(data, showBook, showTrans, showAbbr, showLang);
}
/**
* Get the formatted verses.
*
* @param {Scripture} scripture - The data containing verses and their details.
* @returns {string} The formatted verses.
*/
get(scripture) {
return this.format.get(scripture);
}
}

View File

@ -1,56 +1,48 @@
import { BaseFormat } from './BaseFormat.js';
import {BaseFormat} from './BaseFormat.js';
import {Scripture} from '../core/Scripture.js';
export class InlineFormat extends BaseFormat {
/**
* Formats the verses for HTML inline elements.
*
* @param {Object} data - The data containing verses and their details.
* @param {boolean} showBook - Whether to show book names.
* @param {boolean} showTrans - Whether to show translations.
* @param {boolean} showAbbr - Whether to show abbreviations.
* @param {boolean} showLang - Whether to show languages.
* @returns {string} The formatted HTML string.
*/
get(data, showBook, showTrans, showAbbr, showLang) {
let formattedHtml = '';
let setBookName = new Set();
let setTranslation = new Set();
let setAbbreviation = new Set();
let setLanguage = new Set();
constructor(action) {
super(action);
}
for (const key in data) {
if (!data.hasOwnProperty(key)) continue;
/**
* Formats the verses for HTML inline elements.
*
* @param {Scripture} scripture - The data containing verses and their details.
* @returns {string} The formatted verses.
*/
get(scripture) {
let display = [];
scripture.forEachReference((reference) => {
let footer = [];
display.push(`<div dir="${reference.getTextDirection().toUpperCase()}" class="getbible-reference-inline">`);
if (this.action().showBookName()) {
footer.push(`<span class="getbible-book-name">${reference.getBookName()}</span>`);
}
if (this.action().showReference()) {
footer.push(`<span class="getbible-reference">${reference.getReference()}</span>`);
}
if (this.action().showTranslation()) {
footer.push(`<span class="getbible-translation">${reference.getTranslation()}</span>`);
}
if (this.action().showAbbreviation()) {
footer.push(`<span class="getbible-abbreviation">${reference.getAbbreviation()}</span>`);
}
if (this.action().showLanguage()) {
footer.push(`<span class="getbible-language">${reference.getLanguage()}</span>`);
}
const verses = reference.getVerses()
.map(verse => `<span class="getbible-verse">${verse.verse}. ${verse.text}</span>`)
.join("\n");
display.push(`<span class="getbible-verses">${verses}</span>`);
// Construct the footer
if (footer.length > 0) {
display.push(`<b class="getbible-footer">${footer.join(' - ')}</b>`);
}
display.push(`</div>`);
});
let footerParts = [];
if (showTrans && !setTranslation.has(key)) {
footerParts.push(`<span class="getbible-translation">${data[key].translation}</span>`);
setTranslation.add(key);
}
if (showAbbr && !setAbbreviation.has(key)) {
footerParts.push(`<span class="getbible-abbreviation">${data[key].abbreviation}</span>`);
setAbbreviation.add(key);
}
if (showBook && !setBookName.has(key)) {
footerParts.push(`<span class="getbible-book-name">${data[key].name}</span>`);
setBookName.add(key);
}
if (showLang && !setLanguage.has(key)) {
footerParts.push(`<span class="getbible-language">${data[key].language}</span>`);
setLanguage.add(key);
}
// Add verses
const verses = data[key].verses
.map(verse => `<span class="getbible-verse">${verse.verse}. ${verse.text}</span>`)
.join("\n");
formattedHtml += `<span class="getbible-verses">${verses}</span>\n`;
// Construct the footer
if (footerParts.length > 0) {
formattedHtml += `<span class="getbible-footer">[${footerParts.join(' - ')}]</span>\n`;
}
}
return `<span class="getbible-element getbible-inline">${formattedHtml}</span>`;
}
return `<div class="getbible-element getbible-inline">${display.join("\n")}</div>`;
}
}

View File

@ -1,54 +1,47 @@
import { BaseFormat } from './BaseFormat.js';
import {BaseFormat} from './BaseFormat.js';
import {Scripture} from '../core/Scripture.js';
export class PlainFormat extends BaseFormat {
/**
* Formats the verses for plain text display.
*
* @param {Object} data - The data containing verses and their details.
* @param {boolean} showBook - Whether to show book names.
* @param {boolean} showTrans - Whether to show translations.
* @param {boolean} showAbbr - Whether to show abbreviations.
* @param {boolean} showLang - Whether to show languages.
* @returns {string} The formatted text.
*/
get(data, showBook, showTrans, showAbbr, showLang) {
let formattedText = '';
let setBookName = new Set();
let setTranslation = new Set();
let setAbbreviation = new Set();
let setLanguage = new Set();
constructor(action) {
super(action);
}
for (const key in data) {
if (!data.hasOwnProperty(key)) continue; // Ensure processing only own properties
/**
* Formats the verses for plain text display.
*
* @param {Scripture} scripture - The data containing verses and their details.
* @returns {string} The formatted verses.
*/
get(scripture) {
let display = [];
scripture.forEachReference((reference) => {
let header = [];
if (this.action().showBookName()) {
header.push(`${reference.getBookName()}`);
}
if (this.action().showReference()) {
header.push(`${reference.getReference()}`);
}
if (this.action().showTranslation()) {
header.push(`${reference.getTranslation()}`);
}
if (this.action().showAbbreviation()) {
header.push(`${reference.getAbbreviation()}`);
}
if (this.action().showLanguage()) {
header.push(`${reference.getLanguage()}`);
}
// Construct the header
if (header.length > 0) {
display.push(`[${header.join(' - ')}]`);
}
display.push(
reference.getVerses()
.map(verse => `${verse.verse}. ${verse.text}`)
.join("\n")
);
});
let headerParts = [];
if (showTrans && !setTranslation.has(key)) {
headerParts.push(data[key].translation);
setTranslation.add(key);
}
if (showAbbr && !setAbbreviation.has(key)) {
headerParts.push(data[key].abbreviation);
setAbbreviation.add(key);
}
if (showBook && !setBookName.has(key)) {
headerParts.push(data[key].name);
setBookName.add(key);
}
if (showLang && !setLanguage.has(key)) {
headerParts.push(data[key].language);
setLanguage.add(key);
}
// Construct the header
if (headerParts.length > 0) {
formattedText += '[' + headerParts.join(' - ') + "]\n";
}
// Add verses
const verses = data[key].verses.map(verse => `${verse.verse}. ${verse.text}`).join("\n");
formattedText += verses + "\n\n"; // Add extra newline for separation
}
return formattedText.trim();
}
return `${display.join("\n")}\n`;
}
}

View File

@ -1,14 +1,35 @@
import { Loader } from "./core/Loader.js";
import {Api} from './core/Api.js';
import {Loader} from "./core/Loader.js";
/**
* Entry point to load Bible references.
* Attaches event listener to DOMContentLoaded to find elements with class 'getBible'
* and initializes Loader for each element.
* Initializes loaders for elements with class 'getBible'.
* Each element gets its own Loader instance because each loader maintains state
* specific to the element it operates on. This function encapsulates the logic
* for finding relevant elements and initializing loaders for them.
* @param {Api} api - The Api instance to be used by each Loader.
*/
document.addEventListener('DOMContentLoaded', (event) => {
function initializeGetBibleLoaders(api) {
const elements = document.querySelectorAll('.getBible');
elements.forEach(element => {
const loader = new Loader();
loader.load(element);
// Create a new loader instance for each element
const loader = new Loader(api);
loader.load(element).catch(error => {
// Error handling for each loader instance
console.error(`Loading error for element ${element}:`, error);
});
});
}
/**
* Entry point to load Reference references.
* Attaches event listener to DOMContentLoaded to ensure the DOM is fully loaded
* before attempting to initialize loaders.
*/
document.addEventListener('DOMContentLoaded', (event) => {
try {
const api = new Api();
initializeGetBibleLoaders(api);
} catch (error) {
console.error("Error initializing GetBible loaders:", error);
}
});

View File

@ -20,7 +20,7 @@
data-format="tooltip">John 3:16,19
</li>
<li class="getBible" data-show-abbreviation="1" data-format="modal">John 3:16-17; 1 John 3:16-19,22</li>
<li class="getBible" data-translation="kjv;codex" data-show-language="1" data-format="modal">Genesis 1:1</li>
<li class="getBible" data-translation="kjv;codex;aov" data-show-reference="1" data-format="modal">Genesis 1:1</li>
<li class="getBible" data-translation="kjv;codex" data-show-language="1" data-format="inline">Psalms 23:1-4</li>
<li class="getBible">Romans 8:28,31-39</li>
</ul>

View File

@ -26,7 +26,7 @@
<li class="getBible" data-translation="kjv;aov" data-show-translation="1" data-show-language="1"
data-format="tooltip">John 3:16,19
</li>
<li class="getBible" data-show-abbreviation="1" data-format="modal">John 3:16-17; 1 John 3:16-19,22</li>
<li class="getBible" data-translation="kjv;aov" data-show-abbreviation="1" data-format="modal">John 3:16-17; 1 John 3:16-19,22</li>
<li class="getBible" data-translation="kjv;codex" data-show-language="1" data-format="modal">Genesis 1:1</li>
<li class="getBible" data-translation="kjv;codex" data-show-language="1" data-format="tooltip">Psalms 23:1-4</li>
<li class="getBible">Romans 8:28,31-39</li>