@everymatrix/casino-game-page 0.0.260 → 0.0.263

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/index.html CHANGED
@@ -30,8 +30,13 @@
30
30
  </header>
31
31
 
32
32
  <div class="webcomponent">
33
- <casino-game-page></casino-game-page>
33
+ <casino-game-page
34
+ gameid="46985"
35
+ lang="en"
36
+ endpoint="https://demo-api.stage.norway.everymatrix.com/v1"
37
+ playforfun="true"
38
+ ></casino-game-page>
34
39
  </div>
35
-
40
+
36
41
  </body>
37
42
  </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@everymatrix/casino-game-page",
3
- "version": "0.0.260",
3
+ "version": "0.0.263",
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": "a30fdd6f6180c69aabbc0daf1bf2a2e1342bf0e2"
39
+ "gitHead": "fccb99c4d5259efacf828703242697132621b19d"
40
40
  }
@@ -16,7 +16,6 @@
16
16
  import moment from 'moment';
17
17
 
18
18
  export let endpoint:string = '';
19
- export let datasource:string = '';
20
19
  export let lang:string = ''; // Language
21
20
  export let session:string = ''; // Value for sessionID
22
21
  export let userid:string = ''; // Value for UserID;
@@ -35,6 +34,8 @@
35
34
  export let haspanicbutton:string = 'false';
36
35
  export let playforfun:string = 'true';
37
36
 
37
+ export let gameid:string = '';
38
+
38
39
  let time:Object;
39
40
  let iframe:any;
40
41
 
@@ -49,6 +50,7 @@
49
50
  let detailsObtained:boolean = false;
50
51
  let funMode:boolean = false;
51
52
  let anonymousFunMode:boolean = false;
53
+ let isModal:boolean = true;
52
54
 
53
55
  let gameFrameContainer:HTMLElement;
54
56
  let gameInnerContainer:HTMLElement;
@@ -90,35 +92,45 @@
90
92
  return game;
91
93
  }
92
94
 
93
- const messageHandler = (e:any):void => {
94
- switch (e.data.type) {
95
- case 'GameLaunchID':
96
- let url:URL = new URL(`${endpoint}/casino/games/${e.data.gameId}`);
95
+ const createGameURL = (gameId:string, modal?):void => {
96
+ let url:URL = new URL(`${endpoint}/casino/games/${gameId}`);
97
97
 
98
- url.searchParams.append('language', lang);
99
- url.searchParams.append('expand', 'vendor');
98
+ url.searchParams.append('language', lang);
99
+ url.searchParams.append('expand', 'vendor');
100
100
 
101
- fetch(url.href)
102
- .then((res:any) => res.json())
103
- .then((data:any) => {
104
- game = formatGameLaunchUrl(data[0]);
101
+ isModal = modal || false;
105
102
 
106
- if (game.launchUrl) {
107
- detailsObtained = true;
108
- funMode = playforfun == 'true' ? game.hasFunMode : false;
109
- anonymousFunMode = playforfun == 'true' ? game.hasAnonymousFunMode : false;
110
- }
111
- }, (err:any) => {
112
- console.error('There was an error', err);
103
+ fetch(url.href)
104
+ .then((res:any) => res.json())
105
+ .then((data:any) => {
106
+ game = formatGameLaunchUrl(data[0]);
113
107
 
114
- hasErrors = true;
115
- }).then(() => {
116
- if (gameFrameContainer) {
117
- keepIframeRatio();
118
- }
119
- });
108
+ if (game.launchUrl) {
109
+ detailsObtained = true;
110
+ funMode = playforfun == 'true' ? game.hasFunMode : false;
111
+ anonymousFunMode = playforfun == 'true' ? game.hasAnonymousFunMode : false;
112
+ }
113
+ }, (err:any) => {
114
+ console.error('There was an error', err);
115
+
116
+ hasErrors = true;
117
+ }).then(() => {
118
+ if (gameFrameContainer) {
119
+ if (isModal) {
120
+ keepIframeRatio();
121
+ } else {
122
+ maximizeGameFrame();
123
+ }
124
+ }
125
+ });
120
126
 
121
- window.postMessage({ type: 'RequestModalSize' }, window.location.href);
127
+ window.postMessage({ type: 'RequestModalSize' }, window.location.href);
128
+ }
129
+
130
+ const messageHandler = (e:any):void => {
131
+ switch (e.data.type) {
132
+ case 'GameLaunchID':
133
+ createGameURL(e.data.gameId, true);
122
134
  break;
123
135
 
124
136
  case 'LaunchGameFrame':
@@ -194,6 +206,12 @@
194
206
  }
195
207
  }
196
208
 
209
+ const setGameData = (game, gameFunMode) => {
210
+ anonymousFunMode = playforfun == 'true' ? game.hasAnonymousFunMode : false;
211
+ funMode = playforfun == 'true' ? gameFunMode : false;
212
+ detailsObtained = true;
213
+ return checkFavorite(game.id);
214
+ }
197
215
  const openGameFrame = (gameId:string, gameFunMode:boolean):void => {
198
216
  let url:URL = new URL(`${endpoint}/casino/games/${gameId}`);
199
217
 
@@ -203,18 +221,24 @@
203
221
  .then((res:any) => res.json())
204
222
  .then((data:any) => {
205
223
  game = formatGameLaunchUrl(data[0]);
206
-
207
224
  if (game.launchUrl) {
208
- anonymousFunMode = playforfun == 'true' ? game.hasAnonymousFunMode : false;
209
- funMode = playforfun == 'true' ? gameFunMode : false;
210
- detailsObtained = true;
211
- game.isFavored = checkFavorite(game.id);
225
+ game.isFavored = setGameData(game, gameFunMode);
212
226
  }
213
227
  });
214
228
  }
229
+ const maximizeGameFrame = ():void => {
230
+ modalFrameWidth = game.width;
231
+ modalFrameHeight = game.height;
232
+
233
+ definitiveIframeWidth = game.width;
234
+ definitiveIframeHeight = game.height;
235
+
236
+ gameFrameWidth = game.width;
237
+ gameFrameHeight = game.height;
238
+ }
215
239
 
216
240
  // Start section: keep aspect ratio for iframe on resize
217
- let keepIframeRatio = () => {
241
+ const keepIframeRatio = ():void => {
218
242
  let iframeContainer = getComputedStyle(gameFrameContainer);
219
243
  let gameFrame = getComputedStyle(gameInnerContainer);
220
244
  let gameContainerWidth = parseInt(iframeContainer.width.slice(0, -2));
@@ -355,17 +379,15 @@
355
379
  }
356
380
  }
357
381
 
358
- const timeInterval = setInterval(() => {
382
+ const timeInterval = setInterval(():void => {
359
383
  refreshTime();
360
384
  }, 100);
361
385
 
362
- const initialSetup = ():void => {
386
+ const setActiveLanguage = ():void => {
363
387
  setLocale(lang);
364
- isLoading = false;
365
388
 
366
- if (isMobile(userAgent)) {
367
- mobileView = true;
368
- }
389
+ isLoading = false;
390
+ mobileView = isMobile(userAgent);
369
391
  }
370
392
 
371
393
  const setSession = ():void => {
@@ -417,7 +439,8 @@
417
439
  }
418
440
  });
419
441
 
420
- $: endpoint && datasource && lang && initialSetup();
442
+ $: lang && setActiveLanguage();
443
+ $: endpoint && gameid && lang && createGameURL(gameid);
421
444
  $: session && userid && endpoint && setSession();
422
445
  $: clientstyling && setClientStyling();
423
446
  $: clientstylingurl && setClientStylingURL();
@@ -526,7 +549,7 @@
526
549
  {:else}
527
550
  {#if funMode}
528
551
  <div id="IframeContainer" part="IframeContainer" bind:this={gameFrameContainer} class:FullsScreenLayout={isFullscreen} style="width: {modalFrameWidth}; height: {modalFrameHeight}">
529
- <div id="IframeGame" part="IframeGame" bind:this={gameInnerContainer} style="width: {isFullscreen ? '100%' : definitiveIframeWidth}; height: {isFullscreen ? '100%' : definitiveIframeHeight}; max-width: {isFullscreen ? 'none' : (game.width ? Math.floor(game.width) + 'px' : '1280px')}; max-height: {isFullscreen ? 'none' : (game.height ? (Math.floor(game.height) + 100) + 'px' : '720px')}">
552
+ <div id="IframeGame" part="IframeGame" bind:this={gameInnerContainer} style="width: {isFullscreen ? '100%' : definitiveIframeWidth}; height: {isFullscreen ? '100%' : definitiveIframeHeight}; max-width: {isFullscreen || !isModal ? 'none' : (game.width ? Math.floor(game.width) + 'px' : '1280px')}; max-height: {isFullscreen || !isModal ? 'none' : (game.height ? (Math.floor(game.height) + 100) + 'px' : '720px')}">
530
553
  <iframe title="Games" class="GamesContainer" part="GamesContainer" aria-hidden="false" src={game.launchUrl} bind:this={iframe}/>
531
554
  <div class="BottomGame" part="BottomGame">
532
555
  <div class="ButtonsContainer" part="ButtonsContainer">
@@ -570,6 +593,10 @@
570
593
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji';
571
594
  }
572
595
 
596
+ .CasinoGamePageContainer {
597
+ height: 100%;
598
+ }
599
+
573
600
  .BottomGame {
574
601
  padding-left: 60px;
575
602
  padding-right: 60px;
@@ -690,8 +717,8 @@
690
717
  }
691
718
  .FavIconContainer {
692
719
  position: absolute;
693
- top: 42px;
694
- left: 42px;
720
+ top: 15px;
721
+ left: 15px;
695
722
  cursor: pointer;
696
723
  }
697
724
  .PanicSectionMobile {