@everymatrix/casino-search 1.1.6 → 1.2.0
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/casino-search.js +235 -155
- package/dist/casino-search.js.map +1 -1
- package/index.html +1 -0
- package/package.json +2 -2
- package/src/CasinoSearch.svelte +61 -4
package/index.html
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@everymatrix/casino-search",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"main": "index.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": "3800c3e93fdc948c5bc48101acce6cd81ce65706"
|
|
40
40
|
}
|
package/src/CasinoSearch.svelte
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
export let integratedgameframedesktop:string = 'false';
|
|
17
17
|
export let integratedgameframemobile:string = 'false';
|
|
18
18
|
export let translationUrl:string = '';
|
|
19
|
+
export let showfavorites:string = '';
|
|
19
20
|
|
|
20
21
|
let userAgent:any = window.navigator.userAgent;
|
|
21
22
|
let searchArray:Array<any> = [];
|
|
@@ -30,6 +31,11 @@
|
|
|
30
31
|
let isLoading:boolean = false;
|
|
31
32
|
let customStylingContainer:HTMLElement;
|
|
32
33
|
|
|
34
|
+
let isLoggedIn:boolean = false;
|
|
35
|
+
let sessionID:string;
|
|
36
|
+
let playerID:string;
|
|
37
|
+
let favoriteGamesIds: string[] = [];
|
|
38
|
+
|
|
33
39
|
const setTranslationUrl = ():void => {
|
|
34
40
|
let url:string = translationUrl;
|
|
35
41
|
|
|
@@ -51,6 +57,17 @@
|
|
|
51
57
|
if (e.data && e.data.type == 'OpenGameFrame') {
|
|
52
58
|
addSearchedItem(e.data.gameId);
|
|
53
59
|
}
|
|
60
|
+
|
|
61
|
+
if (e.data && e.data.type == 'ShowGameModal') {
|
|
62
|
+
addSearchedItem(e.data.gameId);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (e.data.type === 'UserSessionID') {
|
|
66
|
+
sessionID = e.data.session;
|
|
67
|
+
playerID = e.data.userid;
|
|
68
|
+
isLoggedIn = true;
|
|
69
|
+
}
|
|
70
|
+
|
|
54
71
|
}
|
|
55
72
|
|
|
56
73
|
const onFocus = ():void => {
|
|
@@ -82,7 +99,11 @@
|
|
|
82
99
|
}
|
|
83
100
|
|
|
84
101
|
Promise.all(promises).then((res:any):void => {
|
|
85
|
-
searchArray = res
|
|
102
|
+
searchArray = res.map((item) => {
|
|
103
|
+
item.isFavorite = checkFavorite(item.id);
|
|
104
|
+
|
|
105
|
+
return item;
|
|
106
|
+
});
|
|
86
107
|
});
|
|
87
108
|
}
|
|
88
109
|
}
|
|
@@ -144,6 +165,37 @@
|
|
|
144
165
|
}
|
|
145
166
|
});
|
|
146
167
|
}
|
|
168
|
+
|
|
169
|
+
const getFavoriteGames = ():void => {
|
|
170
|
+
|
|
171
|
+
const url:URL = new URL(`${endpoint}/player/${playerID}/favorites/`);
|
|
172
|
+
|
|
173
|
+
isLoading = true;
|
|
174
|
+
|
|
175
|
+
let options = {
|
|
176
|
+
method: "GET",
|
|
177
|
+
headers: {
|
|
178
|
+
'X-SessionID': sessionID,
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
fetch(url.href, options)
|
|
183
|
+
.then((res:any) => res.json())
|
|
184
|
+
.then((favoriteGames:any) => {
|
|
185
|
+
isLoading = false;
|
|
186
|
+
|
|
187
|
+
favoriteGamesIds = favoriteGames.items.map(favoriteGame => favoriteGame.id);
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const checkFavorite = (gameId:string):boolean => {
|
|
192
|
+
if (favoriteGamesIds.findIndex((favGameId:any) => favGameId == gameId) !== -1) {
|
|
193
|
+
return true;
|
|
194
|
+
} else {
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
147
199
|
|
|
148
200
|
const addSearchedItem = (gameID:any):void => {
|
|
149
201
|
searchedValues = getCookieValue(`searchedGamesWds_casino`);
|
|
@@ -226,7 +278,11 @@
|
|
|
226
278
|
searchUrl.searchParams.append("filter", `name=${searchValue}`);
|
|
227
279
|
|
|
228
280
|
getGames(searchUrl).then((searchData:any) => {
|
|
229
|
-
searchArray = searchData.items.map((item) =>
|
|
281
|
+
searchArray = searchData.items.map((item) => {
|
|
282
|
+
item.isFavorite = checkFavorite(item.id);
|
|
283
|
+
|
|
284
|
+
return item;
|
|
285
|
+
});
|
|
230
286
|
});
|
|
231
287
|
} else {
|
|
232
288
|
if (!searchCancelled) {
|
|
@@ -244,11 +300,11 @@
|
|
|
244
300
|
|
|
245
301
|
$: lang && setActiveLanguage();
|
|
246
302
|
$: translationUrl && setTranslationUrl();
|
|
303
|
+
$: showfavorites && isLoggedIn && getFavoriteGames();
|
|
247
304
|
$: clientstyling && customStylingContainer && setClientStyling();
|
|
248
305
|
$: clientstylingurl && customStylingContainer && setClientStylingURL();
|
|
249
306
|
|
|
250
307
|
</script>
|
|
251
|
-
|
|
252
308
|
<div class="CasinoSearch" bind:this={customStylingContainer}>
|
|
253
309
|
<div class="Search">
|
|
254
310
|
<div class="SearchIcon">
|
|
@@ -286,6 +342,8 @@
|
|
|
286
342
|
{#if searchCancelled === false}
|
|
287
343
|
{#each searchArray as game}
|
|
288
344
|
<casino-game-thumbnail
|
|
345
|
+
endpoint={endpoint}
|
|
346
|
+
favorites = {showfavorites}
|
|
289
347
|
lang={lang}
|
|
290
348
|
gamethumbnail={game.thumbnail}
|
|
291
349
|
gamename={game.name}
|
|
@@ -297,7 +355,6 @@
|
|
|
297
355
|
gamefunmode={game.hasFunMode}
|
|
298
356
|
gamefavorite={game.isFavorite}
|
|
299
357
|
livelobbyendpoint={game.details ? game.launchUrl : ''}
|
|
300
|
-
endpoint={endpoint}
|
|
301
358
|
{integratedgameframedesktop}
|
|
302
359
|
{integratedgameframemobile}
|
|
303
360
|
{clientstyling}
|