2019-02-22 19:23:42 +00:00
|
|
|
|
<template>
|
2019-05-07 16:09:45 +00:00
|
|
|
|
<v-container>
|
2019-05-08 19:34:50 +00:00
|
|
|
|
<Header />
|
|
|
|
|
|
|
2019-05-14 14:20:38 +00:00
|
|
|
|
<template v-if="user">
|
|
|
|
|
|
<p>user logged in: {{ user.login }}</p>
|
|
|
|
|
|
|
|
|
|
|
|
<template v-if="decks">
|
|
|
|
|
|
<v-expansion-panel>
|
|
|
|
|
|
<v-expansion-panel-content v-for="deck in decks" :key="deck.id">
|
|
|
|
|
|
<template v-slot:header>
|
|
|
|
|
|
<div>{{ deck.content.name }}</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<v-card>
|
|
|
|
|
|
<v-card-text>
|
|
|
|
|
|
{{ deck.content.note }}
|
|
|
|
|
|
<ul>
|
|
|
|
|
|
<li v-for="card in deck.content.cards" :key="card.serial">
|
|
|
|
|
|
{{ card.serial }}: {{ cardsdb[card.serial].name }}
|
|
|
|
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
</v-card-text>
|
|
|
|
|
|
</v-card>
|
|
|
|
|
|
</v-expansion-panel-content>
|
|
|
|
|
|
</v-expansion-panel>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<v-btn @click.native="logout">Logout</v-btn>
|
|
|
|
|
|
</template>
|
2019-05-07 16:09:45 +00:00
|
|
|
|
</v-container>
|
2019-02-22 19:23:42 +00:00
|
|
|
|
</template>
|
2019-02-23 01:40:15 +00:00
|
|
|
|
|
|
|
|
|
|
<script>
|
2019-05-07 16:09:45 +00:00
|
|
|
|
import * as Cookies from 'js-cookie'
|
|
|
|
|
|
import axios from '@/plugins/axios'
|
2019-05-13 15:35:32 +00:00
|
|
|
|
import CardsDB from '@/plugins/ffdecks'
|
2019-05-07 16:09:45 +00:00
|
|
|
|
|
2019-05-08 19:34:50 +00:00
|
|
|
|
import Header from '@/components/Header.vue'
|
|
|
|
|
|
|
2019-02-23 01:40:15 +00:00
|
|
|
|
export default {
|
2019-05-09 12:20:03 +00:00
|
|
|
|
name: 'UserCP',
|
2019-05-07 16:09:45 +00:00
|
|
|
|
|
2019-05-08 19:34:50 +00:00
|
|
|
|
components: {
|
|
|
|
|
|
Header
|
|
|
|
|
|
},
|
|
|
|
|
|
|
2019-05-07 20:15:18 +00:00
|
|
|
|
methods: {
|
2019-05-07 20:28:51 +00:00
|
|
|
|
goHome() {
|
|
|
|
|
|
Cookies.remove('session')
|
|
|
|
|
|
this.$router.push({ name: 'home' })
|
|
|
|
|
|
},
|
|
|
|
|
|
|
2019-05-07 20:15:18 +00:00
|
|
|
|
logout() {
|
|
|
|
|
|
axios
|
|
|
|
|
|
.post('/user/logout', {
|
|
|
|
|
|
session: Cookies.get('session')
|
|
|
|
|
|
})
|
|
|
|
|
|
.then(response => {
|
|
|
|
|
|
if (response.data.success) {
|
2019-05-07 20:28:51 +00:00
|
|
|
|
this.goHome()
|
2019-05-07 20:15:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
})
|
2019-05-14 14:20:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
|
|
session: () => Cookies.get('session'),
|
|
|
|
|
|
cardsdb: () => CardsDB
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
asyncComputed: {
|
|
|
|
|
|
user() {
|
|
|
|
|
|
return axios
|
|
|
|
|
|
.post('/user/info', {
|
|
|
|
|
|
session: this.session
|
|
|
|
|
|
})
|
|
|
|
|
|
.then(response => {
|
|
|
|
|
|
if (response.data.success) {
|
|
|
|
|
|
return response.data.user
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.goHome()
|
|
|
|
|
|
return null
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2019-05-14 11:46:11 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
2019-05-14 14:20:38 +00:00
|
|
|
|
decks() {
|
|
|
|
|
|
return axios
|
|
|
|
|
|
.post('/decks/list', {
|
|
|
|
|
|
session: this.session
|
|
|
|
|
|
})
|
|
|
|
|
|
.then(response => {
|
|
|
|
|
|
if (response.data.success) {
|
|
|
|
|
|
return response.data.decks
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
mounted() {
|
|
|
|
|
|
let fileContent = `--Generated By FF Decks (www.ffdecks.com)--
|
2019-05-14 11:46:11 +00:00
|
|
|
|
Deck Name: Ashe turbo
|
|
|
|
|
|
Created by: hawks1997
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forward(26):
|
|
|
|
|
|
3 Garland (6-002)
|
|
|
|
|
|
3 Rain (8-134)
|
|
|
|
|
|
3 Garnet (3-129)
|
|
|
|
|
|
2 Zidane (8-115)
|
|
|
|
|
|
3 Ashe (2-121)
|
|
|
|
|
|
3 Basch (2-014)
|
|
|
|
|
|
3 Steiner (4-129)
|
|
|
|
|
|
3 Vivi (3-017)
|
|
|
|
|
|
3 Cecil (2-129)
|
|
|
|
|
|
|
|
|
|
|
|
Summon(8):
|
|
|
|
|
|
2 Cuchulainn, the Impure (2-133)
|
|
|
|
|
|
2 Bahamut (4-016)
|
|
|
|
|
|
1 Phoenix (5-019)
|
|
|
|
|
|
3 Leviathan (6-125)
|
|
|
|
|
|
|
|
|
|
|
|
Backup(16):
|
|
|
|
|
|
2 Sage (2-005)
|
|
|
|
|
|
2 Vermilion Bird l'Cie Caetuna (6-010)
|
|
|
|
|
|
2 Yotsuyu (8-020)
|
|
|
|
|
|
2 Rasler (5-166)
|
|
|
|
|
|
2 Red Mage (1-003)
|
|
|
|
|
|
3 Hilda (6-122)
|
|
|
|
|
|
3 Astrologian (2-130)
|
|
|
|
|
|
|
|
|
|
|
|
Monster(0):`
|
|
|
|
|
|
|
2019-05-14 14:20:38 +00:00
|
|
|
|
// select the line containing 'deck name:'
|
|
|
|
|
|
// and its successor
|
|
|
|
|
|
let metaRE = /^deck name: (.+)$[\s]*?^(.+)$/im
|
|
|
|
|
|
let metaData = metaRE.exec(fileContent)
|
2019-05-14 11:46:11 +00:00
|
|
|
|
|
2019-05-14 14:20:38 +00:00
|
|
|
|
// extract matches
|
|
|
|
|
|
let deckData = {
|
|
|
|
|
|
name: metaData[1],
|
|
|
|
|
|
note: metaData[2],
|
|
|
|
|
|
cards: []
|
|
|
|
|
|
}
|
2019-05-14 11:46:11 +00:00
|
|
|
|
|
2019-05-14 14:20:38 +00:00
|
|
|
|
// select all lines containing card serial numbers
|
|
|
|
|
|
let cardLinesRE = /^.*\b\d-\d{3}[A-Z]?\b.*$/gm
|
|
|
|
|
|
let cardLines = fileContent.match(cardLinesRE)
|
|
|
|
|
|
|
|
|
|
|
|
cardLines.forEach(cardLine => {
|
|
|
|
|
|
// extract serial (guaranteed to be in here!)
|
|
|
|
|
|
let serialRE = /\b(\d-\d{3})[A-Z]?\b/i
|
|
|
|
|
|
let serial = serialRE.exec(cardLine)[1]
|
|
|
|
|
|
|
|
|
|
|
|
// strip out serial number
|
|
|
|
|
|
cardLine = cardLine.replace(serialRE, '')
|
|
|
|
|
|
|
|
|
|
|
|
let countREs = [
|
|
|
|
|
|
// prioritize a count with "times" symbol *, x, ×
|
|
|
|
|
|
/\b([1-3])(?:[*×]|[x]\b)/,
|
|
|
|
|
|
/(?:[*×]|\b[x])([1-3])\b/,
|
|
|
|
|
|
// next priority: with whitespace
|
|
|
|
|
|
/\s+([1-3])\s+/,
|
|
|
|
|
|
/\s+([1-3])\b/,
|
|
|
|
|
|
/\b([1-3])\s+/,
|
|
|
|
|
|
// least priority: any single digit
|
|
|
|
|
|
/\b([1-3])\b/
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
// fallback value
|
|
|
|
|
|
let count = '0'
|
|
|
|
|
|
for (let i = 0; i < countREs.length; i++) {
|
|
|
|
|
|
let data = countREs[i].exec(cardLine)
|
|
|
|
|
|
|
|
|
|
|
|
if (data) {
|
|
|
|
|
|
count = data[1]
|
|
|
|
|
|
break
|
2019-05-14 11:46:11 +00:00
|
|
|
|
}
|
2019-05-14 14:20:38 +00:00
|
|
|
|
}
|
2019-05-14 11:46:11 +00:00
|
|
|
|
|
2019-05-14 14:20:38 +00:00
|
|
|
|
// push card data into deck
|
|
|
|
|
|
deckData.cards.push({
|
|
|
|
|
|
serial: serial,
|
|
|
|
|
|
count: count
|
2019-05-14 11:46:11 +00:00
|
|
|
|
})
|
2019-05-14 14:20:38 +00:00
|
|
|
|
})
|
2019-05-14 11:46:11 +00:00
|
|
|
|
|
2019-05-14 14:20:38 +00:00
|
|
|
|
console.log(deckData)
|
2019-02-23 01:40:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|