Showing
3 changed files
with
111 additions
and
5 deletions
| ... | @@ -9,7 +9,7 @@ module.exports = function (app) { | ... | @@ -9,7 +9,7 @@ module.exports = function (app) { |
| 9 | }); | 9 | }); |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | - app.get('tft/search/:username/', function (req, res) { | 12 | + app.get('/tft/search/:username/', function (req, res) { |
| 13 | // tft api url | 13 | // tft api url |
| 14 | const summonerName = req.params.username; | 14 | const summonerName = req.params.username; |
| 15 | var nameUrl = `https://kr.api.riotgames.com/tft/summoner/v1/summoners/by-name/${summonerName}?api_key=${apikey}` | 15 | var nameUrl = `https://kr.api.riotgames.com/tft/summoner/v1/summoners/by-name/${summonerName}?api_key=${apikey}` |
| ... | @@ -18,7 +18,7 @@ module.exports = function (app) { | ... | @@ -18,7 +18,7 @@ module.exports = function (app) { |
| 18 | var info_summoner_json = JSON.parse(body); | 18 | var info_summoner_json = JSON.parse(body); |
| 19 | console.log('summoner', body); | 19 | console.log('summoner', body); |
| 20 | if (info_summoner_json.status?.status_code) { | 20 | if (info_summoner_json.status?.status_code) { |
| 21 | - return res.render('index', { | 21 | + return res.render('index_tft', { |
| 22 | title: req.params.username, | 22 | title: req.params.username, |
| 23 | error_message: info_summoner_json.status?.message | 23 | error_message: info_summoner_json.status?.message |
| 24 | }); | 24 | }); |
| ... | @@ -45,7 +45,7 @@ module.exports = function (app) { | ... | @@ -45,7 +45,7 @@ module.exports = function (app) { |
| 45 | }); | 45 | }); |
| 46 | Promise.all(promiseList).then(matches => { | 46 | Promise.all(promiseList).then(matches => { |
| 47 | console.log('matches', matches); | 47 | console.log('matches', matches); |
| 48 | - res.render('index', { | 48 | + res.render('index_tft', { |
| 49 | title: req.params.username, | 49 | title: req.params.username, |
| 50 | error_message: false, | 50 | error_message: false, |
| 51 | c_matchList: matches, // 게임 데이터, array | 51 | c_matchList: matches, // 게임 데이터, array |
| ... | @@ -54,7 +54,7 @@ module.exports = function (app) { | ... | @@ -54,7 +54,7 @@ module.exports = function (app) { |
| 54 | }); | 54 | }); |
| 55 | }) | 55 | }) |
| 56 | } else { | 56 | } else { |
| 57 | - res.render('index', { | 57 | + res.render('index_tft', { |
| 58 | title: req.params.username, | 58 | title: req.params.username, |
| 59 | error_message: false, | 59 | error_message: false, |
| 60 | c_matchList: [], | 60 | c_matchList: [], |
| ... | @@ -132,7 +132,7 @@ module.exports = function (app) { | ... | @@ -132,7 +132,7 @@ module.exports = function (app) { |
| 132 | champ_pic[j] = temp_pic; | 132 | champ_pic[j] = temp_pic; |
| 133 | } | 133 | } |
| 134 | } | 134 | } |
| 135 | - res.render('index', { title: req.params.username , | 135 | + res.render('index_lol', { title: req.params.username , |
| 136 | c_id: champ_id, | 136 | c_id: champ_id, |
| 137 | c_name: champ_name, | 137 | c_name: champ_name, |
| 138 | c_point: champ_point, | 138 | c_point: champ_point, | ... | ... |
back/views/index_tft.ejs
0 → 100644
| 1 | +<!DOCTYPE html> | ||
| 2 | +<html> | ||
| 3 | + <head> | ||
| 4 | + <meta charset="utf-8"> | ||
| 5 | + <title><%= title %></title> | ||
| 6 | + <link rel="icon" href = "FindMelogo.png"> | ||
| 7 | + <link rel="stylesheet" href="css/style.css"> | ||
| 8 | + <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css"> | ||
| 9 | + <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css"> | ||
| 10 | + <script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script> | ||
| 11 | + <style> @import url("http://fonts.googleapis.com/earlyaccess/nanumgothic.css");</style> | ||
| 12 | + <script> | ||
| 13 | + function search() { | ||
| 14 | + | ||
| 15 | + console.log("---------------------") | ||
| 16 | + var tft_check = $("tft_check").val(); | ||
| 17 | + console.log(tft_check) | ||
| 18 | + | ||
| 19 | + var name = $("input").val(); | ||
| 20 | + if (tft_check == 1) { | ||
| 21 | + location.href = "http://localhost:3000/tft/search/" + name; | ||
| 22 | + | ||
| 23 | + } else { | ||
| 24 | + location.href = "http://localhost:3000/search/" + name; | ||
| 25 | + | ||
| 26 | + } | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + $(document).ready(function(){ | ||
| 30 | + | ||
| 31 | + | ||
| 32 | + $("button#searchButton").click(function(){ | ||
| 33 | + console.log("---------------------") | ||
| 34 | + var tft_check = $("tft_check").val(); | ||
| 35 | + console.log(tft_check) | ||
| 36 | + | ||
| 37 | + var name = $("input").val(); | ||
| 38 | + if (tft_check == 1) { | ||
| 39 | + location.href = "http://localhost:3000/tft/search/" + name; | ||
| 40 | + | ||
| 41 | + } else { | ||
| 42 | + location.href = "http://localhost:3000/search/" + name; | ||
| 43 | + | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + }) | ||
| 47 | + }); | ||
| 48 | + </script> | ||
| 49 | + </head> | ||
| 50 | + <body> | ||
| 51 | + <div class="imgOpacity"> | ||
| 52 | + <div class="center"> | ||
| 53 | + <img src= "/FindMelogo.png" width = 150, height = 150/> | ||
| 54 | + </div> | ||
| 55 | + <div class="center2"> | ||
| 56 | + <input type="text" class="input_text" placeholder="소환사 이름"> | ||
| 57 | + <span class="input-group-btn"> | ||
| 58 | + <button id="searchButton" class="btn btn-primary" type="button" onclick="search(name)">click!</button> | ||
| 59 | + </span> | ||
| 60 | + </div> | ||
| 61 | + </div> | ||
| 62 | + | ||
| 63 | + <br></br> | ||
| 64 | + <% if (error_message) { %> | ||
| 65 | + <h2><%= error_message %></h2> | ||
| 66 | + <% } else { %> | ||
| 67 | + <font size=10em> | ||
| 68 | + <strong> | ||
| 69 | + <%= c_summoner.name + "\n"%> <!-- 소환사 object --> | ||
| 70 | + </strong> | ||
| 71 | + </font> | ||
| 72 | + <table class="table"> | ||
| 73 | + <thead> | ||
| 74 | + <tr> | ||
| 75 | + <th>Tier</th> | ||
| 76 | + <th>Win</th> | ||
| 77 | + <th>Lose</th> | ||
| 78 | + <th>승률</th> | ||
| 79 | + <th>캐리력</th> | ||
| 80 | + </tr> | ||
| 81 | + </thead> | ||
| 82 | + <% if (c_leagueList.length>0) { %> | ||
| 83 | + <tbody> | ||
| 84 | + <% | ||
| 85 | + c_leagueList.forEach(function(league){ %> | ||
| 86 | + <tr> | ||
| 87 | + <td><%= league.tier + " " + league.rank + " / " + league.leaguePoints + "점"%></td> | ||
| 88 | + <td><%= league.wins %></td> | ||
| 89 | + <td><%= league.losses %></td> | ||
| 90 | + <td><%= ((league.wins/(league.wins+league.losses))*100).toFixed(2) + "%" %></td> | ||
| 91 | + <td><%= (league.wins/league.losses*2).toFixed(2) %></td> | ||
| 92 | + </tr> | ||
| 93 | + <% }); %> | ||
| 94 | + </tbody> | ||
| 95 | + <% } else { %> | ||
| 96 | + <tbody> | ||
| 97 | + <tr > | ||
| 98 | + <td colspan="5" style="text-align: center;">no league</td> | ||
| 99 | + </tr> | ||
| 100 | + </tbody> | ||
| 101 | + <% } %> | ||
| 102 | + </table> | ||
| 103 | + <% } %> | ||
| 104 | + </div> | ||
| 105 | +</body> | ||
| 106 | +</html> |
-
Please register or login to post a comment