서주원

Delete some unused files

...@@ -26,7 +26,6 @@ exports.AddCards=(deckId,cards)=>{ ...@@ -26,7 +26,6 @@ exports.AddCards=(deckId,cards)=>{
26 let cardId = 0 26 let cardId = 0
27 for (let i = 0; i < cardEnUS.length; i++) { 27 for (let i = 0; i < cardEnUS.length; i++) {
28 if (cardEnUS[i].name === cardName) { 28 if (cardEnUS[i].name === cardName) {
29 - console.log(cardEnUS[i].dbfId)
30 cardId = cardEnUS[i].dbfId 29 cardId = cardEnUS[i].dbfId
31 cardName=cardName.replace('\'','\'\'') 30 cardName=cardName.replace('\'','\'\'')
32 break 31 break
......
1 -const puppeteer=require('puppeteer');
2 -const cheerio=require('cheerio');
3 -
4 -exports.getDecks=(cardIds)=>{
5 - console.log('cardIds in crawlerMulligan ',cardIds)
6 - cardIds=JSON.stringify(cardIds)
7 - cardIds=JSON.parse(cardIds)
8 - console.log('stringified cardIds in crawlerMulligan ',cardIds)
9 - console.log(cardIds[0])
10 - let idInQuery=cardIds[0].cardId
11 - for(let i=1;i<cardIds.length && i<10;i++){
12 - idInQuery+= '%2C'+cardIds[i].cardId
13 - }
14 - console.log('idInQuery in crawlerMulligan ',idInQuery)
15 - const getContent=()=>{
16 - return new Promise((resolve,reject)=>{
17 - const asyncFunc=async ()=>{
18 - const browser=await puppeteer.launch()
19 - try{
20 - const page=await browser.newPage()
21 - await page.setViewport({width:1366,height:768})
22 - await page.goto(`https://hsreplay.net/decks/#timeRange=LAST_30_DAYS&includedCards=${idInQuery}`,{waitUntil: 'networkidle2'})
23 - const content=await page.content()
24 - browser.close()
25 - return content
26 - }
27 - catch(err)
28 - {
29 - console.log(err)
30 - browser.close()
31 - }
32 - }
33 - resolve(asyncFunc())
34 - })
35 - }
36 -
37 - const getDeckHref=(content)=>{
38 - return new Promise((resolve,reject)=>{
39 - const $=cheerio.load(content)
40 - let deck=$('#decks-container > div > main > div.deck-list > ul > li:nth-child(2)').find('a')
41 - const deckHref=$(deck).attr('href')
42 - console.log('deckHref in crawlerMulligan :',deckHref)
43 - resolve(deckHref)
44 - })
45 - }
46 - const getDeckContent=(href)=>{
47 - return new Promise((resolve,reject)=>{
48 - const asyncFunc=async ()=>{
49 - const browser=await puppeteer.launch()
50 - try{
51 - const page=await browser.newPage()
52 - await page.setViewport({width:1366,height:768})
53 - await page.goto(`https://hsreplay.net${href}?hl=ko`,{waitUntil: 'networkidle2'})
54 - const content=await page.content()
55 - browser.close()
56 - return content
57 - }
58 - catch(err)
59 - {
60 - console.log(err)
61 - browser.close()
62 - }
63 - }
64 - resolve(asyncFunc())
65 - })
66 - }
67 - const getMulligan=(content)=>{
68 - return new Promise((resolve,reject)=>{
69 - const $=cheerio.load(content)
70 - let cardNames=$('.card-name')
71 - let cardWinRates=$('.table-cell')
72 - let cards=[]
73 - for(let i=0;i<cardNames.length;i++){
74 - let cardName=$(cardNames[i]).text()
75 - let cardWinRate=$(cardWinRates[6*i]).text()
76 - cardWinRate=cardWinRate.replace('▼','')
77 - cardWinRate=cardWinRate.replace('▲','')
78 - cardWinRate=cardWinRate.replace('%','')
79 - cards.push({cardName:cardName,cardWinRate:cardWinRate})
80 - }
81 - cards.sort((a,b)=>{
82 - return a.cardWinRate<b.cardWinRate ? 1:-1
83 - })
84 - console.log(cards)
85 - resolve(cards)
86 - })
87 - }
88 - getContent()
89 - .then(getDeckHref)
90 - .then(getDeckContent)
91 - .then(getMulligan)
92 -}
1 -const puppeteer=require('puppeteer');
2 -const cheerio=require('cheerio');
3 -
4 -exports.getDecks=(opponentClass)=>{
5 -
6 - const getContent=()=>{
7 - return new Promise((resolve,reject)=>{
8 - const asyncFunc=async ()=>{
9 - const browser=await puppeteer.launch()
10 - try{
11 - const page=await browser.newPage()
12 - await page.setViewport({width:1366,height:768})
13 - await page.goto(`https://hsreplay.net/decks/#timeRange=LAST_30_DAYS&playerClasses=${opponentClass}?hl=ko`,{waitUntil: 'networkidle2'})
14 - const content=await page.content()
15 - browser.close()
16 - return content
17 - }
18 - catch(err)
19 - {
20 - console.log(err)
21 - browser.close()
22 - }
23 - }
24 - resolve(asyncFunc())
25 - })
26 - }
27 -
28 - const getDeckInfo=(content)=>{
29 - return new Promise((resolve,reject)=>{
30 - const $=cheerio.load(content)
31 - let deckNames=$('.deck-name')
32 - let deckGames=$('.game-count')
33 - let decks=[]
34 - for(let i=0;i<3;i++){
35 - let deckName=$(deckNames[i]).text()
36 - let deckGame=$(deckGames[i]).text()
37 - decks.push({deckTitle:deckName,deckGame:deckGame})
38 - }
39 - console.log(decks)
40 - resolve(decks)
41 - })
42 - }
43 - getContent()
44 - .then(getDeckInfo)
45 -}
1 -const crawler=require('./crawlerMulligan')
2 -const getCardId=require('./getCardId')
3 -const puppeteer=require('puppeteer')
4 -const cheerio=require('cheerio')
5 -
6 -
7 -exports.GetMulligan=(req,res)=>{
8 - const deckId=req.session.deckId || 113
9 - console.log('deckId in getMulligan',deckId)
10 - const opponentClass=req.session.opponentClass || 'PALADIN'
11 - console.log('opponentClass in getMulligan',opponentClass)
12 - const DataCheck=()=>{
13 - return new Promise((resolve,reject)=>{
14 - if (!deckId || !opponentClass){
15 - return reject({
16 - code:'query_error',
17 - message:'query error',
18 - })
19 - }
20 - resolve()
21 - })
22 - }
23 - const GetCardId=()=>{
24 - return getCardId.GetCardId(deckId)
25 - }
26 - const CrawlerMulligan=(cardIds)=>{
27 - return crawler.getDecks(cardIds)
28 - }
29 -
30 - const GetContent=(cardIds)=>{
31 - cardIds=JSON.stringify(cardIds)
32 - cardIds=JSON.parse(cardIds)
33 - let idInQuery=cardIds[0].cardId
34 - for(let i=1;i<cardIds.length ;i++){
35 - idInQuery+= '%2C'+cardIds[i].cardId
36 - }
37 - console.log('idInQuery in crawlerMulligan ',idInQuery)
38 - return new Promise((resolve,reject)=>{
39 - const asyncFunc=async ()=>{
40 - const browser=await puppeteer.launch()
41 - try{
42 - const page=await browser.newPage()
43 - await page.setViewport({width:1366,height:768})
44 - await page.goto(`https://hsreplay.net/decks/#timeRange=LAST_30_DAYS&includedCards=${idInQuery}`,{waitUntil: 'networkidle2'})
45 - const content=await page.content()
46 - browser.close()
47 - return content
48 - }
49 - catch(err)
50 - {
51 - console.log(err)
52 - browser.close()
53 - }
54 - }
55 - resolve(asyncFunc())
56 - })
57 - }
58 -
59 - const GetDeckHref=(content)=>{
60 - return new Promise((resolve,reject)=>{
61 - const $=cheerio.load(content)
62 - let deck=$('#decks-container > div > main > div.deck-list > ul > li:nth-child(2)').find('a')
63 - const deckHref=$(deck).attr('href')
64 - console.log('deckHref in crawlerMulligan :',deckHref)
65 - resolve(deckHref)
66 - })
67 - }
68 - const GetDeckContent=(href)=>{
69 - return new Promise((resolve,reject)=>{
70 - const asyncFunc=async ()=>{
71 - const browser=await puppeteer.launch()
72 - try{
73 - const page=await browser.newPage()
74 - await page.setViewport({width:1366,height:768})
75 - await page.goto(`https://hsreplay.net${href}?hl=ko`,{waitUntil: 'networkidle2'})
76 - const content=await page.content()
77 - browser.close()
78 - return content
79 - }
80 - catch(err)
81 - {
82 - console.log(err)
83 - browser.close()
84 - }
85 - }
86 - resolve(asyncFunc())
87 - })
88 - }
89 - const GetMulligan=(content)=>{
90 - return new Promise((resolve,reject)=>{
91 - const $=cheerio.load(content)
92 - let cardNames=$('.card-name')
93 - let cardWinRates=$('.table-cell')
94 - let cards=[]
95 - for(let i=0;i<cardNames.length;i++){
96 - let cardName=$(cardNames[i]).text()
97 - let cardWinRate=$(cardWinRates[6*i]).text()
98 - cardWinRate=cardWinRate.replace('▼','')
99 - cardWinRate=cardWinRate.replace('▲','')
100 - cardWinRate=cardWinRate.replace('%','')
101 - cards.push({cardName:cardName,cardWinRate:cardWinRate})
102 - }
103 - cards.sort((a,b)=>{
104 - return a.cardWinRate<b.cardWinRate ? 1:-1
105 - })
106 - console.log(cards)
107 - resolve(cards)
108 - })
109 - }
110 - DataCheck()
111 - .then(GetCardId)
112 - //.then(CrawlerMulligan)
113 - .then(GetContent)
114 - .then(GetDeckHref)
115 - .then(GetDeckContent)
116 - .then(GetMulligan)
117 - .then((cards)=>{
118 - return new Promise((resolve,reject)=>{
119 - console.log('cards in getMulligan : ',cards)
120 - resolve(cards)
121 - })
122 - })
123 - .catch((err)=>{
124 - console.log(err)
125 - })
126 -}
...\ No newline at end of file ...\ No newline at end of file
1 -const crawler=require('./crawlerOpponent')
2 -const puppeteer=require('puppeteer')
3 -const cheerio=require('cheerio')
4 -
5 -exports.GetOpponent=(req,res)=>{
6 - const opponentClass=req.session.opponentClass
7 - const DataCheck=()=>{
8 - return new Promise((resolve,reject)=>{
9 - if(!opponentClass){
10 - return reject({
11 - code:'query_error',
12 - message:'query_error'
13 - })
14 - }
15 - resolve()
16 - })
17 - }
18 - const CrawlerOpponent=()=>{
19 - return crawler.getDecks(opponentClass)
20 - }
21 - const GetContent=()=>{
22 - return new Promise((resolve,reject)=>{
23 - const asyncFunc=async ()=>{
24 - const browser=await puppeteer.launch()
25 - try{
26 - const page=await browser.newPage()
27 - await page.setViewport({width:1366,height:768})
28 - await page.goto(`https://hsreplay.net/decks/#timeRange=LAST_30_DAYS&playerClasses=${opponentClass}?hl=ko`,{waitUntil: 'networkidle2'})
29 - const content=await page.content()
30 - browser.close()
31 - return content
32 - }
33 - catch(err)
34 - {
35 - console.log(err)
36 - browser.close()
37 - }
38 - }
39 - resolve(asyncFunc())
40 - })
41 - }
42 -
43 - const GetDeckInfo=(content)=>{
44 - return new Promise((resolve,reject)=>{
45 - const $=cheerio.load(content)
46 - let deckNames=$('.deck-name')
47 - let deckGames=$('.game-count')
48 - let decks=[]
49 - for(let i=0;i<3;i++){
50 - let deckName=$(deckNames[i]).text()
51 - let deckGame=$(deckGames[i]).text()
52 - decks.push({deckTitle:deckName,deckGame:deckGame})
53 - }
54 - console.log(decks)
55 - resolve(decks)
56 - })
57 - }
58 - DataCheck()
59 - //.then(CrawlerOpponent)
60 - .then(GetContent)
61 - .then(GetDeckInfo)
62 - .then((decks)=>{
63 - return new Promise((resolve,reject)=>{
64 - console.log('decks in getOpponent: ',decks)
65 - resolve(decks)
66 - })
67 - })
68 - .catch((err)=>{
69 - console.log(err)
70 - })
71 -}
...\ No newline at end of file ...\ No newline at end of file
1 -const crawler=require('./crawlerMulligan')
2 const getCardId=require('./getCardId') 1 const getCardId=require('./getCardId')
3 const puppeteer=require('puppeteer') 2 const puppeteer=require('puppeteer')
4 const cheerio=require('cheerio') 3 const cheerio=require('cheerio')
...@@ -7,10 +6,8 @@ const ejs=require('ejs') ...@@ -7,10 +6,8 @@ const ejs=require('ejs')
7 let globalMulligan 6 let globalMulligan
8 let globalDecks 7 let globalDecks
9 exports.GetResult=(req,res)=>{ 8 exports.GetResult=(req,res)=>{
10 - const deckId=req.session.deckId || 113 9 + const deckId=req.session.deckId
11 - console.log('deckId in getMulligan',deckId) 10 + const opponentClass=req.session.opponentClass
12 - const opponentClass=req.session.opponentClass || 'PALADIN'
13 - console.log('opponentClass in getMulligan',opponentClass)
14 const DataCheck=()=>{ 11 const DataCheck=()=>{
15 return new Promise((resolve,reject)=>{ 12 return new Promise((resolve,reject)=>{
16 if (!deckId || !opponentClass){ 13 if (!deckId || !opponentClass){
...@@ -33,7 +30,6 @@ exports.GetResult=(req,res)=>{ ...@@ -33,7 +30,6 @@ exports.GetResult=(req,res)=>{
33 for(let i=1;i<cardIds.length ;i++){ 30 for(let i=1;i<cardIds.length ;i++){
34 idInQuery+= '%2C'+cardIds[i].cardId 31 idInQuery+= '%2C'+cardIds[i].cardId
35 } 32 }
36 - console.log('idInQuery in crawlerMulligan ',idInQuery)
37 return new Promise((resolve,reject)=>{ 33 return new Promise((resolve,reject)=>{
38 const asyncFunc=async ()=>{ 34 const asyncFunc=async ()=>{
39 const browser=await puppeteer.launch() 35 const browser=await puppeteer.launch()
...@@ -60,7 +56,7 @@ exports.GetResult=(req,res)=>{ ...@@ -60,7 +56,7 @@ exports.GetResult=(req,res)=>{
60 const $=cheerio.load(content) 56 const $=cheerio.load(content)
61 let deck=$('#decks-container > div > main > div.deck-list > ul > li:nth-child(2)').find('a') 57 let deck=$('#decks-container > div > main > div.deck-list > ul > li:nth-child(2)').find('a')
62 const deckHref=$(deck).attr('href') 58 const deckHref=$(deck).attr('href')
63 - console.log('deckHref in crawlerMulligan :',deckHref) 59 + console.log(deckHref)
64 resolve(deckHref) 60 resolve(deckHref)
65 }) 61 })
66 } 62 }
...@@ -145,7 +141,6 @@ exports.GetResult=(req,res)=>{ ...@@ -145,7 +141,6 @@ exports.GetResult=(req,res)=>{
145 decks.push({deckTitle:deckName,deckGame:deckGame}) 141 decks.push({deckTitle:deckName,deckGame:deckGame})
146 } 142 }
147 } 143 }
148 - console.log(decks)
149 resolve(decks) 144 resolve(decks)
150 }) 145 })
151 } 146 }
...@@ -179,7 +174,6 @@ exports.GetResult=(req,res)=>{ ...@@ -179,7 +174,6 @@ exports.GetResult=(req,res)=>{
179 }) 174 })
180 }) 175 })
181 .then((result)=>{ 176 .then((result)=>{
182 - console.log('result: ',result)
183 fs.readFile('./views/ejs/result.ejs','utf-8',(err,data)=>{ 177 fs.readFile('./views/ejs/result.ejs','utf-8',(err,data)=>{
184 res.writeHead(200,{'Content-Type':'text/html'}) 178 res.writeHead(200,{'Content-Type':'text/html'})
185 res.end(ejs.render(data,{ 179 res.end(ejs.render(data,{
......
1 const express=require('express') 1 const express=require('express')
2 const router=express.Router() 2 const router=express.Router()
3 3
4 -const getMulligan=require('./getMulligan')
5 -const getOpponent=require('./getOpponent')
6 const setOpponentClass=require('./setOpponentClass') 4 const setOpponentClass=require('./setOpponentClass')
7 5
8 -router.get('/getmulligan',getMulligan.GetMulligan)
9 -router.get('/getopponent',getOpponent.GetOpponent)
10 router.post('/setopponentclass',setOpponentClass.SetOpponentClass) 6 router.post('/setopponentclass',setOpponentClass.SetOpponentClass)
11 7
12 module.exports=router 8 module.exports=router
...\ No newline at end of file ...\ No newline at end of file
......
1 -const mysql=require('../mysql') 1 +const mysql=require('../../database/mysql')
2 -
3 -let deckId
4 2
5 exports.AddDeck=(deckOwner,deckTitle,deckCode)=>{ 3 exports.AddDeck=(deckOwner,deckTitle,deckCode)=>{
6 return new Promise((resolve,reject)=> { 4 return new Promise((resolve,reject)=> {
......
1 -const mysql=require('../../database/mysql')
2 -
3 -exports.GetDeck=(res,req)=>{
4 - const userId='test'
5 -
6 - const getDeck=()=>{
7 - return new Promise((resolve,reject)=>{
8 - mysql.getConnection((err,connection)=>{
9 - if (err) throw err
10 - connection.query(`select id,deckTitle from deck where deckOwner=\'${userId}\'`,(err,results,fields)=>{
11 - if (err) throw err
12 - console.log(JSON.stringify(results))
13 - resolve(JSON.stringify(results))
14 - })
15 - connection.release()
16 - })
17 - })
18 -
19 - }
20 - getDeck()
21 - .then((results)=>{
22 - return res.status(200).json(results)
23 - })
24 - .catch((err)=>{
25 - //return res.status(500).json(err||err.message)
26 - })
27 -}
...\ No newline at end of file ...\ No newline at end of file
1 -const mysql=require('../mysql') 1 +const mysql=require('../../database/mysql')
2 2
3 exports.GetDeckId=(deckOwner,deckTitle)=>{ 3 exports.GetDeckId=(deckOwner,deckTitle)=>{
4 return new Promise((resolve,reject)=>{ 4 return new Promise((resolve,reject)=>{
......
...@@ -2,9 +2,7 @@ const express=require('express') ...@@ -2,9 +2,7 @@ const express=require('express')
2 const router=express.Router() 2 const router=express.Router()
3 3
4 const newDeck=require('./newDeck') 4 const newDeck=require('./newDeck')
5 -const getDeck=require('./getDeck')
6 5
7 router.post('/newdeck',newDeck.NewDeck) 6 router.post('/newdeck',newDeck.NewDeck)
8 -router.get('/getdeck',getDeck.GetDeck)
9 7
10 module.exports=router 8 module.exports=router
...\ No newline at end of file ...\ No newline at end of file
......
1 const crawler=require('./crawlerDeckCodes') 1 const crawler=require('./crawlerDeckCodes')
2 const cheerio=require('cheerio') 2 const cheerio=require('cheerio')
3 const addCards=require('../card/addCards') 3 const addCards=require('../card/addCards')
4 -const addDeck=require('../../database/deck/addDeck') 4 +const addDeck=require('./addDeck')
5 -const getDeckId=require('../../database/deck/getDeckId') 5 +const getDeckId=require('./getDeckId')
6 -let deckId=-1
7 6
8 exports.NewDeck=(req,res)=>{ 7 exports.NewDeck=(req,res)=>{
9 - const deckOwner=req.session.sid || 'test' 8 + const deckOwner=req.session.sid
10 const deckTitle=req.body.deckTitle || new Date() 9 const deckTitle=req.body.deckTitle || new Date()
11 let deckCode=req.body.deckCode 10 let deckCode=req.body.deckCode
12 let cards=[] 11 let cards=[]
13 12
14 - console.log(deckOwner,deckTitle,deckCode)
15 13
16 const DataCheck=()=>{ 14 const DataCheck=()=>{
17 return new Promise((resolve,reject)=>{ 15 return new Promise((resolve,reject)=>{
...@@ -62,7 +60,6 @@ exports.NewDeck=(req,res)=>{ ...@@ -62,7 +60,6 @@ exports.NewDeck=(req,res)=>{
62 const asyncGetDeckId=async ()=>{ 60 const asyncGetDeckId=async ()=>{
63 try{ 61 try{
64 const results=await getDeckId.GetDeckId(deckOwner,deckTitle) 62 const results=await getDeckId.GetDeckId(deckOwner,deckTitle)
65 - console.log(results)
66 return results 63 return results
67 } 64 }
68 catch (err){ 65 catch (err){
...@@ -72,7 +69,6 @@ exports.NewDeck=(req,res)=>{ ...@@ -72,7 +69,6 @@ exports.NewDeck=(req,res)=>{
72 return asyncGetDeckId() 69 return asyncGetDeckId()
73 } 70 }
74 const AddCards=(deckId)=>{ 71 const AddCards=(deckId)=>{
75 - console.log(`deckid in AddCards : ${deckId}`)
76 return addCards.AddCards(deckId,cards) 72 return addCards.AddCards(deckId,cards)
77 } 73 }
78 74
......
1 -const mysql=require('../mysql') 1 +const mysql=require('../../database/mysql')
2 2
3 exports.findById=(userId)=>{ 3 exports.findById=(userId)=>{
4 return new Promise((resolve,reject)=>{ 4 return new Promise((resolve,reject)=>{
...@@ -18,7 +18,6 @@ exports.findById=(userId)=>{ ...@@ -18,7 +18,6 @@ exports.findById=(userId)=>{
18 } 18 }
19 else{ 19 else{
20 connection.release() 20 connection.release()
21 - console.log('result in findById ',result)
22 resolve(result) 21 resolve(result)
23 } 22 }
24 }) 23 })
......
1 -const findById=require('../../database/user/findById') 1 +const findById=require('./findById')
2 const bcrypt=require('bcrypt-nodejs') 2 const bcrypt=require('bcrypt-nodejs')
3 3
4 exports.Login=(req,res)=>{ 4 exports.Login=(req,res)=>{
...@@ -39,7 +39,6 @@ exports.Login=(req,res)=>{ ...@@ -39,7 +39,6 @@ exports.Login=(req,res)=>{
39 }) 39 })
40 } 40 }
41 if(bcrypt.compareSync(password,user[0].password)){ 41 if(bcrypt.compareSync(password,user[0].password)){
42 - console.log(`Login : ${userId}`)
43 req.session.sid=userId 42 req.session.sid=userId
44 req.session.save(()=>{ 43 req.session.save(()=>{
45 res.status(200).json({userId:userId}) 44 res.status(200).json({userId:userId})
......
1 -'use strict' 1 +const findById=require('./findById')
2 -
3 -const express=require('express')
4 -const session=require('express-session')
5 -const findById=require('../../database/user/findById')
6 const mysql=require('../../database/mysql') 2 const mysql=require('../../database/mysql')
7 const bcrypt=require('bcrypt-nodejs') 3 const bcrypt=require('bcrypt-nodejs')
8 4
...@@ -25,7 +21,6 @@ exports.SignUp=(req,res)=>{ ...@@ -25,7 +21,6 @@ exports.SignUp=(req,res)=>{
25 const findUser=async ()=>{ 21 const findUser=async ()=>{
26 try{ 22 try{
27 user= await findById.findById(userId) 23 user= await findById.findById(userId)
28 - console.log(`user in UserCheck : ${JSON.stringify(user)}`)
29 return user 24 return user
30 } 25 }
31 catch(err){ 26 catch(err){
......
...@@ -3,10 +3,7 @@ const bodyParser=require('body-parser') ...@@ -3,10 +3,7 @@ const bodyParser=require('body-parser')
3 const fs=require('fs') 3 const fs=require('fs')
4 const session=require('express-session') 4 const session=require('express-session')
5 const path=require('path') 5 const path=require('path')
6 -const bcrypt=require('bcrypt-nodejs')
7 -const rp=require('request-promise')
8 const morgan=require('morgan') 6 const morgan=require('morgan')
9 -const cheerio=require('cheerio')
10 const mysqlApostrophe=require('mysql-apostrophe') 7 const mysqlApostrophe=require('mysql-apostrophe')
11 const ejs=require('ejs') 8 const ejs=require('ejs')
12 const mysql=require('./database/mysql') 9 const mysql=require('./database/mysql')
...@@ -65,7 +62,6 @@ app.get('/login',(req,res)=>{ ...@@ -65,7 +62,6 @@ app.get('/login',(req,res)=>{
65 }) 62 })
66 63
67 app.post('/logout',(req,res)=>{ 64 app.post('/logout',(req,res)=>{
68 - console.log('logout')
69 delete req.session.deckId 65 delete req.session.deckId
70 delete req.session.sid 66 delete req.session.sid
71 res.status(200).json({result:'Logout Successful'}) 67 res.status(200).json({result:'Logout Successful'})
...@@ -80,8 +76,6 @@ app.get('/decklist',(req,res)=>{ ...@@ -80,8 +76,6 @@ app.get('/decklist',(req,res)=>{
80 connection.query(`select id,deckTitle from deck where deckOwner=\'${req.session.sid}\'`,(err,results,fields)=>{ 76 connection.query(`select id,deckTitle from deck where deckOwner=\'${req.session.sid}\'`,(err,results,fields)=>{
81 if (err) throw err 77 if (err) throw err
82 else{ 78 else{
83 - console.log(results)
84 - console.log('length : '+results.length)
85 fs.readFile('./views/ejs/decklist.ejs','utf-8',(err,data)=>{ 79 fs.readFile('./views/ejs/decklist.ejs','utf-8',(err,data)=>{
86 res.writeHead(200,{'Content-Type':'text/html'}) 80 res.writeHead(200,{'Content-Type':'text/html'})
87 res.end(ejs.render(data,{ 81 res.end(ejs.render(data,{
...@@ -120,53 +114,15 @@ app.get('/newdeck',(req,res)=>{ ...@@ -120,53 +114,15 @@ app.get('/newdeck',(req,res)=>{
120 } 114 }
121 }) 115 })
122 116
123 -const getMulligan=require('./api/card/getMulligan')
124 -const getOpponent=require('./api/card/getOpponent')
125 const getResult=require('./api/card/getResult') 117 const getResult=require('./api/card/getResult')
126 118
127 app.get('/result',(req,res)=>{ 119 app.get('/result',(req,res)=>{
128 if(!req.session.sid) 120 if(!req.session.sid)
129 res.redirect('/login') 121 res.redirect('/login')
130 else{ 122 else{
131 - let mulligan
132 - let opponentDecks;
133 (async ()=>{ 123 (async ()=>{
134 - const result=await getResult.GetResult(req,res) 124 + await getResult.GetResult(req,res)
135 - console.log('hsreplay.net에서 받아오는 중')
136 - /*setTimeout(function(){
137 - console.log('result: ',result)
138 - fs.readFile('./views/html/result.ejs',(err,data)=>{
139 - res.writeHead(200,{'Content-Type':'text/html'})
140 - res.end(ejs.render(data,{
141 - cards:result.cards || [],
142 - decks:result.decks || [],
143 - }))
144 - })
145 - },30000)*/
146 })() 125 })()
147 - const GetInfo=async ()=>{
148 - return getResult.GetResult(req,res)
149 - }
150 - const GetCards=()=>{
151 - return getMulligan.GetMulligan(req,res)
152 - }
153 - const GetDecks=(cards)=>{
154 - mulligan=cards
155 - return getOpponent.GetOpponent(req,res)
156 - }
157 - const Render=async (result)=>{
158 - mulligan=result.cards
159 - opponentDecks=result.decks
160 - setTimeout(function(){
161 - fs.readFile('./views/html/result.ejs',(err,data)=>{
162 - res.writeHead(200,{'Content-Type':'text/html'})
163 - res.end(ejs.render(data,{
164 - cards:mulligan || [],
165 - decks:opponentDecks || [],
166 - }))
167 - })
168 - },1000)
169 - }
170 } 126 }
171 }) 127 })
172 128
......
1 -const express=require('express')
2 -const router=express.Router()
3 -
4 -module.exports=router
...\ No newline at end of file ...\ No newline at end of file
1 -const express=require('express')
2 -const router=express.Router()
3 -
4 -module.exports=router
...\ No newline at end of file ...\ No newline at end of file
1 -const express=require('express')
2 -const router=express.Router()
3 -
4 -router.use('/user',require('./user'))
5 -router.use('/deck',require('./deck'))
6 -router.use('/card',require('./card'))
7 -
8 -module.exports=router
...\ No newline at end of file ...\ No newline at end of file
1 -const express=require('express')
2 -const router=express.Router()
3 -
4 -app.get
5 -
6 -module.exports=router
...\ No newline at end of file ...\ No newline at end of file
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
24 url:'/logout', 24 url:'/logout',
25 success:function(result){ 25 success:function(result){
26 alert('로그아웃 성공!') 26 alert('로그아웃 성공!')
27 - window.location.href='/main' 27 + window.location.href='/'
28 }, 28 },
29 error:function(result){ 29 error:function(result){
30 alert('로그아웃 실패!') 30 alert('로그아웃 실패!')
...@@ -110,6 +110,7 @@ ...@@ -110,6 +110,7 @@
110 <input class="btn btn-lg btn-primary btn-block" type="button" id="backToSelectOpponent" value="상대편 직업 선택으로 돌아가기"/> 110 <input class="btn btn-lg btn-primary btn-block" type="button" id="backToSelectOpponent" value="상대편 직업 선택으로 돌아가기"/>
111 </div> 111 </div>
112 </div> 112 </div>
113 + <div class="padding" style="width:100px"></div>
113 </div> 114 </div>
114 115
115 <!-- jQuery (부트스트랩의 자바스크립트 플러그인을 위해 필요합니다) --> 116 <!-- jQuery (부트스트랩의 자바스크립트 플러그인을 위해 필요합니다) -->
......
...@@ -151,6 +151,7 @@ ...@@ -151,6 +151,7 @@
151 </div> 151 </div>
152 <div class="col-md-5"></div> 152 <div class="col-md-5"></div>
153 </div> 153 </div>
154 + <div class="padding" style="width:100px"></div>
154 </div> 155 </div>
155 156
156 <!-- jQuery (부트스트랩의 자바스크립트 플러그인을 위해 필요합니다) --> 157 <!-- jQuery (부트스트랩의 자바스크립트 플러그인을 위해 필요합니다) -->
......
...@@ -17,6 +17,12 @@ ...@@ -17,6 +17,12 @@
17 17
18 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> 18 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
19 <script> 19 <script>
20 + function onEnterLogin(event) {
21 + var keyCode = event.keyCode;
22 + if (keyCode == 13) {
23 + $('#loginButton').trigger('click')
24 + }
25 + }
20 $(document).ready(function(){ 26 $(document).ready(function(){
21 $('#loginButton').click(function(){ 27 $('#loginButton').click(function(){
22 var data=new Object() 28 var data=new Object()
...@@ -75,9 +81,9 @@ ...@@ -75,9 +81,9 @@
75 <form class="form-signin" id="loginForm"> 81 <form class="form-signin" id="loginForm">
76 <h3 class="form-signin-heading">로그인</h3> 82 <h3 class="form-signin-heading">로그인</h3>
77 <label class="sr-only" for="userId">아이디</label> 83 <label class="sr-only" for="userId">아이디</label>
78 - <input class="form-control" id="userId" autofocus="" required="" type="text" placeholder="아이디" name="userId"> 84 + <input class="form-control" id="userId" autofocus="" required="" type="text" placeholder="아이디" name="userId" >
79 <label class="sr-only" for="password">비밀번호</label> 85 <label class="sr-only" for="password">비밀번호</label>
80 - <input class="form-control" id="password" required="" type="password" placeholder="비밀번호" name="password"> 86 + <input class="form-control" id="password" required="" type="password" placeholder="비밀번호" name="password" onkeydown="javascript:onEnterLogin(event)">
81 <br> 87 <br>
82 <div class="col-md-6"> 88 <div class="col-md-6">
83 <input class="btn btn-lg btn-primary btn-block" type="button" id="loginButton" value="로그인" /> 89 <input class="btn btn-lg btn-primary btn-block" type="button" id="loginButton" value="로그인" />
......
...@@ -37,7 +37,6 @@ ...@@ -37,7 +37,6 @@
37 data.deckTitle=$('#deckTitle').val() 37 data.deckTitle=$('#deckTitle').val()
38 data.deckCode=$('#deckCode').val() 38 data.deckCode=$('#deckCode').val()
39 const stringData=JSON.stringify(data) 39 const stringData=JSON.stringify(data)
40 - console.log(stringData)
41 alert('잠시 기다리시겠습니까?') 40 alert('잠시 기다리시겠습니까?')
42 $.ajax({ 41 $.ajax({
43 type:'POST', 42 type:'POST',
...@@ -90,7 +89,7 @@ ...@@ -90,7 +89,7 @@
90 <label class="sr-only" for="deckTitle">덱 이름</label> 89 <label class="sr-only" for="deckTitle">덱 이름</label>
91 <input class="form-control" id="deckTitle" autofocus="" required="" type="text" placeholder="덱 이름" name="deckTitle"> 90 <input class="form-control" id="deckTitle" autofocus="" required="" type="text" placeholder="덱 이름" name="deckTitle">
92 <label class="sr-only" for="deckCode">덱 코드</label> 91 <label class="sr-only" for="deckCode">덱 코드</label>
93 - <textarea class="form-control" id="deckCode" required="" placeholder="덱 코드" style="resize:none;height:150px;" name="deckCode"></textarea> 92 + <textarea class="form-control" id="deckCode" required="" placeholder="#으로 시작하는 문장은 제외한 덱 코드만 입력해 주세요." style="resize:none;height:150px;" name="deckCode"></textarea>
94 </form> 93 </form>
95 <input type="button" class="btn btn-primary btn-block" id="newDeckButton" value="확인" /> 94 <input type="button" class="btn btn-primary btn-block" id="newDeckButton" value="확인" />
96 </div> 95 </div>
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
28 data.userId=$('#userId').val() 28 data.userId=$('#userId').val()
29 data.password=$('#password').val() 29 data.password=$('#password').val()
30 const stringData=JSON.stringify(data) 30 const stringData=JSON.stringify(data)
31 - console.log(stringData)
32 $.ajax({ 31 $.ajax({
33 type:'POST', 32 type:'POST',
34 url:'api/user/signup', 33 url:'api/user/signup',
......