Full Code of GoDisco/ngFacebook for AI

master 315177f36822
13 files
24.1 KB
6.4k tokens
Repository: GoDisco/ngFacebook
Branch: master
Commit: 315177f36822
Files: 13
Total size: 24.1 KB

Directory structure:
gitextract_nzt6svfo/

├── .gitignore
├── .travis.yml
├── LICENSE
├── README.md
├── bower.json
├── ngFacebook.js
├── package.json
├── protractor.conf.js
└── test/
    ├── features/
    │   └── ngFacebook.feature
    ├── index.html
    ├── index.js
    ├── scripts/
    │   └── web-server.js
    └── specs/
        └── def.js

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitignore
================================================
# Created by .ignore support plugin (hsz.mobi)
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm

*.iml

## Directory-based project format:
.idea/
# if you remove the above rule, at least ignore the following:

# User-specific stuff:
# .idea/workspace.xml
# .idea/tasks.xml
# .idea/dictionaries

# Sensitive or high-churn files:
# .idea/dataSources.ids
# .idea/dataSources.xml
# .idea/sqlDataSources.xml
# .idea/dynamic.xml
# .idea/uiDesigner.xml

# Gradle:
# .idea/gradle.xml
# .idea/libraries

# Mongo Explorer plugin:
# .idea/mongoSettings.xml

## File-based project format:
*.ipr
*.iws

## Plugin-specific files:

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties


### Yeoman template
node_modules/
bower_components/
*.log

build/
dist/




================================================
FILE: .travis.yml
================================================
language: node_js
node_js:
  - "0.10"

env:
  global:
    - secure: "CFH6k4N0JIjJ17qKdKDqjX45yOTcB6DY8wAHL/lDHneaIHeg0A6waHA1Ri6jjChiwsw7h8tSSYmqu+x2fdLNI4SxpVapcRhr8iunoWOIypHDJ0J8cpn4py3zs70g+RkRLXE++Prys/zj2AEvXftBQDlb0dRWf751y+TNFudC0vA="
    - secure: "RNrtdx+CQecGkBWsaWGEr3IEsQsjXpVL/+lJfRnZYs5jQP7uE9sjWLZsBQsEGC9lFinmY+HoU0ucfxA9Kqe1Ts6itEP2lTPg2le/xRZRV6g0jCcvqc57l7WwIxhxQR74u2J3n+NhVT4FE7tvLx4jhkoCP0nIokOfsZF7+EY9W4k="

addons:
  sauce_connect: true

install:
  - npm install
  - npm install protractor cucumber bower -g
  - npm install lodash
  - bower install

script:
  - node test/scripts/web-server.js &
  - sleep 1 # give the server some time to get his things... drink coffee.. and such
  - protractor


================================================
FILE: LICENSE
================================================
The MIT License

Copyright (c) 2014, GoDisco

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.


================================================
FILE: README.md
================================================
# DEPRECATED
This is no longer supported, please consider following [the official HOWTO tutorial](https://developers.facebook.com/docs/javascript/howto/angularjs/).

Angular Facebook [![Build Status](https://travis-ci.org/GoDisco/ngFacebook.svg?branch=master)](https://travis-ci.org/GoDisco/ngFacebook)
==================
Angular service to handle facebook

Installation
------------
1. Download the package:
   1. download using npm: `npm install ng-facebook`
   1. download using the [zip file](https://github.com/GoDisco/ngFacebook/archive/master.zip)
   1. download using bower: `bower install ng-facebook`
1. Modify your application to include `ngFacebook` in your application dependencies
1. Configure the ngFacebook module using the configuration steps outlined in the section titled "Configuration" below.
1. Load the [*Facebook SDK for javascript*](https://developers.facebook.com/docs/reference/javascript/), **BUT DO NOT** call `FB.init` or set `window.fbAsyncInit`. These steps are automatically done by the ngFacebook module.

Example:

```javascript
angular.module('<your-app>', ['ngFacebook'])

.config( function( $facebookProvider ) {
  $facebookProvider.setAppId('<your-facebook-app-id>');
})

.run( function( $rootScope ) {
  // Cut and paste the "Load the SDK" code from the facebook javascript sdk page.
  
  // Load the facebook SDK asynchronously
  (function(){
     ...
   }());
})

;

var DemoCtrl = function ($scope, $facebook) {
  ...
  function refresh() {
    $facebook.api("/me").then( 
      function(response) {
        $scope.welcomeMsg = "Welcome " + response.name;
      },
      function(err) {
        $scope.welcomeMsg = "Please log in";
      });
  }
};

```

For more details check out this [plunker which uses ngFacebook](http://plnkr.co/edit/HcYBFKbqFcgQGhyCGQMw?p=preview).

Configuration
-----
You *must* configure your `facebook application ID` in your app, for example:

    app.config(function(FacebookProvider) {
      $facebookProvider.setAppId(11111111111);
    });

### Additional configurations
You can also configure the following properties. Both `set` and `get` methods are available for each property.


1. `permissions(<string>)` - permissions required by your app.

    Example:

        $facebookProvider.setPermissions("email,user_likes");

1. `customInit(<object>)` - the parameters to pass to `FB.init()`. The 'appId' parameter is automatically specified using the value passed to '$facebookProvider.setAppId()', however the remaining parameters are configurable.

    Example to set:

        $facebookProvider.setCustomInit({
          channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html',
          xfbml      : true
        });
        
1. `version(<string>)` - specify the version of the api (_2.0 by default_).

    Example to set:

        $facebookProvider.setVersion("v2.2");


Using
-----
### Methods
1. `$facebook.config(property)`   - Return the config property.
1. `$facebook.getAuthResponse()`  - Return the `AuthResponse`(assuming you already connected)
1. `$facebook.getLoginStatus()`   - Return *promise* of the result.
1. `$facebook.login()`   - Logged in to your app by facebook. Return *promise* of the result.
1. `$facebook.logout()`   - Logged out from facebook. Return *promise* of the result.
1. `$facebook.ui(params)`   - Do UI action(see facebook sdk docs). Return *promise* of the result.
1. `$facebook.api(args...)`   - Do API action(see facebook sdk docs). Return *promise* of the result.
1. `$facebook.cachedApi(args...)`   - Do API action(see above), but the result will cached. Return *promise* of the result.
1. `$facebook.setVersion(version)` - Set another SDK version
1. `$facebook.getVersion()` - Get current SDK version
    Example:

        app.controller('indexCtrl', function($scope, $facebook) {
          $scope.user=$facebook.cachedApi('/me');
        });

### Events
The service will broadcast the facebook sdk events with the prefix `fb.`.

In return you will get the next arguments to your `$on` handler: `event,response,FB` (`FB` is the facebook native js sdk).

1. `fb.auth.login`
1. `fb.auth.logout`
1. `fb.auth.prompt`
1. `fb.auth.sessionChange`
1. `fb.auth.statusChange`
1. `fb.auth.authResponseChange`
1. `fb.xfbml.render`
1. `fb.edge.create`
1. `fb.edge.remove`
1. `fb.comment.create`
1. `fb.comment.remove`
1. `fb.message.send`

*For additional information about the events see the sdk docs.*

License
--------
This project is released over [MIT license](http://opensource.org/licenses/MIT "MIT License")


Sponsors
------
Thanks to our sponsors for this project:

1. [GoDisco](http://www.godisco.net)
1. [JetBrains](http://www.jetbrains.com/) - for providing the great IDE [PhpStorm](http://www.jetbrains.com/phpstorm/)


Authors
-------

1. [Almog Baku](http://www.AlmogBaku.com "AlmogBaku") - by [GoDisco](http://www.godisco.net)
1. [Amir Valiani](https://github.com/avaliani "Avaliani")
1. [Tal Gleichger](http://gleichger.com/ "talgleichger") - by [GoDisco](http://www.godisco.net)


================================================
FILE: bower.json
================================================
{
  "name": "ng-facebook",
  "main": "ngFacebook.js",
  "version": "0.1.6",
  "homepage": "https://github.com/GoDisco/ngFacebook",
  "authors": [
    "AlmogBaku <almog.baku@gmail.com>"
  ],
  "description": "Angular service to handle facebook api",
  "keywords": [
    "facebook",
    "facebook-api",
    "service",
    "angularjs",
    "angular",
    "ngFacebook",
    "api",
    "facebook-sdk",
    "sdk"
  ],
  "license": "MIT",
  "dependencies": {
    "angular": ">=1.0.0 <2.0.0"
  }
}


================================================
FILE: ngFacebook.js
================================================
/**
 * Angular Facebook service
 * ---------------------------
 *
 * Authored by  AlmogBaku (GoDisco)
 *              almog@GoDisco.net
 *              http://www.GoDisco.net/
 *
 * 9/8/13 10:25 PM
 */

angular.module('ngFacebook', [])
  .provider('$facebook', function() {
    var config = {
      permissions:    'email',
      appId:          null,
      version:        'v2.0',
      customInit:     {}
    };

    this.setAppId = function(appId) {
      config.appId=appId;
      return this;
    };
    this.getAppId = function() {
      return config.appId;
    };
    this.setVersion = function(version) {
      config.version=version;
      return this;
    };
    this.getVersion = function() {
      return config.version;
    };
    this.setPermissions = function(permissions) {
      if(permissions instanceof Array) {
        permissions.join(',');
      }
      config.permissions=permissions;
      return this;
    };
    this.getPermissions = function() {
      return config.permissions;
    };
    this.setCustomInit = function(customInit) {
      if(angular.isDefined(customInit.appId)) {
        this.setAppId(customInit.appId);
      }
      config.customInit=customInit;
      return this;
    };
    this.getCustomInit = function() {
      return config.customInit;
    };

    this.$get = ['$q', '$rootScope', '$window', function($q, $rootScope, $window) {
      var $facebook=$q.defer();
      $facebook.config = function(property) {
        return config[property];
      };

      //Initialization
      $facebook.init = function() {
        if($facebook.config('appId')==null)
          throw "$facebookProvider: `appId` cannot be null";

        $window.FB.init(
          angular.extend({ appId: $facebook.config('appId'), version: $facebook.config('version') }, $facebook.config("customInit"))
        );
        $rootScope.$broadcast("fb.load", $window.FB);
      };

      $rootScope.$on("fb.load", function(e, FB) {
        $facebook.resolve(FB);

        //Define action events
        angular.forEach([
          'auth.login', 'auth.logout', 'auth.prompt',
          'auth.sessionChange', 'auth.statusChange', 'auth.authResponseChange',
          'xfbml.render', 'edge.create', 'edge.remove', 'comment.create',
          'comment.remove', 'message.send'
        ],function(event) {
          FB.Event.subscribe(event, function(response) {
            $rootScope.$broadcast("fb."+event, response, FB);
            if(!$rootScope.$$phase) $rootScope.$apply();
          });
        });

        // Make sure 'fb.auth.authResponseChange' fires even if the user is not logged in.
        $facebook.getLoginStatus();
        $facebook.canvasSetAutoResize();
      });

      /**
       * Internal cache
       */
      $facebook._cache={};
      $facebook.setCache = function(attr,val) {
        $facebook._cache[attr]=val;
      };
      $facebook.getCache = function(attr) {
        if(angular.isUndefined($facebook._cache[attr])) return false;
        return $facebook._cache[attr];
      };
      $facebook.clearCache = function() {
        $facebook._cache = {};
      };

      /**
       * Authentication
       */

      var firstAuthResp=$q.defer();
      var firstAuthRespReceived=false;
      function resolveFirstAuthResp(FB) {
        if (!firstAuthRespReceived) {
          firstAuthRespReceived=true;
          firstAuthResp.resolve(FB);
        }
      }

      $facebook.setCache("connected", null);
      $facebook.isConnected = function() {
        return $facebook.getCache("connected");
      };
      $rootScope.$on("fb.auth.authResponseChange", function(event, response, FB) {
        $facebook.clearCache();

        if(response.status=="connected") {
          $facebook.setCache("connected", true);
        } else {
          $facebook.setCache("connected", false);
        }
        resolveFirstAuthResp(FB);
      });

      $facebook.getAuthResponse = function () {
        return FB.getAuthResponse();
      };
      $facebook.getLoginStatus = function (force) {
        var deferred=$q.defer();

        return $facebook.promise.then(function(FB) {
          FB.getLoginStatus(function(response) {
            if(response.error)  deferred.reject(response.error);
            else {
                deferred.resolve(response);
                if($facebook.isConnected()==null)
                    $rootScope.$broadcast("fb.auth.authResponseChange", response, FB);
            }
            if(!$rootScope.$$phase) $rootScope.$apply();
          }, force);
          return deferred.promise;
        });
      };
      $facebook.login = function (permissions, rerequest) {
        if(permissions==undefined) permissions=$facebook.config("permissions");
        var deferred=$q.defer();

        var loginOptions = { scope: permissions };
        if (rerequest) {
          loginOptions.auth_type = 'rerequest';
        }

        return $facebook.promise.then(function(FB) {
          FB.login(function(response) {
            if(response.error)  deferred.reject(response.error);
            else                deferred.resolve(response);
            if(!$rootScope.$$phase) $rootScope.$apply();
          }, loginOptions);
          return deferred.promise;
        });
      };
      $facebook.logout = function () {
        var deferred=$q.defer();

        return $facebook.promise.then(function(FB) {
          FB.logout(function(response) {
            if(response.error)  deferred.reject(response.error);
            else                deferred.resolve(response);
            if(!$rootScope.$$phase) $rootScope.$apply();
          });
          return deferred.promise;
        });
      };
      $facebook.ui = function (params) {
        var deferred=$q.defer();

        return $facebook.promise.then(function(FB) {
          FB.ui(params, function(response) {
            if(response && response.error_code) {
              deferred.reject(response.error_message);
            } else {
              deferred.resolve(response);
            }
            if(!$rootScope.$$phase) $rootScope.$apply();
          });
          return deferred.promise;
        });
      };
      $facebook.api = function () {
        var deferred=$q.defer();
        var args=arguments;
        args[args.length++] = function(response) {
          if(response.error)        deferred.reject(response.error);
          if(response.error_msg)    deferred.reject(response);
          else                      deferred.resolve(response);
          if(!$rootScope.$$phase) $rootScope.$apply();
        };

        return firstAuthResp.promise.then(function(FB) {
          FB.api.apply(FB, args);
          return deferred.promise;
        });
      };

      /**
       * API cached request - cached request api with promise
       *
       * @param path
       * @returns $q.defer.promise
       */
      $facebook.cachedApi = function() {
        if(typeof arguments[0] !== 'string')
          throw "$facebook.cacheApi can works only with graph requests!";

        var promise = $facebook.getCache(arguments[0]);
        if(promise) return promise;

        var result = $facebook.api.apply($facebook, arguments);
        $facebook.setCache(arguments[0], result);

        return result;
      };

      $facebook.canvasSetAutoGrow = function () {
        return FB.Canvas.setAutoGrow();
      };

      $facebook.canvasScrollTop = function (x,y) {
        return FB.Canvas.scrollTo(x,y);
      };

      $facebook.canvasSetAutoResize = function () {
        setInterval(function() {
          if (!FB)
            return;
          var height = angular.element(document.querySelector('body'))[0].offsetHeight;
          return FB.Canvas.setSize({ height: height });
        }, 500);
      };

      return $facebook;
    }];
  })
  .run(['$rootScope', '$window', '$facebook', function($rootScope, $window, $facebook) {
    $window.fbAsyncInit = function() {
      $facebook.init();
      if(!$rootScope.$$phase) $rootScope.$apply();
    };
  }])
;


================================================
FILE: package.json
================================================
{
  "name": "ng-facebook",
  "version": "0.1.6",
  "description": "Angular service to handle facebook api",
  "main": "ngFacebook.js",
  "repository": {
    "type": "git",
    "url": "https://github.com/GoDisco/ngFacebook.git"
  },
  "keywords": [
    "facebook",
    "angularjs",
    "service",
    "ng-facebook",
    "ngFacebook"
  ],
  "author": "@AlmogBaku (by GoDisco)",
  "license": "MIT License",
  "bugs": {
    "url": "https://github.com/GoDisco/ngFacebook/issues"
  },
  "homepage": "https://github.com/GoDisco/ngFacebook",
  "devDependencies": {
    "express": "~4.10.6",
    "chai": "~1.10.0",
    "chai-as-promised": "~4.1.1"
  },
  "scripts": {
    "test": "protractor"
  }
}


================================================
FILE: protractor.conf.js
================================================
exports.config = {
  seleniumAddress: 'http://localhost:4444/wd/hub',
  baseUrl: 'http://localhost:'+(process.env.HTTP_PORT || 8081)+'/test/',
  framework: 'cucumber',
  specs: [
    'test/features/*.feature'
  ],
  cucumberOpts: {
    require: 'test/specs/*.js',
    format: 'pretty'
  },
  sauceUser: process.env.SAUCE_USERNAME,
  sauceKey: process.env.SAUCE_ACCESS_KEY,
  capabilities: {
    'browserName': (process.env.TEST_BROWSER_NAME    || 'chrome'),
    'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER,
    'build': process.env.TRAVIS_BUILD_NUMBER,
    'name': 'ngFacebook Tests'
  }
};

if(process.env.TRAVIS_BUILD_NUMBER) {
  delete exports.config.seleniumAddress;
}

================================================
FILE: test/features/ngFacebook.feature
================================================
Feature: ngFacebook
  Scenario: Facebook load
    Given angular webpage with ngFacebook
    Then facebook sdk should be loaded
  Scenario: Login
    Given an anonymous state
    When I login with facebook user "charlie_hportxj_chaplin@tfbnw.net" with password "1234"
    Then I should be logged in
    Then my name is "Charlie Chaplin"
  Scenario: cachedApi- friends list
    When I getting the list of my friends
    Then I should see "Marilyn Monroe" as a friend of mine

================================================
FILE: test/index.html
================================================
<!DOCTYPE html>
<html ng-app="myApp">
<head lang="en">
    <meta charset="UTF-8">
    <script src="../bower_components/angular/angular.js"></script>
    <script src="../ngFacebook.js"></script>
    <script src="index.js"></script>
    <style>
        ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak {
            display: none !important;
        }
    </style>
</head>
<body ng-controller="myCtrl" ng-cloak>
    <h1>ngFacebook tests</h1>
    <div>
        <h2>Login</h2>
        <button id="login-btn" ng-click="loginToggle()">
            <span ng-if="status">Logout</span>
            <span ng-if="!status">Login</span>
        </button>
        <span ng-if="status" class="message">
            You are <strong>Logged in</strong> as <em>{{user.first_name}} {{user.last_name}}</em>
        </span>
        <span ng-if="!status" class="message">
            You are <strong>not</strong> logged in.
        </span>
    </div>
    <div ng-show="status">
        <h2>Friends via cachedApi:</h2>
        <button id="friends-btn" ng-click="getFriends()">Get friends</button>
        <div ng-show="friends">
            <h3>List of friends:</h3>
            <ul id="friend-list">
                <li ng-repeat="friend in friends">{{friend.name}}</li>
            </ul>
        </div>
    </div>
</body>
</html>

================================================
FILE: test/index.js
================================================
/*
 * Authored by  AlmogBaku
 *              almog.baku@gmail.com
 *              http://www.almogbaku.com/
 *
 * 27/12/14 21:01
 */

angular.module('myApp', ['ngFacebook'])
  .config(['$facebookProvider', function($facebookProvider) {
    $facebookProvider.setAppId('764262530321266').setPermissions(['email','user_friends']);
  }])
  .run(['$rootScope', '$window', function($rootScope, $window) {
    (function(d, s, id) {
      var js, fjs = d.getElementsByTagName(s)[0];
      if (d.getElementById(id)) return;
      js = d.createElement(s); js.id = id;
      js.src = "//connect.facebook.net/en_US/sdk.js";
      fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));
    $rootScope.$on('fb.load', function() {
      $window.dispatchEvent(new Event('fb.load'));
    });
  }])
  .controller('myCtrl', ['$scope', '$facebook', function($scope, $facebook) {
    $scope.$on('fb.auth.authResponseChange', function() {
      $scope.status = $facebook.isConnected();
      if($scope.status) {
        $facebook.api('/me').then(function(user) {
          $scope.user = user;
        });
      }
    });

    $scope.loginToggle = function() {
      if($scope.status) {
        $facebook.logout();
      } else {
        $facebook.login();
      }
    };

    $scope.getFriends = function() {
      if(!$scope.status) return;
      $facebook.cachedApi('/me/friends').then(function(friends) {
        $scope.friends = friends.data;
      });
    }
  }])
;

================================================
FILE: test/scripts/web-server.js
================================================
/*
 * Authored by  AlmogBaku
 *              almog.baku@gmail.com
 *              http://www.almogbaku.com/
 *
 * 27/12/14 21:20
 */

var express = require('express');
var app = express();

app.use(express.static(__dirname+'/../..'));

var port = process.env.HTTP_PORT || 8081;
app.listen(port, function () {
  var host = (process.env.HTTP_HOST || this.address().address);

  console.log('Example app listening at http://%s:%s/test/', host, port);
});

================================================
FILE: test/specs/def.js
================================================
// Use the external Chai As Promised to deal with resolving promises in expectations.
var chai = require('chai');
var chaiAsPromised = require('chai-as-promised');
chai.use(chaiAsPromised);

var expect = chai.expect;

// Chai expect().to.exist syntax makes default jshint unhappy.
// jshint expr:true

module.exports = function() {
  this.Given('angular webpage with ngFacebook', function(next) {
    browser.get('index.html');
    next();
  });
  this.Then('facebook sdk should be loaded', function(next) {
    var fbRoot = by.id('fb-root');
    browser.wait(function() {
      return browser.driver.isElementPresent(fbRoot);
    }, 10000);
    browser.driver.isElementPresent(fbRoot).then(function(exists) {
      expect(exists).to.equal(true);
    });
    next();
  });

  this.Given('an anonymous state', function(next) {
    browser.driver.executeScript(function() {
      window.addEventListener('fb.load', function () {
        window.FB.logout();
      });
    }).then(function() {
      setTimeout(function() {
        next();
      }, 1000);
    });
  });
  this.When('I login with facebook user "$user" with password "$pass"', function(user, pass, next) {
    var parentWindow;
    element(by.id('login-btn')).click()
      .then(browser.getAllWindowHandles)
      .then(function(handles) {
        parentWindow = handles[0];
        return browser.switchTo().window(handles[1]);
      })
      .then(function() {
        browser.driver.findElement(by.id('email')).sendKeys(user);
        browser.driver.findElement(by.id('pass')).sendKeys(pass);
        return browser.driver.findElement(by.id('loginbutton')).click();
      })
      .then(browser.getAllWindowHandles)
      .then(function(handles){
        var deferred = protractor.promise.defer();

        if(handles.length===1) {
          deferred.fulfill();
        }

        //wait for window to be ready
        setTimeout(function() {
          browser.driver.isElementPresent(by.id('platformDialogForm')).then(function (exists) {
            if (exists) {
              deferred.fulfill(browser.driver.findElement(by.css('button[name=__CONFIRM__]')).click());
            } else {
              deferred.fulfill();
            }
          }).thenCatch(deferred.fulfill);
        }, 500);

        return deferred.promise;
      })
      .then(function() {
        return browser.switchTo().window(parentWindow);
      })
      .then(function() {
        setTimeout(next, 1000);
      });
  });
  this.Then('I should be logged in', function(next) {
    element(by.id('login-btn')).getText().then(function(text) {
      expect(text).to.equal('Logout');
    });
    next();
  });
  this.Then('my name is "$fullname"', function(fullname, next) {
    element(by.css('.message')).getText().then(function(text) {
      expect(text).to.equal('You are Logged in as '+fullname);
    });
    next();
  });

  this.When('I getting the list of my friends', function(next) {
    element(by.id('friends-btn')).click()
      .then(function() {
        setTimeout(next, 1000)
      });
  });
  this.Then('I should see "$friend" as a friend of mine', function(friend, next) {
    element(by.id('friend-list')).getText().then(function(text) {
      var friendlist = text.split('\n')
      expect(friendlist).to.contain(friend);
    });
    next();
  });
};
gitextract_nzt6svfo/

├── .gitignore
├── .travis.yml
├── LICENSE
├── README.md
├── bower.json
├── ngFacebook.js
├── package.json
├── protractor.conf.js
└── test/
    ├── features/
    │   └── ngFacebook.feature
    ├── index.html
    ├── index.js
    ├── scripts/
    │   └── web-server.js
    └── specs/
        └── def.js
Condensed preview — 13 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (26K chars).
[
  {
    "path": ".gitignore",
    "chars": 982,
    "preview": "# Created by .ignore support plugin (hsz.mobi)\n### JetBrains template\n# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpSt..."
  },
  {
    "path": ".travis.yml",
    "chars": 722,
    "preview": "language: node_js\nnode_js:\n  - \"0.10\"\n\nenv:\n  global:\n    - secure: \"CFH6k4N0JIjJ17qKdKDqjX45yOTcB6DY8wAHL/lDHneaIHeg0A6..."
  },
  {
    "path": "LICENSE",
    "chars": 1069,
    "preview": "The MIT License\n\nCopyright (c) 2014, GoDisco\n\nPermission is hereby granted, free of charge, to any person obtaining a co..."
  },
  {
    "path": "README.md",
    "chars": 4999,
    "preview": "# DEPRECATED\nThis is no longer supported, please consider following [the official HOWTO tutorial](https://developers.fac..."
  },
  {
    "path": "bower.json",
    "chars": 490,
    "preview": "{\n  \"name\": \"ng-facebook\",\n  \"main\": \"ngFacebook.js\",\n  \"version\": \"0.1.6\",\n  \"homepage\": \"https://github.com/GoDisco/ng..."
  },
  {
    "path": "ngFacebook.js",
    "chars": 8003,
    "preview": "/**\n * Angular Facebook service\n * ---------------------------\n *\n * Authored by  AlmogBaku (GoDisco)\n *              al..."
  },
  {
    "path": "package.json",
    "chars": 690,
    "preview": "{\n  \"name\": \"ng-facebook\",\n  \"version\": \"0.1.6\",\n  \"description\": \"Angular service to handle facebook api\",\n  \"main\": \"n..."
  },
  {
    "path": "protractor.conf.js",
    "chars": 679,
    "preview": "exports.config = {\n  seleniumAddress: 'http://localhost:4444/wd/hub',\n  baseUrl: 'http://localhost:'+(process.env.HTTP_P..."
  },
  {
    "path": "test/features/ngFacebook.feature",
    "chars": 472,
    "preview": "Feature: ngFacebook\n  Scenario: Facebook load\n    Given angular webpage with ngFacebook\n    Then facebook sdk should be..."
  },
  {
    "path": "test/index.html",
    "chars": 1336,
    "preview": "<!DOCTYPE html>\n<html ng-app=\"myApp\">\n<head lang=\"en\">\n    <meta charset=\"UTF-8\">\n    <script src=\"../bower_components/a..."
  },
  {
    "path": "test/index.js",
    "chars": 1477,
    "preview": "/*\n * Authored by  AlmogBaku\n *              almog.baku@gmail.com\n *              http://www.almogbaku.com/\n *\n * 27/12/..."
  },
  {
    "path": "test/scripts/web-server.js",
    "chars": 451,
    "preview": "/*\n * Authored by  AlmogBaku\n *              almog.baku@gmail.com\n *              http://www.almogbaku.com/\n *\n * 27/12/..."
  },
  {
    "path": "test/specs/def.js",
    "chars": 3311,
    "preview": "// Use the external Chai As Promised to deal with resolving promises in expectations.\nvar chai = require('chai');\nvar ch..."
  }
]

About this extraction

This page contains the full source code of the GoDisco/ngFacebook GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 13 files (24.1 KB), approximately 6.4k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!