@everymatrix/casino-game-page 0.0.216 → 0.0.220
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/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@everymatrix/casino-game-page",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.220",
|
4
4
|
"main": "dist/casino-game-page.js",
|
5
5
|
"svelte": "src/index.ts",
|
6
6
|
"scripts": {
|
@@ -36,5 +36,5 @@
|
|
36
36
|
"publishConfig": {
|
37
37
|
"access": "public"
|
38
38
|
},
|
39
|
-
"gitHead": "
|
39
|
+
"gitHead": "b7cf586f6e593e311259814b945a2806c80f1d0b"
|
40
40
|
}
|
@@ -6,45 +6,52 @@
|
|
6
6
|
import { _, addNewMessages, setupI18n } from './i18n';
|
7
7
|
import { GamePageTranslations } from './translations';
|
8
8
|
|
9
|
+
// Native bridge
|
10
|
+
import {
|
11
|
+
isNative,
|
12
|
+
call as callNative,
|
13
|
+
registerEventListener as registerNativeEventListener,
|
14
|
+
} from 'js-native-bridge';
|
15
|
+
|
9
16
|
import moment from 'moment';
|
10
17
|
|
11
|
-
export let endpoint:
|
12
|
-
export let datasource:
|
13
|
-
export let lang:
|
14
|
-
export let session:
|
15
|
-
export let userid:
|
16
|
-
export let clientstyling:
|
17
|
-
export let clientstylingurl:
|
18
|
+
export let endpoint:string = '';
|
19
|
+
export let datasource:string = '';
|
20
|
+
export let lang:string = ''; // Language
|
21
|
+
export let session:string = ''; // Value for sessionID
|
22
|
+
export let userid:string = ''; // Value for UserID;
|
23
|
+
export let clientstyling:string = '';
|
24
|
+
export let clientstylingurl:string = '';
|
18
25
|
export let favorites:string = '';
|
19
26
|
|
20
|
-
export let loginurl:
|
21
|
-
export let registerurl:
|
22
|
-
export let depositurl:
|
23
|
-
export let loginevent:
|
24
|
-
export let registerevent:
|
25
|
-
export let depositevent:
|
27
|
+
export let loginurl:string = '';
|
28
|
+
export let registerurl:string = '';
|
29
|
+
export let depositurl:string = '';
|
30
|
+
export let loginevent:string = '';
|
31
|
+
export let registerevent:string = '';
|
32
|
+
export let depositevent:string = '';
|
26
33
|
|
27
|
-
export let clockformat:
|
28
|
-
export let haspanicbutton:
|
34
|
+
export let clockformat:string = '';
|
35
|
+
export let haspanicbutton:string = 'false';
|
29
36
|
|
30
37
|
let time:Object;
|
31
38
|
let iframe:any;
|
32
39
|
|
33
|
-
let isLoggedIn:
|
34
|
-
let hasErrors:
|
35
|
-
let isLoading:
|
40
|
+
let isLoggedIn:boolean = false;
|
41
|
+
let hasErrors:boolean = false;
|
42
|
+
let isLoading:boolean = true;
|
36
43
|
|
37
|
-
let playerID:
|
38
|
-
let sessionID:
|
44
|
+
let playerID:string;
|
45
|
+
let sessionID:string;
|
39
46
|
|
40
47
|
let game:any;
|
41
|
-
let detailsObtained:
|
42
|
-
let funMode:
|
43
|
-
let anonymousFunMode:
|
48
|
+
let detailsObtained:boolean = false;
|
49
|
+
let funMode:boolean = false;
|
50
|
+
let anonymousFunMode:boolean = false;
|
44
51
|
|
45
52
|
let gameFrameContainer:HTMLElement;
|
46
53
|
let gameInnerContainer:HTMLElement;
|
47
|
-
let isFullscreen:
|
54
|
+
let isFullscreen:boolean = false;
|
48
55
|
let gameFrameCloseFullScreen:HTMLElement;
|
49
56
|
let modalFrameWidth:number;
|
50
57
|
let modalFrameHeight:number;
|
@@ -53,27 +60,31 @@
|
|
53
60
|
let definitiveIframeWidth:string;
|
54
61
|
let definitiveIframeHeight:string;
|
55
62
|
let userAgent:any = window.navigator.userAgent;
|
56
|
-
let mobileView:
|
63
|
+
let mobileView:boolean = false;
|
57
64
|
let favoriteGames: Array<Object> = [];
|
58
65
|
let customStylingContainer:HTMLElement;
|
59
66
|
|
67
|
+
let isOnNative:boolean = false;
|
68
|
+
|
60
69
|
setupI18n({ withLocale: 'en', translations: {}});
|
61
70
|
|
62
71
|
Object.keys(GamePageTranslations).forEach((item) => {
|
63
72
|
addNewMessages(item, GamePageTranslations[item]);
|
64
73
|
});
|
65
74
|
|
66
|
-
|
67
|
-
|
75
|
+
// @TODO game typescript model type
|
76
|
+
const formatGameLaunchUrl = (game:any):void => {
|
77
|
+
let url:URL = new URL(game.launchUrl);
|
68
78
|
|
69
79
|
url.searchParams.append('language', lang);
|
70
80
|
|
81
|
+
// @TODO wtf? session check or go home
|
71
82
|
// Maybe we should check if the session is valid, somehow?
|
72
83
|
if (sessionID && sessionID.length > 0) {
|
73
84
|
isLoggedIn = true;
|
74
85
|
|
75
86
|
url.searchParams.append('_sid', sessionID)
|
76
|
-
url.searchParams.append('funMode', false)
|
87
|
+
url.searchParams.append('funMode', 'false')
|
77
88
|
url.searchParams.append('language', lang)
|
78
89
|
}
|
79
90
|
|
@@ -82,14 +93,15 @@
|
|
82
93
|
return game;
|
83
94
|
}
|
84
95
|
|
85
|
-
const messageHandler = (e:any) => {
|
96
|
+
const messageHandler = (e:any):void => {
|
86
97
|
switch (e.data.type) {
|
87
98
|
case 'GameLaunchID':
|
88
|
-
let url = new URL(`${endpoint}/casino/games/${e.data.gameId}`);
|
99
|
+
let url:URL = new URL(`${endpoint}/casino/games/${e.data.gameId}`);
|
89
100
|
|
90
101
|
url.searchParams.append('language', lang);
|
102
|
+
url.searchParams.append('expand', 'vendor');
|
91
103
|
|
92
|
-
fetch(url)
|
104
|
+
fetch(url.href)
|
93
105
|
.then((res:any) => res.json())
|
94
106
|
.then((data:any) => {
|
95
107
|
game = formatGameLaunchUrl(data[0]);
|
@@ -166,14 +178,10 @@
|
|
166
178
|
favoriteGames = e.data.receivedFavoriteResults.items;
|
167
179
|
}
|
168
180
|
break;
|
169
|
-
|
170
|
-
default:
|
171
|
-
// Nothing to do here
|
172
|
-
break;
|
173
181
|
}
|
174
182
|
}
|
175
183
|
|
176
|
-
const checkFavorite = (gameId:string) => {
|
184
|
+
const checkFavorite = (gameId:string):boolean => {
|
177
185
|
if (favoriteGames.findIndex(obj => obj.id == gameId) !== -1) {
|
178
186
|
return true;
|
179
187
|
} else {
|
@@ -181,7 +189,7 @@
|
|
181
189
|
}
|
182
190
|
}
|
183
191
|
|
184
|
-
const toggleFavoriteGame = (id:any) => {
|
192
|
+
const toggleFavoriteGame = (id:any):void => {
|
185
193
|
let triggerFactor = "gamepage";
|
186
194
|
|
187
195
|
if (game.isFavored) {
|
@@ -193,12 +201,13 @@
|
|
193
201
|
}
|
194
202
|
}
|
195
203
|
|
196
|
-
|
197
|
-
let url = new URL(`${endpoint}/casino/games/${gameId}`);
|
204
|
+
const openGameFrame = (gameId:string, gameFunMode:boolean):void => {
|
205
|
+
let url:URL = new URL(`${endpoint}/casino/games/${gameId}`);
|
198
206
|
|
199
207
|
url.searchParams.append('language', lang);
|
208
|
+
// url.searchParams.append('expand', 'vendor');
|
200
209
|
|
201
|
-
fetch(url)
|
210
|
+
fetch(url.href)
|
202
211
|
.then((res:any) => res.json())
|
203
212
|
.then((data:any) => {
|
204
213
|
game = formatGameLaunchUrl(data[0]);
|
@@ -237,11 +246,21 @@
|
|
237
246
|
definitiveIframeHeight = Math.floor(gameFrameHeight) + "px";
|
238
247
|
}
|
239
248
|
|
240
|
-
const openGameWindow = (game:any) => {
|
241
|
-
|
249
|
+
const openGameWindow = (game:any):void => {
|
250
|
+
if (isOnNative) {
|
251
|
+
let data = {
|
252
|
+
url: game.launchUrl,
|
253
|
+
id: game.id,
|
254
|
+
vendor: game.vendor.name
|
255
|
+
}
|
256
|
+
|
257
|
+
callNative('OPEN_GAME', data);
|
258
|
+
} else {
|
259
|
+
window.open(game.launchUrl, '_blank');
|
260
|
+
}
|
242
261
|
}
|
243
262
|
|
244
|
-
const resizeHandler = () => {
|
263
|
+
const resizeHandler = ():void => {
|
245
264
|
// sent to modal component a flag (detailsObtained) by witch to determine if a game is open
|
246
265
|
window.postMessage({ type: 'GameStateOnResize', detailsObtained }, window.location.href);
|
247
266
|
// make sure that a game is open before trying to get the element properties
|
@@ -254,36 +273,39 @@
|
|
254
273
|
}
|
255
274
|
|
256
275
|
// End section: keep aspect ratio for iframe on resize
|
257
|
-
const toggleLogin = () => {
|
276
|
+
const toggleLogin = ():void => {
|
258
277
|
if (loginevent) {
|
259
|
-
window.postMessage({ type: loginevent,
|
278
|
+
window.postMessage({ type: loginevent, transition: 'Login' }, window.location.href);
|
260
279
|
window.postMessage({ type: 'ModalClosed' }, window.location.href);
|
261
280
|
}
|
262
281
|
|
263
282
|
if (loginurl) {
|
264
|
-
|
283
|
+
// @ts-ignore
|
284
|
+
window.location = loginurl;
|
265
285
|
}
|
266
286
|
}
|
267
287
|
|
268
|
-
const toggleRegister = () => {
|
288
|
+
const toggleRegister = ():void => {
|
269
289
|
if (registerevent) {
|
270
|
-
window.postMessage({ type: registerevent,
|
290
|
+
window.postMessage({ type: registerevent, transition: 'Register' }, window.location.href);
|
271
291
|
window.postMessage({ type: 'ModalClosed' }, window.location.href);
|
272
292
|
}
|
273
293
|
|
274
294
|
if (registerurl) {
|
275
|
-
|
295
|
+
// @ts-ignore
|
296
|
+
window.location = registerurl;
|
276
297
|
}
|
277
298
|
}
|
278
299
|
|
279
|
-
const toggleDeposit = () => {
|
300
|
+
const toggleDeposit = ():void => {
|
280
301
|
if (depositevent) {
|
281
302
|
window.postMessage({ type: depositevent }, window.location.href);
|
282
303
|
window.postMessage({ type: 'ModalClosed' }, window.location.href);
|
283
304
|
}
|
284
305
|
|
285
306
|
if (depositurl) {
|
286
|
-
|
307
|
+
// @ts-ignore
|
308
|
+
window.location = depositurl;
|
287
309
|
}
|
288
310
|
}
|
289
311
|
|
@@ -329,11 +351,11 @@
|
|
329
351
|
}
|
330
352
|
}
|
331
353
|
|
332
|
-
const
|
354
|
+
const panicAction = ():void => {
|
333
355
|
window.postMessage({ type: 'PanicButtonClicked' }, window.location.href);
|
334
356
|
}
|
335
357
|
|
336
|
-
const refreshTime = () => {
|
358
|
+
const refreshTime = ():void => {
|
337
359
|
if (clockformat) {
|
338
360
|
time = moment().format(clockformat);
|
339
361
|
} else {
|
@@ -345,7 +367,7 @@
|
|
345
367
|
refreshTime();
|
346
368
|
}, 100);
|
347
369
|
|
348
|
-
const initialSetup = () => {
|
370
|
+
const initialSetup = ():void => {
|
349
371
|
isLoading = false;
|
350
372
|
|
351
373
|
if (isMobile(userAgent)) {
|
@@ -353,7 +375,7 @@
|
|
353
375
|
}
|
354
376
|
}
|
355
377
|
|
356
|
-
const setSession = () => {
|
378
|
+
const setSession = ():void => {
|
357
379
|
checkSession(endpoint, session).then((res:any) => {
|
358
380
|
sessionID = res.Guid;
|
359
381
|
playerID = res.UserID;
|
@@ -364,17 +386,19 @@
|
|
364
386
|
});
|
365
387
|
}
|
366
388
|
|
367
|
-
const setClientStyling = () => {
|
389
|
+
const setClientStyling = ():void => {
|
368
390
|
let sheet = document.createElement('style');
|
369
391
|
sheet.innerHTML = clientstyling;
|
370
392
|
customStylingContainer.appendChild(sheet);
|
371
393
|
}
|
372
394
|
|
373
|
-
const setClientStylingURL = () => {
|
395
|
+
const setClientStylingURL = ():void => {
|
374
396
|
let cssFile:HTMLElement = document.createElement('style');
|
375
397
|
|
376
398
|
if (clientstylingurl) {
|
377
|
-
|
399
|
+
let url:URL = new URL(clientstylingurl);
|
400
|
+
|
401
|
+
fetch(url.href)
|
378
402
|
.then((res:any) => res.text())
|
379
403
|
.then((data:any) => {
|
380
404
|
cssFile.innerHTML = data
|
@@ -390,6 +414,8 @@
|
|
390
414
|
window.addEventListener('resize', resizeHandler, false);
|
391
415
|
window.addEventListener('message', messageHandler, false);
|
392
416
|
|
417
|
+
isOnNative = !!isNative(userAgent);
|
418
|
+
|
393
419
|
return () => {
|
394
420
|
window.removeEventListener('resize', resizeHandler);
|
395
421
|
window.removeEventListener('message', messageHandler);
|
@@ -449,7 +475,7 @@
|
|
449
475
|
<svg class="w-1 h-1" fill="none" stroke="white" width="34px" height="34px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
|
450
476
|
<p>{$_('gamePage.break')}</p>
|
451
477
|
</div>
|
452
|
-
<button class="Button" on:click={() =>
|
478
|
+
<button class="Button" on:click={() => panicAction()}>{$_('gamePage.breakButton')}</button>
|
453
479
|
</div>
|
454
480
|
{/if}
|
455
481
|
<p>{time}</p>
|
@@ -489,7 +515,7 @@
|
|
489
515
|
<div class="PanicSection">
|
490
516
|
<svg class="w-1 h-1" fill="none" stroke="white" width="34px" height="34px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
|
491
517
|
<p>{$_('gamePage.break')}</p>
|
492
|
-
<button class="Button" on:click={() =>
|
518
|
+
<button class="Button" on:click={() => panicAction()}>{$_('gamePage.breakButton')}</button>
|
493
519
|
</div>
|
494
520
|
{/if}
|
495
521
|
{#if isFullscreen}
|
package/src/translations.js
CHANGED
@@ -17,8 +17,8 @@ export const GamePageTranslations = {
|
|
17
17
|
deposit: 'Einzahlung',
|
18
18
|
playForFun: 'Play for fun',
|
19
19
|
playNow: 'Jetzt starten!',
|
20
|
-
break: '
|
21
|
-
breakButton: '24
|
20
|
+
break: 'Mach mal einen Tag Pause!',
|
21
|
+
breakButton: '24 Stunden Auszeit',
|
22
22
|
}
|
23
23
|
},
|
24
24
|
it: {
|