source: cats/SCHEMAcat/trunk/urn.org.isocat.schemacat.site/site/scripts/main.js @ 3483

Last change on this file since 3483 was 3483, checked in by andmor, 11 years ago

Initial setup with AngularJS

File size: 1.8 KB
Line 
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");
12if (login != "" && login != null)
13    $("#user-label").html(" " + login);
14else
15    $("#user-label").html(" guest");
16
17function 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
24var SCHEMAcat = angular.module('SCHEMAcat', ['ui.bootstrap', 'ngResource']);
25
26var 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 
43var 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};
Note: See TracBrowser for help on using the repository browser.