mirror of
https://github.com/vkaelin/LeagueStats.git
synced 2026-03-25 12:57:28 +00:00
refactor: export compareSummonernames function
This commit is contained in:
parent
7950d835c4
commit
1dae55db54
4 changed files with 24 additions and 17 deletions
|
|
@ -4,6 +4,7 @@
|
||||||
<DetailedMatchTeam
|
<DetailedMatchTeam
|
||||||
:data="allyTeam"
|
:data="allyTeam"
|
||||||
:all-players="[...allyTeam.players, ...enemyTeam.players]"
|
:all-players="[...allyTeam.players, ...enemyTeam.players]"
|
||||||
|
:ally-team="true"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div class="px-3 py-2 flex justify-between items-start">
|
<div class="px-3 py-2 flex justify-between items-start">
|
||||||
|
|
@ -15,6 +16,7 @@
|
||||||
<DetailedMatchTeam
|
<DetailedMatchTeam
|
||||||
:data="enemyTeam"
|
:data="enemyTeam"
|
||||||
:all-players="[...allyTeam.players, ...enemyTeam.players]"
|
:all-players="[...allyTeam.players, ...enemyTeam.players]"
|
||||||
|
:ally-team="false"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="data.status === 'loading' && detailsOpen">
|
<div v-else-if="data.status === 'loading' && detailsOpen">
|
||||||
|
|
@ -24,6 +26,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { compareSummonernames } from '@/helpers/functions.js'
|
||||||
import DetailedMatchGlobalStats from '@/components/Match/DetailedMatchGlobalStats.vue'
|
import DetailedMatchGlobalStats from '@/components/Match/DetailedMatchGlobalStats.vue'
|
||||||
import DetailedMatchTeam from '@/components/Match/DetailedMatchTeam.vue'
|
import DetailedMatchTeam from '@/components/Match/DetailedMatchTeam.vue'
|
||||||
import SwitchToggle from '@/components/SwitchToggle.vue'
|
import SwitchToggle from '@/components/SwitchToggle.vue'
|
||||||
|
|
@ -47,16 +50,10 @@ export default {
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
allyTeam() {
|
allyTeam() {
|
||||||
return this.data.blueTeam.players.some(p => this.compareSummonernames(p.name, this.$route.params.name)) ? this.data.blueTeam : this.data.redTeam
|
return this.data.blueTeam.players.some(p => compareSummonernames(p.name, this.$route.params.name)) ? this.data.blueTeam : this.data.redTeam
|
||||||
},
|
},
|
||||||
enemyTeam() {
|
enemyTeam() {
|
||||||
return this.data.blueTeam.players.some(p => this.compareSummonernames(p.name, this.$route.params.name)) ? this.data.redTeam : this.data.blueTeam
|
return this.data.blueTeam.players.some(p => compareSummonernames(p.name, this.$route.params.name)) ? this.data.redTeam : this.data.blueTeam
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
|
||||||
compareSummonernames(a, b) {
|
|
||||||
return a.toLowerCase().replace(/ /g, '') === b.toLowerCase().replace(/ /g, '')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@
|
||||||
<router-link
|
<router-link
|
||||||
v-if="player.firstSum"
|
v-if="player.firstSum"
|
||||||
:to="{ name: 'summoner', params: { region: $route.params.region, name: player.name }}"
|
:to="{ name: 'summoner', params: { region: $route.params.region, name: player.name }}"
|
||||||
:class="{'font-semibold text-yellow-400': $route.params.name.toLowerCase() === player.name.toLowerCase()}"
|
:class="{'font-semibold text-yellow-400': compareSummonernames($route.params.name, player.name)}"
|
||||||
class="w-24 text-sm text-white text-left overflow-hidden text-overflow whitespace-no-wrap hover:text-blue-200"
|
class="w-24 text-sm text-white text-left overflow-hidden text-overflow whitespace-no-wrap hover:text-blue-200"
|
||||||
>{{ player.name }}</router-link>
|
>{{ player.name }}</router-link>
|
||||||
<div
|
<div
|
||||||
|
|
@ -156,6 +156,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapState } from 'vuex'
|
import { mapState } from 'vuex'
|
||||||
|
import { compareSummonernames } from '@/helpers/functions.js'
|
||||||
import MatchItems from '@/components/Match/MatchItems'
|
import MatchItems from '@/components/Match/MatchItems'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
@ -168,18 +169,16 @@ export default {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
|
allyTeam: {
|
||||||
|
type: Boolean,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
data: {
|
data: {
|
||||||
type: Object,
|
type: Object,
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
allyTeam: this.data.players.some(p => p.name.toLowerCase().replace(/ /g, '') === this.$route.params.name.toLowerCase().replace(/ /g, ''))
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
statsFormat() {
|
statsFormat() {
|
||||||
return this.percentSettings === 'true' ? 'percentStats' : 'stats'
|
return this.percentSettings === 'true' ? 'percentStats' : 'stats'
|
||||||
|
|
@ -202,7 +201,8 @@ export default {
|
||||||
},
|
},
|
||||||
displayBorderbottom(index) {
|
displayBorderbottom(index) {
|
||||||
return this.allyTeam || index !== this.data.players.length - 1
|
return this.allyTeam || index !== this.data.players.length - 1
|
||||||
}
|
},
|
||||||
|
compareSummonernames,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -151,6 +151,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapActions, mapState, mapGetters } from 'vuex'
|
import { mapActions, mapState, mapGetters } from 'vuex'
|
||||||
|
import { compareSummonernames } from '@/helpers/functions.js'
|
||||||
import Dropdown from '@/components/Dropdown'
|
import Dropdown from '@/components/Dropdown'
|
||||||
import DetailedMatch from '@/components/Match/DetailedMatch'
|
import DetailedMatch from '@/components/Match/DetailedMatch'
|
||||||
import MatchItems from '@/components/Match/MatchItems'
|
import MatchItems from '@/components/Match/MatchItems'
|
||||||
|
|
@ -194,7 +195,7 @@ export default {
|
||||||
},
|
},
|
||||||
isSummonerProfile(allyName) {
|
isSummonerProfile(allyName) {
|
||||||
return {
|
return {
|
||||||
'font-bold': this.$route.params.name.toLowerCase() === allyName.toLowerCase()
|
'font-bold': compareSummonernames(this.$route.params.name, allyName)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
...mapActions('detailedMatch', ['matchDetails']),
|
...mapActions('detailedMatch', ['matchDetails']),
|
||||||
|
|
|
||||||
|
|
@ -25,3 +25,12 @@ export function timeDifference(previous) {
|
||||||
return day + '.' + month + '.' + oldDate.getFullYear().toString().substr(-2)
|
return day + '.' + month + '.' + oldDate.getFullYear().toString().substr(-2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if 2 summoner names are the same
|
||||||
|
* @param a : first summoner name
|
||||||
|
* @param b : second summoner name
|
||||||
|
*/
|
||||||
|
export function compareSummonernames(a, b) {
|
||||||
|
return a.toLowerCase().replace(/ /g, '') === b.toLowerCase().replace(/ /g, '')
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue