Showing
4 changed files
with
74 additions
and
9 deletions
... | @@ -19,6 +19,7 @@ var addressK, addressE; | ... | @@ -19,6 +19,7 @@ var addressK, addressE; |
19 | var detailaddressK, detailaddressE; | 19 | var detailaddressK, detailaddressE; |
20 | var extraaddressK, extraaddressE; | 20 | var extraaddressK, extraaddressE; |
21 | var zipcode; | 21 | var zipcode; |
22 | +var cityE, stateE, streetE; | ||
22 | 23 | ||
23 | app.get('/', function(req, res){ | 24 | app.get('/', function(req, res){ |
24 | //res.send('hello world'); | 25 | //res.send('hello world'); |
... | @@ -34,20 +35,62 @@ var zipcode; | ... | @@ -34,20 +35,62 @@ var zipcode; |
34 | 35 | ||
35 | //app.use('/', indexRoute); | 36 | //app.use('/', indexRoute); |
36 | 37 | ||
37 | -app.post('/', function(req,res){ | 38 | +app.post('/', async function(req,res){ |
38 | console.log(req.body); | 39 | console.log(req.body); |
39 | zipcode = req.body.zipcode; | 40 | zipcode = req.body.zipcode; |
40 | addressK = req.body.addressK; | 41 | addressK = req.body.addressK; |
42 | + addressE = req.body.addressE; | ||
41 | detailaddressK = req.body.detailaddressK; | 43 | detailaddressK = req.body.detailaddressK; |
42 | extraaddressK = req.body.extraaddressK; | 44 | extraaddressK = req.body.extraaddressK; |
45 | + extraaddressK = extraaddressK.replace("(", ""); | ||
46 | + extraaddressK = extraaddressK.replace(")", ""); | ||
47 | + console.log(extraaddressK); | ||
43 | console.log(addressK); | 48 | console.log(addressK); |
44 | - addressE = trans(addressK, detailaddressE); | ||
45 | //trans(detailaddressK, detailaddressE); | 49 | //trans(detailaddressK, detailaddressE); |
46 | //trans(extraaddressK, extraaddressE); | 50 | //trans(extraaddressK, extraaddressE); |
47 | - setTimeout(function(){console.log("set: " +detailaddressE)},500); | 51 | + request.post( |
52 | + { | ||
53 | + url: PAPAGO_URL, | ||
54 | + headers: { | ||
55 | + 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', | ||
56 | + 'X-Naver-Client-Id': `${PAPAGO_ID}`, | ||
57 | + 'X-Naver-Client-Secret': `${PAPAGO_SECRET}` | ||
58 | + }, | ||
59 | + body: 'source=ko&target=en&text=' + detailaddressK, | ||
60 | + json:true | ||
61 | + },(error, response, body) => { | ||
62 | + if(!error && response.statusCode == 200) { | ||
63 | + console.log(body.message); | ||
64 | + detailaddressE = body.message.result.translatedText; | ||
65 | + } | ||
66 | + }); | ||
67 | + request.post( | ||
68 | + { | ||
69 | + url: PAPAGO_URL, | ||
70 | + headers: { | ||
71 | + 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', | ||
72 | + 'X-Naver-Client-Id': `${PAPAGO_ID}`, | ||
73 | + 'X-Naver-Client-Secret': `${PAPAGO_SECRET}` | ||
74 | + }, | ||
75 | + body: 'source=ko&target=en&text=' + extraaddressK, | ||
76 | + json:true | ||
77 | + },(error, response, body) => { | ||
78 | + if(!error && response.statusCode == 200) { | ||
79 | + console.log(body.message); | ||
80 | + extraaddressE = body.message.result.translatedText; | ||
81 | + } | ||
82 | + }); | ||
83 | + setTimeout(function(){ | ||
84 | + var splitaddressE = addressE.split(", "); | ||
85 | + cityE = splitaddressE[4]; | ||
86 | + stateE = splitaddressE[3]; | ||
87 | + streetE = splitaddressE[0] + ", " +splitaddressE[1] + ", " + splitaddressE[2]; | ||
88 | + },300); | ||
89 | + setTimeout(function(){console.log("set2: " +detailaddressE)},300); | ||
90 | + setTimeout(function(){console.log("set2: " +extraaddressE)},300); | ||
91 | + //var splitaddressE = addressE.split(", ") | ||
48 | console.log("address: " + addressE); | 92 | console.log("address: " + addressE); |
49 | - console.log("detail: " + detailaddressE); | 93 | + res.render('changeaddr', { cityE : cityE, stateE : stateE, streetE : streetE, detailaddressE : detailaddressE, extraaddressE : extraaddressE, zipcode : zipcode, os : req.body.os}) |
50 | - | ||
51 | }); | 94 | }); |
52 | 95 | ||
53 | 96 | ||
... | @@ -70,8 +113,8 @@ function trans(message, totrans){ | ... | @@ -70,8 +113,8 @@ function trans(message, totrans){ |
70 | if(!error && response.statusCode == 200) { | 113 | if(!error && response.statusCode == 200) { |
71 | console.log(body.message); | 114 | console.log(body.message); |
72 | totrans = body.message.result.translatedText; | 115 | totrans = body.message.result.translatedText; |
73 | - | 116 | + ffu(); |
74 | - return totrans; | 117 | + return body.message.result.translatedText; |
75 | } | 118 | } |
76 | }); | 119 | }); |
77 | }; | 120 | }; |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
views/amazonaddr.ejs
0 → 100644
1 | +Contry/Region: Korea, Republic of<br> | ||
2 | +Full name: 영문이름<br> | ||
3 | +Street address: <%= streetE %><br> | ||
4 | +Street address: <%= detailaddressE %><br> | ||
5 | +City: <%= cityE %><br> | ||
6 | +Zip Code: <%= zipcode %><br> | ||
7 | +Phone number: (+82)본인의 전화번호<br> | ||
8 | +<br><br> | ||
9 | +복사후 아마존 주소 입력란에 붙여놓기를 하면 된다 | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
views/ebayaddr.ejs
0 → 100644
1 | +Contry: Korea, South<br> | ||
2 | +Name: 영문이름<br> | ||
3 | +Street address: <%= streetE %><br> | ||
4 | +Street address 2: <%= detailaddressE %><br> | ||
5 | +City: <%= cityE %><br> | ||
6 | +Zip Code: <%= zipcode %><br> | ||
7 | +Phone number: (+82)본인의 전화번호<br> | ||
8 | +<br><br> | ||
9 | +복사후 이베이 주소 입력란에 붙여놓기를 하면 된다 | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | 1 | ||
2 | 2 | ||
3 | + | ||
3 | <form action="" method="POST"> | 4 | <form action="" method="POST"> |
4 | <input type="text" name="zipcode" id="sample3_postcode" placeholder="우편번호"> | 5 | <input type="text" name="zipcode" id="sample3_postcode" placeholder="우편번호"> |
5 | <input type="button" onclick="sample3_execDaumPostcode()" value="우편번호 찾기"><br> | 6 | <input type="button" onclick="sample3_execDaumPostcode()" value="우편번호 찾기"><br> |
6 | <input type="text" name="addressK" id="sample3_address" placeholder="주소"><br> | 7 | <input type="text" name="addressK" id="sample3_address" placeholder="주소"><br> |
7 | <input type="text" name="detailaddressK" id="sample3_detailAddress" placeholder="상세주소"> | 8 | <input type="text" name="detailaddressK" id="sample3_detailAddress" placeholder="상세주소"> |
8 | <input type="text" name="extraaddressK" id="sample3_extraAddress" placeholder="참고항목"> | 9 | <input type="text" name="extraaddressK" id="sample3_extraAddress" placeholder="참고항목"> |
10 | + <input type="text" name="addressE" class = "invisible"> | ||
9 | 11 | ||
10 | <p> 사용할 해외 쇼핑몰 선택 후 변환</p> | 12 | <p> 사용할 해외 쇼핑몰 선택 후 변환</p> |
11 | <input type="radio" name="os" value="amazon" checked="checked">Amazon | 13 | <input type="radio" name="os" value="amazon" checked="checked">Amazon |
... | @@ -34,6 +36,9 @@ Contry/Region: <input type="text" name="contry" placeholder="국가"> | ... | @@ -34,6 +36,9 @@ Contry/Region: <input type="text" name="contry" placeholder="국가"> |
34 | var element_wrap = document.getElementById('wrap'); | 36 | var element_wrap = document.getElementById('wrap'); |
35 | var englishadd; | 37 | var englishadd; |
36 | 38 | ||
39 | + document.getElementsByClassName('invisible')[0].style = "display:none;" | ||
40 | + | ||
41 | + | ||
37 | 42 | ||
38 | function foldDaumPostcode() { | 43 | function foldDaumPostcode() { |
39 | // iframe을 넣은 element를 안보이게 한다. | 44 | // iframe을 넣은 element를 안보이게 한다. |
... | @@ -55,12 +60,11 @@ Contry/Region: <input type="text" name="contry" placeholder="국가"> | ... | @@ -55,12 +60,11 @@ Contry/Region: <input type="text" name="contry" placeholder="국가"> |
55 | //사용자가 선택한 주소 타입에 따라 해당 주소 값을 가져온다. | 60 | //사용자가 선택한 주소 타입에 따라 해당 주소 값을 가져온다. |
56 | if (data.userSelectedType === 'R') { // 사용자가 도로명 주소를 선택했을 경우 | 61 | if (data.userSelectedType === 'R') { // 사용자가 도로명 주소를 선택했을 경우 |
57 | addr = data.roadAddress; | 62 | addr = data.roadAddress; |
63 | + document.getElementsByClassName('invisible')[0].value = data.roadAddressEnglish; | ||
58 | } else { // 사용자가 지번 주소를 선택했을 경우(J) | 64 | } else { // 사용자가 지번 주소를 선택했을 경우(J) |
59 | addr = data.jibunAddress; | 65 | addr = data.jibunAddress; |
60 | } | 66 | } |
61 | 67 | ||
62 | - englishadd = data.roadAddressEnglish; | ||
63 | - | ||
64 | // 사용자가 선택한 주소가 도로명 타입일때 참고항목을 조합한다. | 68 | // 사용자가 선택한 주소가 도로명 타입일때 참고항목을 조합한다. |
65 | if(data.userSelectedType === 'R'){ | 69 | if(data.userSelectedType === 'R'){ |
66 | // 법정동명이 있을 경우 추가한다. (법정리는 제외) | 70 | // 법정동명이 있을 경우 추가한다. (법정리는 제외) | ... | ... |
-
Please register or login to post a comment