@everymatrix/casino-tournaments-slider-controller 1.7.2 → 1.8.1
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-tournaments-slider-controller",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.1",
|
|
4
4
|
"main": "dist/casino-tournaments-slider-controller.js",
|
|
5
5
|
"svelte": "src/index.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "e558ed5234cd858fa71696743229caa273752a2e"
|
|
40
40
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<svelte:options tag={null} />
|
|
2
2
|
<script lang="ts">
|
|
3
3
|
import {onMount} from "svelte";
|
|
4
|
+
import {fade } from 'svelte/transition';
|
|
4
5
|
import { getDevice } from 'rvhelper';
|
|
5
6
|
import { _, addNewMessages, setLocale, setupI18n } from './i18n';
|
|
6
7
|
import { TournamentsSliderTranslations } from './translations';
|
|
@@ -42,7 +43,9 @@
|
|
|
42
43
|
let slideAutoInterval;
|
|
43
44
|
let isHided: boolean = false;
|
|
44
45
|
let animatorRef: HTMLElement
|
|
45
|
-
let transistionTime: number = 1
|
|
46
|
+
let transistionTime: number = 1;
|
|
47
|
+
let curTournamentElement:HTMLElement;
|
|
48
|
+
let sliderTransitionTime:number = 300;
|
|
46
49
|
|
|
47
50
|
setupI18n({ withLocale: 'en', translations: {}});
|
|
48
51
|
|
|
@@ -88,24 +91,31 @@
|
|
|
88
91
|
|
|
89
92
|
const slideAuto = () => {
|
|
90
93
|
if(tournamentList.length === 0) return;
|
|
91
|
-
|
|
94
|
+
animator.curTournament.hide();
|
|
95
|
+
setTimeout(()=>{
|
|
96
|
+
currentTournamentIdx = (currentTournamentIdx + 1) % tournamentList.length
|
|
97
|
+
animator.curTournament.show();
|
|
98
|
+
}, sliderTransitionTime*1.5);
|
|
92
99
|
}
|
|
93
|
-
|
|
94
100
|
const setSlideAutoInterval = () => {
|
|
95
101
|
clearInterval(slideAutoInterval)
|
|
96
102
|
slideAutoInterval = setInterval(() => {
|
|
97
103
|
if(isHided) return;
|
|
98
|
-
slideAuto()
|
|
104
|
+
slideAuto();
|
|
99
105
|
}, Number(looptime) * 1000)
|
|
100
106
|
}
|
|
101
107
|
|
|
102
108
|
const slideTo = (idxTo) =>{
|
|
109
|
+
animator.curTournament.hide();
|
|
103
110
|
setSlideAutoInterval()
|
|
104
111
|
if(idxTo > 0 && isLast) onHideSlider();
|
|
105
112
|
if(idxTo > 0 && isLast || (idxTo < 0 && isFirst)){
|
|
106
113
|
return;
|
|
107
114
|
}
|
|
108
|
-
|
|
115
|
+
setTimeout(()=>{
|
|
116
|
+
currentTournamentIdx = currentTournamentIdx+ idxTo;
|
|
117
|
+
animator.curTournament.show();
|
|
118
|
+
}, sliderTransitionTime*1.5);
|
|
109
119
|
}
|
|
110
120
|
|
|
111
121
|
// animator
|
|
@@ -143,6 +153,19 @@
|
|
|
143
153
|
tourSlider.style.transform = `translateX(${tourSlider.clientWidth + 20}px)`;
|
|
144
154
|
delay(() => document.querySelector('body').setAttribute('style', null))
|
|
145
155
|
}
|
|
156
|
+
},
|
|
157
|
+
|
|
158
|
+
curTournament: {
|
|
159
|
+
init: function() {
|
|
160
|
+
curTournamentElement.style.transition = `all ${sliderTransitionTime}ms linear`;
|
|
161
|
+
},
|
|
162
|
+
show: function() {
|
|
163
|
+
curTournamentElement.style.opacity = '1';
|
|
164
|
+
},
|
|
165
|
+
hide: function() {
|
|
166
|
+
this.init();
|
|
167
|
+
curTournamentElement.style.opacity = '0'
|
|
168
|
+
}
|
|
146
169
|
}
|
|
147
170
|
}
|
|
148
171
|
|
|
@@ -182,6 +205,22 @@
|
|
|
182
205
|
urlSearchParams.append('filter', `state=Running`);
|
|
183
206
|
return urlSearchParams;
|
|
184
207
|
}
|
|
208
|
+
|
|
209
|
+
const updateTournamentByNewTour = (newTournament: any) =>{
|
|
210
|
+
let briefTournamentInfo = transformTournamentItem(newTournament);
|
|
211
|
+
let tournamentIdx = tournamentList.findIndex((item)=>{
|
|
212
|
+
return item.id == briefTournamentInfo.id;
|
|
213
|
+
})
|
|
214
|
+
if(currentTournamentIdx == tournamentIdx){
|
|
215
|
+
window.postMessage({type: `TournamentRankInfo_${briefTournamentInfo.id}}`, rankInfo:{
|
|
216
|
+
rank: briefTournamentInfo.rank,
|
|
217
|
+
overallRank: briefTournamentInfo.overallRank,
|
|
218
|
+
prize: briefTournamentInfo.prize
|
|
219
|
+
}});
|
|
220
|
+
}
|
|
221
|
+
tournamentList[tournamentIdx] = briefTournamentInfo;
|
|
222
|
+
}
|
|
223
|
+
|
|
185
224
|
const tournamentsUpdateMessageHandler = (message:any)=>{
|
|
186
225
|
if(!message.data){
|
|
187
226
|
return;
|
|
@@ -189,45 +228,16 @@
|
|
|
189
228
|
try{
|
|
190
229
|
let messageData:any = message.data;
|
|
191
230
|
let updateInfo:any = JSON.parse(messageData);
|
|
192
|
-
let newTournamentList = [];
|
|
193
231
|
if(updateInfo.messageType=='PlayerLeaderBoardsUpdate' && updateInfo.items){
|
|
194
232
|
updateInfo.items.forEach((item:any, idx: number)=>{
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
overallRank: briefTournamentInfo.overallRank,
|
|
200
|
-
prize: briefTournamentInfo.prize
|
|
201
|
-
}});
|
|
202
|
-
}
|
|
203
|
-
newTournamentList.push(briefTournamentInfo);
|
|
204
|
-
})
|
|
205
|
-
tournamentList = newTournamentList;
|
|
206
|
-
if(currentTournamentIdx >= updateInfo.items.length ){
|
|
207
|
-
currentTournamentIdx = updateInfo.items.length - 1;
|
|
208
|
-
}
|
|
209
|
-
currentTournament = newTournamentList[currentTournamentIdx];
|
|
233
|
+
updateTournamentByNewTour(item);
|
|
234
|
+
});
|
|
235
|
+
} else if(updateInfo.messageType=='PlayerLeaderBoardUpdate' && updateInfo.item){
|
|
236
|
+
updateTournamentByNewTour(updateInfo.item);
|
|
210
237
|
}
|
|
211
|
-
|
|
212
|
-
if(updateInfo.messageType=='PlayerLeaderBoardUpdate' && updateInfo.item){
|
|
213
|
-
let briefTournamentInfo = transformTournamentItem(updateInfo.item);
|
|
214
|
-
let tournamentIdx = tournamentList.findIndex((item)=>{
|
|
215
|
-
return item.id == briefTournamentInfo.id;
|
|
216
|
-
})
|
|
217
|
-
if(currentTournamentIdx == tournamentIdx){
|
|
218
|
-
window.postMessage({type: `TournamentRankInfo_${briefTournamentInfo.id}}`, rankInfo:{
|
|
219
|
-
rank: briefTournamentInfo.rank,
|
|
220
|
-
overallRank: briefTournamentInfo.overallRank,
|
|
221
|
-
prize: briefTournamentInfo.prize
|
|
222
|
-
}});
|
|
223
|
-
}
|
|
224
|
-
tournamentList[tournamentIdx] = briefTournamentInfo;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
238
|
}catch(err){
|
|
228
239
|
console.log(err);
|
|
229
240
|
}
|
|
230
|
-
|
|
231
241
|
}
|
|
232
242
|
|
|
233
243
|
const getTouches = (evt:any) => {
|
|
@@ -271,6 +281,10 @@
|
|
|
271
281
|
if(!endpoint){
|
|
272
282
|
return;
|
|
273
283
|
}
|
|
284
|
+
if(tournamentsUpdateEventSource){
|
|
285
|
+
tournamentsUpdateEventSource.removeEventListener('message', tournamentsUpdateMessageHandler);
|
|
286
|
+
tournamentsUpdateEventSource.close();
|
|
287
|
+
}
|
|
274
288
|
let tournamentsUrl:URL = new URL(`${endpoint}/tournaments/leaderboard/player/updates`);
|
|
275
289
|
setTournamentsSearchParams(tournamentsUrl.searchParams, 0, tournamentsshownnumber);
|
|
276
290
|
tournamentsUpdateEventSource = new EventSourcePolyfill(tournamentsUrl.href, {headers: {'accept': 'text/event-stream','X-SessionId': session}});
|
|
@@ -278,14 +292,6 @@
|
|
|
278
292
|
tournamentsUpdateEventSource.addEventListener('message', tournamentsUpdateMessageHandler);
|
|
279
293
|
}
|
|
280
294
|
}
|
|
281
|
-
const resetSliderListener= ()=>{
|
|
282
|
-
if(!tournamentsUpdateEventSource){
|
|
283
|
-
return;
|
|
284
|
-
}
|
|
285
|
-
tournamentsUpdateEventSource.removeEventListener('message', tournamentsUpdateMessageHandler);
|
|
286
|
-
tournamentsUpdateEventSource.close();
|
|
287
|
-
startupUpdateListener();
|
|
288
|
-
}
|
|
289
295
|
|
|
290
296
|
const setClientStyling = ():void => {
|
|
291
297
|
let sheet = document.createElement('style');
|
|
@@ -309,12 +315,46 @@
|
|
|
309
315
|
});
|
|
310
316
|
}
|
|
311
317
|
|
|
318
|
+
const loadData=()=>{
|
|
319
|
+
if(!endpoint || !session){
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
let playerTournamentsUrl:any = new URL(`${endpoint}/tournaments/leaderboard/player`);
|
|
312
323
|
|
|
324
|
+
let reqHeaders = new Headers();
|
|
325
|
+
setTournamentsSearchParams(playerTournamentsUrl.searchParams, 0, tournamentsshownnumber);
|
|
326
|
+
if (session) {
|
|
327
|
+
reqHeaders.append("X-SessionID", session);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
let requestOptions = {
|
|
331
|
+
method: 'GET',
|
|
332
|
+
headers: reqHeaders,
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
fetch(playerTournamentsUrl, requestOptions)
|
|
336
|
+
.then((res:any) => res.json())
|
|
337
|
+
.then((data:any) => {
|
|
338
|
+
if(!data.items){
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
tournamentList = [];
|
|
342
|
+
let tournaments = data.items;
|
|
343
|
+
tournaments.forEach((item:any, idx: number)=>{
|
|
344
|
+
tournamentList.push(transformTournamentItem(item));
|
|
345
|
+
})
|
|
346
|
+
currentTournament = tournamentList[currentTournamentIdx];
|
|
347
|
+
startupUpdateListener();
|
|
348
|
+
setSlideAutoInterval();
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
let isMounted = false;
|
|
313
352
|
onMount(()=>{
|
|
314
|
-
|
|
353
|
+
isMounted = true;
|
|
315
354
|
window.addEventListener("message", messageHandler, false);
|
|
316
|
-
|
|
317
|
-
|
|
355
|
+
setTimeout(()=>{
|
|
356
|
+
lang = 'tr';
|
|
357
|
+
}, 5000);
|
|
318
358
|
return ()=>{
|
|
319
359
|
clearInterval(slideAutoInterval);
|
|
320
360
|
window.removeEventListener("message", messageHandler);
|
|
@@ -329,17 +369,14 @@
|
|
|
329
369
|
$: customStylingContainer && clientstyling && setClientStyling();
|
|
330
370
|
$: customStylingContainer && clientstylingurl && setClientStylingURL();
|
|
331
371
|
$: iconHref = icon || iconDefault
|
|
332
|
-
|
|
333
|
-
$: endpoint && startupUpdateListener();
|
|
372
|
+
$: isMounted && endpoint && tournamentsshownnumber && lang && loadData();
|
|
334
373
|
$: tourSlider && addEventListeners();
|
|
335
374
|
$: session && setSession();
|
|
336
375
|
$: lang && setActiveLanguage();
|
|
337
|
-
$: looptime && setSlideAutoInterval();
|
|
338
376
|
$: translationurl && setTranslationUrl();
|
|
339
377
|
$: currentTournament = tournamentList[currentTournamentIdx];
|
|
340
378
|
$: isLast = currentTournamentIdx == tournamentList.length - 1;
|
|
341
379
|
$: isFirst = currentTournamentIdx == 0;
|
|
342
|
-
$: tournamentsshownnumber && lang && resetSliderListener();
|
|
343
380
|
</script>
|
|
344
381
|
<div bind:this={customStylingContainer}>
|
|
345
382
|
<div part="Tournaments" class="casino-tournaments-slider-controller" bind:this={tourSlider}>
|
|
@@ -358,9 +395,9 @@
|
|
|
358
395
|
</div>
|
|
359
396
|
</div>
|
|
360
397
|
{/if}
|
|
361
|
-
{#if (tournamentList && tournamentList.length > 0)}
|
|
362
|
-
<div part="TournamentInfo" class="TournamentInfo">
|
|
363
|
-
<div part="TournamentInfo_Name" class="name"><span part="TournamentInfo_Name_link" on:click={() => detailsAction(currentTournament.id)}>{currentTournament.name}</span></div>
|
|
398
|
+
{#if (tournamentList && tournamentList.length > 0) }
|
|
399
|
+
<div part="TournamentInfo" class="TournamentInfo" bind:this={curTournamentElement} transition:fade="{{delay: 250, duration: 300}}">
|
|
400
|
+
<div part="TournamentInfo_Name" class="name"><span part="TournamentInfo_Name_link" class="TournamentNameLink" on:click={() => detailsAction(currentTournament.id)} title="{currentTournament.name}">{currentTournament.name}</span></div>
|
|
364
401
|
<div part="TournamentInfo_Rank" class="rank">
|
|
365
402
|
<casino-tournaments-rank displayin="col" showicon="false" userrank="{currentTournament.rank}"
|
|
366
403
|
prize='{currentTournament.prize}' overallrank="{currentTournament.overallRank}"
|
|
@@ -434,15 +471,24 @@
|
|
|
434
471
|
.TournamentInfo{
|
|
435
472
|
width: calc(100% - 4px);
|
|
436
473
|
padding: 2px;
|
|
474
|
+
display: flex;
|
|
475
|
+
flex-direction: column;
|
|
476
|
+
justify-content: center;
|
|
437
477
|
.name{
|
|
438
478
|
white-space: nowrap;
|
|
439
|
-
overflow: auto;
|
|
440
479
|
width: 99%;
|
|
441
480
|
text-align: center;
|
|
442
481
|
text-transform: capitalize;
|
|
443
482
|
font-size: 11px;
|
|
444
483
|
margin-bottom: 5px;
|
|
445
484
|
cursor: pointer;
|
|
485
|
+
overflow: hidden;
|
|
486
|
+
text-overflow: ellipsis;
|
|
487
|
+
}
|
|
488
|
+
.TournamentNameLink{
|
|
489
|
+
overflow: hidden;
|
|
490
|
+
white-space: nowrap;
|
|
491
|
+
text-overflow: ellipsis;
|
|
446
492
|
}
|
|
447
493
|
.circle{text-align: center; height: 7px;
|
|
448
494
|
height: 5px;
|