Rev 21987 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
var context = "/profitmandi-fofo";var googleProfile;var startApp = function() {gapi.load('auth2', function(){// Retrieve the singleton for the GoogleAuth library and set up the client.auth2 = gapi.auth2.init({client_id: '968353813927-c7eb4mm2lmm451kb6plk9cdmtf47e3mk.apps.googleusercontent.com',cookiepolicy: 'single_host_origin',// Request scopes in addition to 'profile' and 'email'//scope: 'additional_scope'});attachSignin(document.getElementById('customBtn'));});};function attachSignin(element) {console.log(element.id);auth2.attachClickHandler(element, {},function(googleUser) {googleProfile = googleUser.getBasicProfile();console.log(googleProfile.getImageUrl());submitUser(googleUser);}, function(error) {console.log(JSON.stringify(error, undefined, 2));});}function submitUser(googleUser){jQuery.ajax({type : "POST",url : context+"/login",data: {"token":googleUser.getAuthResponse().id_token},success: function(data, textStatus, request){console.log(data);addProfileInLocalDb();window.location.href= "/profitmandi-fofo/dashboard";}});}function addProfileInLocalDb(){var profile = {'image_url':googleProfile.getImageUrl(),'name':googleProfile.getName()};localStorage.setItem("profile",JSON.stringify(profile));}function loadNewGrn(domId){jQuery.ajax({type : "GET",url : context+"/purchase",success : function(response) {$('#' + domId).html(response);}});}function findDuplicateSerialNumbers(value){var result = $("#grnImeiInformation :input[value='" + value + "']").length - 1;return result;}