$(document).ready(function () { //facebook login //REN12 start $('.btn-facebook').on('click', function () { var facebook = $('.btn-facebook').attr('title'); function statusChangeCallback(response) { if (response.status === 'connected') { testAPI(response); } } function checkLoginState() { FB.getLoginStatus(function(response) { statusChangeCallback(response); }); } FB.init({ appId : facebook_appId, status : true, version : 'v3.3', cookie : true, // enable cookies to allow the server to access the session xfbml : true }); //FB.AppEvents.logPageView(); FB.login(function(response) { if (response.authResponse) { var accessToken = response.authResponse.accessToken FB.api('/me?fields=id,name', function(response) { $.ajax({ url: "/saveFbAccessDetail", type: 'post', data: { access_token: accessToken,//response.authResponse.accessToken, id : response.id, name : response.name }, success: function (result) {//console.log(result); //if(result.code == 1){ $('#login-form').hide(); $('.modal-backdrop').remove(); location.reload(); // }else{ //console.log(result.message); //swal("Warning!", result.message, "warning"); // } }, }); }); } else { //swal("Warning!", 'User cancelled login or did not fully authorize.', "warning"); } }, { scope: 'email' }); }); }); // login with twitter //REN12 // $('#twitter-button').on('click', function() { // OAuth.initialize('HwAr2OtSxRgEEnO2-JnYjsuA3tc'); // var twitter = OAuth.create('twitter'); // OAuth.popup('twitter').then(twitter => {console.log('hello') // console.log('twitter:', twitter); // twitter.me().then(data => { // console.log('data:', data); // alert('Twitter says your email is:' + data.email + ".\nView browser 'Console Log' for more details"); // }); // twitter.get('/1.1/account/verify_credentials.json?include_email=true').then(data => { // console.log('self data:', data); // }) // }); // }) // }) // linkedin login // $('#linkedin-button').on('click', function() { // // Initialize with your OAuth.io app public key // OAuth.initialize('JW0pu5ssPPpLETlHa3nJqG_DxFQ'); // // Use popup for oauth // OAuth.popup('linkedin2').then(linkedin => { // console.log('linkedin:',linkedin); // // Prompts 'welcome' message with User's email on successful login // // #me() is a convenient method to retrieve user data without requiring you // // to know which OAuth provider url to call // linkedin.me().then(data => { // console.log('me data:', data); // alert('Linkedin says your email is:' + data.email + ".\nView browser 'Console Log' for more details"); // }) // // Retrieves user data from OAuth provider by using #get() and // // OAuth provider url // linkedin.get('/v2/me').then(data => { // console.log('self data:', data); // }) // }); // }) // var OAUTHURL = 'https://accounts.google.com/o/oauth2/auth?'; // var VALIDURL = 'https://www.googleapis.com/oauth2/v1/tokeninfo?access_token='; // var SCOPE = 'https://www.googleapis.com/auth/plus.business.manage'; // var CLIENTID = '984373296032-fj9jgo49b9pr57cq8psu5jjafcorj0vr.apps.googleusercontent.com'; // var CLIENT_SECRET = "X0emJFXBRN-q3I9Xw4zhr-2l"; // var REDIRECT = 'https://store1.furnituremalldirect.com' // var LOGOUT = 'http://accounts.google.com/Logout'; // var TYPE = 'code';//'token'; // var _url = OAUTHURL + 'scope=' + SCOPE + '&client_id=' + CLIENTID + '&redirect_uri=' + REDIRECT + '&response_type=' + TYPE+"&access_type=offline&prompt=consent"; // var acToken; // var tokenType; // var expiresIn; // var user; // var auth_code; // var loggedIn = false; // function login(googleUser) { // var win = window.open(_url, "windowname1", 'width=800, height=600'); // var pollTimer = window.setInterval(function() { // try { // //console.log(win.document.URL); // if (win.document.URL.indexOf(REDIRECT) != -1) { // window.clearInterval(pollTimer); // var url = win.document.URL; // //--- to get code from the redirect url after sign in ----// // //console.log(" redirected url = "+url); // var curLocation = window.location.href; // var lastchar = curLocation.substr(curLocation.length-1,curLocation.length); // if(lastchar == "#") // { // curLocation = curLocation.replace("#",""); // url = url.replace(curLocation,""); // } // else // { // url = url.replace(window.location.href,""); // } // url = url.replace("?",""); // var urlParams = new URLSearchParams(url); // auth_code = urlParams.get('code'); // $.ajax({ // url: '/companyCredentials/saveGoogleAccessToken?code='+ auth_code, // // data: {access_token:acToken}, // success: function(resp){ // console.log("resp = "+resp); // // $("#authorizedusername_google").html(resp); // }, // //dataType: "jsonp" // }); // win.close(); // $("#login-form").hide(); // } // } catch(e) { // } // }, 500); // } // //credits: http://www.netlobo.com/url_query_string_javascript.html // function gup(url, name) { // name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); // var regexS = "[\\#&]"+name+"=([^&#]*)"; // var regex = new RegExp( regexS ); // var results = regex.exec( url ); // if( results == null ) // return ""; // else // return results[1]; // }