mirror of
https://github.com/vkaelin/LeagueStats.git
synced 2026-03-25 12:57:28 +00:00
Replace some old syntax
This commit is contained in:
parent
2a12c38ab2
commit
0ad9788941
3 changed files with 30 additions and 43 deletions
|
|
@ -3,12 +3,12 @@
|
|||
* @param previous : time we want to get difference
|
||||
*/
|
||||
export function timeDifference(previous) {
|
||||
var current = new Date();
|
||||
var msPerMinute = 60 * 1000;
|
||||
var msPerHour = msPerMinute * 60;
|
||||
var msPerDay = msPerHour * 24;
|
||||
var msPerWeek = msPerDay * 7;
|
||||
var elapsed = current - previous;
|
||||
const current = new Date();
|
||||
const msPerMinute = 60 * 1000;
|
||||
const msPerHour = msPerMinute * 60;
|
||||
const msPerDay = msPerHour * 24;
|
||||
const msPerWeek = msPerDay * 7;
|
||||
const elapsed = current - previous;
|
||||
|
||||
if (elapsed < msPerMinute) {
|
||||
return Math.round(elapsed / 1000) + 's';
|
||||
|
|
@ -19,9 +19,9 @@ export function timeDifference(previous) {
|
|||
} else if (elapsed < msPerWeek) {
|
||||
return Math.round(elapsed / msPerDay) + 'j';
|
||||
} else {
|
||||
var oldDate = new Date(previous);
|
||||
var day = oldDate.getDate() < 10 ? '0' + oldDate.getDate() : oldDate.getDate();
|
||||
var month = oldDate.getMonth() < 9 ? '0' + (oldDate.getMonth() + 1) : (oldDate.getMonth() + 1);
|
||||
const oldDate = new Date(previous);
|
||||
const day = oldDate.getDate() < 10 ? '0' + oldDate.getDate() : oldDate.getDate();
|
||||
const month = oldDate.getMonth() < 9 ? '0' + (oldDate.getMonth() + 1) : (oldDate.getMonth() + 1);
|
||||
return day + '.' + month + '.' + oldDate.getFullYear().toString().substr(-2);
|
||||
}
|
||||
}
|
||||
|
|
@ -32,8 +32,8 @@ export function timeDifference(previous) {
|
|||
* @param sec : time in seconds to convert
|
||||
*/
|
||||
export function secToTime(sec) {
|
||||
var min = Math.floor(sec / 60);
|
||||
var newSec = sec - min * 60;
|
||||
const min = Math.floor(sec / 60);
|
||||
const newSec = sec - min * 60;
|
||||
return min + ':' + (newSec < 10 ? '0' + newSec : newSec); //
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -82,8 +82,8 @@ export default {
|
|||
this.loading = true;
|
||||
this.axios({
|
||||
method: "POST",
|
||||
url: "https://vue.valentinkaelin.ch/api",
|
||||
//url: "http://localhost:5000/api",
|
||||
// url: "https://vue.valentinkaelin.ch/api",
|
||||
url: "http://localhost:5000/api",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
|
|
@ -131,20 +131,10 @@ export default {
|
|||
// Loop on all matches
|
||||
for (let i = 0; i < matches.length; i++) {
|
||||
const currentMatch = matches[i];
|
||||
let participantId;
|
||||
for (let i = 0; i < currentMatch.participantIdentities.length; i++) {
|
||||
if (currentMatch.participantIdentities[i].player.accountId === userStats.accountId)
|
||||
participantId = currentMatch.participantIdentities[i].participantId;
|
||||
}
|
||||
const participantId = currentMatch.participantIdentities.find((p) => p.player.accountId === userStats.accountId).participantId
|
||||
|
||||
const teamId = currentMatch.participants[participantId - 1].teamId;
|
||||
let win = false;
|
||||
for (let i = 0; i < currentMatch.teams.length; i++) {
|
||||
if (currentMatch.teams[i].teamId === teamId) {
|
||||
if (currentMatch.teams[i].win === 'Win')
|
||||
win = true;
|
||||
}
|
||||
}
|
||||
const win = currentMatch.teams.find((t) => t.teamId === teamId).win === 'Win'
|
||||
|
||||
const map = maps[currentMatch.mapId];
|
||||
let mode = gameModes[currentMatch.queueId];
|
||||
|
|
@ -189,7 +179,7 @@ export default {
|
|||
firstSum: this.getSummonerLink(firstSum),
|
||||
secondSum: this.getSummonerLink(secondSum)
|
||||
});
|
||||
}
|
||||
} // end loop matches
|
||||
console.log(matchesInfos);
|
||||
|
||||
this.localInfos = {
|
||||
|
|
@ -219,11 +209,8 @@ export default {
|
|||
return `url('https://cdn.valentinkaelin.ch/riot/${itemImage.sprite}') -${itemImage.x}px -${itemImage.y}px`;
|
||||
},
|
||||
getSummonerLink(id) {
|
||||
for(var prop in summonersJSON.data) {
|
||||
if(summonersJSON.data[prop].key == id) {
|
||||
return `https://cdn.valentinkaelin.ch/riot/spells/${summonersJSON.data[prop].id}.png`;
|
||||
}
|
||||
}
|
||||
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/" + this.search)
|
||||
|
|
|
|||
|
|
@ -20,21 +20,21 @@ let finalJSON = [];
|
|||
app.set('port', (process.env.PORT || 5000))
|
||||
|
||||
/* DEV */
|
||||
//var cors = require('cors');
|
||||
//app.use(cors({origin: '*'}));
|
||||
var cors = require('cors');
|
||||
app.use(cors({origin: '*'}));
|
||||
|
||||
/* PRODUCTION */
|
||||
const staticFileMiddleware = express.static(path.join(__dirname + '/dist'));
|
||||
app.use(staticFileMiddleware);
|
||||
app.use(history({
|
||||
disableDotRule: true,
|
||||
verbose: true
|
||||
}));
|
||||
app.use(staticFileMiddleware);
|
||||
// const staticFileMiddleware = express.static(path.join(__dirname + '/dist'));
|
||||
// app.use(staticFileMiddleware);
|
||||
// app.use(history({
|
||||
// disableDotRule: true,
|
||||
// verbose: true
|
||||
// }));
|
||||
// app.use(staticFileMiddleware);
|
||||
|
||||
app.get('/', function (req, res) {
|
||||
res.render(path.join(__dirname + '/dist/index.html'));
|
||||
});
|
||||
// app.get('/', function (req, res) {
|
||||
// res.render(path.join(__dirname + '/dist/index.html'));
|
||||
// });
|
||||
|
||||
/* To retrieve data of post request */
|
||||
app.use(bodyParser.json()); // to support JSON-encoded bodies
|
||||
|
|
|
|||
Loading…
Reference in a new issue