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