장주현

complete translate address

......@@ -19,6 +19,7 @@ var addressK, addressE;
var detailaddressK, detailaddressE;
var extraaddressK, extraaddressE;
var zipcode;
var cityE, stateE, streetE;
app.get('/', function(req, res){
//res.send('hello world');
......@@ -34,20 +35,62 @@ var zipcode;
//app.use('/', indexRoute);
app.post('/', function(req,res){
app.post('/', async function(req,res){
console.log(req.body);
zipcode = req.body.zipcode;
addressK = req.body.addressK;
addressE = req.body.addressE;
detailaddressK = req.body.detailaddressK;
extraaddressK = req.body.extraaddressK;
extraaddressK = extraaddressK.replace("(", "");
extraaddressK = extraaddressK.replace(")", "");
console.log(extraaddressK);
console.log(addressK);
addressE = trans(addressK, detailaddressE);
//trans(detailaddressK, detailaddressE);
//trans(extraaddressK, extraaddressE);
setTimeout(function(){console.log("set: " +detailaddressE)},500);
request.post(
{
url: PAPAGO_URL,
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'X-Naver-Client-Id': `${PAPAGO_ID}`,
'X-Naver-Client-Secret': `${PAPAGO_SECRET}`
},
body: 'source=ko&target=en&text=' + detailaddressK,
json:true
},(error, response, body) => {
if(!error && response.statusCode == 200) {
console.log(body.message);
detailaddressE = body.message.result.translatedText;
}
});
request.post(
{
url: PAPAGO_URL,
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'X-Naver-Client-Id': `${PAPAGO_ID}`,
'X-Naver-Client-Secret': `${PAPAGO_SECRET}`
},
body: 'source=ko&target=en&text=' + extraaddressK,
json:true
},(error, response, body) => {
if(!error && response.statusCode == 200) {
console.log(body.message);
extraaddressE = body.message.result.translatedText;
}
});
setTimeout(function(){
var splitaddressE = addressE.split(", ");
cityE = splitaddressE[4];
stateE = splitaddressE[3];
streetE = splitaddressE[0] + ", " +splitaddressE[1] + ", " + splitaddressE[2];
},300);
setTimeout(function(){console.log("set2: " +detailaddressE)},300);
setTimeout(function(){console.log("set2: " +extraaddressE)},300);
//var splitaddressE = addressE.split(", ")
console.log("address: " + addressE);
console.log("detail: " + detailaddressE);
res.render('changeaddr', { cityE : cityE, stateE : stateE, streetE : streetE, detailaddressE : detailaddressE, extraaddressE : extraaddressE, zipcode : zipcode, os : req.body.os})
});
......@@ -70,8 +113,8 @@ function trans(message, totrans){
if(!error && response.statusCode == 200) {
console.log(body.message);
totrans = body.message.result.translatedText;
return totrans;
ffu();
return body.message.result.translatedText;
}
});
};
\ No newline at end of file
......
Contry/Region: Korea, Republic of<br>
Full name: 영문이름<br>
Street address: <%= streetE %><br>
Street address: <%= detailaddressE %><br>
City: <%= cityE %><br>
Zip Code: <%= zipcode %><br>
Phone number: (+82)본인의 전화번호<br>
<br><br>
복사후 아마존 주소 입력란에 붙여놓기를 하면 된다
\ No newline at end of file
Contry: Korea, South<br>
Name: 영문이름<br>
Street address: <%= streetE %><br>
Street address 2: <%= detailaddressE %><br>
City: <%= cityE %><br>
Zip Code: <%= zipcode %><br>
Phone number: (+82)본인의 전화번호<br>
<br><br>
복사후 이베이 주소 입력란에 붙여놓기를 하면 된다
\ No newline at end of file
<form action="" method="POST">
<input type="text" name="zipcode" id="sample3_postcode" placeholder="우편번호">
<input type="button" onclick="sample3_execDaumPostcode()" value="우편번호 찾기"><br>
<input type="text" name="addressK" id="sample3_address" placeholder="주소"><br>
<input type="text" name="detailaddressK" id="sample3_detailAddress" placeholder="상세주소">
<input type="text" name="extraaddressK" id="sample3_extraAddress" placeholder="참고항목">
<input type="text" name="addressE" class = "invisible">
<p> 사용할 해외 쇼핑몰 선택 후 변환</p>
<input type="radio" name="os" value="amazon" checked="checked">Amazon
......@@ -34,6 +36,9 @@ Contry/Region: <input type="text" name="contry" placeholder="국가">
var element_wrap = document.getElementById('wrap');
var englishadd;
document.getElementsByClassName('invisible')[0].style = "display:none;"
function foldDaumPostcode() {
// iframe을 넣은 element를 안보이게 한다.
......@@ -55,12 +60,11 @@ Contry/Region: <input type="text" name="contry" placeholder="국가">
//사용자가 선택한 주소 타입에 따라 해당 주소 값을 가져온다.
if (data.userSelectedType === 'R') { // 사용자가 도로명 주소를 선택했을 경우
addr = data.roadAddress;
document.getElementsByClassName('invisible')[0].value = data.roadAddressEnglish;
} else { // 사용자가 지번 주소를 선택했을 경우(J)
addr = data.jibunAddress;
}
englishadd = data.roadAddressEnglish;
// 사용자가 선택한 주소가 도로명 타입일때 참고항목을 조합한다.
if(data.userSelectedType === 'R'){
// 법정동명이 있을 경우 추가한다. (법정리는 제외)
......