1// Adrien 10/05/23 : Attention, ce fichier n'est plus utilisé sur la majorité des sites web excepté sur le compte client et le script de résa 2 3var _idBtnConnexionGoogle; // variable à renseigner dans les js qui appellent la fonction "initBtnGoogle" 4var _fctGooglePlusOK; 5var _fctGooglePlusKO; 6 7/** 8 * Fonction appelée après la tentative de connexion à Facebook, on vérifie la valeur retournée et on fait les actions adaptées 9 * @param {type} fonctionOK : fonction appelée en cas de succès 10 * @param {type} fonctionKO : fonction appelée en cas d'échec 11 */ 12function connexionFacebook(fonctionOK, fonctionKO) { 13 FB.login(function(response) { 14 if (response.authResponse) { 15 FB.api('me?fields=email,gender,last_name,first_name,locale,id', function(obj) { 16 fonctionOK(getTabInfosFacebook(obj)); 17 }); 18 } else { 19 fonctionKO(); 20 } 21 }, {scope: 'public_profile,email'}); 22} 23 24function getTabInfosFacebook(obj) { 25 var tabInfos = {site: 'facebook'}; 26 27 if (obj.email) { 28 tabInfos.email = obj.email; 29 } 30 if (obj.gender) { 31 var civilite = getCiviliteByGenre(obj.gender); 32 if(civilite) { 33 tabInfos.civilite = civilite; 34 } 35 } 36 if (obj.last_name) { 37 tabInfos.nom = obj.last_name; 38 } 39 if (obj.first_name) { 40 tabInfos.prenom = obj.first_name; 41 } 42 43 // J'enlève location : on ne peut plus le demander sans autorisation spéciale 44// if (obj.location) { 45// tabInfos.ville = getVilleFacebook(obj.location); 46// } else if (obj.hometown) { 47// tabInfos.ville = getVilleFacebook(obj.hometown); 48// } 49 50 if (obj.locale) { 51 // on prend les lettres de la locale situées après le "_" (elles représentent le code ISO) 52 tabInfos.pays = obj.locale.substr(obj.locale.indexOf('_') + 1); 53 } 54 // J'enlève birthday : on ne peut plus le demander sans autorisation spéciale 55// if (obj.birthday) { //format JJ/MM/AAAA 56// tabInfos.date_naissance = obj.birthday; 57// } 58 if (obj.id) { 59 tabInfos.photo = 'https://graph.facebook.com/'+obj.id+'/picture'; 60 } 61 //console.log(tabInfos); 62 63 return tabInfos; 64} 65 66function getVilleFacebook(location) { 67 var ville = location.name; 68 if (ville.indexOf(',') !== -1) { 69 ville = ville.substr(0, ville.indexOf(',')); 70 } 71 return ville; 72} 73 74function getCiviliteByGenre(genre) { 75 var civilite; 76 if (genre === 'male') { 77 civilite = 1; 78 } else if (genre === 'female') { 79 civilite = 2; 80 } 81 return civilite; 82} 83 84function initActionsAuthentification(){ 85 86} 87 88function initBtnGooglePlus(){ 89 return; // fin de google plus, on return pour éviter les erreurs js 90 (function($){ 91 var googleAppID = $('#'+_idBtnConnexionGoogle).data('appid'); 92 gapi.signin.render(_idBtnConnexionGoogle, { 93 // 'clientid': '99400871605-qcgpfk1im6qclre6a3rv3s18rkhgl2og.apps.googleusercontent.com', 94 'clientid': googleAppID, 95 'cookiepolicy': 'single_host_origin', 96 'requestvisibleactions': 'http://schemas.google.com/AddActivity', 97 'scope': 'https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/plus.me', 98 'callback': 'connexionGooglePlus' 99 }); 100 })(jQuery); 101} 102 103/** 104 * Fonction appelée après la demande de connexion à Google, si la connexion s'est correctement déroulée on récupère les infos du client 105 * Sinon on ne fait rien (pour le moment) 106 * 107 * @param {type} retour 108 * @param {type} fonctionOK : fonction appelée en cas de succès 109 * @param {type} fonctionKO : fonction appelée en cas d'échec 110 * @returns {undefined} 111 */ 112function connexionGooglePlus(retour) { 113 return; // fin de google plus, on return pour éviter les erreurs js 114 if (retour['access_token']) { 115 gapi.client.load('plus', 'v1', function() { 116 gapi.client.plus.people.get({'userId': 'me'}).execute(function(objPers) { 117 _fctGooglePlusOK(retour['access_token'], getTabInfosGooglePlus(objPers)); 118 }); 119 }); 120 } else if (retour['error']) { 121 _fctGooglePlusKO(retour['error']); 122 } 123} 124 125function getTabInfosGooglePlus(obj) { 126 return;
126 // fin de google plus, on return pour éviter les erreurs js 127 var tabInfos = {site: 'google'}; 128 129 (function($) { 130 if (obj.emails) { 131 $.each(obj.emails, function (i, objEmail) { 132 if (objEmail.type === 'account') { 133 tabInfos.email = objEmail.value; 134 return false; 135 } 136 }); 137 } 138 if (obj.gender) { 139 var civilite = getCiviliteByGenre(obj.gender); 140 if(civilite) { 141 tabInfos.civilite = civilite; 142 } 143 } 144 if (obj.name) { 145 tabInfos.nom = obj.name.familyName; 146 tabInfos.prenom = obj.name.givenName; 147 } 148 if (obj.placesLived) { 149 $.each(obj.placesLived, function (i, objVille) { 150 if (objVille.primary) { 151 tabInfos.ville = objVille.value; 152 return false; 153 } 154 }); 155 } 156 // Le langage n'est pas le code ISO donc on ne peut pas le stocker dans le champ "pays" de client compil. 157 // A la limite il faudrait le mettre dans un nouveau champ "langage" de client compil, mais, vu avec Vincent, 158 // c'est plutôt au moment de la 1ère resa qu'on remplira cette info avec la langue du navigateur. 159 /*if (obj.language) { 160 tabInfos.pays = obj.language; 161 }*/ 162 if (obj.birthday) { 163 tabInfos.date_naissance = obj.birthday; 164 } 165 if(obj.image) { 166 if(obj.image.isDefault === false) { // car si isDefault === false on a bien une photo 167 tabInfos.photo = obj.image.url; 168 } 169 } 170 //console.log(tabInfos); 171 })(jQuery); 172 173 return tabInfos; 174} 175 176function deconnecteGooglePlus(accessToken, fonctionOK, fonctionKO) { 177 return; // fin de google plus, on return pour éviter les erreurs js 178 (function($) { 179 var revokeUrl = 'https://accounts.google.com/o/oauth2/revoke?token=' + accessToken; 180 181 // Exécuter une requête GET asynchrone. 182 $.ajax({ 183 type: 'GET', 184 url: revokeUrl, 185 async: false, 186 contentType: 'application/json', 187 dataType: 'jsonp', 188 success: function(nullResponse) { 189 if(typeof fonctionOK !== 'undefined') { 190 fonctionOK(); 191 } 192 }, 193 error: function(e) { 194 if(typeof fonctionKO !== 'undefined') { 195 fonctionKO(); 196 } 197 } 198 }); 199 })(jQuery); 200} 201 202function authentificationFacebookCompteGdf(tabInfos){ 203 (function($) { 204 // Cette fonction peut être appelée dans le script de résa et en-dehors 205 // A l'intérieur du script de résa urlAJAX contient le PHPSESSID, à l'extérieur il faut le récupérer sur l'attribut data-sessid 206 var data = 'email='+tabInfos.email+'&type=connexionCompteGdf'; 207 if ($('#div_btnConnexionFacebookFede').data('sessid')) { 208 data += '&phpsessid='+$('#div_btnConnexionFacebookFede').data('sessid'); 209 } 210 if ($('#div_btnConnexionFacebookFede').data('idsrv')) { 211 data += '&idsrv='+$('#div_btnConnexionFacebookFede').data('idsrv'); 212 } 213 data += '&connectFacebook=1'; 214 $.ajax({ 215 type: 'POST', 216 url: urlAJAX, 217// url: '/lib_2/ajax/gereResa.php?', 218 data: data, 219 success:function(result){ 220 var tabResult = XMLToArray(result); 221 retourConnexionCompteGdf(tabResult); 222 } 223 }); 224 })(jQuery); 225} 226 227function authentificationGoogleCompteGdf(accessToken, tabInfosUser){ 228 (function($) { 229 // Cette fonction peut être appelée dans le script de résa et en-dehors 230 // A l'intérieur du script de résa urlAJAX contient le PHPSESSID, à l'extérieur il faut le récupérer sur l'attribut data-sessid 231 var data = 'email='+tabInfosUser.email+'&type=connexionCompteGdf'; 232 if ($('#div_btnConnexionGoogleFede').data('sessid')) { 233 data += '&phpsessid='+$('#div_btnConnexionGoogleFede').data('sessid'); 234 } 235 if ($('#div_btnConnexionGoogleFede').data('idsrv')) { 236 data += '&idsrv='+$('#div_btnConnexionGoogleFede').data('idsrv'); 237 } 238 data += '&connectGoogle=1'; 239 $.ajax({ 240 type: 'POST', 241 url: urlAJAX, 242 data: data, 243 success:function(result){ 244 var tabResult = XMLToArray(result); 245 retourConnexionCompteGdf(tabResult); 246 } 247 }); 248 })(jQuery); 249} 250 251function retourConnexionCompteGdf(tabResult){ 252 (function($){ 253 if(tabResult.code === 'KO') { 254 if (window.opener && window.location.host!=window.opener.location.host) { 255 window.opener.postMessage(tabResult.msg,'*'); 256 } else { 257 if(tabResult.attenteMiseEnLigne == 'true'){ 258 $('#itea_cnxCptGDFResa_msgInfo').html(tabResult.msg); 259 $('#itea_cnxCptGDFResa_msgInfo').fadeOut().fadeIn(); 260 }else { 261 var lienCreaCpt = '<a href="javascript:void(0)" id="lienCreaCpt">'+tabResult.msg_creaCpt+' '+tabResult.type+' '+tabResult.msg_creaCpt2+'</a>'; 262 $('#itea_cnxCptGDFResa_msgInfo').html(tabResult.msg + lienCreaCpt); 263 $('#itea_cnxCptGDFResa_msgInfo').fadeOut().fadeIn(); 264 if(tabResult.type == 'Facebook'){ 265 var handler = function(){ 266 $('#div_pasdecomptegdf').click(); 267 connexionFacebook(creaCptGDFFacebook, resaFacebookKO); 268 } 269 }else { 270 var handler = function(){ 271 $('#div_pasdecomptegdf').click(); 272 $('#div_btnConnexionGoogle_creaCptGDF').click(); 273 } 274 } 275 $('#lienCreaCpt').click(handler); 276 } 277 } 278 } 279 else { 280 if (window.opener && window.location.host!=window.opener.location.host) { 281 window.opener.postMessage('reload','*'); 282 } else { 283 var urlHref = location.search + "&" + getIdSessionInHtml(); 284 location.href = urlHref; 285 } 286 } 287 if (window.opener && window.location.host!=window.opener.location.host) { 288 window.close(); 289 } 290 })(jQuery); 291} 292 293function authentificationGoogleCompteGdfKO(){ 294 console.log('authentificationGoogleCompteGdfKO'); 295} 296 297function initAuthentificationGoogleForCompteGdf(){ 298 _idBtnConnexionGoogle = 'div_btnConnexionGoogleFede'; 299 _fctGooglePlusOK = authentificationGoogleCompteGdf; 300 _fctGooglePlusKO = authentificationGoogleCompteGdfKO; 301} 302 303function clickBtnGoogleCompteGdf(){ 304 (function($) { 305 $('#div_btnConnexionGoogleFede').click(); 306 })(jQuery); 307}
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.