mobile support for home and player
This commit is contained in:
@@ -1,16 +1,22 @@
|
||||
import {DateTime} from "luxon/build/es6/luxon";
|
||||
import router from '@/router'
|
||||
import {DateTime, Duration} from "luxon/build/es6/luxon";
|
||||
import router from '../router'
|
||||
|
||||
export const FormatDuration = (d) => {
|
||||
const hours = Math.floor(d / 3600)
|
||||
const num = d % 3600
|
||||
const minutes = Math.floor(num % 3600 / 60)
|
||||
const seconds = Math.floor(num % 3600 % 60)
|
||||
const duration = Duration.fromObject({hours: 0, minutes: 0, seconds: d}).normalize().toObject()
|
||||
|
||||
if (hours !== 0)
|
||||
return `${hours}:${minutes < 10 ? '0' + minutes : minutes}:${seconds < 10 ? '0' + seconds : seconds}`
|
||||
else
|
||||
return `${minutes < 10 ? '0' + minutes : minutes}:${seconds < 10 ? '0' + seconds : seconds}`
|
||||
if (duration.hours > 1)
|
||||
return `${duration.hours} h ${duration.minutes} min`
|
||||
else if (duration.hours < 1)
|
||||
return `${duration.minutes} min`
|
||||
}
|
||||
|
||||
export const FormatFullDuration = (d) => {
|
||||
const duration = Duration.fromObject({hours: 0, minutes: 0, seconds: d}).normalize()
|
||||
|
||||
if (duration.hours > 1)
|
||||
return duration.toFormat('hh:mm:ss')
|
||||
else if (duration.hours < 1)
|
||||
return duration.toFormat('mm:ss')
|
||||
}
|
||||
|
||||
export const FormatDate = (date) => {
|
||||
@@ -18,7 +24,7 @@ export const FormatDate = (date) => {
|
||||
const diff = DateTime.now().diff(matchDate)
|
||||
|
||||
if (diff.as('days') > 10)
|
||||
return matchDate.toLocaleString({weekday: 'short', day: 'numeric', month: 'numeric', year: 'numeric'})
|
||||
return matchDate.toLocaleString({weekday: 'short', day: '2-digit', month: '2-digit', year: 'numeric'})
|
||||
else if (diff.as('days') < 1)
|
||||
if (diff.as('hours') < 1)
|
||||
return Math.floor(diff.as('minutes')) + ' minutes ago'
|
||||
@@ -28,6 +34,20 @@ export const FormatDate = (date) => {
|
||||
return Math.floor(diff.as('days')) + ' days ago'
|
||||
}
|
||||
|
||||
export const FormatFullDate = (date) => {
|
||||
const matchDate = DateTime.fromISO(date)
|
||||
|
||||
return matchDate.toLocaleString({
|
||||
weekday: 'short',
|
||||
day: '2-digit',
|
||||
month: '2-digit',
|
||||
year: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
second: '2-digit'
|
||||
})
|
||||
}
|
||||
|
||||
export const GoToMatch = (id) => {
|
||||
router.push(`/match/${id}`)
|
||||
}
|
||||
@@ -47,4 +67,17 @@ export const GetHLTV_1 = (kills = 0, rounds, deaths = 0, k2 = 0, k3 = 0, k4 = 0,
|
||||
const RoundsWithMultipleKillsRating = (k1 + 4 * k2 + 9 * k3 + 16 * k4 + 25 * k5) / rounds / Weight_RMK
|
||||
|
||||
return ((KillRating + 0.7 * SurvivalRating + RoundsWithMultipleKillsRating) / 2.7).toFixed(2)
|
||||
}
|
||||
|
||||
export const SaveLastVisitedToLocalStorage = (data) => {
|
||||
let a = JSON.parse(localStorage.getItem('recent-visited')) || [];
|
||||
if (a.length === 0) {
|
||||
a.push(data);
|
||||
} else if (a.find(p => p.steamid64 === data.steamid64)) {
|
||||
a.splice(a.findIndex(j => j.steamid64 === data.steamid64), 1)
|
||||
a.push(data)
|
||||
} else if (!a.find(p => p.steamid64 === data.steamid64)) {
|
||||
a.push(data)
|
||||
}
|
||||
localStorage.setItem('recent-visited', JSON.stringify(a));
|
||||
}
|
Reference in New Issue
Block a user