From: hackbard Date: Mon, 25 Jul 2016 20:08:56 +0000 (+0200) Subject: still idb problems, need to wait until idb init is finished! X-Git-Url: https://hackdaworld.org/gitweb/?a=commitdiff_plain;ds=inline;p=outofuni%2Fstaffline.git still idb problems, need to wait until idb init is finished! --- f0dc92c50972d35141685738b4a32f031db72012 diff --git a/www/index.html b/www/index.html new file mode 100644 index 0000000..b7e08ee --- /dev/null +++ b/www/index.html @@ -0,0 +1,84 @@ + + + + + + + Staff Line + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

{{selected_app.name}}

+
+ + + + +
+ + + +

Staff Line

+
+ + + + {{s.name}} + + + + +
+
+ + + + + + diff --git a/www/js/app.js b/www/js/app.js new file mode 100644 index 0000000..a06b415 --- /dev/null +++ b/www/js/app.js @@ -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 index 0000000..1b0c982 --- /dev/null +++ b/www/js/config.js @@ -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 index 0000000..c9d6d71 --- /dev/null +++ b/www/js/ctrl.js @@ -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 index 0000000..894fea1 --- /dev/null +++ b/www/js/idbsrv.js @@ -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; +}); +