@everymatrix/casino-play-random-game 1.29.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-play-random-game/casino-play-random-game.esm.js +1 -0
- package/dist/casino-play-random-game/index.esm.js +0 -0
- package/dist/casino-play-random-game/p-0f38b3f8.js +1 -0
- package/dist/casino-play-random-game/p-0f957927.entry.js +1 -0
- package/dist/cjs/casino-play-random-game.cjs.entry.js +344 -0
- package/dist/cjs/casino-play-random-game.cjs.js +19 -0
- package/dist/cjs/index-8944e204.js +1247 -0
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/loader.cjs.js +21 -0
- package/dist/collection/collection-manifest.json +12 -0
- package/dist/collection/components/casino-play-random-game/casino-play-random-game.css +347 -0
- package/dist/collection/components/casino-play-random-game/casino-play-random-game.js +469 -0
- package/dist/collection/index.js +1 -0
- package/dist/collection/utils/locale.utils.js +60 -0
- package/dist/collection/utils/utils.js +27 -0
- package/dist/components/casino-play-random-game.d.ts +11 -0
- package/dist/components/casino-play-random-game.js +376 -0
- package/dist/components/index.d.ts +26 -0
- package/dist/components/index.js +1 -0
- package/dist/esm/casino-play-random-game.entry.js +340 -0
- package/dist/esm/casino-play-random-game.js +17 -0
- package/dist/esm/index-58563736.js +1221 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/loader.js +17 -0
- package/dist/esm/polyfills/core-js.js +11 -0
- package/dist/esm/polyfills/css-shim.js +1 -0
- package/dist/esm/polyfills/dom.js +79 -0
- package/dist/esm/polyfills/es5-html-element.js +1 -0
- package/dist/esm/polyfills/index.js +34 -0
- package/dist/esm/polyfills/system.js +6 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/stencil.config.js +22 -0
- package/dist/types/Users/adrian.pripon/Documents/Work/widgets-stencil/packages/casino-play-random-game/.stencil/packages/casino-play-random-game/stencil.config.d.ts +2 -0
- package/dist/types/components/casino-play-random-game/casino-play-random-game.d.ts +73 -0
- package/dist/types/components.d.ts +117 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/stencil-public-runtime.d.ts +1565 -0
- package/dist/types/utils/locale.utils.d.ts +6 -0
- package/dist/types/utils/utils.d.ts +2 -0
- package/loader/cdn.js +3 -0
- package/loader/index.cjs.js +3 -0
- package/loader/index.d.ts +12 -0
- package/loader/index.es2017.js +3 -0
- package/loader/index.js +4 -0
- package/loader/package.json +10 -0
- package/package.json +19 -0
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
|
|
2
|
+
|
|
3
|
+
const getDevice = () => {
|
|
4
|
+
let userAgent = window.navigator.userAgent;
|
|
5
|
+
if (userAgent.toLowerCase().match(/android/i)) {
|
|
6
|
+
return 'Android';
|
|
7
|
+
}
|
|
8
|
+
if (userAgent.toLowerCase().match(/iphone/i)) {
|
|
9
|
+
return 'iPhone';
|
|
10
|
+
}
|
|
11
|
+
if (userAgent.toLowerCase().match(/ipad|ipod/i)) {
|
|
12
|
+
return 'iPad';
|
|
13
|
+
}
|
|
14
|
+
return 'PC';
|
|
15
|
+
};
|
|
16
|
+
const getDevicePlatform = () => {
|
|
17
|
+
const device = getDevice();
|
|
18
|
+
if (device) {
|
|
19
|
+
if (device === 'PC') {
|
|
20
|
+
return 'dk';
|
|
21
|
+
}
|
|
22
|
+
else if (device === 'iPad' || device === 'iPhone') {
|
|
23
|
+
return 'mtWeb';
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
return 'mtWeb';
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const DEFAULT_LANGUAGE = 'en';
|
|
32
|
+
const TRANSLATIONS = {
|
|
33
|
+
en: {
|
|
34
|
+
error: 'Error',
|
|
35
|
+
randomGameLoading: 'Loading ...',
|
|
36
|
+
playRandomGame: 'Play a random game',
|
|
37
|
+
playNowRandomGame: 'Play now',
|
|
38
|
+
spinRandomGame: 'Spin'
|
|
39
|
+
},
|
|
40
|
+
ro: {
|
|
41
|
+
error: 'Eroare',
|
|
42
|
+
playRandomGame: 'Play a random game',
|
|
43
|
+
playNowRandomGame: 'Play now',
|
|
44
|
+
spinRandomGame: 'Spin'
|
|
45
|
+
},
|
|
46
|
+
fr: {
|
|
47
|
+
error: 'Error',
|
|
48
|
+
playRandomGame: 'Play a random game',
|
|
49
|
+
playNowRandomGame: 'Play now',
|
|
50
|
+
spinRandomGame: 'Spin'
|
|
51
|
+
},
|
|
52
|
+
hr: {
|
|
53
|
+
error: 'Greška',
|
|
54
|
+
playRandomGame: 'Play a random game',
|
|
55
|
+
playNowRandomGame: 'Play now',
|
|
56
|
+
spinRandomGame: 'Spin'
|
|
57
|
+
},
|
|
58
|
+
hu: {
|
|
59
|
+
error: 'Greška',
|
|
60
|
+
playRandomGame: 'Play a random game',
|
|
61
|
+
playNowRandomGame: 'Play now',
|
|
62
|
+
spinRandomGame: 'Spin'
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const getTranslations = (url) => {
|
|
66
|
+
// fetch url, get the data, replace the TRANSLATIONS content
|
|
67
|
+
return new Promise((resolve) => {
|
|
68
|
+
fetch(url)
|
|
69
|
+
.then((res) => res.json())
|
|
70
|
+
.then((data) => {
|
|
71
|
+
Object.keys(data).forEach((item) => {
|
|
72
|
+
for (let key in data[item]) {
|
|
73
|
+
TRANSLATIONS[item][key] = data[item][key];
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
resolve(true);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
const translate = (key, customLang, values) => {
|
|
81
|
+
const lang = customLang;
|
|
82
|
+
let translation = TRANSLATIONS[lang !== undefined ? lang : DEFAULT_LANGUAGE][key];
|
|
83
|
+
if (values !== undefined) {
|
|
84
|
+
for (const [key, value] of Object.entries(values.values)) {
|
|
85
|
+
const regex = new RegExp(`{${key}}`, 'g');
|
|
86
|
+
translation = translation.replace(regex, value);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return translation;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const casinoPlayRandomGameCss = ":host {\n display: block;\n font-family: inherit;\n}\n\n.RandomGameWrapper {\n width: 100%;\n overflow: hidden;\n background: transparent;\n position: relative;\n}\n\n.GameContainerGradient {\n position: absolute;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100%;\n background: linear-gradient(90deg, var(--emfe-w-casino-color-bg, var(--emfe-w-color-background, #07072A)) 0%, rgba(7, 7, 42, 0.5) 25%, rgba(7, 7, 42, 0) 50%, rgba(7, 7, 42, 0.5) 75%, var(--emfe-w-casino-color-bg, var(--emfe-w-color-background, #07072A)) 100%);\n pointer-events: none;\n z-index: 1;\n}\n\n.GamesContainer {\n display: flex;\n height: 330px;\n flex-direction: row;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: center;\n align-content: flex-start;\n gap: 20px;\n}\n\n.RandomGameCard {\n position: relative;\n width: 256px;\n height: 170px;\n border-radius: 5px;\n filter: blur(5px);\n}\n.RandomGameCard .RandomGameVendor {\n position: absolute;\n font-size: 12px;\n bottom: 10px;\n left: 10px;\n color: var(--emfe-w-color-white, #FFFFFF);\n}\n\n.TheRandomGame {\n animation-name: ZoomFadeIn;\n animation-duration: 0.5s;\n animation-fill-mode: forwards;\n -webkit-animation-name: ZoomFadeIn;\n -webkit-animation-duration: 0.5s;\n -webkit-animation-fill-mode: forwards;\n opacity: 1;\n cursor: pointer;\n filter: blur(0);\n}\n\n.RandomGameImage {\n width: 256px;\n height: 170px;\n}\n\n.RandomGameDetails {\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n color: var(--emfe-w-casino-typography, var(--emfe-w-color-white, #FFFFFF));\n font-size: 14px;\n width: 100%;\n}\n.RandomGameDetails .RandomGameTitle {\n line-height: 18px;\n}\n.RandomGameDetails .RandomGameInfo {\n border-radius: 50%;\n width: 16px;\n height: 16px;\n font-size: 12px;\n font-weight: 400;\n border: solid 1px var(--emfe-w-casino-typography, var(--emfe-w-color-white, #FFFFFF));\n text-align: center;\n margin: 4px 0;\n line-height: 14px;\n cursor: pointer;\n}\n.RandomGameDetails .RandomGamePlay {\n background: var(--emfe-w-casino-color-primary, var(--emfe-w-color-primary, #D0046C));\n color: var(--emfe-w-button-typography, var(--emfe-w-color-white, #FFFFFF));\n border: none;\n border-radius: 5px;\n width: 200px;\n height: 40px;\n font-size: 14px;\n cursor: pointer;\n}\n\n.ButtonWrapper {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n}\n\n.ButtonContainer {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n gap: 10px;\n width: 100%;\n}\n\n.ButtonIcon {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n gap: 5px;\n}\n\n.QustionMark {\n position: relative;\n font-size: 80px;\n font-weight: 700;\n color: var(--emfe-w-color-white, #FFFFFF);\n z-index: 5;\n bottom: 20px;\n text-shadow: 0px 4px 0px var(--emfe-w-color-black, #000000);\n}\n\n.HexagonMark {\n position: absolute;\n width: 70px;\n height: 85px;\n background: linear-gradient(90deg, var(--emfe-w-casino-color-primary, var(--emfe-w-color-primary, #D0046C)) 0%, var(--emfe-w-categories-color-secondary, var(--emfe-w-color-secondary, #FD2839)) 100%);\n clip-path: polygon(50% 0, 100% 30%, 100% 70%, 50% 100%, 0% 70%, 0% 30%);\n}\n\n.HexagonMarkBorder {\n position: relative;\n display: flex;\n justify-content: center;\n align-items: center;\n top: 5px;\n left: 5px;\n width: 60px;\n height: 75px;\n background: linear-gradient(180deg, var(--emfe-w-casino-color-primary, var(--emfe-w-color-primary, #D0046C)) 0%, var(--emfe-w-categories-color-secondary, var(--emfe-w-color-secondary, #FD2839)) 100%);\n clip-path: polygon(50% 0, 100% 30%, 100% 70%, 50% 100%, 0% 70%, 0% 30%);\n}\n\n.RandomButtons {\n display: flex;\n flex-direction: row;\n justify-content: center;\n align-items: center;\n gap: 5px;\n width: 100%;\n}\n\n.RandomButton {\n font-size: 18px;\n text-transform: uppercase;\n width: max-content;\n border-radius: 5px;\n padding: 5px 25px;\n border: solid 3px var(--emfe-w-casino-color-primary, var(--emfe-w-color-primary, #D0046C));\n color: var(--emfe-w-button-typography, var(--emfe-w-color-white, #FFFFFF));\n opacity: 1;\n text-shadow: 1px 1px 2px var(--emfe-w-color-black, #000000);\n animation: ButtonEffect 3s linear infinite;\n background-image: linear-gradient(to right, var(--emfe-w-casino-color-primary, var(--emfe-w-color-primary, #D0046C)), var(--emfe-w-categories-color-secondary, var(--emfe-w-color-secondary, #FD2839)), var(--emfe-w-casino-color-primary, var(--emfe-w-color-primary, #D0046C)));\n background-size: 300% 100%;\n cursor: pointer;\n}\n.RandomButton:hover {\n opacity: 0.8;\n}\n\n.HideAnimation {\n filter: blur(5px);\n animation: AnimateButton 0.2s forwards;\n}\n\n.Flip {\n animation-name: Flip, Blur;\n animation-duration: 0.75s, 3s;\n animation-iteration-count: infinite, 1;\n -webkit-animation-name: Flip, Blur;\n -webkit-animation-duration: 0.75s, 3s;\n -webkit-animation-iteration-count: infinite, 1;\n}\n\n@keyframes ButtonEffect {\n 0% {\n background-position: 0% 50%;\n }\n 33% {\n background-position: 100% 50%;\n }\n 66% {\n background-position: 200% 50%;\n }\n 100% {\n background-position: 300% 50%;\n }\n}\n@keyframes ZoomFadeIn {\n 0% {\n transform: scale(0.2) translateY(0);\n filter: blur(5px);\n opacity: 0.3;\n }\n 50% {\n transform: scale(1.1) translateY(-30px);\n filter: blur(2px);\n opacity: 0.7;\n }\n 100% {\n transform: scale(1) translateY(-30px);\n filter: blur(0px);\n opacity: 1;\n }\n}\n@keyframes AnimateButton {\n 0% {\n opacity: 0.7;\n }\n 50% {\n opacity: 0.4;\n }\n 100% {\n opacity: 0;\n display: none;\n }\n}\n@keyframes Flip {\n 0% {\n transform: rotateY(0deg);\n }\n 50% {\n transform: rotateY(180deg);\n }\n 100% {\n transform: rotateY(360deg);\n }\n}\n@keyframes Blur {\n 0% {\n filter: blur(0);\n }\n 50% {\n filter: blur(1px);\n }\n 100% {\n filter: blur(3px);\n }\n}\n@container (max-width: 475px) {\n .GameContainerGradient {\n position: absolute;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100%;\n background: linear-gradient(90deg, var(--emfe-w-casino-color-bg, var(--emfe-w-color-background, #07072A)) 0%, rgba(7, 7, 42, 0.2) 25%, rgba(7, 7, 42, 0) 50%, rgba(7, 7, 42, 0.2) 75%, var(--emfe-w-casino-color-bg, var(--emfe-w-color-background, #07072A)) 100%);\n pointer-events: none;\n z-index: 1;\n }\n\n .RandomGameCard {\n width: 102px;\n height: 146px;\n border-radius: 5px;\n filter: blur(5px);\n }\n\n .RandomGameImage {\n width: 102px;\n height: 146px;\n }\n\n .RandomGameDetails {\n font-size: 14px;\n width: 100%;\n }\n .RandomGameDetails .RandomGameTitle {\n line-height: 18px;\n width: 75%;\n }\n .RandomGameDetails .RandomGameInfo {\n border-radius: 50%;\n width: 16px;\n height: 16px;\n font-size: 12px;\n line-height: 14px;\n }\n .RandomGameDetails .RandomGamePlay {\n background: var(--emfe-w-casino-color-primary, var(--emfe-w-color-primary, #D0046C));\n color: var(--emfe-w-button-typography, var(--emfe-w-color-white, #FFFFFF));\n border: none;\n border-radius: 5px;\n width: 200px;\n height: 40px;\n font-size: 14px;\n cursor: pointer;\n }\n\n .RandomGameCard .RandomGameVendor {\n font-size: 12px;\n bottom: 5px;\n right: 5px;\n }\n\n .RandomButtons {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n gap: 5px;\n width: 100%;\n }\n\n .RandomButton {\n font-size: 18px;\n text-transform: uppercase;\n width: max-content;\n border-radius: 5px;\n padding: 5px 25px;\n border: solid 3px var(--emfe-w-casino-color-primary, var(--emfe-w-color-primary, #D0046C));\n color: var(--emfe-w-button-typography, var(--emfe-w-color-white, #FFFFFF));\n opacity: 1;\n text-shadow: 1px 1px 2px var(--emfe-w-color-black, #000000);\n animation: ButtonEffect 3s linear infinite;\n background-image: linear-gradient(to right, var(--emfe-w-casino-color-primary, var(--emfe-w-color-primary, #D0046C)), var(--emfe-w-categories-color-secondary, var(--emfe-w-color-secondary, #FD2839)), var(--emfe-w-casino-color-primary, var(--emfe-w-color-primary, #D0046C)));\n background-size: 300% 100%;\n cursor: pointer;\n }\n .RandomButton:hover {\n opacity: 0.8;\n }\n}";
|
|
93
|
+
|
|
94
|
+
const CasinoPlayRandomGame$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
95
|
+
constructor() {
|
|
96
|
+
super();
|
|
97
|
+
this.__registerHost();
|
|
98
|
+
this.__attachShadow();
|
|
99
|
+
/**
|
|
100
|
+
* Language of the widget
|
|
101
|
+
*/
|
|
102
|
+
this.language = 'en';
|
|
103
|
+
/**
|
|
104
|
+
* Configure a specific category for randomising the games.
|
|
105
|
+
*/
|
|
106
|
+
this.specificCategory = '';
|
|
107
|
+
/**
|
|
108
|
+
* Icon visible initially
|
|
109
|
+
*/
|
|
110
|
+
this.iconVisible = '';
|
|
111
|
+
/**
|
|
112
|
+
* Icon visible while rolling
|
|
113
|
+
*/
|
|
114
|
+
this.iconVisibleOnAnim = '';
|
|
115
|
+
/**
|
|
116
|
+
* Open event on the game card.
|
|
117
|
+
*/
|
|
118
|
+
this.launchByGameCard = '';
|
|
119
|
+
/**
|
|
120
|
+
* Client custom styling via string
|
|
121
|
+
*/
|
|
122
|
+
this.clientStyling = '';
|
|
123
|
+
/**
|
|
124
|
+
* Client custom styling via url
|
|
125
|
+
*/
|
|
126
|
+
this.clientStylingUrl = '';
|
|
127
|
+
/**
|
|
128
|
+
* Translations via URL
|
|
129
|
+
*/
|
|
130
|
+
this.translationUrl = '';
|
|
131
|
+
this.hasErrors = false;
|
|
132
|
+
this.limitStylingAppends = false;
|
|
133
|
+
this.isLoading = true;
|
|
134
|
+
this.selectedGame = null;
|
|
135
|
+
this.animationDone = false;
|
|
136
|
+
this.animationStarted = false;
|
|
137
|
+
this.animation = null;
|
|
138
|
+
this.selectedGameIndex = null;
|
|
139
|
+
this.selectedGameEl = null;
|
|
140
|
+
this.iconVisibility = null;
|
|
141
|
+
this.shuffle = (array) => {
|
|
142
|
+
let currentIndex = array.length;
|
|
143
|
+
let randomIndex;
|
|
144
|
+
while (currentIndex !== 0) {
|
|
145
|
+
randomIndex = Math.floor(Math.random() * currentIndex);
|
|
146
|
+
currentIndex--;
|
|
147
|
+
[array[currentIndex], array[randomIndex]] = [array[randomIndex], array[currentIndex]];
|
|
148
|
+
}
|
|
149
|
+
return array;
|
|
150
|
+
};
|
|
151
|
+
this.setClientStyling = () => {
|
|
152
|
+
let sheet = document.createElement('style');
|
|
153
|
+
sheet.innerHTML = this.clientStyling;
|
|
154
|
+
this.host.shadowRoot.prepend(sheet);
|
|
155
|
+
};
|
|
156
|
+
this.setClientStylingURL = () => {
|
|
157
|
+
let url = new URL(this.clientStylingUrl);
|
|
158
|
+
let cssFile = document.createElement('style');
|
|
159
|
+
fetch(url.href)
|
|
160
|
+
.then((res) => res.text())
|
|
161
|
+
.then((data) => {
|
|
162
|
+
cssFile.innerHTML = data;
|
|
163
|
+
this.clientStyling = data;
|
|
164
|
+
setTimeout(() => { this.host.shadowRoot.prepend(cssFile); }, 1);
|
|
165
|
+
});
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
watchEndpoint(newValue, oldValue) {
|
|
169
|
+
if (newValue && newValue != oldValue && this.endpoint) {
|
|
170
|
+
this.fetchGameList();
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
handleNewTranslations() {
|
|
174
|
+
this.isLoading = true;
|
|
175
|
+
getTranslations(this.translationUrl).then(() => {
|
|
176
|
+
this.isLoading = false;
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
connectedCallback() {
|
|
180
|
+
this.iconVisibility = this.iconVisible === 'true' ? true : false;
|
|
181
|
+
}
|
|
182
|
+
componentWillLoad() {
|
|
183
|
+
if (this.translationUrl.length > 2) {
|
|
184
|
+
getTranslations(this.translationUrl);
|
|
185
|
+
}
|
|
186
|
+
if (this.endpoint && this.language && this.datasource) {
|
|
187
|
+
return this.fetchGameList();
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
componentDidLoad() {
|
|
191
|
+
if (!this.limitStylingAppends && this.host) {
|
|
192
|
+
if (this.clientStyling)
|
|
193
|
+
this.setClientStyling();
|
|
194
|
+
if (this.clientStylingUrl)
|
|
195
|
+
this.setClientStylingURL();
|
|
196
|
+
this.limitStylingAppends = true;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
fetchGameList() {
|
|
200
|
+
let url = new URL(`${this.endpoint}/v1/casino/games`);
|
|
201
|
+
url.searchParams.append('device', getDevicePlatform());
|
|
202
|
+
url.searchParams.append('datasource', this.datasource);
|
|
203
|
+
url.searchParams.append('fields', 'gId,id,href,thumbnail,name,vendor,launchUrl,subVendor');
|
|
204
|
+
url.searchParams.append('expand', 'vendor');
|
|
205
|
+
// Number of games chosen
|
|
206
|
+
url.searchParams.append('pagination', 'offset=0,limit=423');
|
|
207
|
+
url.searchParams.append('language', this.language);
|
|
208
|
+
if (this.specificCategory) {
|
|
209
|
+
url.searchParams.append('filter', `categories(id=${this.specificCategory})`);
|
|
210
|
+
}
|
|
211
|
+
return new Promise((resolve, reject) => {
|
|
212
|
+
this.isLoading = true;
|
|
213
|
+
fetch(url.href)
|
|
214
|
+
.then((res) => res.json())
|
|
215
|
+
.then((data) => {
|
|
216
|
+
this.gamesToShow = this.setUpGames(data === null || data === void 0 ? void 0 : data.items);
|
|
217
|
+
resolve(true);
|
|
218
|
+
}).catch((err) => {
|
|
219
|
+
console.error(err);
|
|
220
|
+
this.hasErrors = true;
|
|
221
|
+
reject(err);
|
|
222
|
+
}).finally(() => {
|
|
223
|
+
this.isLoading = false;
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
setUpGames(games) {
|
|
228
|
+
// Only 40 games will be selected at a time; the random game will be selected from these.
|
|
229
|
+
const shuffledGames = this.shuffle(games).slice(0, 40);
|
|
230
|
+
// Clone the games
|
|
231
|
+
return shuffledGames.concat(shuffledGames);
|
|
232
|
+
}
|
|
233
|
+
selectRandomGame() {
|
|
234
|
+
const originalGamesLength = this.gamesToShow.length / 2;
|
|
235
|
+
// Substract 3 to ensure there are always at least 5 cards after the selected one
|
|
236
|
+
this.selectedGameIndex = Math.floor(Math.random() * (originalGamesLength - 3));
|
|
237
|
+
// Offset by the length of the original to select from the cloned part
|
|
238
|
+
this.selectedGameIndex += originalGamesLength;
|
|
239
|
+
this.selectedGameEl = this.gameContainer.children[this.selectedGameIndex];
|
|
240
|
+
}
|
|
241
|
+
playRandomGame() {
|
|
242
|
+
this.animateGames();
|
|
243
|
+
//@ts-ignore
|
|
244
|
+
if (typeof gtag == 'function') {
|
|
245
|
+
//@ts-ignore
|
|
246
|
+
gtag('event', 'PlayRandomGame', {
|
|
247
|
+
'context': 'CasinoPlayRandomGame'
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
respin() {
|
|
252
|
+
this.animateGames();
|
|
253
|
+
//@ts-ignore
|
|
254
|
+
if (typeof gtag == 'function') {
|
|
255
|
+
//@ts-ignore
|
|
256
|
+
gtag('event', 'RespinRandomGame', {
|
|
257
|
+
'context': 'CasinoPlayRandomGame'
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
animateGames() {
|
|
262
|
+
this.iconVisibility = this.iconVisibleOnAnim === 'true' ? true : false;
|
|
263
|
+
this.animationStarted = true;
|
|
264
|
+
this.animationDone = false;
|
|
265
|
+
if (this.animation)
|
|
266
|
+
this.animation.cancel();
|
|
267
|
+
if (this.selectedGameEl) {
|
|
268
|
+
this.selectedGameEl.classList.remove('TheRandomGame');
|
|
269
|
+
this.selectedGame = null;
|
|
270
|
+
this.selectedGameIndex = null;
|
|
271
|
+
}
|
|
272
|
+
this.selectRandomGame();
|
|
273
|
+
const gapStyle = window.getComputedStyle(this.gameContainer).getPropertyValue('gap');
|
|
274
|
+
const gap = parseInt(gapStyle, 10);
|
|
275
|
+
const cardWidth = this.selectedGameEl.offsetWidth;
|
|
276
|
+
const gameContainerWidth = this.gameContainer.offsetWidth;
|
|
277
|
+
const translation = ((cardWidth + gap) * this.selectedGameIndex) + // Width of game cards up to the selected
|
|
278
|
+
(cardWidth / 2) - // Additional half card width to center to the selected game
|
|
279
|
+
(gameContainerWidth / 2); // Minus half the container width to center the card
|
|
280
|
+
const containerRolling = [
|
|
281
|
+
{ transform: `translateX(0px)`, scale: 1 },
|
|
282
|
+
{ scale: 0.75 },
|
|
283
|
+
{ transform: `translateX(-${translation}px)`, scale: 1 }
|
|
284
|
+
];
|
|
285
|
+
const containerTiming = {
|
|
286
|
+
duration: 3000,
|
|
287
|
+
easing: 'cubic-bezier(0.5, 0, 0.5, 1.2)',
|
|
288
|
+
fill: 'forwards'
|
|
289
|
+
};
|
|
290
|
+
this.animation = this.gameContainer.animate(containerRolling, containerTiming);
|
|
291
|
+
this.animation.onfinish = () => {
|
|
292
|
+
this.animationDone = true;
|
|
293
|
+
this.selectedGameEl.classList.add('TheRandomGame');
|
|
294
|
+
this.selectedGame = this.gamesToShow[this.selectedGameIndex];
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
playGame() {
|
|
298
|
+
if (!this.selectedGame)
|
|
299
|
+
return;
|
|
300
|
+
window.postMessage({ type: 'PlayRandomGame', gameId: this.selectedGame.id, launchUrl: this.selectedGame.launchUrl, gameName: this.selectedGame.name, subVendor: this.selectedGame.subVendor }, window.location.href);
|
|
301
|
+
//@ts-ignore
|
|
302
|
+
if (typeof gtag == 'function') {
|
|
303
|
+
//@ts-ignore
|
|
304
|
+
gtag('event', 'OpenRandomGame', {
|
|
305
|
+
'context': 'CasinoPlayRandomGame'
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
;
|
|
310
|
+
showGameInfo() {
|
|
311
|
+
window.postMessage({ type: 'InfoRandomGame', gameId: this.selectedGame.id, launchUrl: this.selectedGame.launchUrl, gameName: this.selectedGame.name, subVendor: this.selectedGame.subVendor }, window.location.href);
|
|
312
|
+
//@ts-ignore
|
|
313
|
+
if (typeof gtag == 'function') {
|
|
314
|
+
//@ts-ignore
|
|
315
|
+
gtag('event', 'OpenRandomGameInfo', {
|
|
316
|
+
'context': 'CasinoPlayRandomGame'
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
renderGameDetails() {
|
|
321
|
+
return h("div", { class: "RandomButtonsWrapper" }, h("div", { class: "RandomGameDetails" }, h("span", { class: "RandomGameTitle" }, this.selectedGame.name), h("span", { class: "RandomGameInfo", onClick: () => this.showGameInfo() }, "i")), h("div", { class: "RandomButtons" }, h("button", { class: "RandomButton On", onClick: () => this.respin() }, translate('spinRandomGame')), !this.launchByGameCard &&
|
|
322
|
+
h("button", { class: "RandomButton On", onClick: () => this.playGame() }, translate('playNowRandomGame'))));
|
|
323
|
+
}
|
|
324
|
+
render() {
|
|
325
|
+
if (this.hasErrors) {
|
|
326
|
+
return (h("div", { class: "RandomGameError" }, h("div", { class: "Title" }, translate('error', this.language))));
|
|
327
|
+
}
|
|
328
|
+
if (!this.isLoading) {
|
|
329
|
+
return h("div", { class: "RandomGameWrapper" }, h("div", { class: 'GameContainerGradient' }), h("div", { class: 'GamesContainer', ref: (el) => this.gameContainer = el }, this.gamesToShow && this.gamesToShow.map((game, index) => (h("div", { class: 'RandomGameCard', key: index, onClick: this.launchByGameCard === 'true' ? () => this.playGame() : null }, h("div", { class: "RandomGameVendor" }, game.vendor.name), h("img", { class: 'RandomGameImage', src: game.thumbnail, alt: game.name, title: game.name }), this.selectedGame && this.selectedGameIndex === index && this.renderGameDetails())))), h("div", { class: `ButtonWrapper ${this.animationDone ? 'HideAnimation' : ''}` }, h("div", { class: "ButtonContainer" }, this.iconVisibility && h("div", { class: `ButtonIcon ${this.animationStarted ? 'Flip' : ''}` }, h("div", { class: `QustionMark ${this.animationStarted ? 'Flip' : ''}` }, "?"), h("div", { class: "HexagonMark" }, h("div", { class: "HexagonMarkBorder" }))), !this.animationStarted && h("div", { class: `RandomButton ${this.animationStarted ? 'HideAnimation' : ''}`, onClick: () => this.playRandomGame() }, translate('playRandomGame')))));
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
get host() { return this; }
|
|
333
|
+
static get watchers() { return {
|
|
334
|
+
"endpoint": ["watchEndpoint"],
|
|
335
|
+
"datasource": ["watchEndpoint"],
|
|
336
|
+
"language": ["watchEndpoint"],
|
|
337
|
+
"translationUrl": ["handleNewTranslations"]
|
|
338
|
+
}; }
|
|
339
|
+
static get style() { return casinoPlayRandomGameCss; }
|
|
340
|
+
}, [1, "casino-play-random-game", {
|
|
341
|
+
"endpoint": [513],
|
|
342
|
+
"datasource": [513],
|
|
343
|
+
"language": [513],
|
|
344
|
+
"specificCategory": [513, "specific-category"],
|
|
345
|
+
"iconVisible": [513, "icon-visible"],
|
|
346
|
+
"iconVisibleOnAnim": [513, "icon-visible-on-anim"],
|
|
347
|
+
"launchByGameCard": [513, "launch-by-game-card"],
|
|
348
|
+
"clientStyling": [513, "client-styling"],
|
|
349
|
+
"clientStylingUrl": [513, "client-styling-url"],
|
|
350
|
+
"translationUrl": [513, "translation-url"],
|
|
351
|
+
"hasErrors": [32],
|
|
352
|
+
"limitStylingAppends": [32],
|
|
353
|
+
"isLoading": [32],
|
|
354
|
+
"gamesToShow": [32],
|
|
355
|
+
"selectedGame": [32],
|
|
356
|
+
"animationDone": [32],
|
|
357
|
+
"animationStarted": [32]
|
|
358
|
+
}]);
|
|
359
|
+
function defineCustomElement$1() {
|
|
360
|
+
if (typeof customElements === "undefined") {
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
const components = ["casino-play-random-game"];
|
|
364
|
+
components.forEach(tagName => { switch (tagName) {
|
|
365
|
+
case "casino-play-random-game":
|
|
366
|
+
if (!customElements.get(tagName)) {
|
|
367
|
+
customElements.define(tagName, CasinoPlayRandomGame$1);
|
|
368
|
+
}
|
|
369
|
+
break;
|
|
370
|
+
} });
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
const CasinoPlayRandomGame = CasinoPlayRandomGame$1;
|
|
374
|
+
const defineCustomElement = defineCustomElement$1;
|
|
375
|
+
|
|
376
|
+
export { CasinoPlayRandomGame, defineCustomElement };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/* CasinoPlayRandomGame custom elements */
|
|
2
|
+
|
|
3
|
+
import type { Components, JSX } from "../types/components";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Used to manually set the base path where assets can be found.
|
|
7
|
+
* If the script is used as "module", it's recommended to use "import.meta.url",
|
|
8
|
+
* such as "setAssetPath(import.meta.url)". Other options include
|
|
9
|
+
* "setAssetPath(document.currentScript.src)", or using a bundler's replace plugin to
|
|
10
|
+
* dynamically set the path at build time, such as "setAssetPath(process.env.ASSET_PATH)".
|
|
11
|
+
* But do note that this configuration depends on how your script is bundled, or lack of
|
|
12
|
+
* bundling, and where your assets can be loaded from. Additionally custom bundling
|
|
13
|
+
* will have to ensure the static assets are copied to its build directory.
|
|
14
|
+
*/
|
|
15
|
+
export declare const setAssetPath: (path: string) => void;
|
|
16
|
+
|
|
17
|
+
export interface SetPlatformOptions {
|
|
18
|
+
raf?: (c: FrameRequestCallback) => number;
|
|
19
|
+
ael?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
|
|
20
|
+
rel?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
|
|
21
|
+
}
|
|
22
|
+
export declare const setPlatformOptions: (opts: SetPlatformOptions) => void;
|
|
23
|
+
|
|
24
|
+
export type { Components, JSX };
|
|
25
|
+
|
|
26
|
+
export * from '../types';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { setAssetPath, setPlatformOptions } from '@stencil/core/internal/client';
|