From 714e3dd465ec416d16b417f208d1ecc241c8f70a Mon Sep 17 00:00:00 2001 From: hackbard Date: Tue, 21 Jun 2016 23:39:12 +0200 Subject: [PATCH] passwd input in admin subapp --- app/www/css/index.css | 29 +++++++++++++++ app/www/index.html | 53 ++++++++++++++++++++++++--- app/www/js/config.js | 33 +++++++++++++++++ app/www/js/index.js | 83 +++++++++++++++++++++++++++++++++++++------ 4 files changed, 184 insertions(+), 14 deletions(-) create mode 100644 app/www/js/config.js diff --git a/app/www/css/index.css b/app/www/css/index.css index c48c225..12ab07a 100644 --- a/app/www/css/index.css +++ b/app/www/css/index.css @@ -60,3 +60,32 @@ body { display: none; } +.head { + width: 100%; + height: 10%; + color: white; + text-align: center; + background-color: #222; +} + +.main { + width: 100%; + height: 90%; + color: #ccc; + background-color: #666; +} + +#adminset { + display: none; + color: black; + text-align: center; +} + +#adminmain { + display: none; +} + +#adminauth { + display: none; +} + diff --git a/app/www/index.html b/app/www/index.html index b0777cc..55c85d2 100644 --- a/app/www/index.html +++ b/app/www/index.html @@ -40,6 +40,7 @@ + @@ -53,10 +54,54 @@ -
-
-
-
+
+
+ Time Clock +
+
+
+
+
+
+ Roster +
+
+
+
+
+
+ Brainstorming +
+
+
+
+
+
+ ToDo +
+
+
+
+
+
+ Administration +
+
+
+ Set your initial admin password +

+ + +
+
+
+
+
+
diff --git a/app/www/js/config.js b/app/www/js/config.js new file mode 100644 index 0000000..bc8cbd4 --- /dev/null +++ b/app/www/js/config.js @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* db stores */ + +var db_admin_store = { + keyname: true, + keytype: 'autoIncrement', + content: { + 1: [ + { + 'passswd': "", + } + ] + } +} + diff --git a/app/www/js/index.js b/app/www/js/index.js index 98eaa9f..446c060 100644 --- a/app/www/js/index.js +++ b/app/www/js/index.js @@ -34,15 +34,22 @@ var stafforg = { }, startup: function() { cl("starting stafforg app ..."); - // ui + + // idb + var stores={ + 'admin': db_admin_store + } + idb.init('stafforg',stafforg.dbcb,1,stores); + + // ui will be initialized in db callback + }, + dbcb: function() { stafforg.activate_subapp('start'); $('.startbtn').click(function(event) { - cl("clicked "+event.target.id); - stafforg.event_action(event,'start'); + var sapp=event.target.id.replace(/^sel/,''); + cl("clicked "+event.target.id+", starting "+sapp); + stafforg.event_action(sapp,'start'); }); - // db - }, - dbcb: function() { }, activate_subapp: function(sapp) { $('.startbtn').each(function() { @@ -55,12 +62,68 @@ var stafforg = { $(sappid).css('display','none'); }); if(sapp=='start') { - var sappid='#'+sapp; - $(sappid).css('height','100%'); - $(sappid).css('display','block'); + $('#start').css('height','100%'); + $('#start').css('display','block'); + } + else { + $('#start').css('display','none'); + } + vert_align_text('.head'); + switch(sapp) { + case 'admin': + stafforg.admin_init(); + break; + } + }, + event_action: function(sapp,type) { + switch(type) { + case 'start': + stafforg.activate_subapp(sapp); + break; } }, - event_action: function() { + admin_init: function() { + idb.get_item_by_key('admin',1,function(item) { + if(item.passwd==undefined) { + $('#adminset').css('display','block'); + $('#adminauth').css('display','none'); + $('#adminmain').css('display','none'); + $('#adminpw1').keyup(function() { + stafforg.checkpw(); + }); + $('#adminpw2').keyup(function() { + stafforg.checkpw(); + }); + } + else { + } + }); + }, + checkpw: function() { + var pw1=$('#adminpw1').val(); + var pw2=$('#adminpw2').val(); + + if(pw1=='') { + $('#adminpw1').css('border-color','red'); + return + } + else { + $('#adminpw1').css('border-color','black'); + } + + if(pw2=='') { + $('#adminpw2').css('border-color','grey'); + return + } + + if(pw1!=pw2) { + $('#adminpw2').css('border-color','red'); + return + } + + if(pw1==pw2) { + alert("yep, i will store this password!"); + } } }; -- 2.39.2