diff --git a/index.html b/index.html
index 84fc979..b484902 100644
--- a/index.html
+++ b/index.html
@@ -12,6 +12,8 @@
+
+
@@ -31,6 +33,57 @@
Default division
Default ratio
+
+
+
+
+ -
+
+
+
+
+
+
Summoner's Rift
+
Normal (Draft Mode)
+
+
+
+
+
+
+
+
+
+
@@ -40,6 +93,7 @@
+
diff --git a/node_modules/bluebird/package.json b/node_modules/bluebird/package.json
index d6af92f..a6d9940 100644
--- a/node_modules/bluebird/package.json
+++ b/node_modules/bluebird/package.json
@@ -1,28 +1,29 @@
{
- "_from": "bluebird@^3.5.3",
+ "_from": "bluebird",
"_id": "bluebird@3.5.3",
"_inBundle": false,
"_integrity": "sha512-/qKPUQlaW1OyR51WeCPBvRnAlnZFUJkCSG5HzGnuIqhgyJtF+T94lFnn33eiazjRm2LAHVy2guNnaq48X9SJuw==",
"_location": "/bluebird",
"_phantomChildren": {},
"_requested": {
- "type": "range",
+ "type": "tag",
"registry": true,
- "raw": "bluebird@^3.5.3",
+ "raw": "bluebird",
"name": "bluebird",
"escapedName": "bluebird",
- "rawSpec": "^3.5.3",
+ "rawSpec": "",
"saveSpec": null,
- "fetchSpec": "^3.5.3"
+ "fetchSpec": "latest"
},
"_requiredBy": [
+ "#USER",
"/",
"/request-promise"
],
"_resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.3.tgz",
"_shasum": "7d01c6f9616c9a51ab0f8c549a79dfe6ec33efa7",
- "_spec": "bluebird@^3.5.3",
- "_where": "C:\\Users\\valik\\Desktop\\RiotAPIHeroku",
+ "_spec": "bluebird",
+ "_where": "G:\\Logiciels portables\\NodeJS\\RiotAPINode",
"author": {
"name": "Petka Antonov",
"email": "petka_antonov@hotmail.com",
diff --git a/node_modules/body-parser/package.json b/node_modules/body-parser/package.json
index 2584a90..30b9ead 100644
--- a/node_modules/body-parser/package.json
+++ b/node_modules/body-parser/package.json
@@ -1,27 +1,29 @@
{
- "_from": "body-parser@1.18.3",
+ "_from": "body-parser",
"_id": "body-parser@1.18.3",
"_inBundle": false,
"_integrity": "sha1-WykhmP/dVTs6DyDe0FkrlWlVyLQ=",
"_location": "/body-parser",
"_phantomChildren": {},
"_requested": {
- "type": "version",
+ "type": "tag",
"registry": true,
- "raw": "body-parser@1.18.3",
+ "raw": "body-parser",
"name": "body-parser",
"escapedName": "body-parser",
- "rawSpec": "1.18.3",
+ "rawSpec": "",
"saveSpec": null,
- "fetchSpec": "1.18.3"
+ "fetchSpec": "latest"
},
"_requiredBy": [
+ "#USER",
+ "/",
"/express"
],
"_resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.3.tgz",
"_shasum": "5b292198ffdd553b3a0f20ded0592b956955c8b4",
- "_spec": "body-parser@1.18.3",
- "_where": "G:\\Logiciels portables\\NodeJS\\RiotAPINode\\node_modules\\express",
+ "_spec": "body-parser",
+ "_where": "G:\\Logiciels portables\\NodeJS\\RiotAPINode",
"bugs": {
"url": "https://github.com/expressjs/body-parser/issues"
},
diff --git a/node_modules/lodash/package.json b/node_modules/lodash/package.json
index 8afdf1f..e88511b 100644
--- a/node_modules/lodash/package.json
+++ b/node_modules/lodash/package.json
@@ -21,7 +21,7 @@
"_resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz",
"_shasum": "b39ea6229ef607ecd89e2c8df12536891cac9b8d",
"_spec": "lodash@^4.13.1",
- "_where": "C:\\Users\\valik\\Desktop\\RiotAPIHeroku\\node_modules\\request-promise-core",
+ "_where": "G:\\Logiciels portables\\NodeJS\\RiotAPINode\\node_modules\\request-promise-core",
"author": {
"name": "John-David Dalton",
"email": "john.david.dalton@gmail.com",
diff --git a/node_modules/request-promise-core/package.json b/node_modules/request-promise-core/package.json
index 52fb6b6..4ee5421 100644
--- a/node_modules/request-promise-core/package.json
+++ b/node_modules/request-promise-core/package.json
@@ -21,7 +21,7 @@
"_resolved": "https://registry.npmjs.org/request-promise-core/-/request-promise-core-1.1.1.tgz",
"_shasum": "3eee00b2c5aa83239cfb04c5700da36f81cd08b6",
"_spec": "request-promise-core@1.1.1",
- "_where": "C:\\Users\\valik\\Desktop\\RiotAPIHeroku\\node_modules\\request-promise",
+ "_where": "G:\\Logiciels portables\\NodeJS\\RiotAPINode\\node_modules\\request-promise",
"author": {
"name": "Nicolai Kamenzky",
"url": "https://github.com/analog-nico"
diff --git a/node_modules/request-promise/package.json b/node_modules/request-promise/package.json
index 7f50b48..4e696c3 100644
--- a/node_modules/request-promise/package.json
+++ b/node_modules/request-promise/package.json
@@ -16,12 +16,13 @@
"fetchSpec": "^4.2.2"
},
"_requiredBy": [
+ "#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/request-promise/-/request-promise-4.2.2.tgz",
"_shasum": "d1ea46d654a6ee4f8ee6a4fea1018c22911904b4",
"_spec": "request-promise@^4.2.2",
- "_where": "C:\\Users\\valik\\Desktop\\RiotAPIHeroku",
+ "_where": "G:\\Logiciels portables\\NodeJS\\RiotAPINode",
"author": {
"name": "Nicolai Kamenzky",
"url": "https://github.com/analog-nico"
diff --git a/node_modules/stealthy-require/package.json b/node_modules/stealthy-require/package.json
index e334e0a..3f744ff 100644
--- a/node_modules/stealthy-require/package.json
+++ b/node_modules/stealthy-require/package.json
@@ -21,7 +21,7 @@
"_resolved": "https://registry.npmjs.org/stealthy-require/-/stealthy-require-1.1.1.tgz",
"_shasum": "35b09875b4ff49f26a777e509b3090a3226bf24b",
"_spec": "stealthy-require@^1.1.0",
- "_where": "C:\\Users\\valik\\Desktop\\RiotAPIHeroku\\node_modules\\request-promise",
+ "_where": "G:\\Logiciels portables\\NodeJS\\RiotAPINode\\node_modules\\request-promise",
"author": {
"name": "Nicolai Kamenzky",
"url": "https://github.com/analog-nico"
diff --git a/public/client.js b/public/client.js
index 76b75a7..becdf35 100644
--- a/public/client.js
+++ b/public/client.js
@@ -1,4 +1,23 @@
var championsId = { 266: "Aatrox", 103: "Ahri", 84: "Akali", 12: "Alistar", 32: "Amumu", 34: "Anivia", 1: "Annie", 22: "Ashe", 136: "AurelionSol", 268: "Azir", 432: "Bard", 53: "Blitzcrank", 63: "Brand", 201: "Braum", 51: "Caitlyn", 164: "Camille", 69: "Cassiopeia", 31: "Chogath", 42: "Corki", 122: "Darius", 131: "Diana", 119: "Draven", 36: "DrMundo", 245: "Ekko", 60: "Elise", 28: "Evelynn", 81: "Ezreal", 9: "Fiddlesticks", 114: "Fiora", 105: "Fizz", 3: "Galio", 41: "Gangplank", 86: "Garen", 150: "Gnar", 79: "Gragas", 104: "Graves", 120: "Hecarim", 74: "Heimerdinger", 420: "Illaoi", 39: "Irelia", 427: "Ivern", 40: "Janna", 59: "JarvanIV", 24: "Jax", 126: "Jayce", 202: "Jhin", 222: "Jinx", 145: "Kaisa", 429: "Kalista", 43: "Karma", 30: "Karthus", 38: "Kassadin", 55: "Katarina", 10: "Kayle", 141: "Kayn", 85: "Kennen", 121: "Khazix", 203: "Kindred", 240: "Kled", 96: "KogMaw", 7: "Leblanc", 64: "LeeSin", 89: "Leona", 127: "Lissandra", 236: "Lucian", 117: "Lulu", 99: "Lux", 54: "Malphite", 90: "Malzahar", 57: "Maokai", 11: "MasterYi", 21: "MissFortune", 62: "MonkeyKing", 82: "Mordekaiser", 25: "Morgana", 267: "Nami", 75: "Nasus", 111: "Nautilus", 76: "Nidalee", 56: "Nocturne", 20: "Nunu", 2: "Olaf", 61: "Orianna", 516: "Ornn", 80: "Pantheon", 78: "Poppy", 555: "Pyke", 133: "Quinn", 497: "Rakan", 33: "Rammus", 421: "RekSai", 58: "Renekton", 107: "Rengar", 92: "Riven", 68: "Rumble", 13: "Ryze", 113: "Sejuani", 35: "Shaco", 98: "Shen", 102: "Shyvana", 27: "Singed", 14: "Sion", 15: "Sivir", 72: "Skarner", 37: "Sona", 16: "Soraka", 50: "Swain", 134: "Syndra", 223: "TahmKench", 163: "Taliyah", 91: "Talon", 44: "Taric", 17: "Teemo", 412: "Thresh", 18: "Tristana", 48: "Trundle", 23: "Tryndamere", 4: "TwistedFate", 29: "Twitch", 77: "Udyr", 6: "Urgot", 110: "Varus", 67: "Vayne", 45: "Veigar", 161: "Velkoz", 254: "Vi", 112: "Viktor", 8: "Vladimir", 106: "Volibear", 19: "Warwick", 498: "Xayah", 101: "Xerath", 5: "XinZhao", 157: "Yasuo", 83: "Yorick", 154: "Zac", 238: "Zed", 115: "Ziggs", 26: "Zilean", 142: "Zoe", 143: "Zyra" };
+var maps = { 10: "The Twisted Treeline", 11: "Summoner's Rift", 12: "Howling Abyss" };
+
+var gameModes = {
+ 76: 'URF',
+ 100: 'ARAM',
+ 400: 'Normal (Draft)',
+ 420: 'Ranked (Solo)',
+ 430: 'Normal (Blind)',
+ 440: 'Ranked (Flex)',
+ 460: '3v3 Blind',
+ 470: '3v3 Ranked (Flex)',
+ 800: '3v3 Co-op vs. AI (Intermediate)',
+ 810: '3v3 Co-op vs. AI (Intro)',
+ 820: '3v3 Co-op vs. AI (Beginner)',
+ 830: 'Co-op vs. AI (Intro)',
+ 840: 'Co-op vs. AI (Beginner)',
+ 850: 'Co-op vs. AI (Intermediate)'
+};
+
var req = new XMLHttpRequest();
var url = '/api';
var params = 'playerName=Kalane';
@@ -56,6 +75,7 @@ changeName.addEventListener('submit', function (e) {
* @param JSONData : big JSON with all the data of the request to the server
*/
function createObject(JSONData) {
+ console.log('--- ALL INFOS ---')
console.log(JSONData);
var userStats = JSONData[0];
@@ -82,13 +102,43 @@ function createObject(JSONData) {
}
}
+ var map = maps[currentMatch.mapId];
+ var mode = gameModes[currentMatch.queueId];
+ if (!mode)
+ mode = 'Undefinded gamemode';
var champion = currentMatch.participants[participantId - 1].championId;
var role = currentMatch.participants[participantId - 1].timeline.lane;
+ var timeAgo = timeDifference(currentMatch.gameCreation);
+ var time = secToTime(currentMatch.gameDuration);
+ var kills = currentMatch.participants[participantId - 1].stats.kills;
+ var deaths = currentMatch.participants[participantId - 1].stats.deaths;
+ var assists = currentMatch.participants[participantId - 1].stats.assists;
+ var level = currentMatch.participants[participantId - 1].stats.champLevel;
+
+ var items = [];
+ for (let i = 0; i < 6; i++) {
+ var currentItem = 'item' + i;
+ items.push(currentMatch.participants[participantId - 1].stats[currentItem]);
+ }
+
+ var gold = (currentMatch.participants[participantId - 1].stats.goldEarned / 1000).toFixed(1) + 'k';
+ var minions = currentMatch.participants[participantId - 1].stats.totalMinionsKilled + currentMatch.participants[participantId - 1].stats.neutralMinionsKilled;
matchesInfos.push({
result: win,
+ map: map,
+ gamemode: mode,
champ: champion,
- role: role
+ role: role,
+ date: timeAgo,
+ time: time,
+ kills: kills,
+ deaths: deaths,
+ assists: assists,
+ level: level,
+ items: items,
+ gold: gold,
+ minions: minions
});
}
console.log(matchesInfos);
@@ -105,7 +155,7 @@ function createObject(JSONData) {
nameChosen = userStats.name;
- console.log('=============');
+ console.log('====== Saved infos ======');
console.log(infos);
localStorage[nameChosen] = JSON.stringify(infos);
@@ -113,23 +163,6 @@ function createObject(JSONData) {
}
-/**
- * Return the link of the rank image
- * @param soloQStats : stats in soloQ of the player
- */
-function getRankImg(soloQStats) {
- if (soloQStats) {
- if (soloQStats.tier != 'MASTER' && soloQStats.tier != 'CHALLENGER') {
- return 'https://cdn.valentinkaelin.ch/riot/tier-icons/' + soloQStats.tier.toLowerCase() + '_' + soloQStats.rank.toLowerCase() + '.png';
- } else {
- return 'https://cdn.valentinkaelin.ch/riot/tier-icons/' + soloQStats.tier.toLowerCase() + '.png';
- }
- } else {
- return 'https://cdn.valentinkaelin.ch/riot/tier-icons/provisional.png';
- }
-}
-
-
/**
* Display on the page all the dynamic content
* @param stringData : Stringify object with all datas
@@ -146,21 +179,129 @@ function displayContent(stringData) {
document.querySelector('.player__ratio').innerHTML = data.rankedWins ? data.rankedWins + ' wins / ' + data.rankedLosses + ' losses' : "Joueur non classé";
var playerContainer = document.querySelector('.player');
- var oldList = document.querySelector('.list-matches');
+ var oldList = document.querySelector('.list-matches--debug');
if (oldList)
oldList.parentNode.removeChild(oldList);
var matchesList = document.createElement('ul');
- matchesList.className = 'list-matches';
+ matchesList.className = 'list-matches--debug';
playerContainer.appendChild(matchesList);
+
data.matches.forEach(e => {
var li = document.createElement('li');
- li.className = e.result ? 'win' : 'lose';
- var img = document.createElement('img');
+ if (e.result)
+ li.className = 'match win';
+ else
+ li.className = 'match lose';
+ var container = document.createElement('div');
+ container.className = 'content-container';
+
+ /* First col */
+ var first = document.createElement('div');
+ first.className = 'first';
+ var imgChamp = document.createElement('img');
var championName = championsId[e.champ];
- img.setAttribute('src', '/public/img/champions/' + championName + '.png');
- img.className = 'champion-icon';
- li.innerHTML = championName + ' - ' + e.role;
- li.appendChild(img);
+ imgChamp.setAttribute('src', '/public/img/champions/' + championName + '.png');
+ imgChamp.className = 'champion-img';
+
+ var level = document.createElement('span');
+ level.className = 'level';
+ level.innerText = e.level;
+
+ var summonerSpells = document.createElement('div');
+ summonerSpells.className = 'summonerSpells';
+
+ var firstSpell = document.createElement('img');
+ firstSpell.setAttribute('src', 'https://cdn.valentinkaelin.ch/riot/spells/SummonerFlash.png');
+ firstSpell.className = 'spell-icon';
+ summonerSpells.appendChild(firstSpell);
+
+ var secondSpell = document.createElement('img');
+ secondSpell.setAttribute('src', 'https://cdn.valentinkaelin.ch/riot/spells/SummonerDot.png');
+ secondSpell.className = 'spell-icon';
+ summonerSpells.appendChild(secondSpell);
+
+ var name = document.createElement('span');
+ name.className = 'champion-name';
+ name.innerText = championName;
+
+ first.appendChild(imgChamp);
+ first.appendChild(level);
+ first.appendChild(summonerSpells);
+ first.appendChild(name);
+
+
+ /* Second col */
+ var second = document.createElement('div');
+ second.className = 'second';
+ var map = document.createElement('div');
+ map.className = 'map';
+ map.innerText = e.map;
+ var gamemode = document.createElement('div');
+ gamemode.className = 'gamemode';
+ gamemode.innerText = e.gamemode;
+
+ second.appendChild(map);
+ second.appendChild(gamemode);
+
+
+ /* Third col */
+ var third = document.createElement('div');
+ third.className = 'third';
+ e.items.forEach(e => {
+ var img = document.createElement('img');
+ img.className = 'item';
+ img.setAttribute('src', 'https://cdn.valentinkaelin.ch/riot/items/' + e + '.png');
+ third.appendChild(img);
+ });
+
+
+ /* Fourth col */
+ var fourth = document.createElement('div');
+ fourth.className = 'fourth';
+ var score = document.createElement('div');
+ score.className = 'score';
+ score.innerText = e.kills + '/' + e.deaths + '/' + e.assists;
+
+ var goldFarm = document.createElement('div');
+ goldFarm.className = 'gold-farm';
+ var gold = document.createElement('div');
+ gold.className = 'gold';
+ gold.innerText = e.gold;
+ var farm = document.createElement('div');
+ farm.className = 'farm';
+ farm.innerText = e.minions;
+ goldFarm.appendChild(gold);
+ goldFarm.appendChild(farm);
+
+ var durationDate = document.createElement('div');
+ durationDate.className = 'duration-date';
+ var duration = document.createElement('div');
+ duration.className = 'duration';
+ duration.innerText = e.time;
+ var date = document.createElement('div');
+ date.className = 'date';
+ date.innerText = e.date;
+ durationDate.appendChild(duration);
+ durationDate.appendChild(date);
+
+ fourth.appendChild(score);
+ fourth.appendChild(goldFarm);
+ fourth.appendChild(durationDate);
+
+
+ /* End */
+ container.appendChild(first);
+ container.appendChild(second);
+ container.appendChild(third);
+ container.appendChild(fourth);
+ li.appendChild(container);
matchesList.appendChild(li);
});
-}
\ No newline at end of file
+}
+
+
+/* Debug button to reset localstorage */
+document.querySelector('.debug').addEventListener('click', () => {
+ console.log('CLEAR LOCALSTORAGE');
+ localStorage.clear();
+});
\ No newline at end of file
diff --git a/public/functions.js b/public/functions.js
new file mode 100644
index 0000000..1976cd8
--- /dev/null
+++ b/public/functions.js
@@ -0,0 +1,55 @@
+/**
+ * Return the relative time betweeen a chosen moment and the current time
+ * @param previous : time we want to get difference
+ */
+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;
+
+ if (elapsed < msPerMinute) {
+ return Math.round(elapsed / 1000) + 's';
+ } else if (elapsed < msPerHour) {
+ return Math.round(elapsed / msPerMinute) + 'm';
+ } else if (elapsed < msPerDay) {
+ return Math.round(elapsed / msPerHour) + 'h';
+ } 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);
+ return day + '.' + month + '.' + oldDate.getFullYear().toString().substr(-2);
+ }
+}
+
+
+/**
+ * Return time in a formatted way
+ * @param sec : time in seconds to convert
+ */
+function secToTime(sec) {
+ var min = Math.floor(sec / 60);
+ var newSec = sec - min * 60;
+ return min + ':' + (newSec < 10 ? '0' + newSec : newSec); //
+}
+
+
+/**
+ * Return the link of the rank image
+ * @param soloQStats : stats in soloQ of the player
+ */
+function getRankImg(soloQStats) {
+ if (soloQStats) {
+ if (soloQStats.tier != 'MASTER' && soloQStats.tier != 'CHALLENGER') {
+ return 'https://cdn.valentinkaelin.ch/riot/tier-icons/' + soloQStats.tier.toLowerCase() + '_' + soloQStats.rank.toLowerCase() + '.png';
+ } else {
+ return 'https://cdn.valentinkaelin.ch/riot/tier-icons/' + soloQStats.tier.toLowerCase() + '.png';
+ }
+ } else {
+ return 'https://cdn.valentinkaelin.ch/riot/tier-icons/provisional.png';
+ }
+}
\ No newline at end of file
diff --git a/public/style.css b/public/style.css
index 4bcbd52..61a3702 100644
--- a/public/style.css
+++ b/public/style.css
@@ -1,3 +1,17 @@
+body {
+ background: #F1F5F8;
+}
+
+.debug {
+ position: absolute;
+ right: 0;
+ top: 0;
+ width: 40px;
+ height: 40px;
+ background: #EF5753;
+ border: none;
+}
+
.search {
background: #ebebeb;
}
@@ -13,7 +27,7 @@
.player {
text-align: center;
margin: 16px auto;
- width: 400px;
+ /*width: 400px;*/
border: 1px solid #ebebeb;
padding: 16px;
}
@@ -51,4 +65,99 @@
height: 48px;
display: block;
margin: 0 auto;
+}
+
+.champion-img {
+ width: 48px;
+ height: 48px;
+ display: block;
+ margin: 0 2px 0 0;
+}
+
+.spell-icon {
+ width: 23px;
+ height: 23px;
+ display: block;
+}
+
+
+/* ############## */
+
+
+.list-matches--debug {
+ list-style-type: none;
+ padding: 0;
+}
+
+.match {
+ background: #fff;
+ padding: 10px 0;
+ border-bottom: 1px solid #DAE1E7;
+}
+
+.match .content-container {
+ display: flex;
+ flex-wrap: wrap;
+ padding: 16px;
+
+}
+
+.match.win .content-container {
+ border-left: 10px solid #51D88A;
+}
+
+.match.lose .content-container {
+ border-left: 10px solid #EF5753;
+}
+
+/* First col */
+.match .first {
+ position: relative;
+ display: flex;
+ flex-direction: row;
+ align-items: center;
+ flex: 1 0 0;
+}
+
+.match .level {
+ position: absolute;
+ bottom: 0;
+ left: 0;
+
+ color: #fff;
+ font-weight: bold;
+}
+
+.match .summonerSpells {
+ margin: 0 8px 0 0;
+}
+
+.match .spell-icon:first-child {
+ margin: 0 0 2px 0;
+}
+
+/* Second col */
+.match .second {
+ flex: 1 0 0;
+ text-align: left;
+}
+
+/* Third col */
+.match .third {
+ flex: 1 0 0;
+ display: flex;
+}
+
+.third .item {
+ width: 48px;
+ height: 48px;
+ margin: 0 2px 0 0;
+}
+
+/* Fourth col */
+.match .fourth {
+ flex: 1 0 0;
+ display: flex;
+ justify-content: space-around;
+ align-items: center;
}
\ No newline at end of file
diff --git a/save/index.html b/save/index.html
deleted file mode 100644
index 09d2b60..0000000
--- a/save/index.html
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
-
-
- Riot Api Node
-
-
-
-
-
-
Default name
-
Default level
-
Default division
-
Default ratio
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/save/package.json b/save/package.json
deleted file mode 100644
index 2e12453..0000000
--- a/save/package.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "name": "riotapi",
- "version": "1.0.0",
- "description": "",
- "main": "index.js",
- "scripts": {
- "test": "echo \"Error: no test specified\" && exit 1"
- },
- "author": "kalane",
- "license": "ISC",
- "dependencies": {
- "express": "^4.16.4"
- }
-}
diff --git a/save/public/client.js b/save/public/client.js
deleted file mode 100644
index fb0be0b..0000000
--- a/save/public/client.js
+++ /dev/null
@@ -1,41 +0,0 @@
-var req = new XMLHttpRequest();
-var url = '/api';
-
-req.open('GET', url, true); // set this to POST if you would like
-req.addEventListener('load', onLoad);
-req.addEventListener('error', onError);
-
-req.send();
-
-function onLoad() {
- var response = this.responseText;
- var parsedEntireResponse = JSON.parse(response);
- //console.log(parsedEntireResponse);
-
- var userStats = parsedEntireResponse[0];
- var rankedStats = JSON.parse(parsedEntireResponse[1]);
- console.log(userStats);
- console.log(rankedStats);
- //console.log(rankedStats[0].playerOrTeamName);
-
- document.querySelector('.player__pp').style.background = 'url(http://cdn.kalane.ch/riot/profileicon/' + userStats.profileIconId + '.png) center/cover';
- document.querySelector('.player__name').innerHTML = userStats.name;
- document.querySelector('.player__level').innerHTML = userStats.summonerLevel;
- document.querySelector('.player__rank').innerHTML = rankedStats.length !== 0 ? rankedStats[0].tier + ' ' + rankedStats[0].rank : "Joueur non classé";
- document.querySelector('.player__ratio').innerHTML = rankedStats.length !== 0 ? rankedStats[0].wins + ' wins / ' + rankedStats[0].losses + ' losses': "Joueur non classé";
-}
-
-function onError() {
- console.log('error receiving async AJAX call');
-}
-
-
-/* Formulaire */
-var changeName = document.querySelector('#changeName');
-var nameToPick = document.querySelector('#name')
-changeName.addEventListener('submit', function (e) {
- e.preventDefault();
- url = '/api?' + nameToPick.value;
- req.open('GET', url, true);
- req.send();
-});
\ No newline at end of file
diff --git a/save/public/style.css b/save/public/style.css
deleted file mode 100644
index 12a8083..0000000
--- a/save/public/style.css
+++ /dev/null
@@ -1,5 +0,0 @@
-.player__pp {
- width: 75px;
- height: 75px;
- background: #ebebeb;
-}
\ No newline at end of file
diff --git a/save/server.js b/save/server.js
deleted file mode 100644
index 3b4a278..0000000
--- a/save/server.js
+++ /dev/null
@@ -1,78 +0,0 @@
-const express = require('express')
-const request = require('request');
-const path = require('path');
-const bodyParser = require("body-parser");
-
-const app = express()
-const port = 3000
-
-const key = 'RGAPI-0db7bf7a-c8a7-40d1-927b-2cd33e22d873';
-var id = 65362306;
-var pseudo = 'Chil';
-
-var dataAPI;
-
-/* Homepage */
-app.get('/', function (request, response) {
- response.sendFile(path.join(__dirname, 'index.html'));
-});
-
-app.use('/public', express.static(__dirname + '/public'));
-
-app.use(bodyParser.urlencoded({
- extended: true
-}));
-
-app.use(bodyParser.json());
-
-app.listen(port, () => console.log(`RiotAPI test app listening on port ${port}!`))
-
-
-// Get data of rankeds
-function getRanked(callback) {
- request('https://euw1.api.riotgames.com/lol/league/v3/positions/by-summoner/' + id + '?api_key=' + key, function (error, response, body) {
- if (!error && response.statusCode == 200) {
- callback(body);
- }
- })
-}
-
-getRanked(function (body) {
- dataAPI = body;
-});
-
-
-// send data of rankeds and of username
-app.get('/api', function (req, res) {
- var name = req.url.split('?')[1];
- if (name != undefined) {
- pseudo = name;
- }
- getAccountID(function (JSONBody) {
- id = JSONBody.id;
- getRanked(function (body) {
- dataAPI = body;
- var finalJSON = new Array();
- finalJSON.push(JSONBody);
- finalJSON.push(dataAPI);
- //console.log(finalJSON);
- res.send(finalJSON);
- //res.send(dataAPI);
- });
- });
-
-});
-
-
-// Get accountId of username
-function getAccountID(callback) {
- request('https://euw1.api.riotgames.com/lol/summoner/v3/summoners/by-name/' + pseudo + '?api_key=' + key, function (error, response, body) {
- if (!error && response.statusCode == 200) {
- dataAPI = body;
- var JSONBody = JSON.parse(body);
- //console.log(JSONBody);
- id = JSONBody.id;
- callback(JSONBody);
- }
- });
-}
diff --git a/server.js b/server.js
index 87b9c7a..f552c68 100644
--- a/server.js
+++ b/server.js
@@ -8,7 +8,7 @@ var Promise = require("bluebird");
const app = express()
app.set('port', (process.env.PORT || 5000))
-const key = 'RGAPI-48b725ad-3376-4b20-856b-66787c36d348';
+const key = 'RGAPI-858eb2b5-24a7-4a54-bf71-45e8b9f3327a';
var summonerID = 'HMOiIUvzYtfgPk5X53zWTeOZo52T-HYJQhwvhkPNh0BWxZ0';
var accountID = 'V1xNS14bjVeP54hg03JeMxkXJB29K4TfUMvijDB85nxbD4Y';
var pseudo = 'Chil';
@@ -91,8 +91,8 @@ function getMatches(callback) {
if (!error && response.statusCode == 200) {
JSONMatches = JSON.parse(body);
- let matchsId = new Array();
- for (let i = 0; i < JSONMatches.matches.length; i++) {
+ var matchsId = new Array();
+ for (var i = 0; i < JSONMatches.matches.length; i++) {
matchsId[i] = JSONMatches.matches[i].gameId;
}
@@ -113,7 +113,7 @@ function getMatches(callback) {
function addMatchToJSON(obj) {
//console.log(obj.gameId);
- for (let i = 0; i < JSONMatches.matches.length; i++) {
+ for (var i = 0; i < JSONMatches.matches.length; i++) {
if(JSONMatches.matches[i].gameId == obj.gameId) {
//console.log('yes');
JSONMatches.matches[i] = obj;