김세윤

챔피언 숙련도 레벨, 소환사 아이콘 추가

......@@ -2,7 +2,7 @@ module.exports = function(app){
var request = require("request");
var urlenconde = require('urlencode');
var apikey = "RGAPI-4591bbaf-8e3f-4afa-91c2-359b66a402b7"//api
var apikey = "RGAPI-26fe9028-bf28-4baa-a0e0-34c116c57742"//api
var profileIconId; //아이콘 번호
var revisionDate; //수정날짜
......@@ -39,7 +39,11 @@ var rotation_champ = new Array();
profileIconId = info_summoner_json["profileIconId"];
summonerLevel = info_summoner_json["summonerLevel"];
revisionDate = info_summoner_json["revisionDate"];
var profileUrl="http://ddragon.leagueoflegends.com/cdn/10.23.1/img/profileicon/";
request(profileUrl,function(error,response,body){
var profileIcon;
profileIcon="http://ddragon.leagueoflegends.com/cdn/10.23.1/img/profileicon/"+profileIconId+".png";
var champUrl = "https://kr.api.riotgames.com/lol/champion-mastery/v4/champion-masteries/by-summoner/" + urlenconde(id) + "?api_key=" + apikey;
request(champUrl,function(error,response,body){
var info_champ_json = JSON.parse(body);
......@@ -49,6 +53,7 @@ var rotation_champ = new Array();
var rotation_name = new Array();
var champ_pic = new Array();
var rotation_pic =new Array();
var champ_level=new Array();//숙련도 레벨
var champions_length = Object.keys(info_champ_json).length;
//console.log("\n\ninfo_champ_json\n\n", info_champ_json);
......@@ -65,7 +70,7 @@ var rotation_champ = new Array();
for(var i=0; i < champions_length; i++){
champ_point[i] = (info_champ_json[i]["championPoints"]);
champ_id[i] = info_champ_json[i]["championId"];
champ_level[i]=info_champ_json[i]["championLevel"]
}
var rotationUrl = "https://kr.api.riotgames.com/lol/platform/v3/champion-rotations?api_key="+apikey;
request(rotationUrl,function(error,response,body){
......@@ -80,7 +85,7 @@ var rotation_champ = new Array();
var staticUrl = "http://ddragon.leagueoflegends.com/cdn/10.23.1/data/en_US/champion.json";
request(staticUrl,function(error,response,body){
......@@ -149,17 +154,21 @@ var rotation_champ = new Array();
var temp_name;
var temp_point;
var temp_pic;
var temp_chamlev;
for(var i=0; i < champ_id.length-1; i++){//챔피언 포인트 순으로 sorting
for(var j=i+1;j <champ_id.length-1; j++)
if(champ_point[i] < champ_point[j]){
temp_chamlev=champ_level[i];
temp_id = champ_id[i];
temp_name = champ_name[i];
temp_point = champ_point[i];
temp_pic = champ_pic[i];
champ_level[i]=champ_level[j];
champ_id[i] = champ_id[j]
champ_name[i] = champ_name[j];
champ_point[i] = champ_point[j];
champ_pic[i] = champ_pic[j];
champ_level[j]=champ_level[i];
champ_id[j] = temp_id
champ_name[j] = temp_name;
champ_point[j] = temp_point;
......@@ -198,6 +207,8 @@ var rotation_champ = new Array();
res.render('index', { title: req.params.username ,//데이터를 ejs로 넘길 때 사용
c_lev: champ_level,
c_profile: profileIcon,
c_id: champ_id,
c_name: champ_name,
c_point: champ_point,
......@@ -215,6 +226,7 @@ var rotation_champ = new Array();
});
});
});
});
});
});
};
......
......@@ -11,7 +11,12 @@
<style> @import url("http://fonts.googleapis.com/earlyaccess/nanumgothic.css");</style>
<script>
$(document).ready(function(){
$("#enter").on("keypress",function(event){
if(event.keyCode==13){
var name = $("input").val();
location.href = "http://localhost:3000/search/" + name;
}
});
$("button#searchButton").click(function(){
var name = $("input").val();
......@@ -22,7 +27,7 @@
</head>
<body>
<div class="imgOpacity">
<div class="center">
<img src= "/FindMelogo.png" width = 150, height = 150/>
......@@ -47,6 +52,7 @@
<table class="basic">
<tbody>
<tr><td> <img src= <%=c_profile%> width=120, height=120></td></tr>
<tr><td> <img src= <%=c_imgtier%> width=120, height=120></td></tr>
<tr><td><%= "Tier : " + c_tier + " " + c_rank + " / " + c_leaguePoint + "점"%></td></tr>
<tr><td><%= "Win : " + c_wins + " / Lose : " + c_losses%></td></tr>
......@@ -96,12 +102,17 @@
<%}%>
</strong>
</div>
<br>
<% for (var i=0; i<c_id.length-1; i++){ %>
<div class="champImage">
<div class="center">
<img src= <%=c_pic[i]%> width=50, height=50>
<B>
<%= c_name[i] %>
<%= "point: " + c_point[i] %>
</B>
<%= "point: " + c_point[i]+ " \tchampion level: " + c_lev[i] %>
<% } %>
</div>
......
......@@ -11,16 +11,23 @@
<style> @import url("http://fonts.googleapis.com/earlyaccess/nanumgothic.css");</style>
<script>
$(document).ready(function(){
$("#enter").on("keypress",function(event){
if(event.keyCode==13){
var name = $("input").val();
location.href = "http://localhost:3000/search/" + name;
}
});
$("button#searchButton").click(function(){
var name = $("input").val();
location.href = "http://localhost:3000/search/" + name;
})
});
</script>
</head>
<body>
<div class="imgOpacity">
<div class="center">
<img src= "FindMelogo.png" width = 300, height = 300/>
......