git-svn-id: https://msi/svn/firstRepo/WebClient/branches/Manut_2.2.3@25 0f545695-f87b-41b6-9a03-7f16563b5454
This commit is contained in:
@@ -1,29 +1,78 @@
|
||||
define(['jquery','underscore', 'backbone', 'router', 'classes/profile'],function
|
||||
($, _, Backbone,Router, Profile) {
|
||||
'use strict';
|
||||
var init=function(){
|
||||
define(['jquery', 'underscore', 'backbone', 'router', 'classes/profile', 'classes/cache'], function
|
||||
($, _, Backbone, Router, Profile, Cache) {
|
||||
'use strict';
|
||||
var init = function () {
|
||||
//create backbone router
|
||||
var router=new Router();
|
||||
var router = new Router();
|
||||
Backbone.history.start();
|
||||
Backbone.emulateJSON = true;
|
||||
var origin = location.protocol + '//' + location.hostname + (location.port ? ':' + location.port : '') + (location.pathname?location.pathname:'');
|
||||
openFB.init('1466942266882168', origin, window.localStorage);
|
||||
openGPlus.init('319140243944-qk0lfhgmi8shi4go97r83l69f1k0gdf4.apps.googleusercontent.com', origin, window.localStorage);
|
||||
//console.log("Backbone history start");
|
||||
// Trigger 'route' event on router instance.
|
||||
router.on('route', function(name, args) {
|
||||
//alert(name);
|
||||
});
|
||||
|
||||
if( Profile.isConnected()) {
|
||||
hello.init({
|
||||
facebook: '1466942266882168',
|
||||
google: '319140243944-qk0lfhgmi8shi4go97r83l69f1k0gdf4.apps.googleusercontent.com'
|
||||
}, {display: 'page', scope: 'email'});
|
||||
|
||||
//console.log("Backbone history start");
|
||||
// Trigger 'route' event on router instance.
|
||||
router.on('route', function (name, args) {
|
||||
//alert(name);
|
||||
});
|
||||
|
||||
Cache.checkCacheFromServer();
|
||||
|
||||
if (Profile.isConnected()) {
|
||||
Profile.loadProfile();
|
||||
}
|
||||
|
||||
hello.on('auth.login', function (auth) {
|
||||
if (!Profile.isConnected())
|
||||
{
|
||||
hello(auth.network).api("me").then(function (json) {
|
||||
var id = "";
|
||||
var displayName = "";
|
||||
var email = "";
|
||||
var gender = "";
|
||||
|
||||
if (auth.network === "google")
|
||||
{
|
||||
id = json.id;
|
||||
displayName = json.displayName;
|
||||
email = json.email;
|
||||
gender = json.gender;
|
||||
}
|
||||
else if (auth.network === "facebook")
|
||||
{
|
||||
id = json.id;
|
||||
displayName = json.name;
|
||||
email = json.email;
|
||||
gender = json.gender;
|
||||
}
|
||||
Profile.internalLoadProfile(id, function(retVal){
|
||||
if(retVal === false)
|
||||
{
|
||||
Profile.createProfile(
|
||||
id,
|
||||
auth.network,
|
||||
displayName,
|
||||
email,
|
||||
gender,
|
||||
function () {
|
||||
window.location.href = "#syncView/tokenFound";
|
||||
}
|
||||
);
|
||||
}
|
||||
else
|
||||
window.location.href = "#syncView/tokenFound";
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$('body').css('background-color', '');
|
||||
$('#loadingFrm').remove();
|
||||
};
|
||||
|
||||
return {
|
||||
initialize:init
|
||||
};
|
||||
|
||||
return {
|
||||
initialize: init
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user