@everymatrix/casino-page 1.0.3 → 1.0.8

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-page",
3
- "version": "1.0.3",
3
+ "version": "1.0.8",
4
4
  "main": "dist/casino-page.js",
5
5
  "svelte": "src/index.ts",
6
6
  "scripts": {
@@ -112,9 +112,7 @@
112
112
  let searchFocus:boolean = false;
113
113
  let lobbyScreen:boolean = true;
114
114
  let mostPlayedScreen:boolean = false;
115
- let mostPlayedEmpty:boolean = false;
116
115
  let lastPlayedScreen:boolean = false;
117
- let lastPlayedEmpty:boolean = false;
118
116
  let adjustingScroll:boolean = false;
119
117
  let searchBarCleared:boolean = true;
120
118
 
@@ -135,9 +133,8 @@
135
133
  const scrollOffset:number = 0;
136
134
 
137
135
  let scrollTop:boolean = false;
138
- let mostPlayedGames:Array<any> = [];
139
- let lastPlayedGames:Array<any> = [];
140
136
 
137
+ let activeRecentSearches:boolean = false;
141
138
  let favoredGamesCollection:Array<string> = [];
142
139
  let categoriesData;
143
140
  let receivedFavoriteResults:Object;
@@ -190,39 +187,6 @@
190
187
 
191
188
  case 'MOSTPLAYED':
192
189
  if (mostplayed == 'true') {
193
- isLoading = true;
194
-
195
- getMostPlayedGames({
196
- limit: 100,
197
- device: getDevice(userAgent),
198
- rounds: 10
199
- }).then((res:any) => {
200
- isLoading = false;
201
-
202
- if (res.count > 0) {
203
- let promises:any = [];
204
-
205
- res.items.forEach((item:any) => {
206
- let url:URL = new URL(`${endpoint}/casino/games/${item.gameId}`);
207
-
208
- url.searchParams.append('datasource', datasource);
209
- if (livecasino) {
210
- promises.push(fetch(url.href).then((res:any) => res.json()));
211
- } else {
212
- promises.push(fetch(url.href).then((res:any) => res.json()));
213
- }
214
- });
215
-
216
- Promise.all(promises).then((values:any) => {
217
- mostPlayedGames = values.map((item:any) => item[0]);
218
-
219
- window.postMessage({ type: 'MostPlayedData', mostPlayedGames }, window.location.href);
220
- });
221
- } else {
222
- mostPlayedEmpty = true;
223
- }
224
- });
225
-
226
190
  activeCategory = '';
227
191
  lobbyScreen = false;
228
192
  favoritesScreen = false;
@@ -232,38 +196,6 @@
232
196
 
233
197
  case 'LASTPLAYED':
234
198
  if (lastplayed == 'true') {
235
- isLoading = true;
236
-
237
- getLastPlayedCategory({
238
- device: getDevice(userAgent),
239
- period: lastplayedperiod || 'Last30Days'
240
- }).then((res:any) => {
241
- isLoading = false;
242
-
243
- if (res.count > 0) {
244
- let promises:any = [];
245
-
246
- res.items.forEach((item:any) => {
247
- let url:URL = new URL(`${endpoint}/casino/games/${item.gameId}`);
248
-
249
- url.searchParams.append('datasource', datasource);
250
- if (livecasino) {
251
- promises.push(fetch(url.href).then((res:any) => res.json()));
252
- } else {
253
- promises.push(fetch(url.href).then((res:any) => res.json()));
254
- }
255
- });
256
-
257
- Promise.all(promises).then((values:any) => {
258
- lastPlayedGames = values.map((item:any) => item[0]);
259
-
260
- window.postMessage({ type: 'LastPlayedData', lastPlayedGames }, window.location.href);
261
- });
262
- } else {
263
- lastPlayedEmpty = true;
264
- }
265
- });
266
-
267
199
  activeCategory = '';
268
200
  lobbyScreen = false;
269
201
  lastPlayedScreen = true;
@@ -343,111 +275,44 @@
343
275
  setFilterNumberValue();
344
276
  break;
345
277
 
346
- case 'GameHovered':
278
+ case 'GameHoveredPc':
347
279
  gameFocus = true;
348
280
  break;
349
281
 
350
- case 'GameBlur':
351
- gameFocus = false;
282
+ case 'GameBlurPc':
283
+ if(activeRecentSearches){
284
+ searchElement.focus();
285
+ gameFocus = false;
286
+ } else {
287
+ gameFocus = false;
288
+ }
352
289
  break;
353
290
 
354
- default:
355
- // Nothing to do here
291
+ case 'GameHoveredMobile':
292
+ gameFocus = true;
356
293
  break;
357
- }
358
- }
359
- }
360
-
361
- const getMostPlayedGames = (options:any) => {
362
- let url = new URL(`${endpoint}/player/${playerID}/games/most-played`);
363
-
364
- if (options.limit) {
365
- url.searchParams.append('limit', options.limit);
366
- }
367
-
368
- if (options.order) {
369
- url.searchParams.append('order', options.order);
370
- }
371
-
372
- url.searchParams.append('expand', 'games')
373
-
374
- let device = options.device;
375
-
376
- if (device) {
377
- if (device === 'PC') {
378
- url.searchParams.append('device', 'Desktop');
379
- } else {
380
- url.searchParams.append('device', 'Mobile');
381
- }
382
- } else {
383
- url.searchParams.append('device', 'All');
384
- }
385
-
386
- if (options.rounds) {
387
- url.searchParams.append('rounds', options.rounds);
388
- }
389
-
390
- urlCasino = livecasino ? url : url.href;
391
- return new Promise((resolve, reject) => {
392
- fetch(urlCasino)
393
- .then((res:any) => res.json())
394
- .then((data:any) => {
395
- resolve(data);
396
294
 
397
- //window.postMessage({ type: 'AddNewCategory', category: { name: 'Last played', id: 'LASTPLAYED' }}, window.location.href);
398
- //window.postMessage({ type: 'MostPlayedGames', data }, window.location.href);
399
- }).catch((err:any) => {
400
- console.error(err);
401
-
402
- reject(err);
403
- });
404
- });
405
- }
406
-
407
- const getLastPlayedCategory = (options:any) => {
408
- return new Promise((resolve, reject) => {
409
- let url = new URL(`${endpoint}/player/${playerID}/games/last-played`);
410
-
411
- if (options.limit) {
412
- url.searchParams.append('limit', options.limit);
413
- }
414
-
415
- if (options.order) {
416
- url.searchParams.append('order', options.order);
417
- }
295
+ case 'GameBlurMobile':
296
+ if(activeRecentSearches){
297
+ onBlur();
298
+ } else {
299
+ gameFocus = false;
300
+ }
301
+ break;
418
302
 
419
- let device = options.device;
303
+ case 'ModalClosed':
304
+ if(activeRecentSearches){
305
+ activeRecentSearches = false;
306
+ gameFocus = false;
307
+ }
308
+ break;
420
309
 
421
- if (device) {
422
- if (device === 'PC') {
423
- url.searchParams.append('device', 'Desktop');
424
- } else {
425
- url.searchParams.append('device', 'Mobile');
310
+ default:
311
+ // Nothing to do here
312
+ break;
426
313
  }
427
- } else {
428
- url.searchParams.append('device', 'All');
429
314
  }
430
-
431
- if (options.period) {
432
- url.searchParams.append('period', options.period);
433
- }
434
-
435
- urlCasino = livecasino ? url : url.href;
436
- fetch(urlCasino)
437
- .then((res:any) => res.json())
438
- .then((data:any) => {
439
- resolve(data);
440
-
441
- window.postMessage({ type: 'AddNewCategory', category: { name: 'Last Played', id: 'LASTPLAYED' }}, window.location.href);
442
- window.postMessage({ type: 'LastPlayedGames', data }, window.location.href);
443
- }).catch((err:any) => {
444
- console.error(err);
445
-
446
- reject(err);
447
- });
448
- });
449
315
  }
450
-
451
316
  //
452
317
  // --- START of Favorites section
453
318
  //
@@ -471,7 +336,6 @@
471
336
 
472
337
  updatedFavoriteResultsIds = getGamesIds(receivedFavoriteResults.items);
473
338
  }
474
-
475
339
  return receivedFavoriteResults;
476
340
  }).then((favResults) => {
477
341
  if (favoritesScreen) {
@@ -667,6 +531,7 @@
667
531
  }
668
532
 
669
533
  const onFocus = () => {
534
+ activeRecentSearches = true;
670
535
  if (endpoint && datasource && lang) {
671
536
  searchFocus = true;
672
537
 
@@ -708,6 +573,12 @@
708
573
  }
709
574
  }
710
575
  }
576
+ //Analytics event
577
+ if(typeof gtag == 'function'){
578
+ gtag('event', 'SearchInitialized', {
579
+ 'context': 'CasinoPage'
580
+ });
581
+ }
711
582
  }
712
583
 
713
584
  const onBlur = () => {
@@ -723,7 +594,8 @@
723
594
  window.postMessage({ type: 'CategoryUpdate', itemId: activeCategory }, window.location.href);
724
595
  }
725
596
 
726
- window.postMessage({ type: 'OutOfRecentSearches' }, window.location.href);
597
+ activeRecentSearches = false;
598
+ window.postMessage({ type: 'OutOfRecentSearches' }, window.location.href);
727
599
  }
728
600
  }
729
601
 
@@ -812,15 +684,6 @@
812
684
  //
813
685
  // --- START of communication with other widgets
814
686
  //
815
- const sendMostPlayed = (node:any, mostPlayedData:CategoriesData) => {
816
- window.postMessage({ type: 'MostPlayedData', mostPlayedData }, window.location.href);
817
- }
818
-
819
- const sendLastPlayed = (node:any, lastPlayedData:CategoriesData) => {
820
- window.postMessage({ type: 'LastPlayedData', lastPlayedData }, window.location.href);
821
- console.log('lastplayed 2');
822
- }
823
-
824
687
  const submitFilters = (venArray:Array<Object>) => {
825
688
  window.postMessage({ type: "AvailableVendors", venArray}, window.location.href);
826
689
  }
@@ -977,26 +840,6 @@
977
840
  }
978
841
  }
979
842
 
980
- const setClientStyling = () => {
981
- let sheet = document.createElement('style');
982
- sheet.innerHTML = clientstyling;
983
- customStylingContainer.appendChild(sheet);
984
- }
985
-
986
- const setClientStylingURL = () => {
987
- let cssFile:HTMLElement = document.createElement('style');
988
-
989
- fetch(new URL(clientstylingurl))
990
- .then((res:any) => res.text())
991
- .then((data:any) => {
992
- cssFile.innerHTML = data
993
-
994
- if (customStylingContainer) {
995
- setTimeout(() => { customStylingContainer.appendChild(cssFile); }, 1);
996
- }
997
- });
998
- }
999
-
1000
843
  const startInterval = (e:any):void => {
1001
844
  timer = 0;
1002
845
 
@@ -1037,6 +880,24 @@
1037
880
  panicButton?.removeEventListener("touchend", endInterval);
1038
881
  }
1039
882
 
883
+ const setClientStyling = () => {
884
+ let sheet = document.createElement('style');
885
+ sheet.innerHTML = clientstyling;
886
+ customStylingContainer.appendChild(sheet);
887
+ }
888
+
889
+ const setClientStylingURL = () => {
890
+ let cssFile:HTMLElement = document.createElement('style');
891
+
892
+ fetch(new URL(clientstylingurl))
893
+ .then((res:any) => res.text())
894
+ .then((data:any) => {
895
+ cssFile.innerHTML = data
896
+
897
+ setTimeout(() => { customStylingContainer.appendChild(cssFile); }, 1);
898
+ });
899
+ }
900
+
1040
901
  onMount(() => {
1041
902
  window.addEventListener('scroll', scrollHandler, false);
1042
903
  window.addEventListener('message', messageHandler, false);
@@ -1053,8 +914,8 @@
1053
914
  $: session && userid && endpoint && setSession();
1054
915
  $: endpoint && datasource && lang && alternativesearch && initialSetup();
1055
916
  $: lang && updateCategoriesLanguage();
1056
- $: clientstyling && setClientStyling();
1057
- $: clientstylingurl && setClientStylingURL();
917
+ $: clientstyling && customStylingContainer && setClientStyling();
918
+ $: clientstylingurl && customStylingContainer && setClientStylingURL();
1058
919
  $: panicButton && addEventsToDisplayedElements();
1059
920
  </script>
1060
921
 
@@ -1189,7 +1050,7 @@
1189
1050
  {/if}
1190
1051
 
1191
1052
  {#if playrandomgame == 'true' && searchFocus == false}
1192
- <casino-random-game {datasource} {endpoint} {lang} {gameevent} {randombuttonicon}>
1053
+ <casino-random-game {datasource} {endpoint} {lang} {gameevent} {randombuttonicon} {clientstyling} {clientstylingurl}>
1193
1054
  </casino-random-game>
1194
1055
  {/if}
1195
1056
 
@@ -1241,10 +1102,10 @@
1241
1102
  />
1242
1103
  </div>
1243
1104
  {/if}
1244
- {#if index === 4 && enablejackpotbanner == 'true'}
1105
+ {#if index === 4 && enablejackpotbanner == 'true'}
1245
1106
  <br>
1246
1107
  <jackpot-banner
1247
- title="Egypt Quest"
1108
+ title="Egypt Quest"
1248
1109
  currency = {currency || 'RON'}
1249
1110
  gameid = "999"
1250
1111
  {endpoint}
@@ -1257,7 +1118,9 @@
1257
1118
  {caticon2}
1258
1119
  {caticon3}
1259
1120
  {iconlabels}
1260
- {visualstructure}
1121
+ {visualstructure}
1122
+ {clientstyling}
1123
+ {clientstylingurl}
1261
1124
  />
1262
1125
  {:else if index === 6 && enablejackpotbanner == 'true'}
1263
1126
  <br>
@@ -1275,11 +1138,13 @@
1275
1138
  caticon2="/assets/icon2.svg"
1276
1139
  caticon3="/assets/icon3.svg"
1277
1140
  {iconlabels}
1278
- visualstructure="typeSpread"
1141
+ visualstructure="typeSpread"
1142
+ {clientstyling}
1143
+ {clientstylingurl}
1279
1144
  />
1280
1145
  {/if}
1281
1146
  {#if index == 7 && enablecollections == 'true'}
1282
- <casino-collections-providers
1147
+ <casino-collections-providers
1283
1148
  endpoint = {endpoint.slice(0, -2)}
1284
1149
  {datasource}
1285
1150
  {lang}
@@ -1289,11 +1154,11 @@
1289
1154
  {clientstylingurl}>
1290
1155
  </casino-collections-providers>
1291
1156
  {:else if index == (shownCategories.length - 1) && enablecollections == 'true'}
1292
- <casino-collections-providers
1157
+ <casino-collections-providers
1293
1158
  endpoint = {endpoint.slice(0, -2)}
1294
1159
  {datasource}
1295
1160
  {lang}
1296
- type='vendor'
1161
+ type='vendor'
1297
1162
  titletype="logo"
1298
1163
  {clientstyling}
1299
1164
  {clientstylingurl}>
@@ -1343,57 +1208,61 @@
1343
1208
  {integratedgameframemobile}
1344
1209
  />
1345
1210
  {:else if mostPlayedScreen}
1346
- {#if mostPlayedEmpty}
1347
- <p class="SearchLoading" part="SearchLoading">{$_('casinoPage.noGamesPlayed')}</p>
1348
- {:else if lastPlayedScreen}
1349
- {#if lastPlayedEmpty}
1350
- <p class="SearchLoading" part="SearchLoading">{$_('casinoPage.noGamesPlayed')}</p>
1351
- {/if}
1352
- {:else}
1353
- <casino-games-category-section
1354
- session={session}
1355
- userid={userid}
1356
- endpoint={endpoint}
1357
- datasource={datasource}
1358
- lang={lang}
1359
- currency={currency}
1360
- favorites={favorites}
1361
- categoryid="MOSTPLAYED"
1362
- categoryindex="1"
1363
- categorygames="9"
1364
- class="CategoryContainer"
1365
- {clientstyling}
1366
- {clientstylingurl}
1367
- {livecasino}
1368
- {visiblegames}
1369
- {gamepagemodalurl}
1370
- {integratedgameframedesktop}
1371
- {integratedgameframemobile}
1372
- />
1373
-
1374
- {/if}
1211
+ <casino-most-played-section
1212
+ userid={userid}
1213
+ endpoint={endpoint}
1214
+ datasource={datasource}
1215
+ favorites={favorites}
1216
+ lang={lang}
1217
+ currency={currency}
1218
+ session={session}
1219
+ class="CategoryContainer"
1220
+ {clientstyling}
1221
+ {clientstylingurl}
1222
+ {livecasino}
1223
+ {visiblegames}
1224
+ {gamepagemodalurl}
1225
+ {integratedgameframedesktop}
1226
+ {integratedgameframemobile}
1227
+ ></casino-most-played-section>
1228
+ {:else if lastPlayedScreen}
1229
+ <casino-last-played-section
1230
+ userid={userid}
1231
+ endpoint={endpoint}
1232
+ datasource={datasource}
1233
+ favorites={favorites}
1234
+ lang={lang}
1235
+ currency={currency}
1236
+ session={session}
1237
+ class="CategoryContainer"
1238
+ {clientstyling}
1239
+ {clientstylingurl}
1240
+ {livecasino}
1241
+ {visiblegames}
1242
+ {gamepagemodalurl}
1243
+ {integratedgameframedesktop}
1244
+ {integratedgameframemobile}
1245
+ ></casino-last-played-section>
1375
1246
  {:else}
1376
- {#if !recentSearches}
1377
- <casino-games-category-section
1378
- userid={userid}
1379
- endpoint={endpoint}
1380
- datasource={datasource}
1381
- favorites={favorites}
1382
- lang={lang}
1383
- currency={currency}
1384
- session={session}
1385
- categoryid={activeCategory}
1386
- categorygames="9"
1387
- class="CategoryContainer"
1388
- {clientstyling}
1389
- {clientstylingurl}
1390
- {livecasino}
1391
- {visiblegames}
1392
- {gamepagemodalurl}
1393
- {integratedgameframedesktop}
1394
- {integratedgameframemobile}
1395
- />
1396
- {/if}
1247
+ <casino-games-category-section
1248
+ userid={userid}
1249
+ endpoint={endpoint}
1250
+ datasource={datasource}
1251
+ favorites={favorites}
1252
+ lang={lang}
1253
+ currency={currency}
1254
+ session={session}
1255
+ categoryid={activeCategory}
1256
+ categorygames="9"
1257
+ class="CategoryContainer"
1258
+ {clientstyling}
1259
+ {clientstylingurl}
1260
+ {livecasino}
1261
+ {visiblegames}
1262
+ {gamepagemodalurl}
1263
+ {integratedgameframedesktop}
1264
+ {integratedgameframemobile}
1265
+ />
1397
1266
  {/if}
1398
1267
  {/if}
1399
1268
  {/if}