Commits

Rodrigo Bistolfi committed 8bd81d6

Initial commit

  • Participants

Comments (0)

Files changed (4)

+# Celebrity Status
+
+Check out the uptime of your favorite Hollywood star. Minimize failure and
+costs from stalking dead people.
+<!DOCTYPE html>
+<html ng-app="cstat">
+  <head>
+    <meta charset="utf-8">
+    <title>Celebrity Status</title>
+    <link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.0.1/css/bootstrap.min.css">
+    <link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.0.1/css/bootstrap-theme.min.css">
+    <script src="https://code.jquery.com/jquery.js"></script>
+    <script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.1/js/bootstrap.min.js"></script>
+    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.min.js"></script>
+    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular-resource.js"></script>
+    <script src="js/services.js"></script>
+    <script src="js/cstat.js"></script>
+  </head>
+  <body>
+    <h1>Celebrity Status</h1>
+    <div ng-controller="CelebrityStatusController">
+      <form>
+	<input type="text" placeholder="Enter a celebrity name" ng-model="name">
+	<button ng-click="add(name)">Search</button>
+      </form>
+      <ul ng-repeat="c in celebrities">
+	<li>{{c.name}}:  {{c.is_dead}}</li>
+      </ul>
+    </div>
+  </body>
+</html>
+/* Celebrity Status */
+
+
+var app = angular.module("cstat", ["cstatServices"]);
+
+
+function CelebrityStatusController ($scope, $http, CelebrityStatus) {
+    $scope.celebrities = [];
+    $scope.add = function (name) {
+	name = name.replace(/ /g, "_");
+	var status = CelebrityStatus.get({name: name}, function() {
+	    $scope.celebrities.push(status)
+	    console.log(status);
+	});
+    }
+}
+
+
+// CelebrityStatusController.$inject = ["$scope", "CelebrityStatus"];

File js/services.js

+/* Celebrity Status Services */
+
+
+var cstatServices = angular.module("cstatServices", ["ngResource"]);
+var _backendURL = "http://celebritystatus-backend.herokuapp.com/:query";
+var _backendURL = "http://0e067f21-toni.conrad.pre.3scale.net/:query"
+
+
+cstatServices.factory("CelebrityStatus", ["$resource",
+    function($resource) { 
+	return $resource(
+	    _backendURL,
+	    {query: 'is_dead'}, 
+	    {get: {method: "GET", headers: {"Accept": "application/json", "Access-Control-Request-Method": "GET"}}}
+	);
+    }]
+);