김명주

Create game and Connect homepage

......@@ -6,11 +6,13 @@ 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.use('/',express.static('views'));
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
var chname;
var vec=[];
app.post("/inf/result",(req,res)=>{
chname=encodeURIComponent(req.body.test);
});
......@@ -63,11 +65,21 @@ app.get("/inf/result",(req,res)=>{
}
});
});
app.post("/game",(req,res)=>{
vec.push(req.body.test);
console.log(vec);
})
app.get("/game",(req,res)=>{
res.render('game_home');
})
app.get("/inf",(req,res)=>{
res.render('inf_search_home');
});
app.get("/",(req,res)=>{
res.render('main_home');
});
app.listen("8080",function(req,res){
console.log('server listening at port no. 8080');
});
......
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
</head>
<body>
<script language="JavaScript">
function Ajax(index){
$.ajax({
url: '/game', // postTest 주소로
async: true, // 동기화 - 서버에서 반응이 올때까지 기다림
type: 'POST', // POST 방식으로
data: {
test: index // 텍스트필드에 입력한 값을 test라는 이름으로 보냄
},
dataType: 'json'
});
}
function Change(num) {
if(num==1){
document.getElementById("btn1").innerText="선택지1-1";
document.getElementById("btn2").innerText="선택지2-1";
Ajax(1);
}
else{
document.getElementById("btn1").innerText="선택지1-1";
document.getElementById("btn2").innerText="선택지2-1";
Ajax(2);
}
/*
var a=document.getElementById("btn").innerText;
if(a=="뭘보냐"){
document.getElementById("btn1").innerText="선택지1-1";
document.getElementById("btn2").innerText="선택지1-1";
Ajax(1);
}
else if(a=="안봤는데?"){
document.getElementById("btn1").innerText="선택지1-2";
Ajax(2);
}
else if(a=="본거다안다"){
document.getElementById("btn2").innerText="선택지1-3";
Ajax(3);
}*/
}
</script>
<button id="btn1" onclick="Change(1)">선택지 1</button>
<button id="btn2" onclick="Change(2)">선택지 2</button>
</body>
</html>
\ No newline at end of file
<html>
<head>
<title>TESTESTEST</title>
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
</head>
......
......@@ -8,8 +8,8 @@
<img id="logo" src="image/logo.png">
<A href= "https://kart.nexon.com/Main/Index.aspx" target="_blank">공식 홈페이지 바로가기</A>
<div id="div1">
<button id="btn1"> <img src="image/btn1.png"></button>
<button id="btn2"> <img src="image/btn2.png"></button>
<button id="btn1" onClick="location.href='game'"> <img src="image/btn1.png"></button>
<button id="btn2" onClick="location.href='inf'"> <img src="image/btn2.png"></button>
</div>
</body>
......