]> hackdaworld.org Git - outofuni/stafforg.git/commitdiff
passwd input in admin subapp
authorhackbard <hackbard@hackdaworld.org>
Tue, 21 Jun 2016 21:39:12 +0000 (23:39 +0200)
committerhackbard <hackbard@hackdaworld.org>
Tue, 21 Jun 2016 21:39:12 +0000 (23:39 +0200)
app/www/css/index.css
app/www/index.html
app/www/js/config.js [new file with mode: 0644]
app/www/js/index.js

index c48c2255c531da492f83f233155f184553dc1224..12ab07ae0b20ad692a7f5f6b5ac299f1d2327cc6 100644 (file)
@@ -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;
+}
+
index b0777cc81cd63a0c7a4daa16e4fca812ee1df0ac..55c85d28640e9cae52e964e69e510402ffe812f4 100644 (file)
@@ -40,6 +40,7 @@
                </script>
                <script type="text/javascript" src="js/jsutils/xhr.js">
                </script>
+               <script type="text/javascript" src="js/config.js"></script>
                <script type="text/javascript" src="js/index.js"></script>
        </head>
 
                        <button id=seladmin class=startbtn>Administration
                        </button>
                </div>
-               <div id=clock></div>
-               <div id=roster</div>
-               <div id=ideas</div>
-               <div id=todo</div>
+               <div id=clock>
+                       <div class=head>
+                       Time Clock
+                       </div>
+                       <div class=main>
+                       </div>
+               </div>
+               <div id=roster>
+                       <div class=head>
+                       Roster
+                       </div>
+                       <div class=main>
+                       </div>
+               </div>
+               <div id=ideas>
+                       <div class=head>
+                       Brainstorming
+                       </div>
+                       <div class=main>
+                       </div>
+               </div>
+               <div id=todo>
+                       <div class=head>
+                       ToDo
+                       </div>
+                       <div class=main>
+                       </div>
+               </div>
+               <div id=admin>
+                       <div class=head>
+                       Administration
+                       </div>
+                       <div id=adminset class=main>
+                               <br>
+                               Set your initial admin password
+                               <br><br>
+                               <input type=password
+                                      placeholder="Password"
+                                      id=adminpw1 required>
+                               <input type=password
+                                      placeholder="Confirm password"
+                                      id=adminpw2 required>
+                       </div>
+                       <div id=adminauth class=main>
+                       </div>
+                       <div id=adminmain class=main>
+                       </div>
+               </div>
        </body>
 </html>
 
diff --git a/app/www/js/config.js b/app/www/js/config.js
new file mode 100644 (file)
index 0000000..bc8cbd4
--- /dev/null
@@ -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': "",
+                       }
+               ]
+       }
+}
+
index 98eaa9fcd5af184286a8a6de56243de5baa7fda3..446c060c8b63d93a13194106fd5598b77210e75c 100644 (file)
@@ -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!");
+               }
        }
 };