more refactoring

This commit is contained in:
cnachtigall1991
2021-10-13 21:10:40 +02:00
parent 93d0cdbdc4
commit f536a0527f
8 changed files with 158 additions and 301 deletions

View File

@@ -10,6 +10,39 @@ export const GetWinLoss = (matchResult, teamId) => {
}
}
export const truncate = (str, len, ending) => {
if (len == null)
len = 100
if (ending == null)
ending = '..'
if (str.length > len)
return str.substring(0, len - ending.length) + ending
else
return str
}
export const checkStatEmpty = (stat) => {
if (stat)
return stat
return 0
}
export const getPlayerArr = (stats, team) => {
let arr = []
for (let i = (team - 1) * 5; i < team * 5; i++) {
arr.push({
value: truncate(stats[i].player.name, 15),
textStyle: {
color: 'white'
}
})
}
arr.reverse()
return arr
}
export const TrackMe = async (id64, authcode, sharecode) => {
let statusError = ''
let status = 200

View File

@@ -4,7 +4,7 @@ import {SaveLastVisitedToLocalStorage} from "./LocalStorage";
import {GetHLTV_1} from "./HLTV";
import {DisplayRank, LoadImage} from "./Display";
import {GetUser} from "./ApiRequests";
import {GetWinLoss, TrackMe} from "./Utils";
import {GetWinLoss, TrackMe, truncate, checkStatEmpty, getPlayerArr} from "./Utils";
export {
FormatDate, FormatFullDuration, FormatFullDate, FormatDuration,
@@ -13,5 +13,5 @@ export {
GetHLTV_1,
DisplayRank, LoadImage,
GetUser,
GetWinLoss, TrackMe
GetWinLoss, TrackMe, truncate, checkStatEmpty, getPlayerArr
}