still idb problems, need to wait until idb init is finished!
[outofuni/staffline.git] / www / js / ctrl.js
1 // staffline - crew organization app
2
3 appmod.controller('slctrl',function($scope,idbsrv) {
4
5         $scope.subapps = [
6                 {
7                         name: "Time Clock",
8                         icon: "ion-android-time",
9                         id: "timeclock"
10                 },
11                 {
12                         name: "Roster",
13                         icon: "ion-person-stalker",
14                         id: "roster"
15                 },
16                 {
17                         name: "Brainstorming",
18                         icon: "ion-android-chat",
19                         id: "brainstorming"
20                 },
21                 {
22                         name: "ToDo",
23                         icon: "ion-clipboard",
24                         id: "todo"
25                 },
26                 {
27                         name: "Settings",
28                         icon: "ion-android-settings",
29                         id: "settings"
30                 }
31         ];
32
33         $scope.selected_app = $scope.subapps[0];
34
35         $scope.app_click = function(app) {
36                 $scope.selected_app=app;
37                 for(s in $scope.subapps) {
38                         var id=$scope.subapps[s].id;
39                         if(app.id==id) {
40                                 $('#'+id).css('display','block');
41                                 cl("enabled "+id);
42                         }
43                         else {
44                                 $('#'+id).css('display','none');
45                                 cl("disabled "+id);
46                         }
47                 }
48                 console.log("selecting app "+app.name);
49         }
50
51         // indexxed db
52         var dbdel=false;
53         //dbdel=true;
54         if(!dbdel) {
55                 $scope.idbstores = {
56                         'settings': db_settings_store
57                 };
58                 idbsrv.init('staffline',function(event) {
59                         cl("indexed db initialized successfuly!");
60                 },1,$scope.idbstores,function(event) {
61                         objdbg(event);
62                 }).then(function() {
63                         idbsrv.get_store_items('settings',undefined,0,-1).then(
64                                 function(item) {
65                                         for(var i in item);
66                                         console.log("passwd: "+item[i].passwd);
67                                 }
68                         );
69                 });
70         }
71         else {
72                 idb.name='staffline';
73                 idbsrv.del()
74         }
75
76 });
77
78 appmod.controller('settingsctrl',function($scope,idbsrv) {
79
80 /*
81         idbsrv.get_store_items('settings',undefined,0,-1),then(function(item) {
82                 for(var i in item);
83                 if(item[i].passwd==undefined)
84                         $scope.test = [ "Enter passwd" ];
85                 else
86                         $scope.test = [ "Verify passwd" ];
87         });
88 */
89
90 });
91