김명주

Merge branch 'test' into 'master'

Test

Update detail information 
Add image file

See merge request !1
......@@ -5,6 +5,7 @@ var app=express();
const bodyParser=require('body-parser');
app.use(bodyParser.urlencoded({extended: false})); // URL 인코딩 안함
app.use(bodyParser.json()); // json 타입으로 파싱하게 설정
app.use('/inf/result',express.static('metadata'));
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
......@@ -25,8 +26,37 @@ app.get("/inf/result",(req,res)=>{
request.get(options, function(error, response, body){
if (!error && response.statusCode == 200) {
var jsbody=JSON.parse(body);
//res.writeHead(200, {'Content-Type': 'text/json;charset=utf-8'}); and res.end(body)
res.render('inf_search_result', {aid:jsbody.accessId, name: jsbody.name, level: jsbody.level});
var option2={
url: "https://api.nexon.co.kr/kart/v1.0/users/"+jsbody.accessId+"/matches?start_date=&end_date= &offset=0&limit=1&match_types=",
headers:{Authorization: key}
};
request.get(option2, function(error, response, body){
var match=JSON.parse(body);
var tId=match.matches[0].matches[0].trackId;
var kartId=match.matches[0].matches[0].player.kart;
var mrank=match.matches[0].matches[0].player.matchRank;
//한화라고 검색하면 아직 오류존재
var players=match.matches[0].matches[0].playerCount;
var stime=new Date(match.matches[0].matches[0].startTime.split('T')[0]+" "+match.matches[0].matches[0].startTime.split('T')[1]);
var etime=new Date(match.matches[0].matches[0].endTime.split('T')[0]+" "+match.matches[0].matches[0].endTime.split('T')[1]);
var diff=etime-stime
var minute= Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60));
var second = Math.floor((diff % (1000 * 60)) / 1000);
var diff_time=minute + " : " + second;
if(mrank=="99"){
mrank="retire";
diff_time="retire";
}
var ranking=mrank+" / "+players
if (!error && response.statusCode == 200) {
res.render('inf_search_result', {name: jsbody.name, level: jsbody.level, trackId: tId, kart:kartId,rank:ranking,time: diff_time});
}
else{
res.status(response.statusCode).end();
console.log('error = ' + response.statusCode);
}
});
} else {
res.status(response.statusCode).end();
console.log('error = ' + response.statusCode);
......@@ -38,6 +68,6 @@ app.get("/inf",(req,res)=>{
res.render('inf_search_home');
});
app.listen(8080,function(req,res){
app.listen("8080",function(req,res){
console.log('server listening at port no. 8080');
});
\ No newline at end of file
......
......@@ -7,7 +7,7 @@
</head>
<body>
<input type="text" id="name" />
<input type="submit" onClick="location.href='result'" id="OK"/>
<input type="submit" onClick="location.href='inf/result'" id="OK"/>
<script>
$("#OK").click(function(){ // OK 버튼 클릭하면
......
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Hello World!</title>
<!--
<head>
<meta charset="utf-8">
<title>Hello World!</title>
<!--
<link rel="stylesheet" href="/css/master.css" >
-->
</head>
<body>
<h1>유저 정보 출력</h1><br>
<script>
</script>
<span class="aid">USER ID<%= aid %></span><br>
<span class="name">NAME<%= name %></span><br>
<span class="level">LEVEL<%= level %></span>
</body>
<body>
<script language="JavaScript">
var name = '<%-name%>';
var level = '<%-level%>';
var trackId= '<%-trackId%>';
var kart='<%-kart%>';
document.write(name);
document.write("\n");
function Img() {
var a = Math.floor(Math.random() * 9) + 1;
return "main_character/" + a + ".png";
}
function Img2(){
return "level/"+level+".png"
}
function Img3(){
return "track/"+trackId+".png"
}
function Img4(){
return "kart/"+kart+".png"
}
</script>
<img id="imgId" src="" width="135" height="100">
<script>document.getElementById("imgId").src = Img()</script>
<p>레벨</p>
<img id="imgId2" src="">
<script>document.getElementById("imgId2").src = Img2()</script>
<H1>――――――――――――――――경기 정보――――――――――――――</H1>
<p>등수</p>
<span class="rank"><%= rank %></span>
<p>주행 시간</p>
<span class="time"><%= time %></span>
<p>트랙정보</p>
<img id="imgId3" src="">
<script>document.getElementById("imgId3").src = Img3()</script>
<p>카트정보</p>
<img id="imgId4" src="" width="135" height="100">
<script>document.getElementById("imgId4").src = Img4()</script>
</body>
</html>
\ No newline at end of file
......