//system Messgae
msg_item._cate1 = "Login";
msg_item._cate2 = "Login";
msg_item._complage_function = "msg_obj_complete";
msg_item._systemMessageCall(document.location.href);
$rj(document).ready(function() {
try{
var _userid = $rj("#userid");
var _userpw = $rj("#userpw");
var _userotp = $rj("#userotp");
var _result = $rj("#result");
var _ru = $rj("#ru");
var _rq = $rj("#rq");
var _rv = $rj("#rv");
var _submit = $rj("#submit");
var _frm = $rj("#frm");
var _opener = $rj("#opener");
var _returnval;
var _val = null;
var _returnurl = "/Return_page.html";
if (document.location.href.toUpperCase().indexOf("LOGIN_POPUP.HTML") > 0){
_returnurl = "/Return_Popup_page.html";
}
_userid.live({
load : function(){ _userid.focus();},blur : function(){if(_userid.val() == "" ){_userid.val(f_obj_msg("Login", 100, "Portal ID"));}else{_result.html("");}},focus : function(){if(_userid.val() == "" || _userid.val() == f_obj_msg("Login", 100, "Portal ID")){_userid.val("");}}
,keypress : function(e){if(e.which == 13){_userpw.focus();}}
});
_userpw.live({
blur : function(){if(_userpw.val() == "" ){_userpw.val(f_obj_msg("Login", 101, "User Password"));}else{_result.html("");}},focus : function(){if(_userpw.val() == "" || _userpw.val() == f_obj_msg("Login", 101, "User Password")){_userpw.val("");}}
,keypress : function(e){if(e.which == 13){_submit.click();}}
});
_submit.click(function(e){
if(_userid.val() == "" || _userid.val() == f_obj_msg("Login", 100, "Portal ID")){
_returnval = "" + f_obj_msg("Login", 102, "Please enter a Portal ID") + ""; _result.html(_returnval); _userid.focus().val("");
return;
}
if(_userpw.val() == "" || _userpw.val() == f_obj_msg("Login", 101, "User Password")){
_returnval = "" + f_obj_msg("Login", 103, "Please enter a User Password")+ ""; _result.html(_returnval); _userpw.focus().val("");
return;
}
//var logincheckbtn = $rj.getJSON(S_domain.__PortalHttps + "/Login/Login.process.html", _frm.serialize());
var logincheckbtn = $rj.post(S_domain.__PortalHttps + "/Login/Login.process.html", _frm.serialize(), function(response){}, 'json');
logincheckbtn.success(function(data){
if (data.result.returncode == 0){
var __returndomain = S_domain.__PortalHttps;
if (_rv.val() == "off"){__returndomain = S_domain.__PortalHttp;}
document.location.href = __returndomain + _returnurl + "?ru="+ _ru.val() +"&rq="+ _rq.val() +"&opener="+ _opener.val(); return;
}
else if (data.result.returncode == 200)
{
$rj("#login_content").load("/login/loginotp.html?uid="+$rj("#userid").val()+"&upw="+$rj("#userpw").val());
}
else{
_returnval = ""+data.result.returnmsg.toString()+"";
_result.html(_returnval);
}
debug.__debug("Ajax_success : " + data.result.returncode.toString());
debug.__debug("Ajax_success : " + data.result.returnmsg.toString());
});
logincheckbtn.error(function(xhr, ajaxOptions, thrownError){
debug.__debug("Ajax_error : " + xhr.status.toString());
debug.__debug("Ajax_error : " + thrownError);
});
logincheckbtn.complete(function(data, textStatus){
debug.__debug("Ajax_complete : " + textStatus.toString());
});
});
_userid.focus();
}catch (e){debug.__debug("Error : $rj(document).ready(function() { ["+ e +"]");}
});
//facebook
function fb_login() {
FB.login(function() {
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
}, {
scope: 'email,public_profile'
} );
//checkLoginState();
}
// This is called with the results from from FB.getLoginStatus().
// function statusChangeCallback(response) {
function statusChangeCallback(response) {
//console.log('statusChangeCallback');
//console.log(response);
// The response object is returned with a status field that lets the
// app know the current login status of the person.
// Full docs on the response object can be found in the documentation
// for FB.getLoginStatus().
if (response.status === 'connected') {
// Logged into your app and Facebook.
testAPI();
} else if (response.status === 'not_authorized') {
// The person is logged into Facebook, but not your app.
//document.getElementById('status').innerHTML = 'Please log ' +
// 'into this app.';
} else {
// The person is not logged into Facebook, so we're not sure if
// they are logged into this app or not.
//document.getElementById('status').innerHTML = 'Please log ' +
// 'into Facebook.';
}
}
function checkLoginState() {
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
}
window.fbAsyncInit = function() {
FB.init({
appId : '971979496155297',
cookie : true, // enable cookies to allow the server to access
// the session
xfbml : true, // parse social plugins on this page
version : 'v2.1' // use version 2.1
});
};
// Load the SDK asynchronously
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
// Here we run a very simple test of the Graph API after login is
// successful. See statusChangeCallback() for when this call is made.
function testAPI() {
FB.api('/me', {'fields':'id,email'}, function(response) {
document.getElementById('type_sns').value = 'facebook';
document.getElementById('id_sns').value = response.id;
document.getElementById('email_sns').value = response.email;
document.getElementById('type_sns_connect').value = 'facebook_connect';
document.getElementById('id_facebook_connect').value = response.id;
document.getElementById('email_facebook_connect').value = response.email;
alert(response.id);
alert(response.email);
check_status_sns(response.id, 'facebook', response.email);
});
}
//facebook
//google
(function() {
var po = document.createElement('script');
po.type = 'text/javascript';
po.async = false;
po.src = 'https://apis.google.com/js/client:plusone.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(po, s);
})();
function render() {
gapi.signin.render('customBtn', {
'callback': 'signinCallback',
'clientid': '872592397740-urcq2bo4qlpnl1i0jad7k9e9oufqgrm7.apps.googleusercontent.com',
'cookiepolicy': 'single_host_origin',
'requestvisibleactions': 'http://schemas.google.com/AddActivity',
'scope': 'https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/userinfo.email'
//'approvalprompt': 'force'
});
}
function signinCallback(authResult) {
if (authResult['access_token']) {
// success
// EX] success -> hide button:
//document.getElementById('signinButton').setAttribute('style', 'display: none');
gapi.client.load('plus', 'v1', apiClientLoaded);
} else if (authResult['error']) {
//occur error.
// Enable Error Codes:
// "access_denied" - denide
// "immediate_failed" - fail automatic login
// console.log('Occur Error: ' + authResult['error']);
}
}
//Sets up an API call after the Google API client loads.
function apiClientLoaded() {
gapi.client.plus.people.get({userId: 'me'}).execute(handleEmailResponse);
gapi.auth.signOut(); //turn off immediate mode
}
//Response callback for when the API client receives a response.
//@param resp The API response object with the user email and profile information.
function handleEmailResponse(resp) {
var primaryEmail, birthDay, id, gender, name, firstName, lastName, currentLocation, nickName;
for (var i=0; i < resp.emails.length; i++) {
if (resp.emails[i].type === 'account'){
primaryEmail = resp.emails[i].value;
}
id = resp.id;
gender = resp.gender;
firstName = resp.name.givenName;
lastName = resp.name.familyName;
nickName = resp.nickName;
birthDay = resp.birthday;
}
//console.log('Successful login for: ' + response.name);
document.getElementById('type_sns').value = 'google';
document.getElementById('id_sns').value = id;
document.getElementById('email_sns').value = primaryEmail;
document.getElementById('type_sns_connect').value = 'google_connect';
document.getElementById('id_google_connect').value = id;
document.getElementById('email_google_connect').value = primaryEmail;
check_status_sns(id, 'google', primaryEmail);
}
//google
//processing after sns logins
function check_status_sns(id_sns, type_sns, email_sns) {
//rj(document).ready(function());
var _userid = $rj("#userid");
var _userpw = $rj("#userpw");
var _result = $rj("#result");
var _ru = $rj("#ru");
var _rq = $rj("#rq");
var _rv = $rj("#rv");
var _submit = $rj("#submit");
var _frm = $rj("#frm");
var _opener = $rj("#opener");
var _returnval;
var _val = null;
var _returnurl = "/Return_page.html";
if (document.location.href.toUpperCase().indexOf("LOGIN_POPUP.HTML") > 0){
_returnurl = "/Return_Popup_page.html";
}
if(email_sns == "" || email_sns == f_obj_msg("Login", 100, "Portal ID")){
_returnval = "" + f_obj_msg("Login", 102, "Invalid information") + ""; _result.html(_returnval); _userid.focus().val("");
return;
}
if(id_sns == "" || id_sns == f_obj_msg("Login", 101, "User Password")){
_returnval = "" + f_obj_msg("Login", 103, "Invalid information")+ ""; _result.html(_returnval); _userpw.focus().val("");
return;
}
if(type_sns == "" || type_sns == f_obj_msg("Login", 101, "User Password")){
_returnval = "" + f_obj_msg("Login", 103, "Invalid information")+ ""; _result.html(_returnval); _userpw.focus().val("");
return;
}
//var logincheckbtn = $rj.getJSON(S_domain.__PortalHttps + "/Login/Login.process_sns.html", _frm.serialize());
var logincheckbtn = $rj.post(S_domain.__PortalHttps + "/Login/Login.process_sns.html", $rj("#frm").serialize(), function(response){}, 'json');
logincheckbtn.success(function(data){
if (data.result.returncode == 0){
var __returndomain = S_domain.__PortalHttps;
if (_rv.val() == "off"){__returndomain = S_domain.__PortalHttp;}
document.location.href = __returndomain + _returnurl + "?ru="+ _ru.val() +"&rq="+ _rq.val() +"&opener="+ _opener.val(); return;
}else if (data.result.returncode == -1005){
if(confirm('Your email is already in use. Do you want to connect between your email and ' + type_sns + ' account?') == true){
if (type_sns == 'facebook') {
document.getElementById('type_sns').value = 'facebook_connect';
document.facebook_connect.submit();
} else if (type_sns == 'google') {
document.getElementById('type_sns').value = 'google_connect';
document.google_connect.submit();
}
}else{
return false;
}
}else{
_returnval = ""+data.result.returnmsg.toString()+"";
_result.html(_returnval);
}
debug.__debug("Ajax_success : " + data.result.returncode.toString());
debug.__debug("Ajax_success : " + data.result.returnmsg.toString());
});
logincheckbtn.error(function(xhr, ajaxOptions, thrownError){
debug.__debug("Ajax_error : " + xhr.status.toString());
debug.__debug("Ajax_error : " + thrownError);
});
logincheckbtn.complete(function(data, textStatus){
debug.__debug("Ajax_complete : " + textStatus.toString());
});
}
//processing after sns logins