김명주

Create game and Connect homepage

...@@ -6,11 +6,13 @@ const bodyParser=require('body-parser'); ...@@ -6,11 +6,13 @@ const bodyParser=require('body-parser');
6 app.use(bodyParser.urlencoded({extended: false})); // URL 인코딩 안함 6 app.use(bodyParser.urlencoded({extended: false})); // URL 인코딩 안함
7 app.use(bodyParser.json()); // json 타입으로 파싱하게 설정 7 app.use(bodyParser.json()); // json 타입으로 파싱하게 설정
8 app.use('/inf/result',express.static('metadata')); 8 app.use('/inf/result',express.static('metadata'));
9 +app.use('/',express.static('views'));
9 10
10 app.set('views', __dirname + '/views'); 11 app.set('views', __dirname + '/views');
11 app.set('view engine', 'ejs'); 12 app.set('view engine', 'ejs');
12 13
13 var chname; 14 var chname;
15 +var vec=[];
14 app.post("/inf/result",(req,res)=>{ 16 app.post("/inf/result",(req,res)=>{
15 chname=encodeURIComponent(req.body.test); 17 chname=encodeURIComponent(req.body.test);
16 }); 18 });
...@@ -63,11 +65,21 @@ app.get("/inf/result",(req,res)=>{ ...@@ -63,11 +65,21 @@ app.get("/inf/result",(req,res)=>{
63 } 65 }
64 }); 66 });
65 }); 67 });
66 - 68 +app.post("/game",(req,res)=>{
69 + vec.push(req.body.test);
70 + console.log(vec);
71 +})
72 +app.get("/game",(req,res)=>{
73 + res.render('game_home');
74 +})
67 app.get("/inf",(req,res)=>{ 75 app.get("/inf",(req,res)=>{
68 res.render('inf_search_home'); 76 res.render('inf_search_home');
69 }); 77 });
70 78
79 +app.get("/",(req,res)=>{
80 + res.render('main_home');
81 +});
82 +
71 app.listen("8080",function(req,res){ 83 app.listen("8080",function(req,res){
72 console.log('server listening at port no. 8080'); 84 console.log('server listening at port no. 8080');
73 -});
...\ No newline at end of file ...\ No newline at end of file
85 +});
......
1 +<!DOCTYPE html>
2 +<html>
3 +
4 +<head>
5 + <meta charset="utf-8">
6 + <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
7 + <script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
8 +</head>
9 +<body>
10 + <script language="JavaScript">
11 + function Ajax(index){
12 + $.ajax({
13 + url: '/game', // postTest 주소로
14 + async: true, // 동기화 - 서버에서 반응이 올때까지 기다림
15 + type: 'POST', // POST 방식으로
16 + data: {
17 + test: index // 텍스트필드에 입력한 값을 test라는 이름으로 보냄
18 + },
19 + dataType: 'json'
20 + });
21 + }
22 + function Change(num) {
23 + if(num==1){
24 + document.getElementById("btn1").innerText="선택지1-1";
25 + document.getElementById("btn2").innerText="선택지2-1";
26 + Ajax(1);
27 + }
28 + else{
29 + document.getElementById("btn1").innerText="선택지1-1";
30 + document.getElementById("btn2").innerText="선택지2-1";
31 + Ajax(2);
32 + }
33 +
34 + /*
35 + var a=document.getElementById("btn").innerText;
36 + if(a=="뭘보냐"){
37 + document.getElementById("btn1").innerText="선택지1-1";
38 + document.getElementById("btn2").innerText="선택지1-1";
39 + Ajax(1);
40 + }
41 + else if(a=="안봤는데?"){
42 + document.getElementById("btn1").innerText="선택지1-2";
43 + Ajax(2);
44 + }
45 + else if(a=="본거다안다"){
46 + document.getElementById("btn2").innerText="선택지1-3";
47 + Ajax(3);
48 + }*/
49 + }
50 + </script>
51 + <button id="btn1" onclick="Change(1)">선택지 1</button>
52 + <button id="btn2" onclick="Change(2)">선택지 2</button>
53 +</body>
54 +</html>
...\ No newline at end of file ...\ No newline at end of file
1 <html> 1 <html>
2 <head> 2 <head>
3 - <title>TESTESTEST</title>
4 -
5 <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script> 3 <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
6 <script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script> 4 <script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
7 </head> 5 </head>
......
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
8 <img id="logo" src="image/logo.png"> 8 <img id="logo" src="image/logo.png">
9 <A href= "https://kart.nexon.com/Main/Index.aspx" target="_blank">공식 홈페이지 바로가기</A> 9 <A href= "https://kart.nexon.com/Main/Index.aspx" target="_blank">공식 홈페이지 바로가기</A>
10 <div id="div1"> 10 <div id="div1">
11 - <button id="btn1"> <img src="image/btn1.png"></button> 11 + <button id="btn1" onClick="location.href='game'"> <img src="image/btn1.png"></button>
12 - <button id="btn2"> <img src="image/btn2.png"></button> 12 + <button id="btn2" onClick="location.href='inf'"> <img src="image/btn2.png"></button>
13 </div> 13 </div>
14 </body> 14 </body>
15 15
......