2 * stafforg: crew organizaion app
3 * author: hackbard@hackdaworld.org
8 * Licensed to the Apache Software Foundation (ASF) under one
9 * or more contributor license agreements. See the NOTICE file
10 * distributed with this work for additional information
11 * regarding copyright ownership. The ASF licenses this file
12 * to you under the Apache License, Version 2.0 (the
13 * "License"); you may not use this file except in compliance
14 * with the License. You may obtain a copy of the License at
16 * http://www.apache.org/licenses/LICENSE-2.0
18 * Unless required by applicable law or agreed to in writing,
19 * software distributed under the License is distributed on an
20 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 * KIND, either express or implied. See the License for the
22 * specific language governing permissions and limitations
28 document.addEventListener('deviceready',this.startup,false);
29 window.addEventListener('orientationchange',function() {
30 setTimeout(function() {
31 cl("orientation change ...");
36 cl("starting stafforg app ...");
39 //idb.name='stafforg';
43 'admin': db_admin_store
45 idb.init('stafforg',stafforg.dbcb,1,stores);
47 // ui will be initialized in db callback
50 stafforg.activate_subapp('start');
51 $('.startbtn').click(function(event) {
52 var sapp=event.target.id.replace(/^sel/,'');
53 cl("clicked "+event.target.id+", starting "+sapp);
54 stafforg.event_action(sapp,'start');
57 activate_subapp: function(sapp) {
58 $('.startbtn').each(function() {
59 var sappname=this.id.replace(/^sel/,'');
60 var sappid='#'+sappname;
61 $(sappid).css('height','100%');
63 $(sappid).css('display','block');
65 $(sappid).css('display','none');
68 $('#start').css('height','100%');
69 $('#start').css('display','block');
72 $('#start').css('display','none');
74 vert_align_text('.head');
77 stafforg.admin_init();
81 event_action: function(sapp,type) {
84 stafforg.activate_subapp(sapp);
88 admin_init: function() {
89 idb.get_item_by_key('admin',1,function(item) {
90 if(item.passwd==undefined) {
91 $('#adminset').css('display','block');
92 $('#adminauth').css('display','none');
93 $('#adminmain').css('display','none');
94 $('#adminpw1').keyup(function() {
97 $('#adminpw2').keyup(function() {
102 $('#adminset').css('display','none');
103 $('#adminauth').css('display','block');
104 $('#adminmain').css('display','none');
105 $('#adminpw').each(function() {
108 $('#adminpw').keyup(function() {
109 stafforg.verifypw(item.passwd);
114 checkpw: function() {
115 var pw1=$('#adminpw1').val();
116 var pw2=$('#adminpw2').val();
119 $('#adminpw1').css('border-color','red');
123 $('#adminpw1').css('border-color','black');
127 $('#adminpw2').css('border-color','grey');
132 $('#adminpw2').css('border-color','red');
140 idb.update_store_item('admin',1,nitem,function() {
141 cl("password '"+nitem.passwd+"' set!");
142 setTimeout(function() {
143 stafforg.admin_init();
149 verifypw: function(passwd) {
150 cl("verify called!");
151 if($('#adminpw').val()!=passwd) {
152 $('#adminpw').css('border-color','red');
161 $(document).ready(function() {
162 if('cordova' in window) {