@everymatrix/casino-tournaments-table 0.0.260 → 0.0.263

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-table",
3
- "version": "0.0.260",
3
+ "version": "0.0.263",
4
4
  "main": "dist/casino-tournaments-table.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": "a30fdd6f6180c69aabbc0daf1bf2a2e1342bf0e2"
39
+ "gitHead": "fccb99c4d5259efacf828703242697132621b19d"
40
40
  }
@@ -6,6 +6,9 @@
6
6
  import { _, addNewMessages } from './i18n';
7
7
  import { TournamentsTableTranslations } from './translations';
8
8
 
9
+ import arrowUpSvg from './images/arrow-up.svg';
10
+ import arrowDownSvg from './images/arrow-down.svg'
11
+
9
12
  export let sortable:Boolean = false;
10
13
  export let firstrow:Boolean = false;
11
14
  export let lang:String = 'en';
@@ -18,6 +21,10 @@
18
21
  let firstRowData:any = null;
19
22
  let showTable:Boolean = true;
20
23
  let userAgent = window.navigator.userAgent;
24
+ let isUserPositionChanged:Boolean = false;
25
+ let isUserPositionUp:Boolean = false;
26
+ let firstRowChangeFlagTimer: any=null;
27
+ let lastUserPosition:number;
21
28
 
22
29
  Object.keys(TournamentsTableTranslations).forEach((item) => {
23
30
  addNewMessages(item, TournamentsTableTranslations[item]);
@@ -25,10 +32,31 @@
25
32
 
26
33
  const findTableRowDataByRank =(position: Number, data)=>{
27
34
  let rowData = data.find((row)=>{
28
- return row.Position == position;
35
+ return row.Rank == position;
29
36
  })
30
37
  return rowData;
31
38
  }
39
+ let rankChangeTime1,rankChangeTime2:any;
40
+ const processUserRankChanged = (newUserPosion) =>{
41
+ if(!lastUserPosition){
42
+ lastUserPosition = newUserPosion;
43
+ return;// first place bet, do not show change flag
44
+ }
45
+ isUserPositionChanged = lastUserPosition != newUserPosion;
46
+ // when (position changed) or (position not changed but still in 2.5s)
47
+ isUserPositionUp = lastUserPosition > newUserPosion;
48
+ if(isUserPositionChanged){
49
+ rankChangeTime1 = (new Date()).getTime(); //reset time1, make sure userrank change more than once during 5mins
50
+ firstRowChangeFlagTimer = setTimeout(function (){
51
+ rankChangeTime2 = (new Date()).getTime();
52
+ let timeInterval = (rankChangeTime2 - rankChangeTime1)/1000;
53
+ if(timeInterval > 4){
54
+ isUserPositionChanged = false;
55
+ }
56
+ lastUserPosition = newUserPosion;
57
+ }, 5000);
58
+ }
59
+ }
32
60
  const messageHandler = (e:any) => {
33
61
  if (e.data && e.data.type === 'CasinoTableData') {
34
62
  data = e.data.tableData;
@@ -45,6 +73,16 @@
45
73
  data.forEach(item => {
46
74
  if(item.userID == e.data.tableData.userID){
47
75
  item.isCurrentUser = true;
76
+ //clear first row data when update
77
+ if(!lastUserPosition){
78
+ lastUserPosition = e.data.tableData.Rank;
79
+ }
80
+ if(firstRowData){
81
+ processUserRankChanged( e.data.tableData.Rank);
82
+ firstRowData = null;
83
+ }else{
84
+ processUserRankChanged( e.data.tableData.Rank);
85
+ }
48
86
  }
49
87
  });
50
88
  display = data;
@@ -52,7 +90,17 @@
52
90
  }
53
91
  if (firstrow) {
54
92
  if (e.data && e.data.type === 'CasinoTableFirstRowData') {
55
- firstRowData = e.data.tableData;
93
+ let newFirstRowData:any = e.data.tableData;
94
+ if(!firstRowData){
95
+ firstRowData = e.data.tableData;
96
+ lastUserPosition = firstRowData.Rank;
97
+ return;
98
+ }
99
+ if(firstRowData && firstRowData.UserID == newFirstRowData.UserID){
100
+ processUserRankChanged( newFirstRowData.Rank);
101
+ firstRowData = e.data.tableData;
102
+ }
103
+
56
104
  }
57
105
  }
58
106
  // CasinoTableDataUpdate
@@ -63,7 +111,7 @@
63
111
  return;
64
112
  }
65
113
  data.forEach(function (row, idx){
66
- let updateRowByPosition = findTableRowDataByRank(row.Position, tableUpdateData);
114
+ let updateRowByPosition = findTableRowDataByRank(row.Rank, tableUpdateData);
67
115
  if(!updateRowByPosition){
68
116
  return;
69
117
  }
@@ -131,7 +179,6 @@
131
179
 
132
180
  onMount(() => {
133
181
  window.addEventListener('message', messageHandler, false);
134
-
135
182
  return () => {
136
183
  window.removeEventListener('message', messageHandler);
137
184
  }
@@ -159,7 +206,9 @@
159
206
  </div>
160
207
  {#if firstrow == 'true' && firstRowData}
161
208
  <div class="TableUser CurrentUserRow {firstRowData.Unqualified ? 'UnqualifiedRow' : ''}" part="TableUser">
162
- <div class="TableCell TableRank {firstRowData.Prize? 'Qualified' : ''}">{firstRowData.Rank}</div>
209
+ <div class="TableCell TableRank {firstRowData.Prize? 'Qualified' : ''}">
210
+ {firstRowData.Rank}
211
+ </div>
163
212
  <div class="TableCell TablePlayer">{firstRowData.Player}</div>
164
213
  <div class="TableCell TablePoints">{firstRowData.Points}</div>
165
214
  {#if firstRowData.Prize}
@@ -221,9 +270,16 @@
221
270
  <tbody>
222
271
  {#if firstrow == 'true' && firstRowData}
223
272
  <tr class="FirstRow" part="FirstRow">
224
- <td><strong><em>#{firstRowData.Rank}</em></strong></td>
273
+ <td><strong class="RankCol"><em>#{firstRowData.Rank}</em>
274
+ <div class="ScoreChangeFlag {isUserPositionChanged ? 'Show' : 'Hidden'}">
275
+ <img src="{arrowUpSvg}" part="Rank_Arror_UP" class="svg Arrow Up {isUserPositionChanged && isUserPositionUp ? 'Show' : 'Hidden'}" />
276
+ <img src="{arrowDownSvg}" part="Rank_Arror_Down" class="svg Arrow Down {isUserPositionChanged && !isUserPositionUp ? 'Show' : 'Hidden'}" />
277
+ </div></strong>
278
+ </td>
225
279
  <td>{firstRowData.Player}</td>
226
- <td><div class="Flex" part="Flex">{firstRowData.Points}</div></td>
280
+ <td>
281
+ <div class="Flex">{firstRowData.Points}</div>
282
+ </td>
227
283
  <td>
228
284
  {#if firstRowData.Prize}
229
285
  {firstRowData.Prize}
@@ -236,9 +292,17 @@
236
292
  {#if showTable}
237
293
  {#each display as row}
238
294
  <tr class="{row.isCurrentUser ? 'FirstRow' : ''}" >
239
- <td><strong><em>#{row.Rank}</em></strong></td>
295
+ <td><strong class="RankCol"><em>#{row.Rank}
296
+ <div class="ScoreChangeFlag {isUserPositionChanged ? 'Show' : 'Hidden'}">
297
+ {#if row.isCurrentUser}
298
+ <img src="{arrowUpSvg}" part="Rank_Arror_UP" class="svg Arrow Up {isUserPositionChanged && isUserPositionUp ? 'Show' : 'Hidden'}" />
299
+ <img src="{arrowDownSvg}" part="Rank_Arror_Down" class="svg Arrow Down {isUserPositionChanged && !isUserPositionUp ? 'Show' : 'Hidden'}" />
300
+ {/if}
301
+ </div>
302
+
303
+ </em></strong></td>
240
304
  <td>{row.Player}</td>
241
- <td><div class="Flex" part="Flex">{row.Points}</div></td>
305
+ <td><div class="Flex ScoreUp">{row.Points}</div></td>
242
306
  <td>
243
307
  {#if row.Prize}
244
308
  {row.Prize}
@@ -428,7 +492,37 @@
428
492
  }
429
493
 
430
494
  .FirstRow {
431
- outline: 2px solid var(--emfe-w-color-green, #48952a);
495
+ outline: 2px solid #1B9800;
496
+ .RankCol{
497
+ position: relative;
498
+ width: max-content;
499
+ display: inline;
500
+ .ScoreChangeFlag{
501
+ position: absolute;
502
+ top: 0px;
503
+ right: -29px;
504
+ .Arrow{
505
+ &.Up{ color: #0cdc13}
506
+ &.Down{color: #FF4500}
507
+ }
508
+ }
509
+
510
+ }
511
+ }
512
+ .Show{display: inline-flex}
513
+ .Hidden{display: none}
514
+ svg.Arrow.Up, svg.Arrow.Down, .svg.Arrow.Up, .svg.Arrow.Down {
515
+ &.Show{display: inline-flex}
516
+ &.Hidden{display: none}
517
+ animation-name: twinkle;
518
+ animation-duration: 1s;
519
+ animation-iteration-count: infinite;
520
+ }
521
+
522
+ @keyframes twinkle {
523
+ 0% {opacity: 0;}
524
+ 25% {opacity: 1;}
525
+ 100% {opacity: 0;}
432
526
  }
433
527
 
434
528
  table {
@@ -0,0 +1,14 @@
1
+ <svg width="15" height="15" viewBox="0 0 10 10" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <circle r="4.9999" transform="matrix(1 0 0 -1 4.9999 5.0001)" fill="#434647"/>
3
+ <g clip-path="url(#clip0_2591_1154)">
4
+ <line y1="-0.933315" x2="3.99992" y2="-0.933315" transform="matrix(0 -1 -1 0 4 6)"
5
+ stroke="#CA0000" stroke-width="1.86663"/>
6
+ <path d="M4.99896 8L7.59699 5.00006H2.40094L4.99896 8Z" fill="#CA0000"/>
7
+ </g>
8
+ <defs>
9
+ <clipPath id="clip0_2591_1154">
10
+ <rect width="5.99988" height="5.99928" fill="white"
11
+ transform="matrix(1 0 0 -1 1.99902 8)"/>
12
+ </clipPath>
13
+ </defs>
14
+ </svg>
@@ -0,0 +1,12 @@
1
+ <svg width="15" height="15" viewBox="0 0 10 10" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <circle cx="4.9999" cy="4.9999" r="4.9999" fill="#434647"/>
3
+ <g clip-path="url(#clip0_2591_1149)">
4
+ <line x1="4.93332" y1="4" x2="4.93332" y2="7.99992" stroke="#59CA00" stroke-width="1.86663"/>
5
+ <path d="M4.99896 2L7.59699 4.99994H2.40094L4.99896 2Z" fill="#59CA00"/>
6
+ </g>
7
+ <defs>
8
+ <clipPath id="clip0_2591_1149">
9
+ <rect width="5.99988" height="5.99928" fill="white" transform="translate(1.99902 2)"/>
10
+ </clipPath>
11
+ </defs>
12
+ </svg>