Ext.ns('S100'); S100.Community100 = function() { this.stepsEl = Ext.get('steps'); S100.observer.on('fb_status', this.onFbGetLoginStatus, this); // Get cookie value and case boolean this.step1Setup = (/^true|1$/i).test(document.cookie.match(/c100_submit_step1_complete=(false|true|0|1);/)[1]); this.step2Setup = (/^true|1$/i).test(document.cookie.match(/c100_submit_step2_complete=(false|true|0|1);/)[1]); this.step3Setup = (/^true|1$/i).test(document.cookie.match(/c100_submit_step3_complete=(false|true|0|1);/)[1]); if (this.step2Setup) { this.setupStep3(); } else { // this.setupStep1(); } }; // Set cookie and instance value for steps processed S100.Community100.prototype.setSubmitStep = function(stepName, value) { value = value || true; document.cookie = 'c100_submit_' + stepName + '_complete=' + value; this[stepName+'Setup'] = true; }; S100.Community100.prototype.onFbGetLoginStatus = function(opts) { var session = opts.session; if (session) { S100.fbSession = session; this.setSubmitStep('step1', true); if (this.step2Setup) { return; } if (Ext.isObject(S100.fbUser)) { this.setupSteps(); } else { FB.api('/me', function(res) { S100.fbUser = res; this.setupSteps(); }.createDelegate(this)); } } else { this.setupStep1(); } }; S100.Community100.prototype.setupSteps = function() { this.setupStep1(); this.setupStep2(); this.setupStep3(); }; S100.Community100.prototype.setupStep1 = function() { this.stepsEl.child('.step1 .disable-step').hide(); if (!Ext.isObject(S100.fbSession)) { Ext.fly('submit-login-btn').show(); } else { if (Ext.fly('submit-login-btn')) { Ext.fly('submit-login-btn').remove(); } // Add name and photo to step 1 Ext.fly('fb-profile').child('img') .set({src: 'https://graph.facebook.com/me/picture?access_token=' + S100.fbSession.access_token}); Ext.fly('fb-profile').child('.logged-in .name') .update('
Logged in as:
' + S100.fbUser.name + '