@everymatrix/casino-tournaments-limited-controller 1.43.4 → 1.45.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 DELETED
@@ -1,40 +0,0 @@
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-tournaments-limited-controller
9
- </title>
10
- <link rel="stylesheet" href="public/reset.css">
11
- <script src='dist/casino-tournaments-limited-controller.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 {
22
- /* padding: 10px 0; */
23
- }
24
- </style>
25
-
26
- <div class="webcomponent">
27
- <casino-tournaments-limited-controller
28
- session="a887ca78-e59c-460f-b9d0-9f80acde0a98"
29
- userid="3198998"
30
- endpoint="https://jetbull-api.stage.norway.everymatrix.com"
31
- lang="en"
32
- state="Ongoing"
33
- states="Scheduled,Ongoing,Finished"
34
- filter="PlayerEnrolled=true"
35
- >
36
- </casino-tournaments-limited-controller>
37
- </div>
38
-
39
- </body>
40
- </html>
package/index.js DELETED
@@ -1 +0,0 @@
1
- import './dist/casino-tournaments-limited-controller.js';
Binary file
package/public/reset.css DELETED
@@ -1,48 +0,0 @@
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
- }
package/rollup.config.js DELETED
@@ -1,59 +0,0 @@
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-tournaments-limited-controller.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
- };
@@ -1,439 +0,0 @@
1
- <svelte:options tag={null} />
2
-
3
- <script lang="ts">
4
- import { onMount } from "svelte";
5
- import { formatDate } from './date'
6
- import icon from './icon'
7
- import './private.loader.svelte'
8
-
9
- import {
10
- _fetch,
11
- matchStatusFromApiToView,
12
- } from "./util";
13
-
14
- import { setLocale, setLocaleWhenInit, _, addNewMessages } from './i18n'
15
-
16
- import {
17
- onMountMessageLifeCycle,
18
- updateEventSourceLifeCycle,
19
- composeEventSourceMessageHandler,
20
- postMessageTabLocaleTextUpdate,
21
- postMessageTabTotalUpdate,
22
- _postMessage,
23
- createEventSource,
24
- } from "./message";
25
-
26
- import '@everymatrix/casino-tournaments-tab'
27
- import { TRANSLATIONS } from './TRANSLATIONS'
28
-
29
- type State = 'Scheduled' | 'Ongoing' | 'Finished'
30
-
31
- export let endpoint: string = ''
32
- export let lang: string = 'en'
33
- export let session: string = ''
34
- export let state: State | undefined = undefined
35
- export let states: string = 'Scheduled,Ongoing,Finished'
36
- export let filter: string = ''
37
-
38
- export let clientstyling:string = '';
39
- export let clientstylingurl:string = '';
40
- export let translationurl:string = '';
41
-
42
- const setTranslationUrl = ():void => {
43
- let url:string = translationurl;
44
-
45
- fetch(url).then((res:any) => res.json())
46
- .then((res) => {
47
- Object.keys(res).forEach((item:any):void => {
48
- addNewMessages(item, res[item]);
49
- });
50
- setTabTexts();
51
- }).catch((err:any) => {
52
- console.log(err);
53
- });
54
- }
55
-
56
- let customStylingContainer: HTMLElement;
57
- let displayNone:boolean = false;
58
-
59
- let eventSource = undefined
60
- let svgSize: number = 0
61
- let href = icon
62
- let isLoading:boolean = true
63
-
64
- type Tournament = {
65
- id: string
66
- nameOrTitle: string
67
- endTime: string
68
- state: string
69
- }
70
-
71
- type TournamentForRendering = {
72
- id: string,
73
- title: string,
74
- rank: string,
75
- enddate: string,
76
- prize: string,
77
- }
78
-
79
- type TournamentsMatrix = {
80
- [P in State]?: TournamentForRendering[]
81
- }
82
-
83
- let tournamentsMatrix: TournamentsMatrix = {}
84
-
85
- const setTournamentsMatrix = (data) => {
86
- let _tournamentsMatrix: TournamentsMatrix = {}
87
- __states.map(s => {
88
- if(!_tournamentsMatrix[s]){
89
- _tournamentsMatrix[s] = []
90
- }
91
- })
92
-
93
- // data.items = []
94
- data.items.map(_item => {
95
-
96
- const { id, nameOrTitle: title, endTime: enddate } = _item.tournament
97
-
98
- const tournamentComposed: TournamentForRendering = {
99
- id,
100
- title,
101
- rank: _item.leaderBoard && `#${_item.leaderBoard.rank}/${_item.endRank}`,
102
- enddate,
103
- prize: _item.leaderBoard && _item.leaderBoard.prizeName,
104
- }
105
-
106
- _tournamentsMatrix[matchStatusFromApiToView(_item.tournament.state)].push(tournamentComposed)
107
- })
108
-
109
- tournamentsMatrix = _tournamentsMatrix
110
- }
111
-
112
- const eventSourceHandler = composeEventSourceMessageHandler({
113
- "PlayerLeaderBoardsUpdate": (data) => {
114
- setTournamentsMatrix(data)
115
- statesNeedSubscribe.map(s => {
116
- postMessageTabTotalUpdate(s, tournamentsMatrix[s].length)
117
- })
118
- },
119
- 'TournamentUpdate': (data) => {
120
- if(data.item){
121
- const tournament = data.item as Tournament
122
- let _state = matchStatusFromApiToView(tournament.state)
123
- tournamentsMatrix = {
124
- ...tournamentsMatrix,
125
- [_state]: tournamentsMatrix[_state].map(t => {
126
- if(t.id === tournament.id){
127
- return {
128
- ...t,
129
- title: tournament.nameOrTitle,
130
- enddate: tournament.endTime
131
- }
132
- }else{
133
- return t
134
- }
135
- })
136
- }
137
- }
138
- },
139
- })
140
-
141
- const subscribeApi = async (offset:number, limit:number) => {
142
-
143
- const source = `${endpoint}/v1/tournaments`
144
- const url = new URL(source)
145
-
146
- url.searchParams.append('pagination', `offset=${offset},limit=${limit}`);
147
- url.searchParams.append('sortField', 'StartTime');
148
- url.searchParams.append('sortOrder', 'desc');
149
- url.searchParams.append('language', lang);
150
- url.searchParams.append('XSessionId', session);
151
-
152
-
153
- if(filter){
154
- url.searchParams.append('filter', filter);
155
- }
156
-
157
- eventSource = updateEventSourceLifeCycle(
158
- eventSource,
159
- createEventSource(`${source}/leaderboard/player/updates?${url.searchParams.toString()}`),
160
- eventSourceHandler
161
- )
162
- }
163
-
164
- // =============== define above, run below =============== \\
165
-
166
- setLocaleWhenInit()
167
-
168
- $: __state = state
169
- $: __states = states.split(',') as State[]
170
- $: statesNeedSubscribe = __states.filter(s => s !== 'Finished')
171
- $: list = tournamentsMatrix[__state]
172
-
173
- const init = () => {
174
- subscribeApi(0, 30)
175
- setLocale(lang)
176
- setTabTexts()
177
- }
178
-
179
- const setClientStyling = ():void => {
180
- let sheet = document.createElement('style');
181
- sheet.innerHTML = clientstyling;
182
- customStylingContainer.appendChild(sheet);
183
- }
184
-
185
- const setClientStylingURL = ():void => {
186
- displayNone = true;
187
-
188
- let url:URL = new URL(clientstylingurl);
189
- let cssFile:HTMLElement = document.createElement('style');
190
-
191
- fetch(url.href)
192
- .then((res:any) => res.text())
193
- .then((data:any) => {
194
- cssFile.innerHTML = data
195
-
196
- setTimeout(() => { customStylingContainer.appendChild(cssFile) }, 1);
197
- setTimeout(() => { displayNone = false; }, 500);
198
- });
199
- }
200
-
201
- const setTabTexts = () => {
202
- setTimeout(() => {
203
- const getText = (key) => $_(`tournamentsLimitedController.${key}`)
204
- postMessageTabLocaleTextUpdate('Scheduled', getText('Scheduled'))
205
- postMessageTabLocaleTextUpdate('Ongoing', getText('Ongoing'))
206
- postMessageTabLocaleTextUpdate('Finished', `${getText(`Finished`)} (${getText('last')} 48h)`)
207
- }, 1)
208
- }
209
-
210
- onMount(() => {
211
- return () => {
212
- if(eventSource){
213
- eventSource.removeEventListener('message', eventSourceHandler);
214
- }
215
- }
216
- })
217
-
218
- onMountMessageLifeCycle({
219
- TournamentsTabSwitch: async (data) => __state = data.tab
220
- })
221
-
222
- $: endpoint && filter && lang && session && init();
223
- $: clientstyling && customStylingContainer && setClientStyling();
224
- $: clientstylingurl && customStylingContainer && setClientStylingURL();
225
- $: translationurl && setTranslationUrl();
226
-
227
- $: lang && setTabTexts()
228
-
229
- $: Object.keys(tournamentsMatrix).length && (() => {
230
- isLoading = false
231
- setTabTexts()
232
- })()
233
- </script>
234
-
235
- <div class="Root" part="Root" bind:this={customStylingContainer}>
236
-
237
- <div class="top-wrapper">
238
- <div class="svg" bind:clientWidth={svgSize}>
239
- <svg width={svgSize} height={svgSize} viewBox={`0 0 ${svgSize} ${svgSize}`} fill="none" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
240
- <rect width={svgSize} height={svgSize} fill="url(#pattern0)"/>
241
- <defs>
242
- <pattern id="pattern0" patternContentUnits="objectBoundingBox" width="1" height="1">
243
- <use xlink:href="#image0_2606_356" transform="scale(0.00195312)"/>
244
- </pattern>
245
- {#if href}
246
- <image
247
- id="image0_2606_356"
248
- width="512"
249
- height="512"
250
- xlink:href={href}
251
- />
252
- {/if}
253
- </defs>
254
- </svg>
255
- </div>
256
-
257
- <div class="text">
258
- {$_('tournamentsLimitedController.myTournaments')}
259
- </div>
260
-
261
- <div class="CloseButton" part="CloseButton"
262
- on:click='{
263
- ()=>window.postMessage({ type: 'OnCloseThumbnail' }, window.location.href)
264
- }'
265
- >X</div>
266
- </div>
267
-
268
- {#if isLoading}
269
- <div class="Loading">
270
- <casino-tournaments-limited-controller-loader />
271
- </div>
272
- {:else}
273
- <section>
274
- <casino-tournaments-tab
275
- tabs={states}
276
- tab={state}
277
- />
278
-
279
- {#if list}
280
- <table>
281
- <thead>
282
- <tr>
283
- {#each [
284
- $_('tournamentsLimitedController.name'),
285
- $_('tournamentsLimitedController.rank'),
286
- $_('tournamentsLimitedController.enddate'),
287
- $_('tournamentsLimitedController.prize')
288
- ] as item}
289
- <th>{item}</th>
290
- {/each}
291
- </tr>
292
- </thead>
293
- {#each list as item, i}
294
- <tbody>
295
- <tr>
296
- {#if item}
297
-
298
- <td class="Title" part="Title" on:click={() => {
299
- window.postMessage({
300
- type: 'MyTournamentFromNavClicked',
301
- tournamentId: item.id,
302
- showLeaderboard: true
303
- }, window.location.href)
304
- }}>
305
- {item.title}
306
- </td>
307
- <td class:active={item.prize} class="Rank">{item.rank || ' -'}</td>
308
- <td class="EndDate" part="EndDate" nowrap>
309
- {#each formatDate(item.enddate) as s}
310
- <p>{s}</p>
311
- {/each}
312
- </td>
313
- <td class:active={item.prize} class="Prize">{item.prize || ' -'}</td>
314
- {/if}
315
- </tr>
316
- </tbody>
317
- {/each}
318
- </table>
319
- {:else}
320
- <div class="NoContent"></div>
321
- {/if}
322
-
323
- </section>
324
- {/if}
325
- </div>
326
-
327
- <style lang="scss">
328
-
329
-
330
- *,
331
- *::before,
332
- *::after {
333
- margin: 0;
334
- padding: 0;
335
- list-style: none;
336
- text-decoration: none;
337
- outline: none;
338
- box-sizing: border-box;
339
- }
340
-
341
- $vw_base: 320px;
342
- @function vw($px) {
343
- @return ($px / $vw_base) * 100vw;
344
- }
345
-
346
- .CloseButton {
347
- position: absolute;
348
- right: vw(5px);
349
- font-size: vw(11px);
350
- color: #FFFFFF;
351
- cursor: pointer
352
- }
353
-
354
- .NoContent {
355
- padding: 120px;
356
- }
357
-
358
- .Root {
359
- background: #282828;
360
-
361
- .top-wrapper {
362
- padding: vw(6px);
363
- display: flex;
364
- background: #333333;
365
-
366
- .svg {
367
- & {
368
- width: vw(35px);
369
- height: vw(35px);
370
- }
371
- }
372
-
373
- .text {
374
- color: white;
375
- font-size: vw(16px);
376
- padding-left: vw(10px);
377
- font-weight: bold;
378
- line-height: vw(19px);
379
- padding-top: vw(7px);
380
- }
381
- }
382
-
383
- section {
384
- padding: 0 vw(12px);
385
- }
386
- }
387
-
388
- table {
389
- width: 100%;
390
- border-collapse: collapse;
391
- font-size: vw(12px);
392
- line-height: vw(14px);
393
-
394
-
395
- @import url('https://rsms.me/inter/inter.css');
396
- div { font: initial; font-family: 'Inter', sans-serif; }
397
- @supports (font-variation-settings: normal) {
398
- div { font: initial; font-family: 'Inter var', sans-serif; }
399
- }
400
-
401
- thead {
402
-
403
- background: #1C1C1C;
404
- color: #F7F7F7;
405
- }
406
-
407
- th, td {
408
- padding: vw(8px) vw(5px);
409
- overflow-wrap: break-word;
410
- }
411
-
412
- td {
413
- color: #B5B5B5;
414
- }
415
- }
416
-
417
- .Title {
418
- color: #FF8364;
419
- text-decoration-line: underline;
420
- word-break: break-word;
421
-
422
- &:active {
423
- opacity: 0.6;
424
- }
425
- }
426
-
427
- .Prize .Rank {
428
- &:active {
429
- color: #FFD700;
430
- }
431
- }
432
-
433
- .Loading {
434
- display: flex;
435
- justify-content: center;
436
- padding: vw(30px);
437
- }
438
-
439
- </style>
package/src/date.js DELETED
@@ -1,26 +0,0 @@
1
- function padTo2Digits(num) {
2
- return num.toString().padStart(2, '0');
3
- }
4
-
5
- export function formatDate(date) {
6
-
7
- const _date = new Date(date)
8
-
9
- const day = [
10
- padTo2Digits(_date.getDate()),
11
- padTo2Digits(_date.getMonth() + 1),
12
- _date.getFullYear() % 100,
13
- ].join('.')
14
-
15
- const hm = [
16
- padTo2Digits(_date.getHours()),
17
- padTo2Digits(_date.getMinutes()),
18
- ].join(':')
19
-
20
- const xm = _date.getHours() >= 12 ? 'PM' : 'AM'
21
-
22
- return [
23
- day,
24
- hm + ' ' + xm
25
- ]
26
- }
package/src/i18n.js DELETED
@@ -1,38 +0,0 @@
1
- import {
2
- dictionary,
3
- locale,
4
- addMessages,
5
- _
6
- } from 'svelte-i18n';
7
-
8
- import { TRANSLATIONS } from './translations';
9
-
10
- function setupI18n({ withLocale: _locale, translations }) {
11
- locale.subscribe((data) => {
12
- if (data == null) {
13
- dictionary.set(translations);
14
- locale.set(_locale);
15
- }
16
- }); // maybe we will need this to make sure that the i18n is set up only once
17
- /*dictionary.set(translations);
18
- locale.set(_locale);*/
19
- }
20
-
21
- function addNewMessages(lang, dict) {
22
- addMessages(lang, dict);
23
- }
24
-
25
- function setLocale(_locale) {
26
- locale.set(_locale);
27
- }
28
-
29
- const setLocaleWhenInit = () => {
30
-
31
- setupI18n({ withLocale: 'en', translations: {}});
32
-
33
- Object.keys(TRANSLATIONS).forEach((item) => {
34
- addNewMessages(item, TRANSLATIONS[item]);
35
- });
36
- }
37
-
38
- export { _, setupI18n, addNewMessages, setLocale, setLocaleWhenInit };