]> hackdaworld.org Git - outofuni/staffline.git/commitdiff
still idb problems, need to wait until idb init is finished! master
authorhackbard <hackbard@hackdaworld.org>
Mon, 25 Jul 2016 20:08:56 +0000 (22:08 +0200)
committerhackbard <hackbard@hackdaworld.org>
Mon, 25 Jul 2016 20:08:56 +0000 (22:08 +0200)
www/index.html [new file with mode: 0644]
www/js/app.js [new file with mode: 0644]
www/js/config.js [new file with mode: 0644]
www/js/ctrl.js [new file with mode: 0644]
www/js/idbsrv.js [new file with mode: 0644]

diff --git a/www/index.html b/www/index.html
new file mode 100644 (file)
index 0000000..b7e08ee
--- /dev/null
@@ -0,0 +1,84 @@
+<!DOCTYPE html>
+<html>
+
+  <head>
+    <meta charset="utf-8">
+    <meta name="viewport"
+          content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
+    <title>Staff Line</title>
+
+    <link href="lib/ionic/css/ionic.css" rel="stylesheet">
+    <link href="css/style.css" rel="stylesheet">
+
+    <!-- IF using Sass (run gulp sass first),
+         then uncomment below and remove the CSS includes above
+    <link href="css/ionic.app.css" rel="stylesheet">
+    -->
+
+    <!-- jquery -->
+    <script src="js/jquery-2.2.3.min.js"></script>
+
+    <!-- ionic/angularjs js -->
+    <script src="lib/ionic/js/ionic.bundle.js"></script>
+
+    <!-- cordova script (this will be a 404 during development) -->
+    <script src="cordova.js"></script>
+
+    <!-- application js -->
+    <script src="js/jsutils/utils.js"></script>
+    <script src="js/jsutils/idb.js"></script>
+    <script src="js/jsutils/xhr.js"></script>
+    <script src="js/idbsrv.js"></script>
+    <script src="js/config.js"></script>
+    <script src="js/app.js"></script>
+    <script src="js/ctrl.js"></script>
+  </head>
+
+  <body ng-app="staffline" ng-controller="slctrl">
+
+
+
+<ion-side-menus>
+       <ion-side-menu-content>
+               <ion-header-bar class="bar-dark">
+                       <button menu-toggle
+                               class="button icon ion-navicon">
+                       </button>
+                       <h1 class="title">{{selected_app.name}}</h1>
+               </ion-header-bar>
+
+               <!--
+               <ion-content ng-repeat="s in subapps" id="{{s.id}}">
+                       {{s.name}} ...
+               </ion-content>
+               -->
+
+               <ion-content id="settings" style="display:none"
+                            ng-controller="settingsctrl">
+                       <h1 ng-repeat="t in test">{{t}}</h1>
+               </ion-content>
+       </ion-side-menu-content>
+
+       <ion-side-menu side="left" expose-aside-when="large">
+               <ion-header-bar class="bar-dark">
+                       <h1 class="title">Staff Line</h1>
+               </ion-header-bar>
+               <ion-content>
+                       <ion-list>
+                               <ion-item menu-close
+                                         ng-repeat="s in subapps"
+                                         class="item item-icon-right"
+                                         ng-click="app_click(s)">
+                                       {{s.name}}
+                                       <i class="icon {{s.icon}}"></i>
+                               </ion-item>
+                       </ion-list>
+               </ion-content>
+       </ion-side-menu>
+</ion-side-menus>
+
+
+  </body>
+
+</html>
+
diff --git a/www/js/app.js b/www/js/app.js
new file mode 100644 (file)
index 0000000..a06b415
--- /dev/null
@@ -0,0 +1,29 @@
+// staffline - crew organization app
+
+var appmod = angular.module('staffline',['ionic','idbmod']);
+
+
+/*
+appmod.run(function($ionicPlatform) {
+       $ionicPlatform.ready(function() {
+               if(window.cordova && window.cordova.plugins.Keyboard) {
+                       cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
+                       cordova.plugins.Keyboard.disableScroll(true);
+               }
+               if(window.StatusBar) {
+                       StatusBar.styleDefault();
+               }
+       });
+});
+
+appmod.config(function($stateProvider, $urlRouterProvider) {
+
+       $stateProvider.state('staffline',{
+               abstract: true,
+               controller: 'stafflinectrl'
+       });
+
+       $urlRouterProvider.otherwise('staffline');
+});
+*/
+
diff --git a/www/js/config.js b/www/js/config.js
new file mode 100644 (file)
index 0000000..1b0c982
--- /dev/null
@@ -0,0 +1,14 @@
+// staffline indexed db stores
+
+var db_settings_store = {
+       keyname: true,
+       keytype: 'autoIncrement',
+       content: {
+               1: [
+                       {
+                               'passwd': ""
+                       }
+               ]
+       }
+}
+
diff --git a/www/js/ctrl.js b/www/js/ctrl.js
new file mode 100644 (file)
index 0000000..c9d6d71
--- /dev/null
@@ -0,0 +1,91 @@
+// staffline - crew organization app
+
+appmod.controller('slctrl',function($scope,idbsrv) {
+
+       $scope.subapps = [
+               {
+                       name: "Time Clock",
+                       icon: "ion-android-time",
+                       id: "timeclock"
+               },
+               {
+                       name: "Roster",
+                       icon: "ion-person-stalker",
+                       id: "roster"
+               },
+               {
+                       name: "Brainstorming",
+                       icon: "ion-android-chat",
+                       id: "brainstorming"
+               },
+               {
+                       name: "ToDo",
+                       icon: "ion-clipboard",
+                       id: "todo"
+               },
+               {
+                       name: "Settings",
+                       icon: "ion-android-settings",
+                       id: "settings"
+               }
+       ];
+
+       $scope.selected_app = $scope.subapps[0];
+
+       $scope.app_click = function(app) {
+               $scope.selected_app=app;
+               for(s in $scope.subapps) {
+                       var id=$scope.subapps[s].id;
+                       if(app.id==id) {
+                               $('#'+id).css('display','block');
+                               cl("enabled "+id);
+                       }
+                       else {
+                               $('#'+id).css('display','none');
+                               cl("disabled "+id);
+                       }
+               }
+               console.log("selecting app "+app.name);
+       }
+
+       // indexxed db
+       var dbdel=false;
+       //dbdel=true;
+       if(!dbdel) {
+               $scope.idbstores = {
+                       'settings': db_settings_store
+               };
+               idbsrv.init('staffline',function(event) {
+                       cl("indexed db initialized successfuly!");
+               },1,$scope.idbstores,function(event) {
+                       objdbg(event);
+               }).then(function() {
+                       idbsrv.get_store_items('settings',undefined,0,-1).then(
+                               function(item) {
+                                       for(var i in item);
+                                       console.log("passwd: "+item[i].passwd);
+                               }
+                       );
+               });
+       }
+       else {
+               idb.name='staffline';
+               idbsrv.del()
+       }
+
+});
+
+appmod.controller('settingsctrl',function($scope,idbsrv) {
+
+/*
+       idbsrv.get_store_items('settings',undefined,0,-1),then(function(item) {
+               for(var i in item);
+               if(item[i].passwd==undefined)
+                       $scope.test = [ "Enter passwd" ];
+               else
+                       $scope.test = [ "Verify passwd" ];
+       });
+*/
+
+});
+
diff --git a/www/js/idbsrv.js b/www/js/idbsrv.js
new file mode 100644 (file)
index 0000000..894fea1
--- /dev/null
@@ -0,0 +1,99 @@
+// indexed db service
+
+var idbmod = angular.module('idbmod',[]);
+
+idbmod.factory("idbsrv",function($q) {
+       var srvobject={};
+       srvobject.init=function(name,successcb,version,stores,upgradecb) {
+               var defer=$q.defer();
+               idb.init(name,function(event) {
+                       if(successcb!==undefined)
+                               successcb(event);
+                       defer.resolve(idb.handle);
+               },version,stores);
+               return defer.promise;
+       };
+       srvobject.del_store=function(store,callback) {
+               var defer=$q.defer();
+               idb.del_store(store,function() {
+                       if(callback!==undefined)
+                               callback();
+                       defer.resolve();
+               });
+               return defer.promise;
+       };
+       srvobject.add_store_item=function(store,item,callback) {
+               var defer=$q.defer();
+               idb.add_store_item(store,item,function(event) {
+                       if(callback!==undefined)
+                               callback(event);
+                       defer.resolve();
+               });
+               return defer.promise;
+       };
+       srvobject.del_store_item=function(store,num,callback) {
+               var defer=$q.defer();
+               idb.del_store_item(store,num,function(event) {
+                       if(callback!==undefined)
+                               callback(event);
+                       defer.resolve();
+               });
+               return defer.promise;
+       };
+       srvobject.update_store_item=function(store,num,nitem,callback) {
+               var defer=$q.defer();
+               idb.update_store_item(store,num,nitem,function(event) {
+                       if(callback!==undefined)
+                               callback(event)
+                       defer.resolve();
+               });
+               return defer.promise;
+       };
+       srvobject.get_store_items=function(store,callback,low,up) {
+               var defer=$q.defer();
+               idb.get_store_items(store,function(item) {
+                       if(callback!==undefined)
+                               callback(item);
+                       defer.resolve(item);
+               });
+               return defer.promise;
+       };
+       srvobject.get_item_by_key=function(store,key,callback) {
+               var defer=$q.defer();
+               idb.get_item_by_key(store,key,function(item) {
+                       if(callback!==undefined)
+                               callback(item);
+                       defer.resolve();
+               });
+               return defer.promise;
+       };
+       srvobject.get_item_by_index=function(store,index,val,callback) {
+               var defer=$q.defer();
+               idb.get_item_by_index(store,index,val,function(item) {
+                       if(callback!==undefined)
+                               callback(item);
+                       defer.resolve();
+               });
+               return defer.promise;
+       };
+       srvobject.del_item_by_key=function(store,key,callback) {
+               var defer=$q.defer();
+               idb.del_item_by_key(store,key,function(event) {
+                       if(callback!==undefined)
+                               callback(event);
+                       defer.resolve();
+               });
+               return defer.promise;
+       };
+       srvobject.del=function(callback) {
+               var defer=$q.defer();
+               idb.del(function() {
+                       if(callback!==undefined)
+                               callback();
+                       defer.resolve();
+               });
+               return defer.promise;
+       };
+       return srvobject;
+});
+