MCPcopy Index your code
hub / github.com/aws-samples/eb-java-scorekeep / Main

Function Main

public/app/main-controller.js:4–40  ·  view source on GitHub ↗
($scope, $http, $location, SessionService, SessionCollection, UserService, UserCollection, api)

Source from the content-addressed store, hash-verified

2
3module.controller('MainController', Main);
4function Main($scope, $http, $location, SessionService, SessionCollection, UserService, UserCollection, api) {
5 $scope.sessions = SessionService.query();
6 $scope.sessionname = "games";
7 $scope.sessionid = "";
8 $scope.username = "random";
9
10 $scope.createSession = function (sessionname, username) {
11 var sessionid;
12 var userid;
13 CreateUser = UserCollection.createUser(username, null);
14 CreateSession = CreateUser.then(function(createUserResult){
15 userid = createUserResult.id;
16 return SessionCollection.createSession(sessionname, createUserResult.id);
17 });
18 JoinSession = CreateSession.then(function(createSessionResult) {
19 console.log("session id: " + createSessionResult.id);
20 sessionid = createSessionResult.id;
21 return SessionCollection.joinSession(createSessionResult.id, createSessionResult.owner);
22 });
23 JoinSession.then(function(){
24 $location.path('/session/'+ sessionid+ '/' + userid);
25 });
26 };
27
28 $scope.joinSession = function(sessionid, username) {
29 var userid;
30 CreateUser = UserCollection.createUser(username, null);
31 JoinSession = CreateUser.then(function(createUserResult) {
32 userid = createUserResult.id;
33 return SessionCollection.joinSession(sessionid, createUserResult.id);
34 });
35 JoinSession.then(function(joinSessionResult){
36 $location.path('/session/'+ sessionid+ '/' + userid);
37 });
38 };
39
40}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected