@everymatrix/casino-games-category-section 1.34.0 → 1.34.2
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
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
<casino-games-category-section
|
|
34
34
|
endpoint="https://demo-api.stage.norway.everymatrix.com"
|
|
35
35
|
lang="en"
|
|
36
|
-
session="
|
|
36
|
+
session="201d23b1-52f0-4a95-a97f-299712b613e3"
|
|
37
37
|
userid="3884262"
|
|
38
38
|
favorites="true"
|
|
39
39
|
fetchviaevent="false"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@everymatrix/casino-games-category-section",
|
|
3
|
-
"version": "1.34.
|
|
3
|
+
"version": "1.34.2",
|
|
4
4
|
"main": "dist/casino-games-category-section.js",
|
|
5
5
|
"svelte": "src/index.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"publishConfig": {
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "99004a0501ea8fb9219aac803a986e470f556838"
|
|
39
39
|
}
|
|
@@ -76,11 +76,10 @@
|
|
|
76
76
|
let container:any;
|
|
77
77
|
let maxTotal:number;
|
|
78
78
|
let categoryName:HTMLElement;
|
|
79
|
-
let favoriteGames:Array<Object>;
|
|
80
79
|
let showFavGamesCategory:boolean = false;
|
|
81
80
|
let customStylingContainer:HTMLElement;
|
|
82
81
|
let validObservers:boolean = false;
|
|
83
|
-
|
|
82
|
+
|
|
84
83
|
let thumbnailContainer:Array<HTMLElement> = new Array(10000);
|
|
85
84
|
let intersectingIndexes:Object = {};
|
|
86
85
|
let visibilityconnect:string = '';
|
|
@@ -89,6 +88,9 @@
|
|
|
89
88
|
let visibilityChange;
|
|
90
89
|
let dataloaded;
|
|
91
90
|
|
|
91
|
+
let favoriteGames:Array<Object>;
|
|
92
|
+
let listOfGamesIDs:Array<string> = [];
|
|
93
|
+
|
|
92
94
|
let favoriteGamesData:any = {
|
|
93
95
|
items: [],
|
|
94
96
|
count: 0,
|
|
@@ -141,50 +143,58 @@
|
|
|
141
143
|
});
|
|
142
144
|
});
|
|
143
145
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
+
// Start favored games section
|
|
147
|
+
const getFavoritesGames = (sessionID:string, playerID:string) => {
|
|
146
148
|
let url = `${endpoint}/v1/player/${playerID}/favorites/`;
|
|
147
|
-
|
|
148
149
|
isLoading = true;
|
|
149
150
|
let options = {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
151
|
+
method: "GET",
|
|
152
|
+
headers: {
|
|
153
|
+
'X-SessionID': sessionID,
|
|
154
|
+
}
|
|
154
155
|
};
|
|
155
156
|
|
|
156
157
|
return new Promise((resolve, reject) => {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
158
|
+
fetch(url, options)
|
|
159
|
+
.then((res:any) => res.json())
|
|
160
|
+
.then((updatedArray:any) => {
|
|
161
|
+
isLoading = false;
|
|
162
|
+
favoriteGames = [];
|
|
163
|
+
if (updatedArray) {
|
|
164
|
+
updatedArray.items.forEach((item: any) => {
|
|
165
|
+
if (item.gameModel) {
|
|
166
|
+
favoriteGames.push(item);
|
|
167
|
+
if (!listOfGamesIDs.includes(item.id)) {
|
|
168
|
+
listOfGamesIDs.push(item.id);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
window.postMessage({ type: 'UpdateFavoritesCount', favoriteGames});
|
|
173
|
+
} else {
|
|
174
|
+
favoriteGames = [];
|
|
175
|
+
}
|
|
161
176
|
|
|
162
|
-
|
|
163
|
-
favoriteGames = updatedArray.items;
|
|
164
|
-
} else {
|
|
165
|
-
favoriteGames = [];
|
|
166
|
-
}
|
|
177
|
+
if(categoryid === 'FAVORITES') showFavoriteSection(favoriteGames);
|
|
167
178
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
179
|
+
shownCategoryData.forEach((item) => {
|
|
180
|
+
item.isFavorite = checkFavorite(item.id);
|
|
181
|
+
});
|
|
171
182
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
183
|
+
let aux:any = shownCategoryData;
|
|
184
|
+
shownCategoryData = undefined;
|
|
185
|
+
shownCategoryData = aux;
|
|
175
186
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
}).catch((err:any) => {
|
|
179
|
-
console.error(err);
|
|
187
|
+
resolve(favoriteGames);
|
|
180
188
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
189
|
+
}).catch((err:any) => {
|
|
190
|
+
console.error(err);
|
|
191
|
+
reject(err);
|
|
192
|
+
});
|
|
193
|
+
});
|
|
184
194
|
}
|
|
185
195
|
|
|
186
196
|
// @TODO categoryId type
|
|
187
|
-
const getData = (
|
|
197
|
+
const getData = (categoryid:any, offset:number, limit:number) => {
|
|
188
198
|
isLoading = true;
|
|
189
199
|
let categoryidparsed = '';
|
|
190
200
|
let url:any = '';
|
|
@@ -247,7 +257,7 @@
|
|
|
247
257
|
}
|
|
248
258
|
}
|
|
249
259
|
}
|
|
250
|
-
|
|
260
|
+
|
|
251
261
|
fetch(url)
|
|
252
262
|
.then((res:any) => res.json())
|
|
253
263
|
.then((categoryData:any) => {
|
|
@@ -403,7 +413,7 @@
|
|
|
403
413
|
|
|
404
414
|
case 'CategoryChange':
|
|
405
415
|
limit = 20;
|
|
406
|
-
|
|
416
|
+
break;
|
|
407
417
|
|
|
408
418
|
case 'ApplySorter':
|
|
409
419
|
categoryid = e.data.itemId;
|
|
@@ -416,101 +426,178 @@
|
|
|
416
426
|
});
|
|
417
427
|
break;
|
|
418
428
|
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
item.isFavorite = checkFavorite(item.id);
|
|
433
|
-
});
|
|
434
|
-
shownCategoryData = categoryData.games.items;
|
|
435
|
-
showLoadCategory = false;
|
|
436
|
-
// @TODO: replace this quick fix - when there are only a few category games, the view scrolls to the footer
|
|
437
|
-
if(shownCategoryData.length < 10 && e.data.origin ==! 'filters') {
|
|
438
|
-
scrollTop = true;
|
|
439
|
-
setTimeout(() => {
|
|
440
|
-
window.postMessage({ type: 'WidgetTopReference', scrollTop }, window.location.href);
|
|
441
|
-
}, 500);
|
|
442
|
-
}
|
|
443
|
-
});
|
|
444
|
-
}
|
|
445
|
-
break;
|
|
446
|
-
|
|
447
|
-
case 'FavoriteUpdate':
|
|
448
|
-
if(categoryData) {
|
|
449
|
-
shownCategoryData = categoryData.games.items;
|
|
450
|
-
shownCategoryData.forEach((item:any) => {
|
|
429
|
+
case 'CategoryUpdate':
|
|
430
|
+
searched = false;
|
|
431
|
+
lobbyView = false;
|
|
432
|
+
searchItem = false;
|
|
433
|
+
validObservers = true;
|
|
434
|
+
categoryid = e.data.itemId;
|
|
435
|
+
if (categoryid !== 'MOSTPLAYED') {
|
|
436
|
+
showLoadCategory = false;
|
|
437
|
+
}
|
|
438
|
+
if(casinomygames !== 'true') {
|
|
439
|
+
getData(categoryid, 0, limit).then((res:any) => {
|
|
440
|
+
categoryData = res;
|
|
441
|
+
categoryData.games.items.forEach((item:any) => {
|
|
451
442
|
item.isFavorite = checkFavorite(item.id);
|
|
452
443
|
});
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
// Start favorite category section
|
|
462
|
-
case 'UpdateCategoryFavoriteGames':
|
|
463
|
-
if (e.data.receivedFavoriteResults) {
|
|
464
|
-
favoriteGames = e.data.receivedFavoriteResults.items;
|
|
465
|
-
if(e.data.favStadalone) return;
|
|
466
|
-
if(showFavGamesCategory) {
|
|
467
|
-
if(!lobbyView) {
|
|
468
|
-
window.postMessage({ type: 'CategoryUpdate', itemId: categoryid }, window.location.href);
|
|
469
|
-
}
|
|
470
|
-
} else {
|
|
471
|
-
window.postMessage({ type: 'FavoriteUpdate', lobbyScreen: e.data.lobbyScreen }, window.location.href);
|
|
444
|
+
shownCategoryData = categoryData.games.items;
|
|
445
|
+
showLoadCategory = false;
|
|
446
|
+
// @TODO: replace this quick fix - when there are only a few category games, the view scrolls to the footer
|
|
447
|
+
if(shownCategoryData.length < 10 && e.data.origin ==! 'filters') {
|
|
448
|
+
scrollTop = true;
|
|
449
|
+
setTimeout(() => {
|
|
450
|
+
window.postMessage({ type: 'WidgetTopReference', scrollTop }, window.location.href);
|
|
451
|
+
}, 500);
|
|
472
452
|
}
|
|
473
|
-
}
|
|
474
|
-
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
break;
|
|
475
456
|
|
|
476
|
-
case
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
if (item.gameModel) {
|
|
484
|
-
item.gameModel.isFavorite = item.gameModel ? true : false;
|
|
485
|
-
}
|
|
486
|
-
});
|
|
487
|
-
}
|
|
488
|
-
favoriteGamesData.items = platformFavorite(favGameArray, favoriteGamesData.items);
|
|
489
|
-
favoriteGamesData.name = "Favorites";
|
|
490
|
-
showFavGamesCategory = true;
|
|
491
|
-
isLoading = false;
|
|
492
|
-
}
|
|
493
|
-
break;
|
|
494
|
-
// End favorite category section
|
|
457
|
+
case `SetUnfavoredGame${categoryid}`:
|
|
458
|
+
removeFavoredGame(`${endpoint}/v1/player/${userid}/favorites`, session, e.data.id);
|
|
459
|
+
break;
|
|
460
|
+
|
|
461
|
+
case `SetFavoredGame${categoryid}`:
|
|
462
|
+
addFavoredGame(`${endpoint}/v1/player/${userid}/favorites`, session, e.data.id);
|
|
463
|
+
break;
|
|
495
464
|
|
|
496
465
|
case 'UserSessionID':
|
|
497
466
|
sessionID = e.data.session;
|
|
498
467
|
playerID = e.data.userID;
|
|
499
468
|
if (favorites == 'true') {
|
|
500
469
|
if (playerID && playerID.length && sessionID && sessionID.length > 0) {
|
|
501
|
-
|
|
470
|
+
getFavoritesGames(sessionID, playerID);
|
|
502
471
|
}
|
|
503
472
|
}
|
|
473
|
+
break;
|
|
504
474
|
|
|
505
|
-
|
|
506
|
-
|
|
475
|
+
case 'UpdateFavoredList':
|
|
476
|
+
if(categoryid === 'FAVORITES') updateFavoredList(e.data.url, e.data.sessionID)
|
|
477
|
+
break;
|
|
478
|
+
|
|
507
479
|
default:
|
|
508
480
|
// do nothing
|
|
509
|
-
|
|
481
|
+
break;
|
|
510
482
|
}
|
|
511
483
|
}
|
|
512
484
|
}
|
|
513
485
|
|
|
486
|
+
const addFavoriteState = () => {
|
|
487
|
+
if(categoryData) {
|
|
488
|
+
shownCategoryData = categoryData.games.items;
|
|
489
|
+
shownCategoryData.forEach((item:any) => {
|
|
490
|
+
item.isFavorite = checkFavorite(item.id);
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
//Adding fav. statement to variables
|
|
496
|
+
const checkFavorite = (gameId: string) => favoriteGames?.some(obj => obj.id === gameId) ?? false;
|
|
497
|
+
|
|
498
|
+
let addFavoredGame = async (url, sessionID, gameID) => {
|
|
499
|
+
// Wait for the updateFavoredList to complete
|
|
500
|
+
await updateFavoredList(url, sessionID);
|
|
501
|
+
|
|
502
|
+
if (!listOfGamesIDs.includes(gameID)) {
|
|
503
|
+
listOfGamesIDs.push(gameID);
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
let data = {
|
|
507
|
+
items: listOfGamesIDs
|
|
508
|
+
};
|
|
509
|
+
|
|
510
|
+
let options = {
|
|
511
|
+
method: "POST",
|
|
512
|
+
headers: {
|
|
513
|
+
'X-SessionID': sessionID,
|
|
514
|
+
'Content-Type': 'application/json',
|
|
515
|
+
'Accept': 'application/json',
|
|
516
|
+
},
|
|
517
|
+
body: JSON.stringify(data)
|
|
518
|
+
};
|
|
519
|
+
|
|
520
|
+
fetch(url, options)
|
|
521
|
+
.then((res) => res.json())
|
|
522
|
+
.then(() => {
|
|
523
|
+
window.postMessage({ type: `AddFavoriteThumbnail_${gameID}` }, window.location.href);
|
|
524
|
+
})
|
|
525
|
+
.catch((err) => {
|
|
526
|
+
console.error('Err', err);
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
const removeFavoredGame = (url:string, sessionID:string, gameID:string) => {
|
|
531
|
+
let options = {
|
|
532
|
+
method: "DELETE",
|
|
533
|
+
headers: {
|
|
534
|
+
'X-SessionID': sessionID,
|
|
535
|
+
}
|
|
536
|
+
};
|
|
537
|
+
|
|
538
|
+
fetch(`${url}/${gameID}`, options)
|
|
539
|
+
.then((res:any) => res.json())
|
|
540
|
+
.then(() => {
|
|
541
|
+
window.postMessage({ type: `RemoveFavoriteThumbnail_${gameID}` }, window.location.href);
|
|
542
|
+
updateFavoredList(url, sessionID);
|
|
543
|
+
});
|
|
544
|
+
|
|
545
|
+
if (listOfGamesIDs.includes(gameID)) {
|
|
546
|
+
listOfGamesIDs = listOfGamesIDs.filter(x => {
|
|
547
|
+
return x != gameID;
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
//Fetch fav list and pass to be updated
|
|
553
|
+
const updateFavoredList = async (url, sessionID) => {
|
|
554
|
+
let options = {
|
|
555
|
+
method: "GET",
|
|
556
|
+
headers: {
|
|
557
|
+
'X-SessionID': sessionID,
|
|
558
|
+
}
|
|
559
|
+
};
|
|
560
|
+
|
|
561
|
+
return fetch(url, options)
|
|
562
|
+
.then((res:any) => res.json())
|
|
563
|
+
.then((updatedArray:any) => {
|
|
564
|
+
favoriteGames = updatedArray.items;
|
|
565
|
+
if (!fetchviaevent) {
|
|
566
|
+
favoriteGames.forEach((item: any) => {
|
|
567
|
+
item.isFavorite = checkFavorite(item.id);
|
|
568
|
+
});
|
|
569
|
+
} else {
|
|
570
|
+
favoriteGames.forEach((item: any) => {
|
|
571
|
+
if (!listOfGamesIDs.includes(item.id)) {
|
|
572
|
+
listOfGamesIDs.push(item.id);
|
|
573
|
+
}
|
|
574
|
+
})
|
|
575
|
+
addFavoriteState();
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
if (categoryid === 'FAVORITES') { window.postMessage({ type: 'UpdateFavoritesCount', favoriteGames }); showFavoriteSection(favoriteGames); }
|
|
579
|
+
|
|
580
|
+
}).catch((err:any) => {
|
|
581
|
+
console.error(err);
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
const showFavoriteSection = (receivedFavoriteResults) => {
|
|
586
|
+
if (!receivedFavoriteResults) return;
|
|
587
|
+
let favGameArray;
|
|
588
|
+
favGameArray = receivedFavoriteResults?.items || receivedFavoriteResults || [];
|
|
589
|
+
if (favGameArray.length > 0) {
|
|
590
|
+
favGameArray.forEach((item: any) => {
|
|
591
|
+
if (item.gameModel) {
|
|
592
|
+
item.gameModel.isFavorite = true;
|
|
593
|
+
}
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
favoriteGamesData.items = platformFavorite(favGameArray, favoriteGamesData.items);
|
|
597
|
+
favoriteGamesData.name = "Favorites";
|
|
598
|
+
isLoading = false;
|
|
599
|
+
}
|
|
600
|
+
|
|
514
601
|
// @TODO categoryId type fix
|
|
515
602
|
const loadMoreGames = (categoryId:any) => {
|
|
516
603
|
limit += 1;
|
|
@@ -536,17 +623,6 @@
|
|
|
536
623
|
}
|
|
537
624
|
}
|
|
538
625
|
|
|
539
|
-
const checkFavorite = (gameId:string) => {
|
|
540
|
-
if (favoriteGames) {
|
|
541
|
-
if (favoriteGames.findIndex(obj => obj.id == gameId) !== -1) {
|
|
542
|
-
return true;
|
|
543
|
-
} else {
|
|
544
|
-
return false;
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
return false;
|
|
548
|
-
}
|
|
549
|
-
|
|
550
626
|
const addGameTag = (tags:any[]):string => {
|
|
551
627
|
if (tags?.length === 0) return '';
|
|
552
628
|
|
|
@@ -580,11 +656,10 @@
|
|
|
580
656
|
const initialSetup = () => {
|
|
581
657
|
// showFavGamesCategory vs categoryData
|
|
582
658
|
// favoriteGamesData vs shownCategoryData
|
|
583
|
-
|
|
584
659
|
switch(categoryid) {
|
|
585
660
|
case 'FAVORITES':
|
|
586
661
|
showFavGamesCategory = true;
|
|
587
|
-
|
|
662
|
+
break;
|
|
588
663
|
case 'MOSTPLAYED':
|
|
589
664
|
if(casinomygames === 'false') {
|
|
590
665
|
showFavGamesCategory = false;
|
|
@@ -644,25 +719,23 @@
|
|
|
644
719
|
}
|
|
645
720
|
|
|
646
721
|
onMount(() => {
|
|
647
|
-
if(fetchviaevent === 'true'){
|
|
648
722
|
window.addEventListener('visibilitychange', (e) => handleVisibilityChange())
|
|
649
723
|
window.addEventListener('message', messageHandler, false);
|
|
650
|
-
|
|
651
|
-
window.postMessage({ type: 'GetFavoredGame' }, window.location.href);
|
|
652
|
-
}
|
|
724
|
+
|
|
653
725
|
|
|
654
726
|
return () => {
|
|
655
727
|
window.removeEventListener('message', messageHandler);
|
|
656
728
|
window.removeEventListener('visibilitychange', messageHandler);
|
|
657
729
|
}
|
|
658
|
-
}
|
|
659
730
|
});
|
|
660
731
|
|
|
661
732
|
$: lang && setActiveLanguage();
|
|
733
|
+
//Widget is working as standalone when fetchviaevent isn't set
|
|
662
734
|
$: (fetchviaevent === 'false' || fetchviaevent === '') && endpoint && lang && categoryid && datasource && displayedgamecount && showallbuttongamescount && fetchGamesByCategory(categoryid, displayedgamecount, showallbuttongamescount);
|
|
663
|
-
|
|
735
|
+
//Call the fav. list fetch when widget is standalone
|
|
736
|
+
$: favorites === 'true' && endpoint && session && userid && getFavoritesGames(session, userid);
|
|
664
737
|
$: dataloaded && thumbnailContainer && setupObserver();
|
|
665
|
-
$: lang && categoryid && initialSetup();
|
|
738
|
+
$: lang && categoryid && userid && session && initialSetup();
|
|
666
739
|
$: translationurl && setTranslationUrl();
|
|
667
740
|
$: clientstyling && customStylingContainer && setClientStyling();
|
|
668
741
|
$: clientstylingurl && customStylingContainer && setClientStylingURL();
|
|
@@ -711,6 +784,7 @@
|
|
|
711
784
|
lang={lang}
|
|
712
785
|
searchitem={searchItem}
|
|
713
786
|
favorites={favorites}
|
|
787
|
+
categoryid={categoryid}
|
|
714
788
|
gamethumbnail={gameprops.thumbnail}
|
|
715
789
|
gamename={gameprops.name}
|
|
716
790
|
gamevendor={gameprops.vendor.name}
|
|
@@ -796,6 +870,7 @@
|
|
|
796
870
|
class="{MASONRY_CLASS_PREFIX}{gameprops.cellSize ? gameprops.cellSize : '1x1'}"
|
|
797
871
|
part="{MASONRY_CLASS_PREFIX}{gameprops.cellSize ? gameprops.cellSize : '1x1'}"
|
|
798
872
|
favorites={favorites}
|
|
873
|
+
categoryid={categoryid}
|
|
799
874
|
gamethumbnail={gameprops.thumbnail}
|
|
800
875
|
gamename={gameprops.name}
|
|
801
876
|
gamevendor={gameprops.vendor.name}
|
|
@@ -858,6 +933,7 @@
|
|
|
858
933
|
userid={userid}
|
|
859
934
|
lang={lang}
|
|
860
935
|
favorites={favorites}
|
|
936
|
+
categoryid={categoryid}
|
|
861
937
|
gamethumbnail={gameprops.gameModel.thumbnail}
|
|
862
938
|
gamename={gameprops.gameModel.name}
|
|
863
939
|
gamevendor={gameprops.gameModel.vendor.name}
|
|
@@ -891,6 +967,7 @@
|
|
|
891
967
|
userid={userid}
|
|
892
968
|
lang={lang}
|
|
893
969
|
favorites={favorites}
|
|
970
|
+
categoryid={categoryid}
|
|
894
971
|
gamethumbnail={gameprops.gameModel.thumbnail}
|
|
895
972
|
gamename={gameprops.gameModel.name}
|
|
896
973
|
gamevendor={gameprops.gameModel.vendor.name}
|