1 2;(function ($, window, document, undefined) { 3 'use strict'; 4 //General 5 function amySocialGeneral() { 6 //Facebook 7 if (amy_user_script.enable_fb_login == 1) { 8 window.fbAsyncInit = function () { 9 FB.init({ 10 appId: amy_user_script.fb_app_id, // App ID 11 status: true, // check login status 12 cookie: true, // enable cookies to allow the server to access the session 13 xfbml: true, // parse XFBML 14 version: 'v2.7' 15 }); 16 }; 17 18 (function (d, s, id) { 19 var js, fjs = d.getElementsByTagName(s)[0]; 20 if (d.getElementById(id)) { 21 return; 22 } 23 js = d.createElement(s); 24 js.id = id; 25 js.src = "//connect.facebook.net/en_US/sdk.js"; 26 fjs.parentNode.insertBefore(js, fjs); 27 }(document, 'script', 'facebook-jssdk')); 28 } 29 30 //Google 31 if (amy_user_script.enable_google_login == 1) { 32 (function() { 33 var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; 34 po.src = 'https://apis.google.com/js/client.js?onload=onLoadCallback'; 35 var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s); 36 })(); 37 38 window.onLoadCallback = function() { 39 gapi.client.setApiKey(amy_user_script.gg_app_id); 40 gapi.client.load('plus', 'v1',function(){}); 41 } 42 } 43 } 44 45 //Facebook 46 function amyFacebookApi() { 47 FB.login(function(response) { 48 if (response.status === 'connected') { 49 FB.api('/me', function(response) { 50 $.ajax({
51 url: amy_user_script.ajax_url, 52 type: 'POST', 53 data: 'action=amy_movie_ajax_social_login&social=fb&info=' + JSON.stringify(response), 54 success: function(res) { 55 if (typeof(res) === 'string' && res === 'success') { 56 location.reload(); 57 } 58 59 if (typeof(res) === 'string' && res === 'failed') { 60 alert('Failed to login, Please refresh the page and try again'); 61 } 62 } 63 }); 64 }); 65 } else if (response.status === 'not_authorized') { 66 FB.login(); 67 } else { 68 FB.login(); 69 } 70 }, { 71 scope: 'email,user_about_me', 72 return_scopes: true 73 }); 74 } 75 76 //Google 77 function amyGoogleApi() { 78 gapi.auth.signIn({ 79 'clientid': amy_user_script.gg_client_id, 80 'cookiepolicy': 'single_host_origin', 81 'approvalprompt': 'force', 82 'scope': 'https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/plus.profile.emails.read', 83 'callback': function(result) { 84 console.log(result); 85 if(result['status']['signed_in']) { 86 var request = gapi.client.plus.people.get({ 87 'userId': 'me' 88 }); 89 90 request.execute(function (resp) { 91 var email = ''; 92 if(resp['emails']) { 93 for(i = 0; i < resp['emails'].length; i++) { 94 if(resp['emails'][i]['type'] == 'account') { 95 email = resp['emails'][i]['value']; 96 } 97 } 98 99 $.ajax({
100 url: amy_user_script.ajax_url, 101 type: 'POST', 102 data: 'action=amy_movie_ajax_social_login&social=gg&email=' + email, 103 success: function(res) { 104 if (typeof(res) === 'string' && res === 'success') { 105 location.reload(); 106 } 107 108 if (typeof(res) === 'string' && res === 'failed') { 109 alert('Failed to login, Please refresh the page and try again'); 110 } 111 } 112 }); 113 } else { 114 alert('Failed to login, Please refresh the page and try again'); 115 } 116 }); 117 118 } 119 } 120 }); 121 } 122 123 function amySocialLogin() { 124 $('.amy-social').each(function() { 125 $(this).click(function() { 126 var social = $(this).attr('data-social'); 127 128 if (social == 'facebook') { 129 if (amy_user_script.enable_fb_login == 1) { 130 amyFacebookApi(); 131 } 132 } else if (social == 'google') { 133 if (amy_user_script.enable_google_login == 1) { 134 amyGoogleApi(); 135 } 136 } 137 }); 138 }); 139 } 140 141 //Ajax submit form 142 function amyUserPopupAjaxForm() { 143 $('#registerform-popup').submit(function(el) { 144 el.preventDefault(); 145 146 alert('tsl'); 147 }); 148 } 149 150 $(document).ready(function() { 151 //fancybox 152 $('.amy-user-fancybox').fancybox(); 153 //function list 154 amySocialGeneral(); 155 amySocialLogin(); 156 }); 157 158})(jQuery, window, document);
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.