1/* 2 SNS login function 3 4 // ê° api í¤ ì»ë ì¬ì´í¸ 주ì 5 naver api key : https://developers.naver.com/appinfo 6 kakao api key : https://developers.kakao.com/ 7 facebook api key : https://developers.facebook.com/ 8 google api : https://console.developers.google.com 9*/ 10//var facebook = [], naver = [], kakao = []; 11//var sns_login = false; 12var facebook_key = '324856122284972'; // facebook_appkey 13var kakao_key = '0ebea99051ea9d2de133d5f626de00a6'; 14var naver_key = 'ui0iu_LYLDf7N474F32N'; // 3a_iBuTR41hKVd9hA4bh 15var google_key = '804396169408-mrndrh5q2sjcaddn1fofgop2m93t9r54'; 16//var nv_domain = ''; 17//var naver_callback= ''; 18 19function login_pop_close() 20{ 21 //$('#sns_login2').popup('hide'); 22 $('#window').modal('hide'); 23 //window.location = r_url; 24 if(r_url != '') { 25 //setTimeout('window.location = r_url;', 100); 26 //setTimeout("history.go(0);", 10); 27 window.location.reload(true); 28 //window.location = r_url; 29 //setTimeout(naver_callback, 10); 30 } 31} 32 33function saveCookie( name, value, expiredays ) 34{ 35 var todayDate = new Date(); 36 todayDate.setDate( todayDate.getDate() + expiredays ); 37 document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";" 38} 39 40 41function saveData(key, val) 42{ 43 saveCookie( key, val, 1); 44} 45 46var kakao_users = {}; 47Kakao.init(kakao_key); 48 49setTimeout(function(){ 50Kakao.Auth.getStatusInfo(function(statusObj) { 51 console.log('kakao statusObj', statusObj); 52}); 53}, 200); 54 55function kakao_login() 56{ 57 // ì´ë¯¸ ì¹´ì¹´ì¤ ë¡ê·¸ì¸íê² ìì¼ë©´ ì ì¥ë ê°ì 58 // ê°ì§ê³ 리뷰창 ì¶ë ¥. 59 if(sns_login || (kakao_users && kakao_users.id)) { 60 console.log('login already!', kakao_users); 61 //alert(kakao_users.id) 62 kakao_review(); 63 return; 64 } 65 66 //if(! sns_login) { 67 Kakao.Auth.logout(function(){ 68 console.log('kakao logout!'); 69 }); 70 //} 71 72 // ë¡ê·¸ì¸ ì°½ì ëìëë¤. 73 Kakao.Auth.login({ 74 success: function(authObj) { 75 //kakao = authObj; 76 //alert(JSON.stringify(authObj)); 77 console.log('auth', authObj); 78 // ë¡ê·¸ì¸ ì±ê³µì, API를 í¸ì¶í©ëë¤. 79 Kakao.API.request({ 80 url: '/v2/user/me', //'/v1/user/me', 81 success: function(res) { 82 //alert(JSON.stringify(res)); 83 sns_login=true; 84 console.log('kakao req', res); 85 kakao_users = res; 86 kakao = kakao_users; 87 kakao_review(); 88 }, 89 fail: function(error) { 90 alert(JSON.stringify(error)); 91 } 92 }); 93 }, 94 fail: function(err) { 95 alert(JSON.stringify(err)); 96 } 97 }); 98} 99 100function kakao_review() 101{ 102 // process. 103 //alert('kakao login ok.'); 104 saveData('login_type', 'kakao'); 105 saveData('mb_id', kakao_users.id); 106 if(kakao_users.properties) { 107 saveData('mb_name', kakao_users.properties.nickname); 108 } else { 109 saveData('mb_name', ''); 110 } 111 112 login_pop_close(); 113} 114 115 // This is called with the results from from FB.getLoginStatus(). 116 function statusChangeCallback(response) { 117 //console.log('statusChangeCallback'); 118 //console.log(response); 119 // response ê°ì²´ë íì¬ ë¡ê·¸ì¸ ìí를 ëíë´ë ì 보를 ë³´ì¬ì¤ë¤. 120 // ì±ìì íì¬ì ë¡ê·¸ì¸ ìíì ë°ë¼ ëìíë©´ ëë¤. 121 // FB.getLoginStatus().ì ë í¼ë°ì¤ìì ë ìì¸í ë´ì©ì´ 참조 ê°ë¥íë¤. 122 if (response.status === 'connected') { 123 // íì´ì¤ë¶ì íµí´ì ë¡ê·¸ì¸ì´ ëì´ìë¤. 124 //alert(response.authResponse.accessToken); 125 sns_login=true; 126 //facebook = response.authResponse; 127 FB.api('/v2.8/me', function(response) { 128 facebook = response; 129 //console.log('Successful login for: ' + response.name); 130 document.getElementById('status').innerHTML ='Thanks for logging in, ' + response.name + '!'; 131 }); 132 133 //testAPI(); 134 // ë¡ê·¸ì¸ì´ ì±ê³µí ë¤ììë ê°ë¨í ê·¸ëíAPI를 í¸ì¶íë¤. 135 //console.log('Welcome! Fetching your information.... '); 136 FB.api('/v2.8/me', function(response) { 137 //console.log('Successful login for: ' + response.name); 138 document.getElementById('status').innerHTML = 139 'Thanks for logging in, ' + response.name + '!'; 140 }); 141 142 } else if (response.status === 'not_authorized') { 143 // íì´ì¤ë¶ìë ë¡ê·¸ì¸ íì¼ë, ì±ìë ë¡ê·¸ì¸ì´ ëì´ìì
143§ ìë¤. 144 document.getElementById('status').innerHTML = 'Please log ' + 145 'into this app.'; 146 } else { 147 // íì´ì¤ë¶ì ë¡ê·¸ì¸ì´ ëì´ìì§ ìë¤. ë°ë¼ì, ì±ì ë¡ê·¸ì¸ì´ ëì´ìëì§ ì¬ë¶ê° ë¶íì¤íë¤. 148 document.getElementById('status').innerHTML = 'Please log ' + 149 'into Facebook.'; 150 } 151 } 152 153 // ì´ í¨ìë ëêµ°ê°ê° ë¡ê·¸ì¸ ë²í¼ì ëí ì²ë¦¬ê° ëë¬ì ë í¸ì¶ëë¤. 154 // onlogin í¸ë¤ë¬ë¥¼ ìëì ê°ì´ 첨ë¶íë©´ ëë¤. 155 function checkLoginState() { 156 FB.getLoginStatus(function(response) { 157 statusChangeCallback(response); 158 }); 159 } 160 161 window.fbAsyncInit = function() { 162 FB.init({ 163 appId : facebook_key, 164 /* cookie : true, // ì¿ í¤ê° ì¸ì ì 참조í ì ìëë¡ íì© */ 165 xfbml : true, // ìì íë¬ê·¸ì¸ì´ ìì¼ë©´ ì²ë¦¬ 166 version : 'v2.8' // ë²ì 2.8 ì¬ì© 167 }); 168 //FB.AppEvents.logPageView(); 169 170 171 // ìë°ì¤í¬ë¦½í¸ SDK를 ì´ê¸°í íì¼ë, FB.getLoginStatus()를 í¸ì¶íë¤. 172 // ì´ í¨ìë ì´ íì´ì§ì ì¬ì©ìê° íì¬ ë¡ê·¸ì¸ ëì´ìë ìí 3ê°ì§ ì¤ íë를 ì½ë°±ì 리í´íë¤. 173 // ê·¸ 3ê°ì§ ìíë ìëì ê°ë¤. 174 // 1. ì±ê³¼ íì´ì¤ë¶ì ë¡ê·¸ì¸ ëì´ìë¤. ('connected') 175 // 2. íì´ì¤ë¶ì ë¡ê·¸ì¸ëì´ìì¼ë, ì±ìë ë¡ê·¸ì¸ì´ ëì´ìì§ ìë¤. ('not_authorized') 176 // 3. íì´ì¤ë¶ì ë¡ê·¸ì¸ì´ ëì´ìì§ ììì ì±ì ë¡ê·¸ì¸ì´ ëìëì§ ë¶íì¤íë¤. 177 // 178 // ììì 구íí ì½ë°± í¨ìë ì´ 3ê°ì§ë¥¼ ë¤ë£¨ëë¡ ëì´ìë¤. 179 /* 180 FB.getLoginStatus(function(response) { 181 statusChangeCallback(response); 182 }); 183 */ 184 185 }; 186 187 // SDK를 ë¹ë기ì ì¼ë¡ í¸ì¶ 188 /**/ 189 (function(d, s, id){ 190 var js, fjs = d.getElementsByTagName(s)[0]; 191 if (d.getElementById(id)) {return;} 192 js = d.createElement(s); js.id = id; 193 js.src = "https://connect.facebook.net/ko_KR/sdk.js"; 194 js.async=1; 195 fjs.parentNode.insertBefore(js, fjs); 196 }(document, 'script', 'facebook-jssdk')); 197 /**/ 198 /* 199 (function(d, s, id){ 200 var js, fjs = d.getElementsByTagName(s)[0]; 201 if (d.getElementById(id)) {return;} 202 js = d.createElement(s); js.id = id; 203 js.src = "//connect.facebook.net/en_US/sdk.js"; 204 fjs.parentNode.insertBefore(js, fjs); 205 }(document, 'script', 'facebook-jssdk')); 206 */ 207 208var facebookAuth = ''; 209 210// íì´ì¤ë¶ ë¡ê·¸ì¸ ë²í¼ ì²ë¦¬ í¨ì 211function facebook_login() 212{ 213 if(sns_login) { 214 login_pop_close(); 215 return; 216 } 217 218 FB.login(function(response) { 219 // response ì²ë¦¬ 220 //console.log('facebook conn:', response.status, response); 221 //alert('fb login: '+response); 222 facebookAuth = response.authResponse; 223 224 if (response.status === 'connected') { 225 // íì´ì¤ë¶ê³¼ ì±ì ê°ì´ ë¡ê·¸ì¸ëì´ ìë¤. 226 //sns_login=true; 227 //facebook = response.authResponse; 228 //FB.api('/v2.8/me', {fields: 'id,name,email'}, function(response) { 229 //FB.api('/v2.8/me?fields=id,name,email', function(response) { 230 FB.api('/me', 'GET', {"fields":"id,name,email"}, function(response2) { 231 //FB.api('/me', function(response) { 232 /* 233 // íìì ë³´ ê°ì ¸ì¤ê¸° 234 response.id : ìì´ë 235 response.name : ì´ë¦ 236 */ 237 facebook = response2; 238 239 /* 240 console.log('facebook conn:', facebookAuth); 241 console.log('facebook login ok.'); 242 console.log('response', JSON.stringify(response2)); 243 console.log('facebook', facebook); 244 console.log('Successful login for: ' + response2.name); 245 */ 246 //document.getElementById('status').innerHTML ='Thanks for logging in, ' + response.name + '!'; 247 }); 248 // /v2.8/me/permissions 249 FB.api('me/permissions', function(response) { 250 //console.log('permissions', JSON.stringify(response)); 251 }); 252 253 if(! facebook.id) { 254 facebook.id = facebookAuth.userID; 255 } 256 if(! facebook.name) { 257 facebook.name = ''; 258 } 259 260 if(facebook.id != '') { 261 sns_login=true; 262 saveData('login_type', 'facebook');
263 saveData('mb_id', facebook.id); 264 saveData('mb_name', facebook.name); 265 } 266 267 //console.log(facebook); 268 // process. 269 //alert('facebook login ok.'); 270 /* 271 saveData('login_type', 'facebook'); 272 saveData('mb_id', facebook.id); 273 saveData('mb_name', facebook.name); 274 */ 275 login_pop_close(); 276 277 //alert('íì´ì¤ë¶ê³¼ ì±ì ê°ì´ ë¡ê·¸ì¸ëì´ ìë¤.'); 278 279 } else if (response.status === 'not_authorized') { 280 // íì´ì¤ë¶ìë ë¡ê·¸ì¸ ëì´ìì¼ë, ì±ìë ë¡ê·¸ì¸ ëì´ìì§ ìë¤. 281 alert('íì´ì¤ë¶ìë ë¡ê·¸ì¸ ëì´ìì¼ë, ì±ìë ë¡ê·¸ì¸ ëì´ìì§ ìë¤.'); 282 } else { 283 // íì´ì¤ë¶ì ë¡ê·¸ì¸ì´ ëì´ìì§ ììì, ì±ì ë¡ê·¸ì¸ ëì´ìëì§ ë¶ëª ííë¤. 284 alert('íì´ì¤ë¶ì ë¡ê·¸ì¸ì´ ëì´ìì§ ììì, ì±ì ë¡ê·¸ì¸ ëì´ìëì§ ë¶ëª ííë¤.'); 285 } 286 287 }, {scope: 'email,public_profile'}); 288} 289 290function facebook_logout() 291{ 292 //alert('logout call'); 293 FB.logout(function(response) { 294 // ì¬ì©ì ë¡ê·¸ ìì ì´í ì½ë°±ì²ë¦¬ 295 alert('logout'); 296}); 297} 298 299// naver_id_login("ë±ë¡í ClientID ê°", "ë±ë¡í Callback URL ê°"); 300var n_state = ''; 301var profileParams = {}; 302var naver_id_login = new naver_id_login(naver_key, naver_callback); 303/* 304var naver_id_login = new naver.LoginWithNaverId({ 305 clientId: naver_key, 306 callbackUrl: naver_callback, 307 isPopup: true, // íì ì íµí ì°ëì²ë¦¬ ì¬ë¶ // 308 loginButton: {color: "green", type: 3, height: 60} // ë¡ê·¸ì¸ ë²í¼ì íì ì ì§ì // 309 }); 310 311 // ì¤ì ì 보를 ì´ê¸°ííê³ ì°ëì ì¤ë¹ // 312 naverLogin.init(); 313*/ 314 315function naver_login() 316{ 317 var win = '', s_url = ''; 318 319 // ì´ë¯¸ ë¤ì´ë² ë¡ê·¸ì¸íê² ìì¼ë©´ ì ì¥ë ê°ì 320 // ê°ì§ê³ 리뷰창 ì¶ë ¥. 321 if(sns_login || (profileParams && profileParams.id)) { 322 naver_review(); 323 return; 324 } 325 326 console.log('naver_id_login: ', naver_key, naver_callback, naver_id_login); 327 console.log('nv_domain: '+nv_domain); 328 //alert('nv_domain: '+nv_domain); 329 //naver_id_login.setPopup(); //Popupííì ì¸ì¦ ì§í 330 naver_id_login.setDomain(nv_domain); //ìí í í° ë¹êµë¥¼ ìí domain ì¤ì 331 n_state = naver_id_login.getUniqState(); 332 naver_id_login.setState(n_state); 333 //naver_id_login.init_naver_id_login(); 334 s_url = naver_id_login.getNaverIdLoginLink(); 335 console.log('nv_login_url: ', s_url); 336 //alert(s_url); 337 //return; 338 if(s_url) { 339 win = window.open(s_url, '', 'titlebar=1, resizable=1, scrollbars=yes, width=600, height=550'); 340 } 341 342 if(win) { 343 win.focus(); 344 } 345} 346 347function naver_review() 348{ 349 // process. 350 //alert('naver login ok.'); 351 saveData('login_type', 'naver'); 352 saveData('mb_id', profileParams.id); 353 saveData('mb_name', profileParams.name); 354 login_pop_close(); 355 //winModal.close(); 356 357} 358 359// naver callback url ìì í¸ì¶ëë í¨ì. 360function recv_naver(json) 361{ 362 //alert(json.access_token); 363 console.log('naver json', json); 364 if(json && json.access_token) { 365 //alert('2. '+json.state+' == '+n_state); 366 //console.log('naver json', json); 367 if(json.state == n_state) { 368 //naver = json; 369 370 $.ajax({ 371 url: "https://apis.naver.com/nidlogin/nid/getUserProfile.json?response_type=json", 372 type: "GET", 373 data: {"access_token":json.access_token}, 374 dataType: "jsonp", 375 jsonp: "oauth_callback", 376 success: function (result) { 377 sns_login = true; 378 379 //console.log('naver result:'); 380 //console.log(result); 381 profileParams.name = result.response.name; 382 profileParams.age = result.response.age; 383 profileParams.birthday = result.response.birthday; 384 profileParams.email = result.response.email; 385 profileParams.enc_id = result.response.enc_id; 386 profileParams.gender = result.response.gender; 387 profileParams.id = result.response.id; 388 profileParams.nickname = result.response.nickname; 389 profileParams.profile_image = result.response.profile_image; 390 391 console.log('naver profile: ', profileParams); 392 nv_naver = profileParams; 393 naver_review(); 394 }, 395 error: function (xhr, ajaxOptions, thrownError) { 396 //ìë¬ ì²ë¦¬ë ì ì í 397 alert(xhr.status+' / '+thrownError); 398 //alert(thrownError); 399 } 400 }); 401 402 } else { 403 alert('ì ìì ì¸ ë¤ì´ë² ë¡ê·¸ì¸ì´ ìëëë¤.'); 404 //$('#code_social').popup('hide'); 405 } 406 } else { 407 alert('ì¸ì¦ì´ ì¤í¨ëììµëë¤.'); 408 //$('#code_social').popup('hide'); 409 } 410} 411 412// google login 413// https://developers.google.com/identity/sign-in/web/people 414var googleUser = {}; 415/* expired api. 416var startApp = function() { 417 gapi.load('auth2', function(){ 418 // Retrieve the singleton for the GoogleAuth library and set up the client. 419 auth2 = gapi.auth2.init({ 420 client_id: google_key+'.apps.googleusercontent.com', 421 cookiepolicy: 'single_host_origin', 422 // Request scopes in addition to 'profile' and 'email' 423 //scope: 'additional_scope' 424 scope: 'profile' 425 }); 426 //attachSignin(document.getElementById('customBtn')); 427 attachSignin(document.getElementById('gga_login')); 428 }); 429}; 430*/ 431 432//function attachSignin(element) { 433function attachSignin(element) 434{
435//console.log(element.id); 436auth2.attachClickHandler(element, {}, 437 function(googleUser) { 438 //document.getElementById('name').innerText = "Signed in: " + 439 // googleUser.getBasicProfile().getName(); 440 var profile = googleUser.getBasicProfile(); 441 google2.name = profile.getName(); 442 google2.id = profile.getId(); 443 google2.email = profile.getEmail(); 444 445 sns_login=true; 446 //console.log('google', google); 447 google_review(); 448 449 }, function(error) { 450 if(error && error.error == 'popup_closed_by_user') { 451 ; 452 } else { 453 alert(JSON.stringify(error, undefined, 2)); 454 } 455 }); 456} 457 458function gga_login() 459{ 460 if(! gapi) { 461 alert('google api not loaded.'); 462 return; 463 } 464 465 gapi.load('auth2', function(){ 466 // Retrieve the singleton for the GoogleAuth library and set up the client. 467 auth2 = gapi.auth2.init({ 468 client_id: google_key+'.apps.googleusercontent.com', 469 cookiepolicy: 'single_host_origin', 470 // Request scopes in addition to 'profile' and 'email' 471 //scope: 'additional_scope' 472 scope: 'profile' 473 }); 474 //attachSignin(document.getElementById('customBtn')); 475 attachSignin(document.getElementById('gga_login')); 476 }); 477} 478/* 479$(function(){ 480 gga_login(); 481}); 482*/ 483 484function google_review() 485{ 486 // process. 487 //alert('google login ok.'); 488 saveData('login_type', 'google'); 489 saveData('mb_id', google2.id); 490 saveData('mb_name', google2.name); 491 login_pop_close(); 492} 493 494/* 495$(function(){ 496 startApp(); 497}); 498*/
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.