@everymatrix/casino-random-game 1.0.3 → 1.0.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@everymatrix/casino-random-game",
3
- "version": "1.0.3",
3
+ "version": "1.0.8",
4
4
  "main": "dist/casino-random-game.js",
5
5
  "svelte": "src/index.ts",
6
6
  "scripts": {
@@ -11,6 +11,8 @@
11
11
  export let lang:string = '';
12
12
  export let randombuttonicon:string = '';
13
13
  export let buttontext: string = '';
14
+ export let clientstyling:string = '';
15
+ export let clientstylingurl:string = '';
14
16
 
15
17
  let games:any = [];
16
18
  let randomGame:any = '';
@@ -21,6 +23,7 @@
21
23
  let slotDone:boolean = false;
22
24
 
23
25
  let userAgent:string = window.navigator.userAgent;
26
+ let customStylingContainer:HTMLElement;
24
27
 
25
28
  setupI18n({ withLocale: 'en', translations: {}});
26
29
 
@@ -28,7 +31,7 @@
28
31
  addNewMessages(item, CasinoRandomGameTranslations[item]);
29
32
  });
30
33
 
31
- const getRandomGame = ():void => {
34
+ const getRandomGame = (refresh?:boolean):void => {
32
35
  gamesToShow = shuffle(gamesToShow);
33
36
  offset = 0;
34
37
  count = 0;
@@ -45,6 +48,16 @@
45
48
  clearInterval(interval);
46
49
  }
47
50
  }, 100);
51
+
52
+ if(refresh){
53
+ //Analytics event
54
+ if(typeof gtag == 'function'){
55
+ gtag('event', 'RefreshRandomGame', {
56
+ 'context': 'RandomGameWidget',
57
+ 'gameId' : `${randomGame.gId || randomGame.id}`
58
+ });
59
+ }
60
+ }
48
61
  }
49
62
 
50
63
  const shuffle = (array):Array<any> => {
@@ -63,6 +76,14 @@
63
76
  const playGame = ():void => {
64
77
  window.postMessage({ type: gameevent, gameId: randomGame.gId || randomGame.id }, window.location.href);
65
78
  show = false;
79
+
80
+ //Analytics event
81
+ if(typeof gtag == 'function'){
82
+ gtag('event', 'OpenGame', {
83
+ 'context': 'RandomGameWidget',
84
+ 'gameId' : `${randomGame.gId || randomGame.id}`
85
+ });
86
+ }
66
87
  }
67
88
 
68
89
  const closeModal = ():void => {
@@ -90,11 +111,33 @@
90
111
  setLocale(lang);
91
112
  }
92
113
 
114
+ const setClientStyling = ():void => {
115
+ let sheet = document.createElement('style');
116
+ sheet.innerHTML = clientstyling;
117
+ customStylingContainer.appendChild(sheet);
118
+ }
119
+
120
+ const setClientStylingURL = ():void => {
121
+
122
+ let url:URL = new URL(clientstylingurl);
123
+ let cssFile:HTMLElement = document.createElement('style');
124
+
125
+ fetch(url.href)
126
+ .then((res:any) => res.text())
127
+ .then((data:any) => {
128
+ cssFile.innerHTML = data;
129
+
130
+ setTimeout(() => { customStylingContainer.appendChild(cssFile) }, 1);
131
+ });
132
+ }
133
+
93
134
  $: lang && setActiveLanguage();
94
135
  $: endpoint && datasource && fetchGameList();
136
+ $: clientstyling && customStylingContainer && setClientStyling();
137
+ $: clientstylingurl && customStylingContainer && setClientStylingURL();
95
138
  </script>
96
139
 
97
- <div part="CustomStylingContainer">
140
+ <div bind:this={customStylingContainer} part="CustomStylingContainer">
98
141
  <div>
99
142
  {#if show}
100
143
  <div class="ModalWindow" part="ModalWindow">
@@ -124,7 +167,7 @@
124
167
  <div class="RandomGameWrapper" part="RandomGameWrapper">
125
168
  <div class="item" part="item">
126
169
  <img class="RandomGameImage" part="RandomGameImage" src={randomGame.thumbnail} alt={randomGame.name} title={randomGame.name}/>
127
- <button class="RandomTryAgain" part="RandomTryAgain" on:click={() => getRandomGame()}>
170
+ <button class="RandomTryAgain" part="RandomTryAgain" on:click={() => getRandomGame(true)}>
128
171
  <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Layer_1" x="0px" y="0px" viewBox="0 0 200 200" style="enable-background:new 0 0 200 200;" xml:space="preserve">
129
172
  <style type="text/css">
130
173
  .st0{fill:var(--emfe-w-color-white, #FFFFFF);;}