Showing
12 changed files
with
267 additions
and
0 deletions
RUTROLL/2012104105_윤태양.pptx
0 → 100644
No preview for this file type
RUTROLL/app.js
0 → 100644
| 1 | +var express = require('express'); | ||
| 2 | +var app = express(); | ||
| 3 | +var router = require('./router/main')(app); | ||
| 4 | +var bodyParser = require('body-parser'); | ||
| 5 | + | ||
| 6 | +app.set('views', __dirname + '/views'); | ||
| 7 | +app.set('view engine', 'ejs'); | ||
| 8 | +app.engine('html', require('ejs').renderFile); | ||
| 9 | + | ||
| 10 | +var server = app.listen(3000, function(){ | ||
| 11 | + console.log('on'); | ||
| 12 | +}); | ||
| 13 | + | ||
| 14 | +app.use(express.static('public')); |
RUTROLL/images/i0215543216.jpg
0 → 100644
518 KB
RUTROLL/images/logo.png
0 → 100644
22.8 KB
RUTROLL/images/main.jpg
0 → 100644
285 KB
RUTROLL/images/teemo.png
0 → 100644
2.86 KB
RUTROLL/images/yasuo.png
0 → 100644
1.88 KB
RUTROLL/package.json
0 → 100644
| 1 | +{ | ||
| 2 | + "name": "yoon", | ||
| 3 | + "version": "1.0.0", | ||
| 4 | + "description": "", | ||
| 5 | + "main": "App.js", | ||
| 6 | + "dependencies": { | ||
| 7 | + "ejs": "^2.6.1", | ||
| 8 | + "express": "^4.16.3", | ||
| 9 | + "urlencode": "^1.1.0" | ||
| 10 | + }, | ||
| 11 | + "devDependencies": {}, | ||
| 12 | + "scripts": { | ||
| 13 | + "test": "echo \"Error: no test specified\" && exit 1" | ||
| 14 | + }, | ||
| 15 | + "author": "", | ||
| 16 | + "license": "ISC" | ||
| 17 | +} |
RUTROLL/public/css/style.css
0 → 100644
| 1 | + | ||
| 2 | +body{ | ||
| 3 | + width:100vw; | ||
| 4 | + height:100vh; | ||
| 5 | + | ||
| 6 | + background-size:auto; | ||
| 7 | +} | ||
| 8 | + | ||
| 9 | + | ||
| 10 | +.imgOpacity{ | ||
| 11 | + width:100vw; | ||
| 12 | + height:100vh; | ||
| 13 | + | ||
| 14 | + background: #fff; | ||
| 15 | + color: white; | ||
| 16 | + color:rgba(1,1,1,1); | ||
| 17 | +} | ||
| 18 | +.header{ | ||
| 19 | + width:100vw; | ||
| 20 | + height:5vh; | ||
| 21 | + display:flex; | ||
| 22 | + align-items:center; | ||
| 23 | + | ||
| 24 | + justify-content:space-around; | ||
| 25 | + | ||
| 26 | +} | ||
| 27 | +.center{ | ||
| 28 | + width:100vw; | ||
| 29 | + height:50vh; | ||
| 30 | + display:flex; | ||
| 31 | + align-items:center; | ||
| 32 | + justify-content:space-around; | ||
| 33 | +} | ||
| 34 | + | ||
| 35 | +.empty{ | ||
| 36 | + width:50vw; | ||
| 37 | + height:30vh; | ||
| 38 | + display:flex; | ||
| 39 | + align-items:center; | ||
| 40 | + justify-content:space-around; | ||
| 41 | +} | ||
| 42 | + | ||
| 43 | +.center2{ | ||
| 44 | + width:100vw; | ||
| 45 | + height:1vh; | ||
| 46 | + display:flex; | ||
| 47 | + align-items:center; | ||
| 48 | + justify-content:space-around; | ||
| 49 | +} |
RUTROLL/router/main.js
0 → 100644
| 1 | +module.exports = function(app){ | ||
| 2 | + | ||
| 3 | +var request = require("request"); | ||
| 4 | +var urlenconde = require('urlencode'); | ||
| 5 | +var apikey = "RGAPI-67430017-718e-4456-8446-94bf05fb39ec"//api | ||
| 6 | + | ||
| 7 | +var profileIconId; //아이콘 번호 | ||
| 8 | +var revisionDate; //수정날짜 | ||
| 9 | +var id; //소환사ID | ||
| 10 | +var accountId; //계정Id | ||
| 11 | +var name; //소환사 이름 | ||
| 12 | +var summonerLevel; //소환사 레벨 | ||
| 13 | + | ||
| 14 | +var startIndex; | ||
| 15 | +var endIndex; | ||
| 16 | +var totalGames; | ||
| 17 | +var matches; //경기정보 | ||
| 18 | + | ||
| 19 | + app.get('/', function(req, res) { | ||
| 20 | + res.render('main', { title: 'R U TROLL?' }); | ||
| 21 | + }); | ||
| 22 | + | ||
| 23 | + app.get('/search/:username/', function(req, res){ | ||
| 24 | + //롤 api url | ||
| 25 | + name = req.params.username; | ||
| 26 | + var nameUrl = "https://kr.api.riotgames.com/lol/summoner/v3/summoners/by-name/" + urlenconde(name)+"?api_key="+ apikey; | ||
| 27 | + request(nameUrl,function(error,response,body){ | ||
| 28 | + var info_summoner_json = JSON.parse(body); | ||
| 29 | + | ||
| 30 | + accountId = info_summoner_json["accountId"]; | ||
| 31 | + id = info_summoner_json["id"]; | ||
| 32 | + summoner = info_summoner_json["name"]; | ||
| 33 | + profileIconId = info_summoner_json["profileIconId"]; | ||
| 34 | + summonerLevel = info_summoner_json["summonerLevel"]; | ||
| 35 | + revisionDate = info_summoner_json["revisionDate"]; | ||
| 36 | + | ||
| 37 | + var rankedUrl = "https://kr.api.pvp.net/api/lol/kr/v2.5/league/by-summoner/"+ urlenconde(id)+ "?api_key=" + apikey; | ||
| 38 | + var champUrl = "https://kr.api.pvp.net/api/lol/kr/v1.3/stats/by-summoner/" + urlenconde(id) + "/ranked?api_key=" + apikey; | ||
| 39 | + request(champUrl,function(error,response,body){ | ||
| 40 | + var info_champ_json = JSON.parse(body); | ||
| 41 | + var champions = info_champ_json["champions"]; | ||
| 42 | + var champ_point = new Array(); | ||
| 43 | + var champ_id = new Array(); | ||
| 44 | + var champ_name = new Array(); | ||
| 45 | + var champ_pic = new Array(); | ||
| 46 | + var champions_length = Object.keys(champions).length; | ||
| 47 | + | ||
| 48 | + for(var i=0; i < champions_length; i++){ | ||
| 49 | + champ_point[i] = (champions[i]["stats"]["totalSessionsWon"]/champions[i]["stats"]["totalSessionsPlayed"]*200) | ||
| 50 | + + ((champions[i]["stats"]["totalAssists"]+champions[i]["stats"]["totalChampionKills"])/champions[i]["stats"]["totalDeathsPerSession"]*100) | ||
| 51 | + + (champions[i]["stats"]["totalSessionsPlayed"]*3); | ||
| 52 | + champ_id[i] = champions[i]["id"]; | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + var staticUrl = "https://global.api.pvp.net/api/lol/static-data/kr/v1.2/champion/?api_key=" + apikey; | ||
| 56 | + request(staticUrl,function(error,response,body){ | ||
| 57 | + var info_static_champ_json = JSON.parse(body); | ||
| 58 | + var champion = info_static_champ_json["data"]; | ||
| 59 | + for(var i=0; i < champ_id.length; i++){ | ||
| 60 | + for(js in champion){ | ||
| 61 | + for(j in champion[js]){ | ||
| 62 | + if(champion[js]["id"] == champ_id[i]){ | ||
| 63 | + champ_name[i] = champion[js]["key"]; | ||
| 64 | + champ_pic[i] = "https://opgg-static.akamaized.net/images/lol/champion/"+champ_name[i]+".png?image=c_scale,w_46"; | ||
| 65 | + } | ||
| 66 | + } | ||
| 67 | + } | ||
| 68 | + } | ||
| 69 | + champ_name[champ_name.length] = "total"; | ||
| 70 | + var temp_id; | ||
| 71 | + var temp_name; | ||
| 72 | + var temp_point; | ||
| 73 | + var temp_pic; | ||
| 74 | + for(var i=0; i < champ_id.length-1; i++){ | ||
| 75 | + for(var j=i+1;j <champ_id.length-1; j++) | ||
| 76 | + if(champ_point[i] > champ_point[j]){ | ||
| 77 | + temp_id = champ_id[i]; | ||
| 78 | + temp_name = champ_name[i]; | ||
| 79 | + temp_point = champ_point[i]; | ||
| 80 | + temp_pic = champ_pic[i]; | ||
| 81 | + champ_id[i] = champ_id[j] | ||
| 82 | + champ_name[i] = champ_name[j]; | ||
| 83 | + champ_point[i] = champ_point[j]; | ||
| 84 | + champ_pic[i] = champ_pic[j]; | ||
| 85 | + champ_id[j] = temp_id | ||
| 86 | + champ_name[j] = temp_name; | ||
| 87 | + champ_point[j] = temp_point; | ||
| 88 | + champ_pic[j] = temp_pic; | ||
| 89 | + } | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + res.render('index', { title: req.params.username , | ||
| 93 | + c_id: champ_id, | ||
| 94 | + c_name: champ_name, | ||
| 95 | + c_point: champ_point, | ||
| 96 | + c_pic: champ_pic, | ||
| 97 | + c_summoner: summoner | ||
| 98 | + }); | ||
| 99 | + }); | ||
| 100 | + }); | ||
| 101 | + }); | ||
| 102 | + }); | ||
| 103 | +}; |
RUTROLL/views/index.ejs
0 → 100644
| 1 | +<!DOCTYPE html> | ||
| 2 | +<html> | ||
| 3 | + <head> | ||
| 4 | + <meta charset="utf-8"> | ||
| 5 | + <title><%= title %></title> | ||
| 6 | + <link rel="stylesheet" href="css/style.css"> | ||
| 7 | + <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css"> | ||
| 8 | + <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css"> | ||
| 9 | + <script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script> | ||
| 10 | + <style> @import url("http://fonts.googleapis.com/earlyaccess/nanumgothic.css");</style> | ||
| 11 | + <script> | ||
| 12 | + $(document).ready(function(){ | ||
| 13 | + | ||
| 14 | + | ||
| 15 | + $("button#searchButton").click(function(){ | ||
| 16 | + var name = $("input").val(); | ||
| 17 | + alert(name); | ||
| 18 | + location.href = "http://127.0.0.1:3000/search/" + name; | ||
| 19 | + }) | ||
| 20 | + }); | ||
| 21 | + </script> | ||
| 22 | + </head> | ||
| 23 | + <body> | ||
| 24 | + <div class="imgOpacity"> | ||
| 25 | + <div class="center"> | ||
| 26 | + <img src="http://postfiles5.naver.net/MjAxNzA1MTRfMjYz/MDAxNDk0NjkzMzQyMjA1.q2Lr8tHc36PRcyVYhCplqB4J868vV67CQr8l1MSduCkg.sfF_kI6oJZpMdOeKzFucmZXRoQXuSOI4M1IZhMPTp30g.PNG.yoonty21/logo.png?type=w580"> | ||
| 27 | + </div> | ||
| 28 | + <div class="center2"> | ||
| 29 | + <input type="text" class="input_text" placeholder="소환사 이름"> | ||
| 30 | + <span class="input-group-btn"> | ||
| 31 | + <button id="searchButton" class="btn btn-primary" type="button" onclick="search(name)">검색!</button> | ||
| 32 | + </span> | ||
| 33 | + </div> | ||
| 34 | + <div class="center2"> | ||
| 35 | + <%= c_summoner %> | ||
| 36 | + <%= "트롤력" %> | ||
| 37 | + <%= "point: " + 1000000/c_point[c_id.length-1] %> | ||
| 38 | + </div> | ||
| 39 | + <% for (var i=0; i<c_id.length-1; i++){ %> | ||
| 40 | + <div class="center2"> | ||
| 41 | + <img src= <%=c_pic[i]%> > | ||
| 42 | + <%= c_name[i] %> | ||
| 43 | + <%= "point: " + 1000000/c_point[i] %> | ||
| 44 | + <% } %> | ||
| 45 | + </div> | ||
| 46 | +</div> | ||
| 47 | +</body> | ||
| 48 | +</html> |
RUTROLL/views/main.ejs
0 → 100644
| 1 | +<!DOCTYPE html> | ||
| 2 | +<html> | ||
| 3 | + <head> | ||
| 4 | + <meta charset="utf-8"> | ||
| 5 | + <title><%= title %></title> | ||
| 6 | + <link rel="stylesheet" href="css/style.css"> | ||
| 7 | + <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css"> | ||
| 8 | + <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css"> | ||
| 9 | + <script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script> | ||
| 10 | + <style> @import url("http://fonts.googleapis.com/earlyaccess/nanumgothic.css");</style> | ||
| 11 | + <script> | ||
| 12 | + $(document).ready(function(){ | ||
| 13 | + | ||
| 14 | + | ||
| 15 | + $("button#searchButton").click(function(){ | ||
| 16 | + var name = $("input").val(); | ||
| 17 | + alert(name); | ||
| 18 | + location.href = "http://127.0.0.1:3000/search/" + name; | ||
| 19 | + }) | ||
| 20 | + }); | ||
| 21 | + </script> | ||
| 22 | + </head> | ||
| 23 | + <body> | ||
| 24 | + <div class="imgOpacity"> | ||
| 25 | + <div class="center"> | ||
| 26 | + <img src="http://postfiles5.naver.net/MjAxNzA1MTRfMjYz/MDAxNDk0NjkzMzQyMjA1.q2Lr8tHc36PRcyVYhCplqB4J868vV67CQr8l1MSduCkg.sfF_kI6oJZpMdOeKzFucmZXRoQXuSOI4M1IZhMPTp30g.PNG.yoonty21/logo.png?type=w580"> | ||
| 27 | + </div> | ||
| 28 | + <div class="center2"> | ||
| 29 | + <input type="text" class="input_text" placeholder="소환사 이름"> | ||
| 30 | + <span class="input-group-btn"> | ||
| 31 | + <button id="searchButton" class="btn btn-primary" type="button" onclick="search(name)">검색!</button> | ||
| 32 | + </span> | ||
| 33 | + </div> | ||
| 34 | + </div> | ||
| 35 | +</body> | ||
| 36 | +</html> |
-
Please register or login to post a comment