@everymatrix/casino-game-page 1.34.1 → 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 +1 -1
- package/package.json +2 -2
- package/src/CasinoGamePage.svelte +25 -56
package/index.html
CHANGED
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
|
}
|
@@ -56,8 +56,6 @@
|
|
56
56
|
let funMode:boolean = false;
|
57
57
|
let anonymousFunMode:boolean = false;
|
58
58
|
let isModal:boolean = true;
|
59
|
-
let favoredGamesCollection:Array<string> = [];
|
60
|
-
let receivedFavoriteResults:Object;
|
61
59
|
|
62
60
|
let gameFrameContainer:HTMLElement;
|
63
61
|
let gameInnerContainer:HTMLElement;
|
@@ -72,6 +70,7 @@
|
|
72
70
|
let userAgent:any = window.navigator.userAgent;
|
73
71
|
let mobileView:boolean = false;
|
74
72
|
let favoriteGames: Array<Object> = [];
|
73
|
+
let listOfGamesIDs:Array<string> = [];
|
75
74
|
let customStylingContainer:HTMLElement;
|
76
75
|
let buttonsContainer:HTMLElement;
|
77
76
|
let timeContainer:HTMLElement;
|
@@ -133,7 +132,7 @@
|
|
133
132
|
game = formatGameLaunchUrl(data[0]);
|
134
133
|
isLoading = false;
|
135
134
|
if (game.launchUrl) {
|
136
|
-
game.
|
135
|
+
game.isFavorite = setGameData(game, game.hasFunMode);
|
137
136
|
isFavLoading = false;
|
138
137
|
}
|
139
138
|
}, (err:any) => {
|
@@ -255,24 +254,17 @@
|
|
255
254
|
.then((res:any) => res.json())
|
256
255
|
.then((updatedArray:any) => {
|
257
256
|
isLoading = false;
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
if (receivedFavoriteResults.items.length > 0) {
|
265
|
-
receivedFavoriteResults.items.forEach((fav:any) => {
|
266
|
-
favoredGamesCollection.push(fav.id);
|
267
|
-
});
|
268
|
-
}
|
269
|
-
|
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
|
+
});
|
270
263
|
} else {
|
271
|
-
|
272
|
-
return receivedFavoriteResults;
|
264
|
+
favoriteGames = [];
|
273
265
|
}
|
274
266
|
|
275
|
-
resolve(
|
267
|
+
resolve(favoriteGames);
|
276
268
|
|
277
269
|
}).catch((err:any) => {
|
278
270
|
console.error(err);
|
@@ -284,23 +276,18 @@
|
|
284
276
|
|
285
277
|
//Add / Remove favorites games
|
286
278
|
const toggleFavoriteGame = (id:any):void => {
|
287
|
-
if (game.
|
279
|
+
if (game.isFavorite) {
|
288
280
|
removeFavoredGame(`${endpoint}/v1/player/${userid}/favorites`, session, game.id);
|
289
281
|
} else {
|
290
|
-
addFavoredGame(`${endpoint}/v1/player/${userid}/favorites`, session, game
|
282
|
+
addFavoredGame(`${endpoint}/v1/player/${userid}/favorites`, session, game);
|
291
283
|
}
|
292
284
|
}
|
293
285
|
|
294
|
-
let addFavoredGame = (url, sessionID,
|
286
|
+
let addFavoredGame = async (url, sessionID, game) => {
|
295
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
|
296
|
-
|
297
|
-
if (!favoredGamesCollection.includes(gameID)) {
|
298
|
-
favoredGamesCollection.push(gameID);
|
299
|
-
}
|
288
|
+
if (!listOfGamesIDs.includes(game.id)) listOfGamesIDs.push(game.id);
|
300
289
|
|
301
|
-
let data = {
|
302
|
-
items: favoredGamesCollection
|
303
|
-
};
|
290
|
+
let data = {items: listOfGamesIDs};
|
304
291
|
|
305
292
|
let options = {
|
306
293
|
method: "POST",
|
@@ -314,12 +301,11 @@
|
|
314
301
|
|
315
302
|
fetch(url, options)
|
316
303
|
.then((res:any) => res.json())
|
317
|
-
.then(() => {
|
318
|
-
window.postMessage({ type: `AddFavoriteThumbnail_${
|
304
|
+
.then((res) => {
|
305
|
+
window.postMessage({ type: `AddFavoriteThumbnail_${game.id}` }, window.location.href);
|
319
306
|
//Make a get for a new list to update the view
|
320
|
-
|
321
307
|
window.postMessage({ type: 'UpdateFavoredList', url, sessionID});
|
322
|
-
|
308
|
+
if( res.items ) favoriteGames = res.items; game.isFavorite = checkFavorite(game.id);
|
323
309
|
})
|
324
310
|
.catch((err:any) => {
|
325
311
|
console.error('Err', err);
|
@@ -327,7 +313,6 @@
|
|
327
313
|
}
|
328
314
|
|
329
315
|
const removeFavoredGame = (url, sessionID, gameID) => {
|
330
|
-
|
331
316
|
let options = {
|
332
317
|
method: "DELETE",
|
333
318
|
headers: {
|
@@ -337,38 +322,22 @@
|
|
337
322
|
|
338
323
|
fetch(`${url}/${gameID}`, options)
|
339
324
|
.then((res:any) => res.json())
|
340
|
-
.then(() => {
|
325
|
+
.then((res) => {
|
341
326
|
window.postMessage({ type: `RemoveFavoriteThumbnail_${gameID}` }, window.location.href);
|
342
327
|
//Make a get for a new list to update the view
|
343
328
|
window.postMessage({ type: 'UpdateFavoredList', url, sessionID});
|
344
|
-
|
329
|
+
if(res.items) favoriteGames = res.items; game.isFavorite = checkFavorite(game.id);
|
345
330
|
});
|
346
331
|
|
347
|
-
if (
|
348
|
-
|
332
|
+
if (listOfGamesIDs.includes(gameID)) {
|
333
|
+
listOfGamesIDs = listOfGamesIDs.filter(x => {
|
349
334
|
return x != gameID;
|
350
335
|
});
|
351
336
|
}
|
352
337
|
}
|
353
338
|
|
354
|
-
//Add isFavored prop. for every favorite game
|
355
|
-
const updateCategoryFavoriteGames = (receivedFavoriteResults) => {
|
356
|
-
if (receivedFavoriteResults) {
|
357
|
-
favoriteGames = receivedFavoriteResults.items;
|
358
|
-
|
359
|
-
if (game && game.id) {
|
360
|
-
game.isFavored = checkFavorite(game.id);
|
361
|
-
isFavLoading = false;
|
362
|
-
}
|
363
|
-
}
|
364
|
-
}
|
365
|
-
|
366
339
|
const checkFavorite = (gameId:string):boolean => {
|
367
|
-
|
368
|
-
return true;
|
369
|
-
} else {
|
370
|
-
return false;
|
371
|
-
}
|
340
|
+
return favoriteGames.findIndex(obj => obj.id == gameId) !== -1;
|
372
341
|
}
|
373
342
|
|
374
343
|
const setGameData = (game, gameFunMode) => {
|
@@ -387,7 +356,7 @@
|
|
387
356
|
game = formatGameLaunchUrl(data[0]);
|
388
357
|
isLoading = false;
|
389
358
|
if (game.launchUrl) {
|
390
|
-
game.
|
359
|
+
game.isFavorite = setGameData(game, gameFunMode);
|
391
360
|
isFavLoading = false;
|
392
361
|
}
|
393
362
|
}).finally(() => {
|
@@ -726,7 +695,7 @@
|
|
726
695
|
{#if isLoggedIn}
|
727
696
|
{#if favorites == 'true'}
|
728
697
|
{#if !isFavLoading}
|
729
|
-
{#if game.
|
698
|
+
{#if game.isFavorite}
|
730
699
|
<div class="FavIconContainer {haspanicbutton == 'true' ? 'FavIconPanicButton' : ''}" on:click="{() => toggleFavoriteGame(game.id)}">
|
731
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">
|
732
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"/>
|