OSDN Git Service

working and stable
authorJohn-Anthony Elenis <johnanthonyelenis@gmail.com>
Wed, 21 Aug 2019 20:24:29 +0000 (16:24 -0400)
committerJohn-Anthony Elenis <johnanthonyelenis@gmail.com>
Wed, 21 Aug 2019 20:24:29 +0000 (16:24 -0400)
index.html
js/theme.js

index 45b7719..58552de 100644 (file)
@@ -48,7 +48,7 @@
     div#console {
       z-index: 9999;
       position: absolute;
-      top: 4px;
+      top: 10px;
     }
     div#console .terminal {
       overflow-y: scroll;
 <body>
                <!-- Debug Console -->
     <div id="console" class="row">
-        <div class="col">
-          <div class="switch">
-            <label>
-              <input type="checkbox" checked="true">
-              <span class="lever"></span>
-              Auto
-            </label>
+        <div class="col s3">
+          <div class="row">
+            <div class="switch">
+              <label>
+                <input type="checkbox" checked="true">
+                <span class="lever"></span>
+                Auto
+              </label>
+            </div>
           </div>
+
+          <div class="row">
+            <div class="input-field col ">
+              <input id="inputEvent" >
+              <label for="inputEvent">Event</label>
+            </div>
+            <a id="buttonTrigger" class="waves-effect waves-light btn">Trigger</a>
+          </div>
+
         </div>
-        <div class="col">
-          <div class="terminal"></div>
+        <div class="col s9">
+          <div contentEditable="true" class="terminal"></div>
         </div>
     </div>
 <!-- End Debug Console -->
@@ -172,12 +183,17 @@ $(greeter).ready(function() {
 
     /* attempt authentication, 'grant' event will be emitted on sucecss
     and 'deny' will be emitted on failure */
-    if (e.keyCode == 13)
-       greeter.auth(username, pass);
+    if (e.keyCode == 13) {
+      greeter.auth(username, pass);
+      log.debug(pass.length);
+      log.debug("logging in with: " + username + " " + pass);
+    }
+
   });
 
   // when the user is authenticated do transitions and login
        $(greeter).on("grant", () => {
+    log.debug("grant event");
     let session_key = $session.children("option:selected").val();
     greeter.login(session_key);
        })
index f878f61..5701750 100644 (file)
@@ -52,14 +52,27 @@ window.onerror = function() {
 };
 var $log;
 var $autoscroll;
+var $buttonTrigger;
 $(document).ready(()=> {
        $log = $("#console .terminal");
        $autoscroll = $("#console input");
+       $buttonTrigger = $("#buttonTrigger");
+
+       $log.keypress(function(e) {
+      e.preventDefault();
+  });
+       $buttonTrigger.click(() => {
+               let e = $("#inputEvent").val();
+               log.debug("triggering: " + e);
+               $(greeter).trigger(e);
+
+       });
 });
 var log = {
        _parse(str, color) {
                        if (typeof str == "object") str = JSON.stringify(str,null, 2);
-                       str =  "[" + moment().format("hh:mm:ss") + "]: " + str;
+
+                       str =  "[" + moment().format("hh:mm:ss") + "] " + str;
                        str = "<text style='color: " + color + "'>" + str + "</text>";
                        return $log.html() + str;
        },
@@ -149,10 +162,9 @@ class LoginManager {
        }
 
 
-       auth(username, password, callback) {
-               // lightdm must have each of
-               let req = ["select_user", "is_authenticated", "authenticate"];
-               if (!req.every((x) => this.lightdm.hasOwnProperty(x) )) {
+       auth(username="", password="", callback) {
+
+               if (!this.lightdm) {
                        log.warn("Cannot attempt login because lightdm is missing the " +
                        "required fields. Please note that lightdm is not explicitly " +
                        "instantiated in a browser session.");
@@ -162,10 +174,6 @@ class LoginManager {
                        return;
                }
 
-               username = username || this.lightdm.select_user;
-               password = password || "";
-               //  session_key = session_key || lightdm.sessions[0].key;
-
                let auth_cb = () =>  {
                     this.lightdm.respond(password);
     }
@@ -238,7 +246,7 @@ class SplashScreen {
                this.$el = $("#splash-screen");
                this.$content = $("#splash-screen-content");
                this.options = this.getUserOptions();
-               this.is_open = false;
+               this.state = "closed";
                this.last_active = 0;
                this.active_timeout = 15;
 
@@ -366,16 +374,16 @@ class SplashScreen {
        keyHandler(e) {
                switch (e.keyCode) {
                        case 32:
-                       case 13:
-                               this.open();
+                       case 13: // Enter key
+                               if (this.state == "closed") this.open();
                                break;
-                       case 27:
+                       case 27: // ESC key
                                if (this.state == "open") this.close();
                                else if (this.state == "closed") this.open();
                                break;
                        default:
-                               if (e.keyCode != 82 && e.keyCode != 17) // for testing
-                               this.open();
+                               if (e.keyCode != 82 && e.keyCode != 17 && this.state == "closed") // for testing
+                                       this.open();
                                break;
                }