//구독하기 //파라미터 - device (디바이스), type (S - 스타기자, I - 연재기사, J - J팟), id (채널 및 이슈 아이디), email (이메일) var mailSubscribeJS = { Open: function(type, id) { if (type == 'B') { document.location.href = 'https://my.joins.com/private/basic.asp'; return; } if (mailSubscribeJS.Error(id)) return; if (type == 'S' || type == 'I') { mailSubscribeJS.StarHtml(id); } else if (type == 'J') { mailSubscribeJS.JpodHtml(id); } }, OpenMobile: function(type, id) { if (type == 'S' || type == 'I') { document.location.href = '/IssueSeries/MailSubscribe/' + id + '?' + type + id; } else if (type == 'J') { document.location.href = '/Jpod/MailSubscribe/' + id + '?' + type + id; } else if (type == 'B') { document.location.href = 'https://my.joins.com/private/basic.asp'; } }, Subscribe: function(device, type, id) { var email = mailSubscribeJS.Email(); if (email == '') return; $('#subscribeArea').blur(); if(grecaptcha.getResponse() == '') { alert('로봇에 의한 자동 가입이 아님을 확인(체크)해 주십시오.'); return; } if (!$('#subscribeArea label').hasClass('checked')) { alert('개인정보 보호를 위한 이용자 동의 내용 확인 후 동의해 주십시오.'); return; } if (type == 'S') { mailSubscribeJS.StarSubscribe(device, id, email); } else if (type == 'J') { mailSubscribeJS.JpodSubscribe(device, id, email); } }, StarHtml: function(id) { $.ajax({ type: 'GET', dataType: 'HTML', url: utils.config('apiPath') + '/pagecall/?u=' + utils.config('webPcPath') + '/IssueSeries/MailSubscribeForm?id=' + id, success: function (html) { if (mailSubscribeJS.Error(html)) return; $.when($('#subscribeArea').html(html)) .done(function() { mailSubscribeJS.Recaptcha(); $('#subscribeArea').show(); if (typeof SubscribeHtmlCallback == 'function') SubscribeHtmlCallback.call(); }); } }); }, StarSubscribe: function(device, id, email) { $.ajax({ type: 'GET', dataType: 'JSON', url: utils.config('apiPath') + '/pagecall/?u=' + utils.config('webPcPath') + '/IssueSeries/MailSubscribe?' + encodeURIComponent('id=' + id + '&email=' + email), success: function (subscribe) { var result = subscribe.result; if (result == -1) { alert('[' + subscribe.title + ']은(는)\n' + subscribe.date + '에 구독 신청한 상품입니다.\n확인 부탁드립니다. 감사합니다.'); } else if (result == -2) { alert('이미 인증 메일을 보냈습니다. 재발송은 1분 후에 가능합니다.'); } else if (result == 1) { alert('[' + subscribe.title + ']이(가)\n' + mailSubscribeJS.Today() + '에 구독 신청되었습니다.\n\n이메일 인증 후 신청 완료됩니다.\n이메일을 확인해 주십시오.\n\n감사합니다.'); } else if (result == 2) { alert('[' + subscribe.title + ']이(가)\n' + mailSubscribeJS.Today() + '에 구독 신청되었습니다.\n감사합니다.'); } else { alert('구독하기에 실패했습니다. 관리자에게 문의해 주세요.'); } mailSubscribeJS.StarClose(device, id, email); } }); }, StarClose: function(device, id, email) { if (device == 'P') { if (document.location.pathname.toLowerCase().indexOf('/newsletter') > -1) { if (email != undefined && email != '') { document.location.href = '/NewsLetter?e=' + email + '&h=S' + id; return; } } $('#subscribeArea').hide(); } else if (device == 'M') { if (document.location.search != '') { if (email == undefined || email == '') { document.location.href = '/NewsLetter#' + document.location.search.replace('?', ''); } else { document.location.href = '/NewsLetter?e=' + email + '&h=' + document.location.search.replace('?', ''); } } else if (document.referrer != '') { document.location.href = document.referrer; } else { document.location.href = '/IssueSeries/' + id; } } }, JpodSubscribe: function(device, id, email) { $.ajax({ type: 'POST', dataType: 'JSON', url: utils.config('apiPath') + '/Jpod/MailSubscribe', data: 'chID=' + id + '&sbEmail=' + email, success: function (subscribe) { var result = subscribe.result; if (result == -1) { alert('[' + subscribe.name + ']은(는)\n' + subscribe.date + '에 구독 신청한 상품입니다.\n확인 부탁드립니다. 감사합니다.'); } else if (result == -2) { alert('이미 인증 메일을 보냈습니다. 재발송은 1분 후에 가능합니다.'); } else if (result == 1) { alert('[' + subscribe.name + ']이(가)\n' + mailSubscribeJS.Today() + '에 구독 신청되었습니다.\n\n이메일 인증 후 신청 완료됩니다.\n이메일을 확인해 주십시오.\n\n감사합니다.'); } else if (result == 2) { alert('[' + subscribe.name + ']이(가)\n' + mailSubscribeJS.Today() + '에 구독 신청되었습니다.\n감사합니다.'); } else { alert('구독하기에 실패했습니다. 관리자에게 문의해 주세요.'); } mailSubscribeJS.JpodClose(device, id, email); } }); }, JpodHtml: function(id) { $.ajax({ type: 'GET', dataType: 'HTML', url: utils.config('apiPath') + '/pagecall/?u=' + utils.config('webPcPath') + '/Jpod/MailSubscribeForm?id=' + id, success: function (html) { if (mailSubscribeJS.Error(html)) return; $.when($('#subscribeArea').html(html)) .done(function() { mailSubscribeJS.Recaptcha(); $('#subscribeArea').show(); if (typeof SubscribeHtmlCallback == 'function') SubscribeHtmlCallback.call(); }); } }); }, JpodClose: function(device, id, email) { if (device == 'P') { if (document.location.pathname.toLowerCase().indexOf('/newsletter') > -1) { if (email != undefined && email != '') { document.location.href = '/NewsLetter?e=' + email + '&h=J' + id; return; } } $('#subscribeArea').hide(); } else if (device == 'M') { if (document.location.search != '') { if (email == undefined || email == '') { document.location.href = '/NewsLetter#' + document.location.search.replace('?', ''); } else { document.location.href = '/NewsLetter?e=' + email + '&h=' + document.location.search.replace('?', ''); } } else if (document.referrer != '') { document.location.href = document.referrer; } else { document.location.href = '/Jpod/Channel/' + id; } } }, Email: function() { var email = $.trim($('#sbEmail').val()); if ($('#sbEmail') == undefined || email == '') { alert('이메일 주소를 입력해 주세요.'); $('#sbEmail').focus(); return ''; } var emailReg = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; if (!emailReg.test(email)) { alert('이메일 주소가 잘못 입력 되었습니다.\n다시 확인해 주십시오.'); $('#sbEmail').focus(); return ''; } return email; }, Recaptcha: function() { grecaptcha.render('recaptchaArea', { 'sitekey' : '6Lcl1W8UAAAAAINHEI-TqOeFFgMWgjK79UFd9Ufa' }); }, Error: function(val) { if (val == '' || val == null || val == undefined || val == 0) { alert('구독신청이 불가능합니다.'); return true; } else { return false; } }, Today: function() { var date = utils.serverDate.get(); var year = date.getFullYear(); var month = (date.getMonth() + 1) > 9 ? (date.getMonth() + 1) : '0' + (date.getMonth() + 1); var day = (date.getDate() > 9) ? date.getDate() : '0' + date.getDate(); return year + '-' + month + '-' + day; } };