@everymatrix/bonus-powerups-ingame-games 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bonus-powerups-ingame-games/app-globals-0f993ce5.js +1 -0
- package/dist/bonus-powerups-ingame-games/bonus-powerups-ingame-games-b2c0935f.js +1 -0
- package/dist/bonus-powerups-ingame-games/bonus-powerups-ingame-games.esm.js +1 -0
- package/dist/bonus-powerups-ingame-games/bonus-powerups-ingame-games_3.entry.js +1 -0
- package/dist/bonus-powerups-ingame-games/index-fd928daa.js +2 -0
- package/dist/bonus-powerups-ingame-games/index.esm.js +1 -0
- package/dist/cjs/app-globals-3a1e7e63.js +5 -0
- package/dist/cjs/bonus-powerups-ingame-games-7de80a10.js +317 -0
- package/dist/cjs/bonus-powerups-ingame-games.cjs.js +25 -0
- package/dist/cjs/bonus-powerups-ingame-games_3.cjs.entry.js +247 -0
- package/dist/cjs/index-e3184c85.js +1246 -0
- package/dist/cjs/index.cjs.js +10 -0
- package/dist/cjs/loader.cjs.js +15 -0
- package/dist/collection/assets/Arrow Curve Left.svg +11 -0
- package/dist/collection/assets/double-right.svg +4 -0
- package/dist/collection/assets/gotoPage.svg +3 -0
- package/dist/collection/assets/return.svg +15 -0
- package/dist/collection/collection-manifest.json +25 -0
- package/dist/collection/components/bonus-powerups-ingame-games/bonus-powerups-ingame-games.css +279 -0
- package/dist/collection/components/bonus-powerups-ingame-games/bonus-powerups-ingame-games.js +335 -0
- package/dist/collection/components/bonus-powerups-ingame-games/index.js +1 -0
- package/dist/collection/index.js +1 -0
- package/dist/collection/utils/constants.js +4 -0
- package/dist/collection/utils/locale.utils.js +38 -0
- package/dist/collection/utils/utils.js +3 -0
- package/dist/esm/app-globals-0f993ce5.js +3 -0
- package/dist/esm/bonus-powerups-ingame-games-b2c0935f.js +315 -0
- package/dist/esm/bonus-powerups-ingame-games.js +20 -0
- package/dist/esm/bonus-powerups-ingame-games_3.entry.js +241 -0
- package/dist/esm/index-fd928daa.js +1217 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/loader.js +11 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/stencil.config.dev.js +20 -0
- package/dist/stencil.config.js +20 -0
- package/dist/storybook/main.js +43 -0
- package/dist/storybook/preview.js +9 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/bonus-powerups-ingame-games/.stencil/libs/common/src/storybook/storybook-utils.d.ts +39 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/bonus-powerups-ingame-games/.stencil/libs/common/src/types/casino/powerups.d.ts +60 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/bonus-powerups-ingame-games/.stencil/packages/stencil/bonus-powerups-ingame-games/stencil.config.d.ts +2 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/bonus-powerups-ingame-games/.stencil/packages/stencil/bonus-powerups-ingame-games/stencil.config.dev.d.ts +2 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/bonus-powerups-ingame-games/.stencil/packages/stencil/bonus-powerups-ingame-games/storybook/main.d.ts +3 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/bonus-powerups-ingame-games/.stencil/packages/stencil/bonus-powerups-ingame-games/storybook/preview.d.ts +70 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/bonus-powerups-ingame-games/.stencil/tools/plugins/index.d.ts +4 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/bonus-powerups-ingame-games/.stencil/tools/plugins/lazy-load-chunk-plugin.d.ts +12 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/bonus-powerups-ingame-games/.stencil/tools/plugins/stencil-clean-deps-plugin.d.ts +5 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/bonus-powerups-ingame-games/.stencil/tools/plugins/vite-chunk-plugin.d.ts +6 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/bonus-powerups-ingame-games/.stencil/tools/plugins/vite-clean-deps-plugin.d.ts +4 -0
- package/dist/types/components/bonus-powerups-ingame-games/bonus-powerups-ingame-games.d.ts +34 -0
- package/dist/types/components/bonus-powerups-ingame-games/index.d.ts +1 -0
- package/dist/types/components.d.ts +69 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/stencil-public-runtime.d.ts +1674 -0
- package/dist/types/utils/constants.d.ts +4 -0
- package/dist/types/utils/locale.utils.d.ts +2 -0
- package/dist/types/utils/utils.d.ts +1 -0
- package/loader/cdn.js +1 -0
- package/loader/index.cjs.js +1 -0
- package/loader/index.d.ts +24 -0
- package/loader/index.es2017.js +1 -0
- package/loader/index.js +2 -0
- package/loader/package.json +11 -0
- package/package.json +27 -0
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
import { h } from "@stencil/core";
|
|
2
|
+
import { setClientStyling, setClientStylingURL, setStreamStyling } from "../../../../../../../../libs/common/src/styling/index";
|
|
3
|
+
import { powerUpGameSearchConditions } from "../../utils/constants";
|
|
4
|
+
import "../../../../../ui-image/dist/types/index";
|
|
5
|
+
import ReturnSvg from "../../assets/return.svg";
|
|
6
|
+
import { translate } from "../../utils/locale.utils";
|
|
7
|
+
export class BonusPowerupsIngameGames {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.mbSource = undefined;
|
|
10
|
+
this.clientStyling = undefined;
|
|
11
|
+
this.clientStylingUrl = undefined;
|
|
12
|
+
this.translationUrl = undefined;
|
|
13
|
+
this.language = 'en';
|
|
14
|
+
this.endpoint = undefined;
|
|
15
|
+
this.session = undefined;
|
|
16
|
+
this.powerupId = undefined;
|
|
17
|
+
this.isLoadingGames = false;
|
|
18
|
+
this.powerUpGames = { items: [], total: 0 };
|
|
19
|
+
this.powerUp = undefined;
|
|
20
|
+
this.limit = 30;
|
|
21
|
+
}
|
|
22
|
+
initializeGamesObserver() {
|
|
23
|
+
if (this.loadMoreGamesObserver) {
|
|
24
|
+
this.loadMoreGamesObserver.disconnect();
|
|
25
|
+
}
|
|
26
|
+
this.loadMoreGamesObserver = new IntersectionObserver((entries) => {
|
|
27
|
+
entries.forEach((entry) => {
|
|
28
|
+
if (entry.isIntersecting) {
|
|
29
|
+
this.loadMoreGames().catch(console.error);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
if (this.lastGameElement) {
|
|
34
|
+
this.loadMoreGamesObserver.observe(this.lastGameElement);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
async loadMoreGames() {
|
|
38
|
+
var _a, _b, _c, _d;
|
|
39
|
+
if (this.isLoadingGames || (this.powerUpGames.total > 0 && this.powerUpGames.items.length >= this.powerUpGames.total)) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
this.isLoadingGames = true;
|
|
43
|
+
if (this.abortController) {
|
|
44
|
+
this.abortController.abort();
|
|
45
|
+
}
|
|
46
|
+
this.abortController = new AbortController();
|
|
47
|
+
try {
|
|
48
|
+
const url = new URL(`${this.endpoint}/v1/elevate/powerups/available?pagination=games(limit=${this.limit},offset=${((_b = (_a = this.powerUpGames) === null || _a === void 0 ? void 0 : _a.items) === null || _b === void 0 ? void 0 : _b.length) || 0})`);
|
|
49
|
+
const options = {
|
|
50
|
+
headers: {
|
|
51
|
+
'Content-Type': 'application/json',
|
|
52
|
+
'x-SessionId': this.session
|
|
53
|
+
},
|
|
54
|
+
method: 'GET',
|
|
55
|
+
signal: this.abortController.signal
|
|
56
|
+
};
|
|
57
|
+
url.searchParams.append('filter', `id=${this.powerupId}`);
|
|
58
|
+
Object.entries(powerUpGameSearchConditions).forEach(([key, value]) => {
|
|
59
|
+
url.searchParams.append(key, value);
|
|
60
|
+
});
|
|
61
|
+
url.searchParams.append('language', this.language);
|
|
62
|
+
const response = await fetch(url, options);
|
|
63
|
+
if (!response.ok) {
|
|
64
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
65
|
+
}
|
|
66
|
+
const res = await response.json();
|
|
67
|
+
this.powerUp = res.data[0];
|
|
68
|
+
const newGames = ((_c = this.powerUp.games) === null || _c === void 0 ? void 0 : _c.items) || [];
|
|
69
|
+
this.powerUpGames = {
|
|
70
|
+
items: [...this.powerUpGames.items, ...newGames],
|
|
71
|
+
total: ((_d = this.powerUp.games) === null || _d === void 0 ? void 0 : _d.total) || this.powerUpGames.total
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
catch (e) {
|
|
75
|
+
if (e.name !== 'AbortError') {
|
|
76
|
+
console.error('Failed to load more games:', e);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
finally {
|
|
80
|
+
if (!this.abortController.signal.aborted) {
|
|
81
|
+
this.isLoadingGames = false;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
onGameClick(game) {
|
|
86
|
+
window.postMessage({ type: 'EngagementSuiteGameRedirect', data: { Slug: game.slug } });
|
|
87
|
+
}
|
|
88
|
+
componentDidUpdate() {
|
|
89
|
+
if (this.powerUpGames.items.length < this.powerUpGames.total) {
|
|
90
|
+
this.initializeGamesObserver();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
render() {
|
|
94
|
+
var _a, _b;
|
|
95
|
+
return h("div", { key: '0d034307e070a8ba1d88303c3e3093ba567444b2', class: 'IngamePowerUpGamesContainer', ref: (el) => (this.stylingContainer = el) }, h("div", { key: '7b01f05d91d274da4ae0de3fc63e55927946b095', class: 'TopBar' }, h("div", { key: 'f8664bf99bb12513f281fe67ee24cd0794d9ba66', class: 'ReturnIcon CircleLinearBorder', onClick: this.backFromPowerupGamesEvent.emit, innerHTML: ReturnSvg }), this.powerUp &&
|
|
96
|
+
h("div", { key: '56083e9dfbc469875b0448f471c455ef8e1fb613', class: 'Title TextContent' }, h("span", { key: '6cde7a32b98c4f8d240cfda6f715e2d3fd4b0a25', class: 'Name' }, this.powerUp.displayName), " /", h("div", { key: 'a2045a41ad40665fa553b7f1e2a25628344188fc', class: 'Label' }, translate('games', this.language)), h("div", { key: 'a2cc2c8a5ebb29b097da802984099860410e0c25', class: 'GamesTotal' }, "( ", this.powerUpGames.total || '', " )"))), h("div", { key: 'b335d598aeea740b4e4a2e58a4061bf092abb773', class: 'GamesWrapper Card ' }, this.isLoadingGames && this.powerUpGames.items.length === 0 &&
|
|
97
|
+
h("div", { key: 'fced976e5554f7864fcf8755494c0cfd74f19a0f', class: 'Loading' }, h("div", { key: '8653c05c761078e11d6c060e5f1d519a133f2d8a', class: 'smart-loader' }, h("div", { key: '4404881893636a48de508d95ab8d6bd09d05acae', class: "smart-item" }), h("div", { key: '8aeafd883609d5840f7603b58300ee9c9350746c', class: "smart-item" }), h("div", { key: 'ded309b5a38d7775c27b3b38dd78746caf5aa557', class: "smart-item" }))), !this.isLoadingGames && !this.powerUp ?
|
|
98
|
+
h("div", { class: 'NoData' }, translate('noDataFound', this.language), " ")
|
|
99
|
+
:
|
|
100
|
+
h("div", { class: 'CircleInner GamesList' }, h("div", { class: 'Games FlexRow' }, this.powerUpGames.total > 0 &&
|
|
101
|
+
this.powerUpGames.items.map((g, index) => {
|
|
102
|
+
const isLastItem = index === this.powerUpGames.items.length - 1;
|
|
103
|
+
return h("div", { class: 'Game', ref: isLastItem ? (el) => (this.lastGameElement = el) : null }, h("ui-image", { src: g.thumbnail, alt: g.name }), h("div", { class: 'GameMask', onClick: this.onGameClick.bind(this, g) }, h("div", { class: 'GameStartBtn' }, h("div", { class: 'PlayIcon' }), h("span", null, translate('playNow', this.language)))));
|
|
104
|
+
}), this.isLoadingGames && ((_b = (_a = this.powerUpGames) === null || _a === void 0 ? void 0 : _a.items) === null || _b === void 0 ? void 0 : _b.length) > this.limit &&
|
|
105
|
+
h("p", { class: 'LoadingMore' }, translate('loadingMore', this.language))))));
|
|
106
|
+
}
|
|
107
|
+
handleClientStylingChange(newValue, oldValue) {
|
|
108
|
+
if (newValue != oldValue) {
|
|
109
|
+
setClientStyling(this.stylingContainer, this.clientStyling);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
handleClientStylingUrlChange(newValue, oldValue) {
|
|
113
|
+
if (newValue != oldValue) {
|
|
114
|
+
setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
handleMbSourceChange(newValue, oldValue) {
|
|
118
|
+
if (newValue != oldValue) {
|
|
119
|
+
setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
componentWillLoad() {
|
|
123
|
+
this.loadMoreGames();
|
|
124
|
+
}
|
|
125
|
+
componentDidLoad() {
|
|
126
|
+
if (this.stylingContainer) {
|
|
127
|
+
if (this.mbSource)
|
|
128
|
+
setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
|
|
129
|
+
if (this.clientStyling)
|
|
130
|
+
setClientStyling(this.stylingContainer, this.clientStyling);
|
|
131
|
+
if (this.clientStylingUrl)
|
|
132
|
+
setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
disconnectedCallback() {
|
|
136
|
+
this.stylingSubscription && this.stylingSubscription.unsubscribe();
|
|
137
|
+
if (this.abortController) {
|
|
138
|
+
this.abortController.abort();
|
|
139
|
+
}
|
|
140
|
+
if (this.loadMoreGamesObserver) {
|
|
141
|
+
this.loadMoreGamesObserver.disconnect();
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
static get is() { return "bonus-powerups-ingame-games"; }
|
|
145
|
+
static get encapsulation() { return "shadow"; }
|
|
146
|
+
static get originalStyleUrls() {
|
|
147
|
+
return {
|
|
148
|
+
"$": ["bonus-powerups-ingame-games.scss"]
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
static get styleUrls() {
|
|
152
|
+
return {
|
|
153
|
+
"$": ["bonus-powerups-ingame-games.css"]
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
static get properties() {
|
|
157
|
+
return {
|
|
158
|
+
"mbSource": {
|
|
159
|
+
"type": "string",
|
|
160
|
+
"mutable": false,
|
|
161
|
+
"complexType": {
|
|
162
|
+
"original": "string",
|
|
163
|
+
"resolved": "string",
|
|
164
|
+
"references": {}
|
|
165
|
+
},
|
|
166
|
+
"required": false,
|
|
167
|
+
"optional": false,
|
|
168
|
+
"docs": {
|
|
169
|
+
"tags": [],
|
|
170
|
+
"text": ""
|
|
171
|
+
},
|
|
172
|
+
"attribute": "mb-source",
|
|
173
|
+
"reflect": true
|
|
174
|
+
},
|
|
175
|
+
"clientStyling": {
|
|
176
|
+
"type": "string",
|
|
177
|
+
"mutable": false,
|
|
178
|
+
"complexType": {
|
|
179
|
+
"original": "string",
|
|
180
|
+
"resolved": "string",
|
|
181
|
+
"references": {}
|
|
182
|
+
},
|
|
183
|
+
"required": false,
|
|
184
|
+
"optional": false,
|
|
185
|
+
"docs": {
|
|
186
|
+
"tags": [],
|
|
187
|
+
"text": ""
|
|
188
|
+
},
|
|
189
|
+
"attribute": "client-styling",
|
|
190
|
+
"reflect": true
|
|
191
|
+
},
|
|
192
|
+
"clientStylingUrl": {
|
|
193
|
+
"type": "string",
|
|
194
|
+
"mutable": false,
|
|
195
|
+
"complexType": {
|
|
196
|
+
"original": "string",
|
|
197
|
+
"resolved": "string",
|
|
198
|
+
"references": {}
|
|
199
|
+
},
|
|
200
|
+
"required": false,
|
|
201
|
+
"optional": false,
|
|
202
|
+
"docs": {
|
|
203
|
+
"tags": [],
|
|
204
|
+
"text": ""
|
|
205
|
+
},
|
|
206
|
+
"attribute": "client-styling-url",
|
|
207
|
+
"reflect": true
|
|
208
|
+
},
|
|
209
|
+
"translationUrl": {
|
|
210
|
+
"type": "string",
|
|
211
|
+
"mutable": false,
|
|
212
|
+
"complexType": {
|
|
213
|
+
"original": "string",
|
|
214
|
+
"resolved": "string",
|
|
215
|
+
"references": {}
|
|
216
|
+
},
|
|
217
|
+
"required": false,
|
|
218
|
+
"optional": false,
|
|
219
|
+
"docs": {
|
|
220
|
+
"tags": [],
|
|
221
|
+
"text": ""
|
|
222
|
+
},
|
|
223
|
+
"attribute": "translation-url",
|
|
224
|
+
"reflect": true
|
|
225
|
+
},
|
|
226
|
+
"language": {
|
|
227
|
+
"type": "string",
|
|
228
|
+
"mutable": false,
|
|
229
|
+
"complexType": {
|
|
230
|
+
"original": "string",
|
|
231
|
+
"resolved": "string",
|
|
232
|
+
"references": {}
|
|
233
|
+
},
|
|
234
|
+
"required": false,
|
|
235
|
+
"optional": false,
|
|
236
|
+
"docs": {
|
|
237
|
+
"tags": [],
|
|
238
|
+
"text": ""
|
|
239
|
+
},
|
|
240
|
+
"attribute": "language",
|
|
241
|
+
"reflect": true,
|
|
242
|
+
"defaultValue": "'en'"
|
|
243
|
+
},
|
|
244
|
+
"endpoint": {
|
|
245
|
+
"type": "string",
|
|
246
|
+
"mutable": false,
|
|
247
|
+
"complexType": {
|
|
248
|
+
"original": "string",
|
|
249
|
+
"resolved": "string",
|
|
250
|
+
"references": {}
|
|
251
|
+
},
|
|
252
|
+
"required": true,
|
|
253
|
+
"optional": false,
|
|
254
|
+
"docs": {
|
|
255
|
+
"tags": [],
|
|
256
|
+
"text": ""
|
|
257
|
+
},
|
|
258
|
+
"attribute": "endpoint",
|
|
259
|
+
"reflect": true
|
|
260
|
+
},
|
|
261
|
+
"session": {
|
|
262
|
+
"type": "string",
|
|
263
|
+
"mutable": false,
|
|
264
|
+
"complexType": {
|
|
265
|
+
"original": "string",
|
|
266
|
+
"resolved": "string",
|
|
267
|
+
"references": {}
|
|
268
|
+
},
|
|
269
|
+
"required": true,
|
|
270
|
+
"optional": false,
|
|
271
|
+
"docs": {
|
|
272
|
+
"tags": [],
|
|
273
|
+
"text": ""
|
|
274
|
+
},
|
|
275
|
+
"attribute": "session",
|
|
276
|
+
"reflect": true
|
|
277
|
+
},
|
|
278
|
+
"powerupId": {
|
|
279
|
+
"type": "string",
|
|
280
|
+
"mutable": false,
|
|
281
|
+
"complexType": {
|
|
282
|
+
"original": "string",
|
|
283
|
+
"resolved": "string",
|
|
284
|
+
"references": {}
|
|
285
|
+
},
|
|
286
|
+
"required": true,
|
|
287
|
+
"optional": false,
|
|
288
|
+
"docs": {
|
|
289
|
+
"tags": [],
|
|
290
|
+
"text": ""
|
|
291
|
+
},
|
|
292
|
+
"attribute": "powerup-id",
|
|
293
|
+
"reflect": true
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
static get states() {
|
|
298
|
+
return {
|
|
299
|
+
"isLoadingGames": {},
|
|
300
|
+
"powerUpGames": {},
|
|
301
|
+
"powerUp": {},
|
|
302
|
+
"limit": {}
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
static get events() {
|
|
306
|
+
return [{
|
|
307
|
+
"method": "backFromPowerupGamesEvent",
|
|
308
|
+
"name": "backFromPowerupGames",
|
|
309
|
+
"bubbles": true,
|
|
310
|
+
"cancelable": true,
|
|
311
|
+
"composed": true,
|
|
312
|
+
"docs": {
|
|
313
|
+
"tags": [],
|
|
314
|
+
"text": ""
|
|
315
|
+
},
|
|
316
|
+
"complexType": {
|
|
317
|
+
"original": "any",
|
|
318
|
+
"resolved": "any",
|
|
319
|
+
"references": {}
|
|
320
|
+
}
|
|
321
|
+
}];
|
|
322
|
+
}
|
|
323
|
+
static get watchers() {
|
|
324
|
+
return [{
|
|
325
|
+
"propName": "clientStyling",
|
|
326
|
+
"methodName": "handleClientStylingChange"
|
|
327
|
+
}, {
|
|
328
|
+
"propName": "clientStylingUrl",
|
|
329
|
+
"methodName": "handleClientStylingUrlChange"
|
|
330
|
+
}, {
|
|
331
|
+
"propName": "mbSource",
|
|
332
|
+
"methodName": "handleMbSourceChange"
|
|
333
|
+
}];
|
|
334
|
+
}
|
|
335
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { BonusPowerupsIngameGames } from './bonus-powerups-ingame-games';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components/bonus-powerups-ingame-games';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const DEFAULT_LANGUAGE = 'en';
|
|
2
|
+
const TRANSLATIONS = {
|
|
3
|
+
en: {
|
|
4
|
+
playNow: 'Play Now',
|
|
5
|
+
games: 'Games',
|
|
6
|
+
noDataFound: 'No data found',
|
|
7
|
+
loading: 'Loading',
|
|
8
|
+
loadingMore: 'Loading More'
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
export const getTranslations = (url) => {
|
|
12
|
+
return new Promise((resolve) => {
|
|
13
|
+
fetch(url)
|
|
14
|
+
.then((res) => res.json())
|
|
15
|
+
.then((data) => {
|
|
16
|
+
Object.keys(data).forEach((lang) => {
|
|
17
|
+
if (!TRANSLATIONS[lang]) {
|
|
18
|
+
TRANSLATIONS[lang] = {};
|
|
19
|
+
}
|
|
20
|
+
for (let key in data[lang]) {
|
|
21
|
+
TRANSLATIONS[lang][key] = data[lang][key];
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
resolve(true);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
export const translate = (key, customLang, values) => {
|
|
29
|
+
const lang = customLang;
|
|
30
|
+
let translation = TRANSLATIONS[(lang !== undefined) && (lang in TRANSLATIONS) ? lang : DEFAULT_LANGUAGE][key];
|
|
31
|
+
if (values !== undefined) {
|
|
32
|
+
for (const [key, value] of Object.entries(values.values)) {
|
|
33
|
+
const regex = new RegExp(`{${key}}`, 'g');
|
|
34
|
+
translation = translation.replace(regex, value);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return translation;
|
|
38
|
+
};
|