1$(function() { 2 3 var XGoogleSignIn = {}; 4 XGoogleSignIn.auth2 = null; 5 XGoogleSignIn.attachSignin = function (element) { 6 // console.log(element.id); 7 XGoogleSignIn.auth2.attachClickHandler(element, {}, 8 function(googleUser) { 9 XGoogleSignIn.onSignIn(googleUser); 10 }, function(error) { 11 console.log(error); 12// var message = error.error; 13// $.gritter.add({ 14// title: '', 15// text: '<p>' + message + '</p>', 16// sticky: false, 17// time: 15000 18// }); 19 }); 20 }; 21 XGoogleSignIn.onSignIn = function(googleUser) { 22 $("#error_messages").empty(); 23 $("#error_messages").hide(); 24 // Useful data for your client-side scripts: 25 var profile = googleUser.getBasicProfile(); 26 // console.log("ID: " + profile.getId()); // Don't send this directly to your server! 27 // console.log('Full Name: ' + profile.getName()); 28 // console.log('Given Name: ' + profile.getGivenName()); 29 // console.log('Family Name: ' + profile.getFamilyName()); 30 // console.log("Image URL: " + profile.getImageUrl()); 31 // console.log("Email: " + profile.getEmail()); 32 33 // The ID token you need to pass to your backend: 34 var id_token = googleUser.getAuthResponse().id_token; 35 // console.log("ID Token: " + id_token); 36 37 var jqxhr = $.ajax({ 38 type: "POST", 39 url: "/ajax/login/google", 40 data: { 41 xtoken: $("#xtoken").val(), 42 // email: profile.getEmail(), 43 token: id_token 44 }, 45 dataType: "json", 46 success: function(data) { 47 var result = data.result; 48 if (result) { 49 document.location.href = data.redirectUrl; 50 } else { 51 $("#error_messages").show(); 52 $("#error_messages").append('<div class="msg-warning">' + data.message + '</div>'); 53 } 54 }, 55 error: function(data) { 56 $("#error_messages").show(); 57 $("#error_messages").append('<div class="msg-warning">' + data.message + '</div>'); 58 } 59 }); 60 }; 61 var $googleCustomBtn = $("#googleCustomBtn"); 62 if (!$googleCustomBtn.length) { 63 return; 64 } 65 gapi.load('auth2', function(){ 66 // Retrieve the singleton for the GoogleAuth library and set up the client. 67 var $googleCustomBtn = $("#googleCustomBtn"); 68 XGoogleSignIn.auth2 = gapi.auth2.init({ 69 client_id: $googleCustomBtn.attr("google-signin-client_id"), 70 cookiepolicy: 'single_host_origin', 71 // Request scopes in addition to 'profile' and 'email' 72 scope: $googleCustomBtn.attr("google-signin-scope") 73 }); 74 XGoogleSignIn.attachSignin(document.getElementById('googleCustomBtn')); 75 }); 76 77});
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.