@everymatrix/casino-most-played-section 1.0.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/index.html ADDED
@@ -0,0 +1,37 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset='utf-8'>
5
+ <meta name='viewport' content='width=device-width,initial-scale=1'>
6
+
7
+ <title>
8
+ casino-most-played-section
9
+ </title>
10
+ <link rel="stylesheet" href="public/reset.css">
11
+ <script src='dist/casino-most-played-section.js'></script>
12
+ </head>
13
+
14
+ <body>
15
+ <style>
16
+ html,body { margin: 0; padding: 0; height: 100%; font-family: "Helvetica Neue", "Helvetica", sans-serif; }
17
+ .header { display: flex; justify-content: center; align-items: center; padding: 10px 20px; margin-bottom: 20px; background: #42a3e2; box-shadow: 3px 4px 5px 0px rgba(0,0,0, .2); }
18
+ .header__logo svg { height: 50px; width: 50px; margin-right: 5px; }
19
+ .header__name { color: #fff; }
20
+ .header__name span { margin-right: 10px; font-weight: bold; }
21
+ .webcomponent { padding: 10px 20px; }
22
+ </style>
23
+ <header class="header">
24
+ <div class="header__logo">
25
+ <svg xmlns="http://www.w3.org/2000/svg" width="161" height="132" viewBox="0 0 161 132"><defs><linearGradient x1="0%" y1="50%" y2="50%" id="a"><stop stop-color="#2A3B8F" offset="0%"/><stop stop-color="#29ABE2" offset="100%"/></linearGradient><linearGradient x1="100%" y1="50%" x2="0%" y2="50%" id="c"><stop stop-color="#B4D44E" offset="0%"/><stop stop-color="#E7F716" offset="100%"/></linearGradient></defs><g fill="none" fill-rule="evenodd"><path fill="#166DA5" d="M160.6 65.9l-17.4 29.3-24.4-29.7 24.4-28.9z"/><path fill="#8FDB69" d="M141.3 100.2l-26.5-31.7-15.9 26.6 24.7 36.1z"/><path fill="#166DA5" d="M141 31.4l-26.2 31.8-15.9-26.6L123.6.9z"/><path fill="url(#a)" opacity=".95" d="M61.1 31.4H141L123.4.7H78.7z M114.8 63.3H159l-15.9-26.8H98.8"/><path fill="url(#c)" opacity=".95" d="M141.3 100.3H61l17.6 30.5h45z M114.8 68.4H159l-15.9 26.8H98.8"/><path fill="#010101" d="M78.6 130.8L41 65.8 79.1.8H37.9L.4 65.8l37.5 65z"/></g></svg>
26
+ </div>
27
+ <h1 class="header__name">
28
+ <span>WEBCOMPONENT:</span> casino-most-played-section
29
+ </h1>
30
+ </header>
31
+
32
+ <div class="webcomponent">
33
+ <casino-most-played-section></casino-most-played-section>
34
+ </div>
35
+
36
+ </body>
37
+ </html>
package/index.js ADDED
@@ -0,0 +1 @@
1
+ import './dist/casino-most-played-section.js';
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@everymatrix/casino-most-played-section",
3
+ "version": "1.0.0",
4
+ "main": "index.js",
5
+ "svelte": "src/index.ts",
6
+
7
+ "scripts": {
8
+ "start": "sirv public",
9
+ "build": "cross-env NODE_ENV=production rollup -c",
10
+ "dev": "cross-env NODE_ENV=\"development\" rollup -c -w",
11
+ "validate": "svelte-check",
12
+ "test": "echo"
13
+ },
14
+ "devDependencies": {
15
+ "rollup": "^2.3.4",
16
+ "@rollup/plugin-babel": "^5.3.0",
17
+ "@rollup/plugin-commonjs": "^16.0.0",
18
+ "@rollup/plugin-node-resolve": "^10.0.0",
19
+ "@rollup/plugin-typescript": "^6.0.0",
20
+ "rollup-plugin-dev-server": "^0.4.3",
21
+ "rollup-plugin-livereload": "^2.0.0",
22
+ "rollup-plugin-uglify": "^6.0.4",
23
+ "rollup-plugin-svelte": "^7.0.0",
24
+ "rollup-plugin-terser": "^7.0.0",
25
+ "svelte-check": "^1.0.0",
26
+ "node-sass": "^5.0.0",
27
+ "typescript": "^3.9.3",
28
+ "svelte-preprocess": "^4.0.0",
29
+ "tslib": "^2.0.0",
30
+ "@tsconfig/svelte": "^1.0.0"
31
+ },
32
+ "dependencies": {
33
+ "cross-env": "^7.0.3",
34
+ "svelte": "^3.0.0",
35
+ "sirv-cli": "^1.0.0"
36
+ },
37
+ "publishConfig": {
38
+ "access": "public"
39
+ }
40
+ }
Binary file
@@ -0,0 +1,48 @@
1
+ /* http://meyerweb.com/eric/tools/css/reset/
2
+ v2.0 | 20110126
3
+ License: none (public domain)
4
+ */
5
+
6
+ html, body, div, span, applet, object, iframe,
7
+ h1, h2, h3, h4, h5, h6, p, blockquote, pre,
8
+ a, abbr, acronym, address, big, cite, code,
9
+ del, dfn, em, img, ins, kbd, q, s, samp,
10
+ small, strike, strong, sub, sup, tt, var,
11
+ b, u, i, center,
12
+ dl, dt, dd, ol, ul, li,
13
+ fieldset, form, label, legend,
14
+ table, caption, tbody, tfoot, thead, tr, th, td,
15
+ article, aside, canvas, details, embed,
16
+ figure, figcaption, footer, header, hgroup,
17
+ menu, nav, output, ruby, section, summary,
18
+ time, mark, audio, video {
19
+ margin: 0;
20
+ padding: 0;
21
+ border: 0;
22
+ font-size: 100%;
23
+ font: inherit;
24
+ vertical-align: baseline;
25
+ }
26
+ /* HTML5 display-role reset for older browsers */
27
+ article, aside, details, figcaption, figure,
28
+ footer, header, hgroup, menu, nav, section {
29
+ display: block;
30
+ }
31
+ body {
32
+ line-height: 1;
33
+ }
34
+ ol, ul {
35
+ list-style: none;
36
+ }
37
+ blockquote, q {
38
+ quotes: none;
39
+ }
40
+ blockquote:before, blockquote:after,
41
+ q:before, q:after {
42
+ content: '';
43
+ content: none;
44
+ }
45
+ table {
46
+ border-collapse: collapse;
47
+ border-spacing: 0;
48
+ }
@@ -0,0 +1,59 @@
1
+ import svelte from 'rollup-plugin-svelte';
2
+ import commonjs from '@rollup/plugin-commonjs';
3
+ import resolve from '@rollup/plugin-node-resolve';
4
+ import serve from 'rollup-plugin-dev-server';
5
+ import livereload from 'rollup-plugin-livereload';
6
+ import { terser } from 'rollup-plugin-terser';
7
+ import sveltePreprocess from 'svelte-preprocess';
8
+ import typescript from '@rollup/plugin-typescript';
9
+ const production = process.env.NODE_ENV === 'production';
10
+ const dev = process.env.NODE_ENV === 'development';
11
+
12
+ export default {
13
+ input: 'src/index.ts',
14
+ output: {
15
+ sourcemap: true,
16
+ format: 'umd',
17
+ name: 'app',
18
+ file: 'dist/casino-most-played-section.js'
19
+ },
20
+ plugins: [
21
+ svelte({
22
+ preprocess: sveltePreprocess(),
23
+ compilerOptions: {
24
+ // enable run-time checks when not in production
25
+ customElement: true,
26
+ dev: !production
27
+ }
28
+ }),
29
+ commonjs(),
30
+ resolve({
31
+ browser: true,
32
+ dedupe: ['svelte']
33
+ }),
34
+ dev && serve({
35
+ open: true,
36
+ verbose: true,
37
+ allowCrossOrigin: true,
38
+ historyApiFallback: false,
39
+ host: 'localhost',
40
+ port: 5050,
41
+ }),
42
+ dev && livereload({ watch: ['', 'dist'] }),
43
+ typescript({
44
+ sourceMap: !production,
45
+ inlineSources: !production,
46
+ }),
47
+ // If we're building for production (npm run build
48
+ // instead of npm run dev), minify
49
+ production &&
50
+ terser({
51
+ output: {
52
+ comments: "all"
53
+ },
54
+ })
55
+ ],
56
+ watch: {
57
+ clearScreen: false
58
+ }
59
+ };
@@ -0,0 +1,195 @@
1
+ <svelte:options tag={null} />
2
+ <script lang="ts">
3
+
4
+ import { getDevice } from 'rvhelper';
5
+ import { _, setLocale } from './i18n';
6
+ import '@everymatrix/casino-games-category-section'
7
+
8
+ export let endpoint:string = '';
9
+ export let datasource:string = '';
10
+ export let currency:string = '';
11
+ export let lang:string = ''; // Language
12
+ export let session:string = ''; // Value for sessionID
13
+ export let userid:string = ''; // Value for UserID;
14
+ export let clientstyling:string = '';
15
+ export let clientstylingurl:string = '';
16
+
17
+ export let livecasino:string = 'false';
18
+ export let integratedgameframemobile:string = 'false';
19
+ export let integratedgameframedesktop:string = 'false';
20
+ export let gamepagemodalurl:string = 'false';
21
+ export let visiblegames:string;
22
+ export let favorites:string = '';
23
+ export let lastPlayedEmpty:string = '';
24
+
25
+
26
+ let userAgent:any = window.navigator.userAgent;
27
+
28
+ let mostPlayedGames:Array<any> = [];
29
+ let playerID:string;
30
+ let urlCasino:any;
31
+ let activeCategory:string;
32
+ let isLoading:boolean = false;
33
+ let mostPlayedEmpty:boolean = false;
34
+
35
+ let customStylingContainer:HTMLElement;
36
+
37
+ const getMostPlayedGames = (options:any) => {
38
+ let url = new URL(`${endpoint}/player/${userid}/games/most-played`);
39
+
40
+ if (options.limit) {
41
+ url.searchParams.append('limit', options.limit);
42
+ }
43
+
44
+ if (options.order) {
45
+ url.searchParams.append('order', options.order);
46
+ }
47
+
48
+ url.searchParams.append('expand', 'games')
49
+
50
+ let device = options.device;
51
+
52
+ if (device) {
53
+ if (device === 'PC') {
54
+ url.searchParams.append('device', 'Desktop');
55
+ } else {
56
+ url.searchParams.append('device', 'Mobile');
57
+ }
58
+ } else {
59
+ url.searchParams.append('device', 'All');
60
+ }
61
+
62
+ if (options.rounds) {
63
+ url.searchParams.append('rounds', options.rounds);
64
+ }
65
+
66
+ urlCasino = livecasino ? url : url.href;
67
+ return new Promise((resolve, reject) => {
68
+ fetch(urlCasino)
69
+ .then((res:any) => res.json())
70
+ .then((data:any) => {
71
+ resolve(data);
72
+
73
+ //window.postMessage({ type: 'AddNewCategory', category: { name: 'Last played', id: 'LASTPLAYED' }}, window.location.href);
74
+ //window.postMessage({ type: 'MostPlayedGames', data }, window.location.href);
75
+ }).catch((err:any) => {
76
+ console.error(err);
77
+
78
+ reject(err);
79
+ });
80
+ });
81
+ }
82
+
83
+ isLoading = true;
84
+
85
+ const initialLoad = (): void => {
86
+ getMostPlayedGames({
87
+ limit: 100,
88
+ device: getDevice(userAgent),
89
+ rounds: 10
90
+ }).then((res:any) => {
91
+ isLoading = false;
92
+
93
+ if (res.count > 0) {
94
+ let promises:any = [];
95
+
96
+ res.items.forEach((item:any) => {
97
+ let url:URL = new URL(`${endpoint}/casino/games/${item.gameId}`);
98
+
99
+ url.searchParams.append('datasource', datasource);
100
+ if (livecasino) {
101
+ promises.push(fetch(url.href).then((res:any) => res.json()));
102
+ } else {
103
+ promises.push(fetch(url.href).then((res:any) => res.json()));
104
+ }
105
+ });
106
+
107
+ Promise.all(promises).then((values:any) => {
108
+ mostPlayedGames = values.map((item:any) => item[0]);
109
+
110
+ window.postMessage({ type: 'MostPlayedData', mostPlayedGames }, window.location.href);
111
+ });
112
+ } else {
113
+ mostPlayedEmpty = true;
114
+ }
115
+ });
116
+ }
117
+
118
+ const setActiveLanguage = ():void => {
119
+ setLocale(lang);
120
+ }
121
+
122
+ const setClientStyling = () => {
123
+ let sheet = document.createElement('style');
124
+ sheet.innerHTML = clientstyling;
125
+ customStylingContainer.appendChild(sheet);
126
+ }
127
+
128
+ const setClientStylingURL = () => {
129
+ let cssFile:HTMLElement = document.createElement('style');
130
+
131
+ fetch(new URL(clientstylingurl))
132
+ .then((res:any) => res.text())
133
+ .then((data:any) => {
134
+ cssFile.innerHTML = data
135
+
136
+ setTimeout(() => { customStylingContainer.appendChild(cssFile); }, 1);
137
+ });
138
+ }
139
+
140
+ $: endpoint && userid && lang && initialLoad();
141
+ $: clientstyling && customStylingContainer && setClientStyling();
142
+ $: clientstylingurl && customStylingContainer && setClientStylingURL();
143
+ $: lang && setActiveLanguage();
144
+ </script>
145
+
146
+ <div class="CasinoGamesCategorySectionContainer" part="CasinoGamesCategorySectionContainer" bind:this={customStylingContainer}>
147
+ <div class="casino-most-played-section">
148
+ {#if mostPlayedEmpty}
149
+ <p class="SearchLoading" part="SearchLoading">No games in most played</p>
150
+ {:else}
151
+ <casino-games-category-section
152
+ session={session}
153
+ userid={userid}
154
+ endpoint={endpoint}
155
+ datasource={datasource}
156
+ lang={lang}
157
+ currency={currency}
158
+ favorites={favorites}
159
+ categoryid="MOSTPLAYED"
160
+ categoryindex="1"
161
+ categorygames="9"
162
+ class="CategoryContainer"
163
+ {clientstyling}
164
+ {clientstylingurl}
165
+ {livecasino}
166
+ {visiblegames}
167
+ {gamepagemodalurl}
168
+ {integratedgameframedesktop}
169
+ {integratedgameframemobile}
170
+ />
171
+ {/if}
172
+ </div>
173
+ </div>
174
+
175
+ <style lang="scss">
176
+ :host {
177
+ font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji';
178
+ }
179
+
180
+ *,
181
+ *::before,
182
+ *::after {
183
+ margin: 0;
184
+ padding: 0;
185
+ list-style: none;
186
+ text-decoration: none;
187
+ outline: none;
188
+ box-sizing: border-box;
189
+ }
190
+
191
+ .casino-most-played-section {
192
+ background: var(--emfe-w-color-black, #000000);
193
+ color: var(--emfe-w-color-white, #FFFFFF);
194
+ }
195
+ </style>
package/src/i18n.js ADDED
@@ -0,0 +1,27 @@
1
+ import {
2
+ dictionary,
3
+ locale,
4
+ addMessages,
5
+ _
6
+ } from 'svelte-i18n';
7
+
8
+ function setupI18n({ withLocale: _locale, translations }) {
9
+ locale.subscribe((data) => {
10
+ if (data == null) {
11
+ dictionary.set(translations);
12
+ locale.set(_locale);
13
+ }
14
+ }); // maybe we will need this to make sure that the i18n is set up only once
15
+ /*dictionary.set(translations);
16
+ locale.set(_locale);*/
17
+ }
18
+
19
+ function addNewMessages(lang, dict) {
20
+ addMessages(lang, dict);
21
+ }
22
+
23
+ function setLocale(_locale) {
24
+ locale.set(_locale);
25
+ }
26
+
27
+ export { _, setupI18n, addNewMessages, setLocale };
package/src/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ import CasinoMostPlayedSection from './CasinoMostPlayedSection.svelte';
2
+
3
+ !customElements.get('casino-most-played-section') && customElements.define('casino-most-played-section', CasinoMostPlayedSection);
4
+ export default CasinoMostPlayedSection;
@@ -0,0 +1,13 @@
1
+ import { html } from 'lit-element';
2
+
3
+ import CasinoMostPlayedSection from '../src/CasinoMostPlayedSection';
4
+
5
+ // This default export determines where your story goes in the story list
6
+ export default {
7
+ title: 'CasinoMostPlayedSection',
8
+ };
9
+
10
+ // 👇 We create a “template” of how args map to rendering
11
+ const CasinoMostPlayedSection = ({ aProperty }) => html`<casino-most-played-section></casino-most-played-section>`;
12
+
13
+ export const FirstStory = CasinoMostPlayedSection.bind({});
package/tsconfig.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "extends": "@tsconfig/svelte/tsconfig.json",
3
+
4
+ "include": ["src/**/*"],
5
+ "exclude": ["node_modules/*", "__sapper__/*", "public/*"]
6
+ }