서주원

Publish result.html and Implement rendering

......@@ -2,11 +2,16 @@ const puppeteer=require('puppeteer');
const cheerio=require('cheerio');
exports.getDecks=(cardIds)=>{
let idInQuery=cardIds[0]
for(let i=1;i<cardIds.length;i++){
idInQuery+= '%2C'+cardIds[i]
console.log('cardIds in crawlerMulligan ',cardIds)
cardIds=JSON.stringify(cardIds)
cardIds=JSON.parse(cardIds)
console.log('stringified cardIds in crawlerMulligan ',cardIds)
console.log(cardIds[0])
let idInQuery=cardIds[0].cardId
for(let i=1;i<cardIds.length && i<10;i++){
idInQuery+= '%2C'+cardIds[i].cardId
}
console.log('idInQuery in crawlerMulligan ',idInQuery)
const getContent=()=>{
return new Promise((resolve,reject)=>{
const asyncFunc=async ()=>{
......@@ -30,51 +35,58 @@ exports.getDecks=(cardIds)=>{
}
const getDeckHref=(content)=>{
const $=cheerio.load(content)
let deck=$('#decks-container > div > main > div.deck-list > ul > li:nth-child(2)').find('a')
const deckHref=$(deck).attr('href')
return deckHref
return new Promise((resolve,reject)=>{
const $=cheerio.load(content)
let deck=$('#decks-container > div > main > div.deck-list > ul > li:nth-child(2)').find('a')
const deckHref=$(deck).attr('href')
console.log('deckHref in crawlerMulligan :',deckHref)
resolve(deckHref)
})
}
const getDeckConetent=(href)=>{
const asyncFunc=async ()=>{
const browser=await puppeteer.launch()
try{
const page=await browser.newPage()
await page.setViewport({width:1366,height:768})
await page.goto(`https://hsreplay.net${href}?hl=ko`,{waitUntil: 'networkidle2'})
const content=await page.content()
browser.close()
return content
}
catch(err)
{
console.log(err)
browser.close()
const getDeckContent=(href)=>{
return new Promise((resolve,reject)=>{
const asyncFunc=async ()=>{
const browser=await puppeteer.launch()
try{
const page=await browser.newPage()
await page.setViewport({width:1366,height:768})
await page.goto(`https://hsreplay.net${href}?hl=ko`,{waitUntil: 'networkidle2'})
const content=await page.content()
browser.close()
return content
}
catch(err)
{
console.log(err)
browser.close()
}
}
}
return asyncFunc()
resolve(asyncFunc())
})
}
const getMulligan=(content)=>{
const $=cheerio.load(content)
let cardNames=$('.card-name')
let cardWinRates=$('.table-cell')
let cards=[]
for(let i=0;i<cardNames.length;i++){
let cardName=$(cardNames[i]).text()
let cardWinRate=$(cardWinRates[6*i]).text()
cardWinRate=cardWinRate.replace('▼','')
cardWinRate=cardWinRate.replace('▲','')
cardWinRate=cardWinRate.replace('%','')
cards.push({cardName:cardName,cardWinRate:cardWinRate})
}
cards.sort((a,b)=>{
return a.cardWinRate<b.cardWinRate ? 1:-1
return new Promise((resolve,reject)=>{
const $=cheerio.load(content)
let cardNames=$('.card-name')
let cardWinRates=$('.table-cell')
let cards=[]
for(let i=0;i<cardNames.length;i++){
let cardName=$(cardNames[i]).text()
let cardWinRate=$(cardWinRates[6*i]).text()
cardWinRate=cardWinRate.replace('▼','')
cardWinRate=cardWinRate.replace('▲','')
cardWinRate=cardWinRate.replace('%','')
cards.push({cardName:cardName,cardWinRate:cardWinRate})
}
cards.sort((a,b)=>{
return a.cardWinRate<b.cardWinRate ? 1:-1
})
console.log(cards)
resolve(cards)
})
console.log(cards)
}
getContent()
.then(getDeckHref)
.then(getDeckConetent)
.then(getDeckContent)
.then(getMulligan)
}
......
......@@ -26,17 +26,19 @@ exports.getDecks=(opponentClass)=>{
}
const getDeckInfo=(content)=>{
const $=cheerio.load(content)
let deckNames=$('.deck-name')
let deckGames=$('.game-count')
let decks=[]
for(let i=0;i<3;i++){
let deckName=$(deckNames[i]).text()
let deckGame=$(deckGames[i]).text()
decks.push({deckTitle:deckName,deckGame:deckGame})
}
console.log(decks)
return decks
return new Promise((resolve,reject)=>{
const $=cheerio.load(content)
let deckNames=$('.deck-name')
let deckGames=$('.game-count')
let decks=[]
for(let i=0;i<3;i++){
let deckName=$(deckNames[i]).text()
let deckGame=$(deckGames[i]).text()
decks.push({deckTitle:deckName,deckGame:deckGame})
}
console.log(decks)
resolve(decks)
})
}
getContent()
.then(getDeckInfo)
......
const crawler=require('./crawlerMulligan')
const getCardId=require('./getCardId')
const puppeteer=require('puppeteer')
const cheerio=require('cheerio')
exports.GetMulligan=(req,res)=>{
const deckId=req.session.deckId || 113
const opponentClass=req.body.class || 'PALADIN'
console.log('deckId in getMulligan',deckId)
const opponentClass=req.session.opponentClass || 'PALADIN'
console.log('opponentClass in getMulligan',opponentClass)
const DataCheck=()=>{
return new Promise((resolve,reject)=>{
if (!deckId || !opponentClass){
......@@ -21,13 +26,101 @@ exports.GetMulligan=(req,res)=>{
const CrawlerMulligan=(cardIds)=>{
return crawler.getDecks(cardIds)
}
const GetContent=(cardIds)=>{
cardIds=JSON.stringify(cardIds)
cardIds=JSON.parse(cardIds)
let idInQuery=cardIds[0].cardId
for(let i=1;i<cardIds.length ;i++){
idInQuery+= '%2C'+cardIds[i].cardId
}
console.log('idInQuery in crawlerMulligan ',idInQuery)
return new Promise((resolve,reject)=>{
const asyncFunc=async ()=>{
const browser=await puppeteer.launch()
try{
const page=await browser.newPage()
await page.setViewport({width:1366,height:768})
await page.goto(`https://hsreplay.net/decks/#timeRange=LAST_30_DAYS&includedCards=${idInQuery}`,{waitUntil: 'networkidle2'})
const content=await page.content()
browser.close()
return content
}
catch(err)
{
console.log(err)
browser.close()
}
}
resolve(asyncFunc())
})
}
const GetDeckHref=(content)=>{
return new Promise((resolve,reject)=>{
const $=cheerio.load(content)
let deck=$('#decks-container > div > main > div.deck-list > ul > li:nth-child(2)').find('a')
const deckHref=$(deck).attr('href')
console.log('deckHref in crawlerMulligan :',deckHref)
resolve(deckHref)
})
}
const GetDeckContent=(href)=>{
return new Promise((resolve,reject)=>{
const asyncFunc=async ()=>{
const browser=await puppeteer.launch()
try{
const page=await browser.newPage()
await page.setViewport({width:1366,height:768})
await page.goto(`https://hsreplay.net${href}?hl=ko`,{waitUntil: 'networkidle2'})
const content=await page.content()
browser.close()
return content
}
catch(err)
{
console.log(err)
browser.close()
}
}
resolve(asyncFunc())
})
}
const GetMulligan=(content)=>{
return new Promise((resolve,reject)=>{
const $=cheerio.load(content)
let cardNames=$('.card-name')
let cardWinRates=$('.table-cell')
let cards=[]
for(let i=0;i<cardNames.length;i++){
let cardName=$(cardNames[i]).text()
let cardWinRate=$(cardWinRates[6*i]).text()
cardWinRate=cardWinRate.replace('▼','')
cardWinRate=cardWinRate.replace('▲','')
cardWinRate=cardWinRate.replace('%','')
cards.push({cardName:cardName,cardWinRate:cardWinRate})
}
cards.sort((a,b)=>{
return a.cardWinRate<b.cardWinRate ? 1:-1
})
console.log(cards)
resolve(cards)
})
}
DataCheck()
.then(GetCardId)
.then(CrawlerMulligan)
//.then(CrawlerMulligan)
.then(GetContent)
.then(GetDeckHref)
.then(GetDeckContent)
.then(GetMulligan)
.then((cards)=>{
res.status(200).json(cards)
return new Promise((resolve,reject)=>{
console.log('cards in getMulligan : ',cards)
resolve(cards)
})
})
.catch((err)=>{
res.status(500).json(err)
console.log(err)
})
}
\ No newline at end of file
......
const request=require('request')
const iconv=require('iconv-lite')
const charset=require('charset')
const crawler=require('./crawlerOpponent')
const puppeteer=require('puppeteer')
const cheerio=require('cheerio')
exports.GetOpponent=(req,res)=>{
const opponentClass=req.body.class
const opponentClass=req.session.opponentClass
const DataCheck=()=>{
return new Promise((resolve,reject)=>{
if(!opponentClass){
......@@ -16,15 +15,57 @@ exports.GetOpponent=(req,res)=>{
resolve()
})
}
const CralwerOpponent=()=>{
const CrawlerOpponent=()=>{
return crawler.getDecks(opponentClass)
}
DataCheck
.then(CralwerOpponent)
const GetContent=()=>{
return new Promise((resolve,reject)=>{
const asyncFunc=async ()=>{
const browser=await puppeteer.launch()
try{
const page=await browser.newPage()
await page.setViewport({width:1366,height:768})
await page.goto(`https://hsreplay.net/decks/#timeRange=LAST_30_DAYS&playerClasses=${opponentClass}?hl=ko`,{waitUntil: 'networkidle2'})
const content=await page.content()
browser.close()
return content
}
catch(err)
{
console.log(err)
browser.close()
}
}
resolve(asyncFunc())
})
}
const GetDeckInfo=(content)=>{
return new Promise((resolve,reject)=>{
const $=cheerio.load(content)
let deckNames=$('.deck-name')
let deckGames=$('.game-count')
let decks=[]
for(let i=0;i<3;i++){
let deckName=$(deckNames[i]).text()
let deckGame=$(deckGames[i]).text()
decks.push({deckTitle:deckName,deckGame:deckGame})
}
console.log(decks)
resolve(decks)
})
}
DataCheck()
//.then(CrawlerOpponent)
.then(GetContent)
.then(GetDeckInfo)
.then((decks)=>{
res.status(200).json(decks)
return new Promise((resolve,reject)=>{
console.log('decks in getOpponent: ',decks)
resolve(decks)
})
})
.catch((err)=>{
res.status(500).json(err)
console.log(err)
})
}
\ No newline at end of file
......
const crawler=require('./crawlerMulligan')
const getCardId=require('./getCardId')
const puppeteer=require('puppeteer')
const cheerio=require('cheerio')
const fs=require('fs')
const ejs=require('ejs')
let globalMulligan
let globalDecks
exports.GetResult=(req,res)=>{
const deckId=req.session.deckId || 113
console.log('deckId in getMulligan',deckId)
const opponentClass=req.session.opponentClass || 'PALADIN'
console.log('opponentClass in getMulligan',opponentClass)
const DataCheck=()=>{
return new Promise((resolve,reject)=>{
if (!deckId || !opponentClass){
return reject({
code:'query_error',
message:'query error',
})
}
resolve()
})
}
const GetCardId=()=>{
return getCardId.GetCardId(deckId)
}
const GetMulContent=(cardIds)=>{
cardIds=JSON.stringify(cardIds)
cardIds=JSON.parse(cardIds)
let idInQuery=cardIds[0].cardId
for(let i=1;i<cardIds.length ;i++){
idInQuery+= '%2C'+cardIds[i].cardId
}
console.log('idInQuery in crawlerMulligan ',idInQuery)
return new Promise((resolve,reject)=>{
const asyncFunc=async ()=>{
const browser=await puppeteer.launch()
try{
const page=await browser.newPage()
await page.setViewport({width:1366,height:768})
await page.goto(`https://hsreplay.net/decks/#timeRange=LAST_30_DAYS&includedCards=${idInQuery}`,{waitUntil: 'networkidle2'})
const content=await page.content()
browser.close()
return content
}
catch(err)
{
console.log(err)
browser.close()
}
}
resolve(asyncFunc())
})
}
const GetDeckHref=(content)=>{
return new Promise((resolve,reject)=>{
const $=cheerio.load(content)
let deck=$('#decks-container > div > main > div.deck-list > ul > li:nth-child(2)').find('a')
const deckHref=$(deck).attr('href')
console.log('deckHref in crawlerMulligan :',deckHref)
resolve(deckHref)
})
}
const GetDeckContent=(href)=>{
return new Promise((resolve,reject)=>{
const asyncFunc=async ()=>{
const browser=await puppeteer.launch()
try{
const page=await browser.newPage()
await page.setViewport({width:1366,height:768})
await page.goto(`https://hsreplay.net${href}?hl=ko`,{waitUntil: 'networkidle2'})
const content=await page.content()
browser.close()
return content
}
catch(err)
{
console.log(err)
browser.close()
}
}
resolve(asyncFunc())
})
}
const GetMulligan=(content)=>{
return new Promise((resolve,reject)=>{
const $=cheerio.load(content)
let cardNames=$('.card-name')
let cardWinRates=$('.table-cell')
let cards=[]
for(let i=0;i<cardNames.length;i++){
let cardName=$(cardNames[i]).text()
let cardWinRate=$(cardWinRates[6*i]).text()
cardWinRate=cardWinRate.replace('▼','')
cardWinRate=cardWinRate.replace('▲','')
cardWinRate=cardWinRate.replace('%','')
cards.push({cardName:cardName,cardWinRate:cardWinRate})
}
cards.sort((a,b)=>{
return a.cardWinRate<b.cardWinRate ? 1:-1
})
resolve(cards)
})
}
const GetOppContent=()=>{
return new Promise((resolve,reject)=>{
const asyncFunc=async ()=>{
const browser=await puppeteer.launch()
try{
const page=await browser.newPage()
await page.setViewport({width:1366,height:768})
await page.goto(`https://hsreplay.net/decks/#playerClasses=${opponentClass}`,{waitUntil: 'networkidle2'})
const content=await page.content()
browser.close()
return content
}
catch(err)
{
console.log(err)
browser.close()
}
}
resolve(asyncFunc())
})
}
const GetDeckInfo=(content)=>{
return new Promise((resolve,reject)=>{
const $=cheerio.load(content)
let deckNames=$('.deck-name')
let deckGames=$('.game-count')
let decks=[]
for(let i=0;decks.length<3;i++) {
let deckName = $(deckNames[i]).text()
let deckGame = $(deckGames[i]).text()
let j=0
for(;j<decks.length;j++){
if(deckName===decks[j].deckTitle)
break
}
if(j===decks.length){
decks.push({deckTitle:deckName,deckGame:deckGame})
}
}
console.log(decks)
resolve(decks)
})
}
DataCheck()
.then(GetCardId)
//.then(CrawlerMulligan)
.then(GetMulContent)
.then(GetDeckHref)
.then(GetDeckContent)
.then(GetMulligan)
.then((cards)=>{
return new Promise((resolve,reject)=>{
globalMulligan=cards
resolve()
})
})
.then(GetOppContent)
.then(GetDeckInfo)
.then((decks)=>{
return new Promise((resolve,reject)=>{
globalDecks=decks
resolve()
})
})
.then(()=>{
return new Promise((resolve,reject)=>{
let result={}
result.cards=globalMulligan
result.decks=globalDecks
resolve(result)
})
})
.then((result)=>{
console.log('result: ',result)
fs.readFile('./views/ejs/result.ejs','utf-8',(err,data)=>{
res.writeHead(200,{'Content-Type':'text/html'})
res.end(ejs.render(data,{
cards:globalMulligan || [],
decks:globalDecks || [],
}))
})
})
.catch((err)=>{
console.log(err)
})
}
\ No newline at end of file
......@@ -2,7 +2,11 @@ const express=require('express')
const router=express.Router()
const getMulligan=require('./getMulligan')
const getOpponent=require('./getOpponent')
const setOpponentClass=require('./setOpponentClass')
router.post('/getmulligan',getMulligan.GetMulligan)
router.get('/getmulligan',getMulligan.GetMulligan)
router.get('/getopponent',getOpponent.GetOpponent)
router.post('/setopponentclass',setOpponentClass.SetOpponentClass)
module.exports=router
\ No newline at end of file
......
exports.SetOpponentClass=(req,res)=>{
const opponentClass=req.body.opponentClass
const DataCheck=()=>{
return new Promise((resolve,reject)=>{
if(!opponentClass){
reject(({
query:'request_body_error'
}))
}
else resolve()
})
}
const Set=()=>{
req.session.opponentClass=req.body.opponentClass
return
}
DataCheck()
.then(Set)
.then(()=>{
res.status(200).json({message:'complete setting opponent class'})
})
.catch((err)=>{
res.status(500).json(err||err.message)
})
}
\ No newline at end of file
......@@ -46,20 +46,9 @@ app.use(session({
}))
app.get('/',(req,res)=>{
res.redirect('/main')
res.redirect('/decklist')
})
app.get('/main',(req,res)=>{
console.log(`GET /main\ncurrent sid : ${req.session.sid}`)
if(!req.session.sid)
res.redirect('/login')
else {
fs.readFile('./views/html/main.html',(err,data)=>{
res.writeHead(200, {'Content-Type': 'text/html'})
res.end(data)
})
}
})
app.get('/signup',(req,res)=>{
fs.readFile('./views/html/signup.html',(err,data)=>{
......@@ -77,6 +66,7 @@ app.get('/login',(req,res)=>{
app.post('/logout',(req,res)=>{
console.log('logout')
delete req.session.deckId
delete req.session.sid
res.status(200).json({result:'Logout Successful'})
})
......@@ -106,10 +96,11 @@ app.get('/decklist',(req,res)=>{
})
app.get('/ingame',(req,res)=>{
app.get('/ingame/:deckId',(req,res)=>{
if(!req.session.sid)
res.redirect('/login')
else{
req.session.deckId=req.params.deckId
fs.readFile('./views/html/ingame.html',(err,data)=>{
res.writeHead(200,{'Content-Type':'text/html'})
res.end(data)
......@@ -127,7 +118,56 @@ app.get('/newdeck',(req,res)=>{
res.end(data)
})
}
})
const getMulligan=require('./api/card/getMulligan')
const getOpponent=require('./api/card/getOpponent')
const getResult=require('./api/card/getResult')
app.get('/result',(req,res)=>{
if(!req.session.sid)
res.redirect('/login')
else{
let mulligan
let opponentDecks;
(async ()=>{
const result=await getResult.GetResult(req,res)
console.log('hsreplay.net에서 받아오는 중')
/*setTimeout(function(){
console.log('result: ',result)
fs.readFile('./views/html/result.ejs',(err,data)=>{
res.writeHead(200,{'Content-Type':'text/html'})
res.end(ejs.render(data,{
cards:result.cards || [],
decks:result.decks || [],
}))
})
},30000)*/
})()
const GetInfo=async ()=>{
return getResult.GetResult(req,res)
}
const GetCards=()=>{
return getMulligan.GetMulligan(req,res)
}
const GetDecks=(cards)=>{
mulligan=cards
return getOpponent.GetOpponent(req,res)
}
const Render=async (result)=>{
mulligan=result.cards
opponentDecks=result.decks
setTimeout(function(){
fs.readFile('./views/html/result.ejs',(err,data)=>{
res.writeHead(200,{'Content-Type':'text/html'})
res.end(ejs.render(data,{
cards:mulligan || [],
decks:opponentDecks || [],
}))
})
},1000)
}
}
})
app.listen(process.env.SERVER_PORT || 3000,()=>{
......
......@@ -24,7 +24,7 @@
url:'/logout',
success:function(result){
alert('로그아웃 성공!')
window.location.href='/main'
window.location.href='/'
},
error:function(result){
alert('로그아웃 실패!')
......@@ -67,7 +67,7 @@
<br>
<table class="table">
<% for ( var i=0;i<decks.length;i++) { %>
<tr><td style="text-align: center;"><a class="list-group-item" href="/ingame?deck=<%= decks[i].id %>"><%= decks[i].deckTitle %></a></td></tr>
<tr><td style="text-align: center;"><a class="list-group-item" href="/ingame/<%= decks[i].id %>"><%= decks[i].deckTitle %></a></td></tr>
<% } %>
</table>
</div>
......
......@@ -15,7 +15,6 @@
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
......@@ -33,53 +32,89 @@
}
})
})
$('#backToSelectOpponent').click(function(){
window.history.back()
})
})
</script>
</head>
<body>
<nav class="navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button class="navbar-toggle collapsed" aria-expanded="false" aria-controls="navbar" type="button" data-toggle="collapse" data-target="#navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/main">Who Are You?</a>
</div>
<div class="navbar-collapse collapse" id="navbar" aria-expanded="false" style="height: 1px;">
<ul class="nav navbar-nav">
</ul>
<div class="navbar-right">
<input type="button" class="btn navbar-btn" id="logoutButton" style="color:#000;" value="로그아웃" />
<nav class="navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button class="navbar-toggle collapsed" aria-expanded="false" aria-controls="navbar" type="button" data-toggle="collapse" data-target="#navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">Who Are You?</a>
</div>
<div class="navbar-collapse collapse" id="navbar" aria-expanded="false" style="height: 1px;">
<ul class="nav navbar-nav">
</ul>
<div class="navbar-right">
<input type="button" class="btn navbar-btn" id="logoutButton" style="color:#000;" value="로그아웃" />
</div>
</div>
</div>
</div>
</nav>
</nav>
<div class="container show-grid" style="height:50%;">
<div class="padding"></div>
<h3 class="form-signin-heading">실행할 메뉴를 선택해 주세요</h3>
<div class="col-md-6 ">
<br>
<br>
<a href="/decklist"><input class="btn btn-lg btn-primary btn-block" type="button" id="goMyDecks" value="덱 확인"/></a>
<div class="container show-grid" >
<div class="padding" style="width:100px"></div>
<br>
<br>
</div>
<div class="col-md-6 ">
<h3 class="form-signin-heading">상대편의 주요 덱</h3>
<div id="opponentDecks">
<table class="table" style="text-align: center;">
<thead>
<td>덱 이름</td>
<td>플레이 수</td>
</thead>
<tbody >
<% for(var i=0;i<decks.length;i++){%>
<tr>
<td><a class="list-group-item"><%= decks[i].deckTitle %></a></td>
<td><a class="list-group-item"><%= decks[i].deckGame %></a></td>
</tr>
<%}%>
</tbody>
</table>
</div>
<br>
<br>
<a href="/ingame"><input class="btn btn-lg btn-primary btn-block" type="button" id="goGame" value="게임 시작"/></a>
<h3 class="form-signin-heading">내 덱의 추천 멀리건</h3>
<div id="yourMulligan">
<table class="table" style="text-align: center;">
<thead>
<td>카드 이름</td>
<td>멀리건 승률</td>
</thead>
<tbody>
<% for(var i=0;i<cards.length;i++){%>
<tr>
<td><a class="list-group-item"><%= cards[i].cardName %></a></td>
<td><a class="list-group-item"><%= cards[i].cardWinRate %></a></td>
</tr>
<%}%>
</tbody>
</table>
</div>
<br>
<br>
<div class="row">
<div class="col-md-6">
<a href="/decklist"><input class="btn btn-lg btn-primary btn-block" type="button" id="backToDeckList" value="덱 선택으로 돌아가기" /></a>
</div>
<div class="col-md-6">
<input class="btn btn-lg btn-primary btn-block" type="button" id="backToSelectOpponent" value="상대편 직업 선택으로 돌아가기"/>
</div>
</div>
</div>
</div>
<!-- jQuery (부트스트랩의 자바스크립트 플러그인을 위해 필요합니다) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<!-- 모든 컴파일된 플러그인을 포함합니다 (아래), 원하지 않는다면 필요한 각각의 파일을 포함하세요 -->
<script src="../../static/bootstrap-3.3.2-dist/js/bootstrap.min.js"></script>
<!-- jQuery (부트스트랩의 자바스크립트 플러그인을 위해 필요합니다) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<!-- 모든 컴파일된 플러그인을 포함합니다 (아래), 원하지 않는다면 필요한 각각의 파일을 포함하세요 -->
<script src="../../static/bootstrap-3.3.2-dist/js/bootstrap.min.js"></script>
</body>
</html>
\ No newline at end of file
......
......@@ -24,7 +24,7 @@
url:'/logout',
success:function(result){
alert('로그아웃 성공!')
window.location.href='/main'
window.location.href='/'
},
error:function(result){
alert('로그아웃 실패!')
......@@ -45,7 +45,7 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/main">Who Are You?</a>
<a class="navbar-brand" href="/">Who Are You?</a>
</div>
<div class="navbar-collapse collapse" id="navbar" aria-expanded="false" style="height: 1px;">
<ul class="nav navbar-nav">
......
......@@ -24,7 +24,7 @@
url:'/logout',
success:function(result){
alert('로그아웃 성공!')
window.location.href='/main'
window.location.href='/'
},
error:function(result){
alert('로그아웃 실패!')
......@@ -33,7 +33,27 @@
})
})
$('#submitButton').click(function(){
let data=new Object()
let opponentClass=$('input[name="checkOpponent"]:checked').val()
data.opponentClass=opponentClass
const stringData=JSON.stringify(data)
alert('잠시 기다리시겠습니까?')
$.ajax({
type:'POST',
url:'/api/card/setopponentclass',
data:stringData,
dataType:'JSON',
contentType:'application/json; charset=utf-8',
traditional:true,
processdata:false,
success:function(){
window.location.href='/result'
},
error:function(){
alert('상대 직업 선택 실패!')
return false
}
})
})
})
</script>
......@@ -48,7 +68,7 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/main">Who Are You?</a>
<a class="navbar-brand" href="/">Who Are You?</a>
</div>
<div class="navbar-collapse collapse" id="navbar" aria-expanded="false" style="height: 1px;">
<ul class="nav navbar-nav">
......@@ -89,7 +109,7 @@
<div class="col-md-4">
<img src="https://d1u5p3l4wpay3k.cloudfront.net/hearthstone_gamepedia/4/4d/Uther_Lightbringer%28257%29.png?version=b45ade5ac3fdd2579160fe5d7b7c1b20" style="width:150px;height:200px;"/>
<br>
<input type="radio" name="checkOpponent" value="PALADIN"/>성기사
<input type="radio" name="checkOpponent" value="PALADIN"/>성기사
</div>
<div class="col-md-4">
<img src="https://d1u5p3l4wpay3k.cloudfront.net/hearthstone_gamepedia/a/a0/Rexxar%28484%29.png?version=c21b57837db15d20cc814f2bf45682b6" style="width:150px;height:200px;"/>
......
......@@ -33,7 +33,7 @@
processdata:false,
success:function(result){
alert('로그인 성공!')
window.location.href='/main'
window.location.href='/decklist'
},
error:function(result){
alert(`로그인 실패!\nmessage:${result['message']}`)
......@@ -58,7 +58,7 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/main">Who Are You?</a>
<a class="navbar-brand" href="/">Who Are You?</a>
</div>
<div class="navbar-collapse collapse" id="navbar" aria-expanded="false" style="height: 1px;">
<ul class="nav navbar-nav">
......
......@@ -24,7 +24,7 @@
url:'/logout',
success:function(result){
alert('로그아웃 성공!')
window.location.href='/main'
window.location.href='/'
},
error:function(result){
alert('로그아웃 실패!')
......@@ -38,6 +38,7 @@
data.deckCode=$('#deckCode').val()
const stringData=JSON.stringify(data)
console.log(stringData)
alert('잠시 기다리시겠습니까?')
$.ajax({
type:'POST',
url:'/api/deck/newdeck',
......@@ -69,7 +70,7 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/main">Who Are You?</a>
<a class="navbar-brand" href="/">Who Are You?</a>
</div>
<div class="navbar-collapse collapse" id="navbar" aria-expanded="false" style="height: 1px;">
<ul class="nav navbar-nav">
......
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Who Are You? - 하스스톤 멀리건 도우미</title>
<!-- 부트스트랩 -->
<link href="../../static/bootstrap-3.3.2-dist/css/bootstrap.min.css?ver=1" rel="stylesheet">
<link href="../../static/main.css" rel="stylesheet">
<!-- IE8 에서 HTML5 요소와 미디어 쿼리를 위한 HTML5 shim 와 Respond.js -->
<!-- WARNING: Respond.js 는 당신이 file:// 을 통해 페이지를 볼 때는 동작하지 않습니다. -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
let mulligan,opponentDecks
$.ajax({
type:'GET',
url:'/api/card/getmulligan',
success:function(result){
mulligan=result
$('#yourMulligan').add('<ul>')
for(let i=0;i<mulligan.length;i++){
$('#yourMulligan').add(`<li><h4>카드 이름:${mulligan[i]['cardName']}</h4><br><h5>멀리건 승률:${mulligan[i]['cardWinRate']}</h5></li>`)
}
$('#yourMulligan').add('</ul>')
}
})
$.ajax({
type:'GET',
url:'/api/card/getopponent',
success:function(result){
opponentDecks=result
$('#opponentDecks').add('<ul>')
for(let i=0;i<opponentDecks.length;i++){
$('#opponentDecks').add(`<li><h4>덱 이름:${opponentDecks[i]['deckTitle']}</h4><br><h5>30일간 플레이 수:${opponentDecks[i]['deckGame']}</h5></li>`)
}
$('#opponentDecks').add('</ul>')
}
})
$('#logoutButton').click(function(){
$.ajax({
type:'POST',
url:'/logout',
success:function(result){
alert('로그아웃 성공!')
window.location.href='/'
},
error:function(result){
alert('로그아웃 실패!')
return false
}
})
})
$('#backToSelectOpponent').click(function(){
window.history.back()
})
})
</script>
</head>
<body>
<nav class="navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button class="navbar-toggle collapsed" aria-expanded="false" aria-controls="navbar" type="button" data-toggle="collapse" data-target="#navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">Who Are You?</a>
</div>
<div class="navbar-collapse collapse" id="navbar" aria-expanded="false" style="height: 1px;">
<ul class="nav navbar-nav">
</ul>
<div class="navbar-right">
<input type="button" class="btn navbar-btn" id="logoutButton" style="color:#000;" value="로그아웃" />
</div>
</div>
</div>
</nav>
<div class="container show-grid" >
<div class="padding" style="width:100px"></div>
<br>
<br>
<h3 class="form-signin-heading">상대편의 주요 덱</h3>
<div id="opponentDecks"></div>
<br>
<br>
<h3 class="form-signin-heading">내 덱의 추천 멀리건</h3>
<div id="yourMulligan"></div>
<br>
<br>
<div class="row">
<div class="col-md-6">
<a href="/decklist"><input class="btn btn-lg btn-primary btn-block" type="button" id="backToDeckList" value="덱 선택으로 돌아가기" /></a>
</div>
<div class="col-md-6">
<input class="btn btn-lg btn-primary btn-block" type="button" id="backToSelectOpponent" value="상대편 직업 선택으로 돌아가기"/>
</div>
</div>
</div>
<!-- jQuery (부트스트랩의 자바스크립트 플러그인을 위해 필요합니다) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<!-- 모든 컴파일된 플러그인을 포함합니다 (아래), 원하지 않는다면 필요한 각각의 파일을 포함하세요 -->
<script src="../../static/bootstrap-3.3.2-dist/js/bootstrap.min.js"></script>
</body>
</html>
\ No newline at end of file
......@@ -62,7 +62,7 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/main">Who Are You?</a>
<a class="navbar-brand" href="/">Who Are You?</a>
</div>
<div class="navbar-collapse collapse" id="navbar" aria-expanded="false" style="height: 1px;">
<ul class="nav navbar-nav">
......