1 | //BottstrapJS way |
---|
2 | /*$("#login").click(function() { |
---|
3 | var login = $("#loginUser").val(); |
---|
4 | alert("Now set the user cookie to ["+login+"]"); |
---|
5 | document.cookie="USER="+login+";domain=;path=/"; |
---|
6 | document.location.reload(true); |
---|
7 | });*/ |
---|
8 | |
---|
9 | |
---|
10 | //Cookie way. Client side |
---|
11 | /*var login = getCookie("USER"); |
---|
12 | if (login != "" && login != null) |
---|
13 | $("#user-label").html(" " + login); |
---|
14 | else |
---|
15 | $("#user-label").html(" guest"); |
---|
16 | |
---|
17 | function getCookie(name) { |
---|
18 | var parts = document.cookie.split(name + "="); |
---|
19 | if (parts.length == 2) |
---|
20 | return parts.pop().split(";").shift(); |
---|
21 | }*/ |
---|
22 | |
---|
23 | //AngularJS stuff |
---|
24 | var SCHEMAcat = angular.module('SCHEMAcat', ['ui.bootstrap', 'ngResource']); |
---|
25 | |
---|
26 | var SchemasCtrl = function($scope, $resource) { |
---|
27 | |
---|
28 | $scope.schemas = $resource('/schemacat/users/:user/schemas', |
---|
29 | {user:'guest', callback:'JSON_CALLBACK'} |
---|
30 | ); |
---|
31 | $scope.schemasResult = $scope.schemas.get({user:$scope.UserService.id}, |
---|
32 | function(result){ |
---|
33 | //alert('this is better'); |
---|
34 | }); |
---|
35 | |
---|
36 | |
---|
37 | $scope.selectSchema = function (schema) { |
---|
38 | alert("You've clicked the " + schema['sc:name'] + " schema"); |
---|
39 | } |
---|
40 | |
---|
41 | }; |
---|
42 | |
---|
43 | var WorkspaceCtrl = function($scope, UserService) { |
---|
44 | //bind UserService to the scope so we can use its values in the html template |
---|
45 | $scope.UserService = UserService; |
---|
46 | |
---|
47 | //Modal window handlers and options |
---|
48 | $scope.loginClick = function () { |
---|
49 | $scope.loginModal = true; |
---|
50 | }; |
---|
51 | |
---|
52 | $scope.loginClose = function () { |
---|
53 | $scope.loginModal = false; |
---|
54 | }; |
---|
55 | |
---|
56 | //set cookie code. REMOVE in production |
---|
57 | $scope.loginSubmit = function () { |
---|
58 | var login = $("#loginUser").val(); |
---|
59 | alert("Now set the user cookie to ["+login+"]"); |
---|
60 | document.cookie="USER="+login+";domain=;path=/"; |
---|
61 | document.location.reload(true); |
---|
62 | } |
---|
63 | |
---|
64 | $scope.opts = { |
---|
65 | backdropFade: true, |
---|
66 | dialogFade:true |
---|
67 | }; |
---|
68 | }; |
---|