@everymatrix/casino-game-page 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/CHANGELOG.md +1 -0
- package/dist/casino-game-page.js +1 -1
- package/dist/casino-game-page.js.map +1 -1
- package/index.html +5 -4
- package/package.json +2 -2
- package/src/CasinoGamePage.svelte +101 -26
package/index.html
CHANGED
@@ -31,11 +31,12 @@
|
|
31
31
|
|
32
32
|
<div class="webcomponent">
|
33
33
|
<casino-game-page
|
34
|
-
|
35
|
-
|
36
|
-
|
34
|
+
favorites="true"
|
35
|
+
gameid="41813"
|
36
|
+
userid="4506648"
|
37
|
+
session="b64bddaa-73be-4173-98da-9265ce10d801"
|
37
38
|
lang="en"
|
38
|
-
endpoint="https://demo-api.stage.norway.everymatrix.com
|
39
|
+
endpoint="https://demo-api.stage.norway.everymatrix.com"
|
39
40
|
playforfun="true"
|
40
41
|
></casino-game-page>
|
41
42
|
</div>
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@everymatrix/casino-game-page",
|
3
|
-
"version": "1.34.
|
3
|
+
"version": "1.34.2",
|
4
4
|
"main": "dist/casino-game-page.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
|
}
|
@@ -70,6 +70,7 @@
|
|
70
70
|
let userAgent:any = window.navigator.userAgent;
|
71
71
|
let mobileView:boolean = false;
|
72
72
|
let favoriteGames: Array<Object> = [];
|
73
|
+
let listOfGamesIDs:Array<string> = [];
|
73
74
|
let customStylingContainer:HTMLElement;
|
74
75
|
let buttonsContainer:HTMLElement;
|
75
76
|
let timeContainer:HTMLElement;
|
@@ -131,7 +132,7 @@
|
|
131
132
|
game = formatGameLaunchUrl(data[0]);
|
132
133
|
isLoading = false;
|
133
134
|
if (game.launchUrl) {
|
134
|
-
game.
|
135
|
+
game.isFavorite = setGameData(game, game.hasFunMode);
|
135
136
|
isFavLoading = false;
|
136
137
|
}
|
137
138
|
}, (err:any) => {
|
@@ -149,6 +150,7 @@
|
|
149
150
|
isLoading = false;
|
150
151
|
});
|
151
152
|
window.postMessage({ type: 'RequestModalSize' }, window.location.href);
|
153
|
+
getFavoritesGames(session, userid)
|
152
154
|
}
|
153
155
|
|
154
156
|
const addEventsToDisplayedElements = () => {
|
@@ -178,7 +180,7 @@
|
|
178
180
|
|
179
181
|
case 'LaunchGameFrame':
|
180
182
|
openGameFrame(e.data.gameId, e.data.gameFunMode);
|
181
|
-
|
183
|
+
break;
|
182
184
|
|
183
185
|
case 'ModalClosed':
|
184
186
|
if (integratedgameframedesktop === 'true' || isMobile(userAgent)) {
|
@@ -232,39 +234,112 @@
|
|
232
234
|
modalFrameWidth = e.data.modalContainerSize.modalWidth;
|
233
235
|
modalFrameHeight = e.data.modalContainerSize.modalHeight;
|
234
236
|
break;
|
237
|
+
}
|
238
|
+
}
|
235
239
|
|
236
|
-
|
237
|
-
|
238
|
-
|
240
|
+
//Get favorites games list and update the favorites category
|
241
|
+
const getFavoritesGames = (sessionID:string, playerID:string) => {
|
242
|
+
let url = `${endpoint}/v1/player/${playerID}/favorites/`;
|
239
243
|
|
240
|
-
|
241
|
-
|
242
|
-
|
244
|
+
isLoading = true;
|
245
|
+
let options = {
|
246
|
+
method: "GET",
|
247
|
+
headers: {
|
248
|
+
'X-SessionID': sessionID,
|
249
|
+
}
|
250
|
+
};
|
251
|
+
|
252
|
+
return new Promise((resolve, reject) => {
|
253
|
+
fetch(url, options)
|
254
|
+
.then((res:any) => res.json())
|
255
|
+
.then((updatedArray:any) => {
|
256
|
+
isLoading = false;
|
257
|
+
favoriteGames = updatedArray.items;
|
258
|
+
if (favoriteGames) {
|
259
|
+
if (game && game.id) game.isFavorite = checkFavorite(game.id); isFavLoading = false;
|
260
|
+
favoriteGames.forEach((fav:any) => {
|
261
|
+
if (!listOfGamesIDs.includes(fav.id)) listOfGamesIDs.push(fav.id);
|
262
|
+
});
|
263
|
+
} else {
|
264
|
+
favoriteGames = [];
|
243
265
|
}
|
244
|
-
|
245
|
-
|
246
|
-
|
266
|
+
|
267
|
+
resolve(favoriteGames);
|
268
|
+
|
269
|
+
}).catch((err:any) => {
|
270
|
+
console.error(err);
|
271
|
+
|
272
|
+
reject(err);
|
273
|
+
});
|
274
|
+
});
|
247
275
|
}
|
248
276
|
|
249
|
-
|
250
|
-
|
251
|
-
|
277
|
+
//Add / Remove favorites games
|
278
|
+
const toggleFavoriteGame = (id:any):void => {
|
279
|
+
if (game.isFavorite) {
|
280
|
+
removeFavoredGame(`${endpoint}/v1/player/${userid}/favorites`, session, game.id);
|
252
281
|
} else {
|
253
|
-
|
282
|
+
addFavoredGame(`${endpoint}/v1/player/${userid}/favorites`, session, game);
|
254
283
|
}
|
255
284
|
}
|
256
285
|
|
257
|
-
|
258
|
-
|
259
|
-
if (game.
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
286
|
+
let addFavoredGame = async (url, sessionID, game) => {
|
287
|
+
// When adding new favored games, the api requires an array with all the current favored games due to the fact that it overwrites the old ones with the ones found in the body of the POST request
|
288
|
+
if (!listOfGamesIDs.includes(game.id)) listOfGamesIDs.push(game.id);
|
289
|
+
|
290
|
+
let data = {items: listOfGamesIDs};
|
291
|
+
|
292
|
+
let options = {
|
293
|
+
method: "POST",
|
294
|
+
headers: {
|
295
|
+
'X-SessionID': sessionID,
|
296
|
+
'Content-Type': 'application/json',
|
297
|
+
'Accept': 'application/json',
|
298
|
+
},
|
299
|
+
body: JSON.stringify(data)
|
300
|
+
};
|
301
|
+
|
302
|
+
fetch(url, options)
|
303
|
+
.then((res:any) => res.json())
|
304
|
+
.then((res) => {
|
305
|
+
window.postMessage({ type: `AddFavoriteThumbnail_${game.id}` }, window.location.href);
|
306
|
+
//Make a get for a new list to update the view
|
307
|
+
window.postMessage({ type: 'UpdateFavoredList', url, sessionID});
|
308
|
+
if( res.items ) favoriteGames = res.items; game.isFavorite = checkFavorite(game.id);
|
309
|
+
})
|
310
|
+
.catch((err:any) => {
|
311
|
+
console.error('Err', err);
|
312
|
+
});
|
313
|
+
}
|
314
|
+
|
315
|
+
const removeFavoredGame = (url, sessionID, gameID) => {
|
316
|
+
let options = {
|
317
|
+
method: "DELETE",
|
318
|
+
headers: {
|
319
|
+
'X-SessionID': sessionID,
|
320
|
+
}
|
321
|
+
};
|
322
|
+
|
323
|
+
fetch(`${url}/${gameID}`, options)
|
324
|
+
.then((res:any) => res.json())
|
325
|
+
.then((res) => {
|
326
|
+
window.postMessage({ type: `RemoveFavoriteThumbnail_${gameID}` }, window.location.href);
|
327
|
+
//Make a get for a new list to update the view
|
328
|
+
window.postMessage({ type: 'UpdateFavoredList', url, sessionID});
|
329
|
+
if(res.items) favoriteGames = res.items; game.isFavorite = checkFavorite(game.id);
|
330
|
+
});
|
331
|
+
|
332
|
+
if (listOfGamesIDs.includes(gameID)) {
|
333
|
+
listOfGamesIDs = listOfGamesIDs.filter(x => {
|
334
|
+
return x != gameID;
|
335
|
+
});
|
265
336
|
}
|
266
337
|
}
|
267
338
|
|
339
|
+
const checkFavorite = (gameId:string):boolean => {
|
340
|
+
return favoriteGames.findIndex(obj => obj.id == gameId) !== -1;
|
341
|
+
}
|
342
|
+
|
268
343
|
const setGameData = (game, gameFunMode) => {
|
269
344
|
anonymousFunMode = playforfun == 'true' ? game.hasAnonymousFunMode : false;
|
270
345
|
funMode = playforfun == 'true' ? gameFunMode : false;
|
@@ -281,7 +356,7 @@
|
|
281
356
|
game = formatGameLaunchUrl(data[0]);
|
282
357
|
isLoading = false;
|
283
358
|
if (game.launchUrl) {
|
284
|
-
game.
|
359
|
+
game.isFavorite = setGameData(game, gameFunMode);
|
285
360
|
isFavLoading = false;
|
286
361
|
}
|
287
362
|
}).finally(() => {
|
@@ -581,7 +656,7 @@
|
|
581
656
|
window.addEventListener('resize', resizeHandler, false);
|
582
657
|
window.addEventListener('message', messageHandler, false);
|
583
658
|
|
584
|
-
|
659
|
+
return () => {
|
585
660
|
removeEventsToDisplayedElements();
|
586
661
|
window.removeEventListener('resize', resizeHandler);
|
587
662
|
window.removeEventListener('message', messageHandler);
|
@@ -620,7 +695,7 @@
|
|
620
695
|
{#if isLoggedIn}
|
621
696
|
{#if favorites == 'true'}
|
622
697
|
{#if !isFavLoading}
|
623
|
-
{#if game.
|
698
|
+
{#if game.isFavorite}
|
624
699
|
<div class="FavIconContainer {haspanicbutton == 'true' ? 'FavIconPanicButton' : ''}" on:click="{() => toggleFavoriteGame(game.id)}">
|
625
700
|
<svg version="1.1" class="FavoredIcon" part="FavoredIcon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 19.481 19.481" xmlns:xlink="http://www.w3.org/1999/xlink" enable-background="new 0 0 19.481 19.481">
|
626
701
|
<path style="fill: var(--emfe-w-color-white, #FFFFFF);" d="m10.201,.758l2.478,5.865 6.344,.545c0.44,0.038 0.619,0.587 0.285,0.876l-4.812,4.169 1.442,6.202c0.1,0.431-0.367,0.77-0.745,0.541l-5.452-3.288-5.452,3.288c-0.379,0.228-0.845-0.111-0.745-0.541l1.442-6.202-4.813-4.17c-0.334-0.289-0.156-0.838 0.285-0.876l6.344-.545 2.478-5.864c0.172-0.408 0.749-0.408 0.921,0z"/>
|