diff --git a/client/src/components/Match.vue b/client/src/components/Match.vue index fd8500d..2a0c95f 100644 --- a/client/src/components/Match.vue +++ b/client/src/components/Match.vue @@ -74,11 +74,6 @@ export default { props: { data: Object - }, - methods: { - tinyItem(link) { - return link.replace('item', 'tiny_item') - } } } diff --git a/client/src/components/SearchForm.vue b/client/src/components/SearchForm.vue new file mode 100644 index 0000000..2409cd2 --- /dev/null +++ b/client/src/components/SearchForm.vue @@ -0,0 +1,76 @@ + + + + + diff --git a/client/src/views/Home.vue b/client/src/views/Home.vue index 9df062e..0df7719 100644 --- a/client/src/views/Home.vue +++ b/client/src/views/Home.vue @@ -1,26 +1,23 @@ - diff --git a/client/src/views/Summoner.vue b/client/src/views/Summoner.vue index d438b26..b538d90 100644 --- a/client/src/views/Summoner.vue +++ b/client/src/views/Summoner.vue @@ -4,26 +4,19 @@ @@ -63,29 +56,47 @@ import itemsJSON from '@/data/item.json' import summonersJSON from '@/data/summoner.json' import Match from '@/components/Match.vue'; +import SearchForm from '@/components/SearchForm.vue'; import { championsId, maps, gameModes } from "@/data/data.js"; import { timeDifference, secToTime, getRankImg } from "@/helpers/functions.js"; export default { components: { - Match + Match, + SearchForm }, data() { return { localInfos: {}, - search: '', summonerFound: true, - loading: false + loading: false, + regionsList: { + 'br': 'br1', + 'eune': 'eun1', + 'euw': 'euw1', + 'jp': 'jp1', + 'kr': 'kr', + 'lan': 'la1', + 'las': 'la2', + 'na': 'na1', + 'oce': 'oc1', + 'tr': 'tr1', + 'ru': 'ru' + } }; }, computed: { summoner() { return this.$route.params.name + }, + region() { + return this.$route.params.region } }, methods: { apiCall() { const summoner = this.summoner; + const region = this.regionsList[this.region]; this.loading = true; this.axios({ method: "POST", @@ -94,7 +105,8 @@ export default { "Content-Type": "application/json" }, data: { - summoner + summoner, + region } }) .then(response => { @@ -116,10 +128,10 @@ export default { }); }, checkLocalStorage() { - if (localStorage[this.summoner]) { + if (localStorage[`${this.summoner}:${this.region}`]) { console.log('cached') this.summonerFound = true - this.localInfos = JSON.parse(localStorage[this.summoner]) + this.localInfos = JSON.parse(localStorage[`${this.summoner}:${this.region}`]) } else { this.apiCall() } @@ -200,12 +212,10 @@ export default { rankedLosses: soloQStats ? soloQStats.losses : undefined } - //this.summoner = userStats.name; - console.log('====== Saved infos ======'); console.log(this.localInfos); - localStorage[this.summoner] = JSON.stringify(this.localInfos); + localStorage[`${this.summoner}:${this.region}`] = JSON.stringify(this.localInfos); }, getItemLink(id) { if(id === 0) { @@ -218,8 +228,9 @@ export default { const spellName = Object.entries(summonersJSON.data).find(([, spell]) => Number(spell.key) === id)[0] return `https://cdn.valentinkaelin.ch/riot/spells/${spellName}.png`; }, - redirect() { - this.$router.push("/summoner/euw/" + this.search) + redirect(summoner, region) { + // this.$router.push("/summoner/euw/" + this.search) + this.$router.push(`/summoner/${region}/${summoner}`) }, resetLocalStorage() { console.log('CLEAR LOCALSTORAGE') @@ -291,68 +302,4 @@ export default { list-style-type: none; padding: 0; } - -/* #######LOADER####### */ -.loader--overlay { - position: absolute; - z-index: 9997; - width: 100%; - height: 100%; - background: rgba(0, 0, 0, 0.8); - - display: none; -} - -.loader-container { - position: absolute; - z-index: 9998; - - width: 100%; - height: 100vh; -} - -.LoaderBalls { - width: 90px; - display: flex; - justify-content: space-between; - align-items: center; - - position: absolute; - z-index: 9999; - left: 50%; - top: 50%; - transform: translate(-50%, -50%); -} - -.LoaderBalls__item { - width: 20px; - height: 20px; - border-radius: 50%; - background: #00f1ca; -} - -.LoaderBalls__item:nth-child(1) { - animation: bouncing 0.4s alternate infinite - cubic-bezier(0.6, 0.05, 0.15, 0.95); -} - -.LoaderBalls__item:nth-child(2) { - animation: bouncing 0.4s 0.1s alternate infinite - cubic-bezier(0.6, 0.05, 0.15, 0.95) backwards; -} - -.LoaderBalls__item:nth-child(3) { - animation: bouncing 0.4s 0.2s alternate infinite - cubic-bezier(0.6, 0.05, 0.15, 0.95) backwards; -} - -@keyframes bouncing { - 0% { - transform: translate3d(0, 10px, 0) scale(1.2, 0.85); - } - - 100% { - transform: translate3d(0, -20px, 0) scale(0.9, 1.1); - } -} diff --git a/server/server.js b/server/server.js index 41f0970..f2ec6d3 100644 --- a/server/server.js +++ b/server/server.js @@ -54,8 +54,10 @@ app.listen(app.get('port'), () => console.log(`RiotAPI app listening on port ${a app.post('/api', function (req, res) { console.log('API Request'); console.log(req.body.summoner); + console.log(req.body.region); //console.log(req.body.playerName); console.time('all') + data.region = req.body.region; data.username = req.body.summoner; data.finalJSON = []; getAccountInfos(res);