Skip to content

Commit

Permalink
Add Promise polyfill & build v0.0.5 release
Browse files Browse the repository at this point in the history
  • Loading branch information
rene-leanix committed Mar 11, 2018
1 parent 7523f08 commit 71ea36f
Show file tree
Hide file tree
Showing 10 changed files with 856 additions and 126 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,19 @@ For now, the script can be included directly from GitHub via RawGit, either thro
### Script tag

```html
<script src="https://cdn.rawgit.com/renehamburger/blinx.js/v0.0.4/dist/blinx.js" defer data-blinx="{
<script src="https://cdn.rawgit.com/renehamburger/blinx.js/v0.0.5/dist/blinx.js" defer data-blinx="{
language: 'de'
}"></script>
```

The `data-blinx` attribute contains the options for blinx.js. For now, look at the definitions of the [blinx.js Options](src/options/options.ts#L7) and the related classes & types such as the [available Languages](src/options/languages.ts) or [the Bible Passage Reference Parser's Options](typings/bible-passage-reference-parser/index.d.ts#L35).

1 further script will be loaded by blinx.js. To speed up load times, it can already be loaded in parallel to blinx.js:
blinx.js loads several resources it requires dnamically and asynchronously. To speed up the identification and linking of Bible references on the page, the following two scripts can already be loaded in parallel to blinx.js:

```html
<script src="https://cdn.polyfill.io/v2/polyfill.js?features=Promise|gated" defer></script>
<script src="https://cdn.rawgit.com/openbibleinfo/Bible-Passage-Reference-Parser/537560a7/js/<LANGUAGE_CODE>_bcv_parser.js" defer></script>
<script src="https://cdn.rawgit.com/renehamburger/blinx.js/v0.0.4/dist/blinx.js" defer></script>
<script src="https://cdn.rawgit.com/renehamburger/blinx.js/v0.0.5/dist/blinx.js" defer></script>
```

The string entered for the `<LANGUAGE_CODE>`, e.g. 'de', will then also determine the language for blinx.js. ('537560a7' is the current [latest commit of the Bible Passage Reference Parser](https://github.com/openbibleinfo/Bible-Passage-Reference-Parser/commits/master) and may need to be updated at a later stage.
Expand All @@ -39,7 +40,7 @@ The string entered for the `<LANGUAGE_CODE>`, e.g. 'de', will then also determin
```js
var blinxScript = document.createElement("script");
blinxScript.type = 'text/javascript';
blinxScript.src = 'https://cdn.rawgit.com/renehamburger/blinx.js/v0.0.4/dist/blinx.js';
blinxScript.src = 'https://cdn.rawgit.com/renehamburger/blinx.js/v0.0.5/dist/blinx.js';
document.documentElement.appendChild(blinxScript);
blinxScript.setAttribute('data-blinx', '{ language: "de" }');
```
Expand Down
928 changes: 820 additions & 108 deletions dist/blinx.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/blinx.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "blinx.js",
"version": "0.0.4",
"version": "0.0.5",
"description": "A multi-language client-side library to automatically convert Bible references to Bible links with passage pop-ups",
"main": "dist/blinx.js",
"scripts": {
Expand Down
17 changes: 13 additions & 4 deletions src/blinx.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { BibleApi } from 'src/bible/bible-api/bible-api.class';
import { getBibleApi } from 'src/bible/bible-api/bible-api-overview';
import { Bible } from 'src/bible/bible.class';
import { transformOsis } from 'src/helpers/osis';
import { loadPolyfills } from 'src/helpers/polyfills';

export class Blinx {

Expand All @@ -27,11 +28,19 @@ export class Blinx {
this.onlineBible = getOnlineBible(this.options.onlineBible);
// TODO: Later on, the best Bible API containing a certain translation should rather be used automatically
this.bibleApi = getBibleApi(this.options.bibleApi);
this.parser.load(this.options, (successful: boolean) => {
// Load dependencies required for link creation
let pending = 2;
const callback = (successful: boolean) => {
if (successful) {
this.initComplete();
pending--;
if (pending === 0) {
this.initComplete();
}
}
});
};
this.parser.load(this.options, callback);
loadPolyfills(callback);
// Load dependencies required for tooltip display
this.loadTippy();
}

Expand Down Expand Up @@ -83,7 +92,7 @@ export class Blinx {
});
}

/** Second step of initialisation after parser loaded. */
/** Second step of initialisation after parser & polyfills are loaded. */
private initComplete(): void {
if (this.options.parseAutomatically) {
if (/^complete|interactive|loaded$/.test(document.readyState)) {
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/osis.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { parseOsis, transformOsis } from './osis';
import { parseOsis, transformOsis } from 'src/helpers/osis';

describe('Osis helpers - ', () => {

Expand Down
2 changes: 1 addition & 1 deletion src/helpers/osis.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BibleBook } from '../bible/versions/bible-version.interface';
import { BibleBook } from 'src/bible/versions/bible-version.interface';

export interface BibleReferencePoint {
book: BibleBook;
Expand Down
12 changes: 12 additions & 0 deletions src/helpers/polyfills.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { loadScript } from 'src/helpers/dom';

/** Load polyfills if required */
export function loadPolyfills(callback?: (successful: boolean) => void) {
if ('Promise' in window) {
if (callback) {
callback(true);
}
} else {
loadScript(`https://cdn.polyfill.io/v2/polyfill.js?features=Promise|gated`, callback);
}
}
6 changes: 1 addition & 5 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
document.querySelectorAll('ul.' + cls + ' a').forEach(function (link) { link.click(); })
}
</script>
<!-- TODO: Add promise polyfill again -->
<script src="https://cdn.polyfill.io/v2/polyfill.js?features=Promise|gated" defer></script>
<script src="https://cdn.rawgit.com/openbibleinfo/Bible-Passage-Reference-Parser/537560a7/js/de_bcv_parser.js" defer></script>
<!-- <script src="http://127.0.0.1:9999/blinx.js/dist/de_bcv_parser.js" defer></script> -->
<script src="/blinx.js" defer data-blinx="{
language: 'de',
bibleVersion: 'de.EU',
Expand Down Expand Up @@ -121,8 +120,5 @@ <h4>First verse of each apocryphal book &mdash; <button onclick="openAllLinks('a
<li>PrMan 1,1</li>
<li>Ps151 1,1</li>
</ul>
<hr>
<h1>An example <a href="https://www.evangelium21.net/ressourcen/die-selige-wiederholung-der-heilsgeschichte">article</a> with German Bible references </h1>
<p>Matthäus zeichnet den Gedanken, dass Jesus das wahre Israel ist, im Laufe der überspannenden Struktur seines Evangeliums in viel größerem Detail nach. Er erklärt, dass Jesus hinab nach Ägypten zog, aus Ägypten heraufkam (Mt 2,13-15); durch das Wasser ging (3,13-17), in die Wüste (4,1—11) und auf einen Berg (Kapitel 5-7); er kam vom Berg herab (Kapitel 8); erfüllte das Königtum (12,1-4; 38-42); erfüllte den Prophetendienst (Kapitel 23); wurde durch seinen Tod am Kreuz ins Exil geschickt (27,32-56); und dann durch die Auferstehung wiederhergestellt (28,1-10). Jede Stufe von Israels Geschichte wurde im Leben und Dienst von Jesus nachvollzogen. Gott hatte Israel hinab nach Ägypten und aus Ägypten wieder heraufgeführt und dann durch das Wasser in die Wüste und zum Berg. Gott gründete Israel daraufhin als Königtum, sprach durch die Propheten, verbannte sie ins Exil und verhieß, sie zu Segen und Leben wiederherzustellen. Wieso haben wir eine klare Rekapitulation dieser Geschichte in der biblischen Aufzeichnung des Lebens Jesu? Die einfache Erklärung ist, dass Jesus kam, um all das zu tun, woran Israel gescheitert war. Er kam, um als der vollkommene Repräsentant seines Volkes zu leben. Er wurde als ein wahrer Israelit geboren, um das wahre und größere Israel Gottes zu sein. Er ist größer als Abraham (Joh 8,58); größer als Mose (Joh 5,46) und größer als David und Salomo (Mt 12,1-4.38-42). Er ist der größere Tempel (Mt 12,5-8) und der größte der Propheten. Jesus ist der Eine, der die Bundesflüche des Gesetzes anstelle seines Volkes auf sich nahm und der das Gesetz Gottes vollkommen hielt, um die Bundessegnungen Gottes für diejenigen zu erlangen, die mit ihm durch Glauben verbunden werden würden. Er wurde unter das Gesetz getan, als ein Israelit, und empfing das Zeichen des Bundes (Beschneidung), „damit er die, welche unter dem Gesetz waren, loskaufte“ (Gal 4,5).</p>
</body>
</html>
2 changes: 1 addition & 1 deletion src/options/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Languages } from 'src/options/languages';
import { Parser } from 'src/parser/parser.class';
import { BibleVersionCode } from 'src/bible/versions/bible-versions.const';
import { OnlineBibleName } from 'src/bible/online-bible/online-bible-overview';
import { BibleApiName } from '../bible/bible-api/bible-api-overview';
import { BibleApiName } from 'src/bible/bible-api/bible-api-overview';

export class Options {
[key: string]: any;
Expand Down

0 comments on commit 71ea36f

Please sign in to comment.