1 //Load the SDK asynchronously 2 3 4 5//(function () { 6// var url = 'http://connect.facebook.net/en_US/all.js'; 7// var iframe = document.createElement('iframe'); 8// (iframe.frameElement || iframe).style.cssText = "width: 0; height: 0; border: 0"; 9// iframe.src = "javascript:false"; 10// document.getElementById('fb-root').appendChild(iframe); 11// var doc = iframe.contentWindow.document; 12// doc.open().write('<body onload="' + 13// 'window.inDapIF = true;' + 14// 'var js = document.createElement(\'script\');' + 15// 'js.src = \'' + url + '\';' + 16// 'document.body.appendChild(js);">'); 17// doc.close(); 18//}()); 19 20 21 22 23window.fbAsyncInit = function () { 24 //console.log('FB init started') 25 FB.init({ 26 appId: '206575231168830', 27 cookie : true, 28 xfbml : true, 29 version : 'v9.0' 30 }); 31 // console.log('FB init finished') 32 FB.AppEvents.logPageView(); 33 }; 34 35(function (d, s, id) { 36 // console.log('load sdk started') 37 38 var language; 39 if (langKey == 'LT') { 40 language = 'lt_LT'; 41 } 42 else { 43 language = 'en_US'; 44 } 45 46 // console.log(language) 47 var js, js2, fjs = d.getElementsByTagName(s)[0]; 48 if (d.getElementById(id)) { return; } 49 js = d.createElement(s); js.id = id; 50 js.src = "//connect.facebook.net/" + language + "/sdk.js"; 51 fjs.parentNode.insertBefore(js, fjs); 52 //return; 53 //js2 = d.createElement(s); js2.id = id; 54 //js2.src = 'https://connect.facebook.net/' + language + '/sdk/xfbml.customerchat.js'; 55 //fjs.parentNode.insertBefore(js2, fjs); 56}(document, 'script', 'facebook-jssdk')); 57 58 59//initiate login buttons 60$(function () { 61 // console.log('buttons init started') 62 $(document).on("click", ".fbLogin", function () { 63 $("#loading").show(); 64 if (searchInitiate == false) { 65 FB.login(function (response) { 66 statusChangeCallback(response); 67 }, 68 { 69 scope: 'email', 70 auth_type: 'rerequest', 71 returnscopes: true 72 }); 73 } 74 else { 75 FB.login(function (response) { 76 statusChangeCallbackSearchTickets(response); 77 }, 78 { 79 scope: 'email', 80 auth_type: 'rerequest', 81 returnscopes: true 82 }); 83 } 84 // $("#loading").hide(); 85 }) 86 $(".fbLogin").click(function () { 87 88 89 }); 90 //$(".fbLogin").on('click', function (e) { 91 // e.preventDefault(); 92 // debugger; 93 // fbLogin(); 94 //}); 95}); 96 97function statusChangeCallbackSearchTickets(response) { 98 console.log('statusChangeCallback'); 99 console.log(response); 100 101 if (response.status === 'connected') { 102 loginSucceededSeachTickets(response); 103 } else if (response.status === 'not_authorized') { 104 105 // alert('Please log into this app.'); 106 $("#loading").hide(); 107 $("#lgnErrorMessage").text('Please log into this app.'); 108 $("#lgnErrorMessage").show(); 109 } else { 110 // alert('Please log into Facebook.'); 111 $("#loading").hide(); 112 $("#lgnErrorMessage").text('Please log into Facebook.'); 113 $("#lgnErrorMessage").show(); 114 } 115} 116 117function loginSucceededSeachTickets(response) { 118 var token = response.authResponse.accessToken; 119 FB.api('/me?fields=email,name,first_name,last_name,ids_for_business', function (response) { 120 //console.log('Successful login for: ' + response.name); 121 122 //console.log('ID: ' + response.id); 123 //console.log('Email: ' + response.email); 124 //console.log('Token: ' + token); 125 //console.log('Name: ' + response.first_name); 126 //console.log('Surname: ' + response.last_name); 127 var idsForBusiness = JSON.stringify(response.ids_for_business.data.map(function (element) { return { FbUserId: element.id, AppId: element.app.id, AppName: element.app.name }; })); 128 129 $("#hProvirderName").val("Facebook"); 130 $("#hFBUserID").val(response.id); 131 $("#hFBEmail").val(response.email); 132 $("#hFBToken").val(token); 133 $("#hFBFirstName").val(response.first_name); 134 $("#hFBLastName").val(response.last_name); 135 $("#hFBidsForBusiness").val(idsForBusiness); 136 137 $("#siForm").prop("action", appRoot + "/" + language + "/Purchase/Login"); 138 //alert("Facebook login searchTickets") 139 $("#siForm").submit(); 140 141 //var input = { 142 // "parameters": { 143 // "Id": id, 144 // "Token": token, 145 // "Email": email, 146 // "FirstName": firstName, 147 // "LastName": lastName 148 // } 149 //}; 150 151 152 }) 153} 154 155function statusChangeCallback(response) { 156 console.log('statusChangeCallback'); 157 console.log(response); 158 // The response object is returned with a status field that lets the 159 // app know the current login status of the person. 160 // Full docs on the response object can be found in the documentation 161 // for FB.getLoginStatus(). 162 if (response.status === 'connected') { 163 // Logged into your app and Facebook. 164 loginSucceeded(response); 165 } else if (response.status === 'not_authorized') { 166 // The person is logged into Facebook, but not your app. 167 $("#loading").hide(); 168 $("#lgnErrorMessage").text('Please log into this app.'); 169 $("#lgnErrorMessage").show(); 170 //alert('Please log into this app.'); 171 } else { 172 // The person is not logged into Facebook, so we're not sure if 173 // they are logged into this app or not. 174 $("#loading").hide(); 175 $("#lgnErrorMessage").text('Please log into Facebook.'); 176 $("#lgnErrorMessage").show(); 177 //alert('Please log into Facebook.'); 178 } 179} 180 181function fbLogout() { 182 FB.getLoginStatus(function (response) { 183 //if (response.status === 'connected') 184 // FB.logout(function (response) { 185 // }); 186 }); 187} 188 189function fbLogin() { 190 FB.login(function (response) { 191 statusChangeCallback(response); 192 }, 193 { 194 scope: 'email', 195 auth_type: 'rerequest', 196 returnscopes: true 197 }); 198} 199 200function loginSucceeded(response) { 201 var id = 0; 202 var email = ""; 203 var token = response.authResponse.accessToken; 204 var firstName = ""; 205 var lastName = ""; 206 var idsForBusiness = []; 207 208 FB.api('/me?fields=email,name,first_name,last_name,ids_for_business', function (response) { 209 id = response.id; 210 email = response.email; 211 firstName = response.first_name; 212 lastName = response.last_name; 213 idsForBusiness = response.ids_for_business.data.map(function (element) { return { FbUserId: element.i
213d, AppId: element.app.id, AppName: element.app.name }; }); 214 215 var input = {"parameters": { 216 "Id": id, 217 "Token": token, 218 "Email": email, 219 "FirstName": firstName , 220 "LastName": lastName, 221 "IdsForBusiness" : idsForBusiness 222 } 223 }; 224 //console.log("json:", JSON.stringify(input)) 225 226 $.ajax({ 227 type: "POST", 228 dataType: "json", 229 contentType: "application/json", 230 data: JSON.stringify(input) , 231 url: appRoot + "/" + langKey + "/LoginFB/" 232 }).always( 233 function (msg) { 234 if (msg.status == "1") { 235 var redirectLink = $('#loginRedirectLink').val(); 236 if (redirectLink == "") { 237 window.location.reload(); 238 } 239 else { 240 window.location = redirectLink; 241 } 242 243 } 244 else { 245 //console.log('log in failed'); 246 $("#loading").hide(); 247 if (msg.errorMessage != "") { 248 //alert(msg.errorMessage); 249 $("#lgnErrorMessage").text(msg.errorMessage); 250 $("#lgnErrorMessage").show(); 251 } 252 else { 253 $("#lgnErrorMessage").text('Prisijungti nepavyko'); 254 $("#lgnErrorMessage").show(); 255 //alert("Prisijungti nepavyko"); 256 } 257 } 258 }); 259 }); 260} 261 262 263 264 265//initiate connect buttons 266$(function () { 267 $(".fbConnect").on('click', function (e) { 268 e.preventDefault(); 269 fbConnect(); 270 }); 271}); 272 273 274function fbConnect() { 275 FB.login(function (response) { 276 statusChangeConnectCallback(response); 277 }); 278} 279 280function statusChangeConnectCallback(response) { 281 console.log('statusChangeConnectCallback'); 282 console.log(response); 283 // The response object is returned with a status field that lets the 284 // app know the current login status of the person. 285 // Full docs on the response object can be found in the documentation 286 // for FB.getLoginStatus(). 287 if (response.status === 'connected') { 288 // Logged into your app and Facebook. 289 connectSucceeded(response); 290 } else if (response.status === 'not_authorized') { 291 // The person is logged into Facebook, but not your app. 292 $("#loading").hide(); 293 $("#lgnErrorMessage").text('Please log into this app.'); 294 $("#lgnErrorMessage").show(); 295 //alert('Please log into this app.'); 296 } else { 297 // The person is not logged into Facebook, so we're not sure if 298 // they are logged into this app or not. 299 $("#loading").hide(); 300 $("#lgnErrorMessage").text('Please log into Facebook.'); 301 $("#lgnErrorMessage").show(); 302 //alert('Please log into Facebook.'); 303 } 304} 305 306 307 308function connectSucceeded(response) { 309 var id = 0; 310 var email = ""; 311 var token = response.authResponse.accessToken; 312 var firstName = ""; 313 var lastName = ""; 314 var idsForBusiness = []; 315 316 FB.api('/me?fields=email,name,first_name,last_name,ids_for_business', function (response) { 317 //console.log('Successful connect for: ' + response.name); 318 319 id = response.id; 320 email = response.email; 321 firstName = response.first_name; 322 lastName = response.last_name; 323 idsForBusiness = response.ids_for_business.data.map(function (element) { return { FbUserId: element.id, AppId: element.app.id, AppName: element.app.name }; }); 324 //console.log('ID: ' + response.id); 325 //console.log('Email: ' + response.email); 326 //console.log('Token: ' + token); 327 //console.log('Name: ' + response.first_name); 328 //console.log('Surname: ' + response.last_name); 329 330 var input = { 331 "parameters": { 332 "Id": id, 333 "Token": token, 334 "Email": email, 335 "FirstName": firstName, 336 "LastName": lastName, 337 "IdsForBusiness": idsForBusiness 338 } 339 }; 340 341 $.ajax({ 342 type: "POST", 343 dataType: "json", 344 contentType: "application/json", 345 data: JSON.stringify(input), 346 url: appRoot + "/" + langKey + "/ConnectFB/" 347 }).always( 348 function (msg) { 349 if (msg.status == "1") { 350 //$('#fbnotification').modal('show') 351 //window.setTimeout(function () { 352 // $('#fbnotification').modal('hide'); 353 //}, 5000); 354 window.location.reload(); 355 } 356 else { 357 //console.log('log in failed'); 358 $("#loading").hide(); 359 if (msg.errorMessage != "") { 360 $("#lgnErrorMessage").text(msg.errorMessage); 361 $("#lgnErrorMessage").show(); 362 // alert(msg.errorMessage); 363 } 364 else { 365 $("#lgnErrorMessage").text('Susieti nepavyko'); 366 $("#lgnErrorMessage").show(); 367 // alert("Susieti nepavyko"); 368 } 369 } 370 }); 371 }); 372}
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.