Browse Source

Expose search endpoint via JS

Getty Ritter 1 year ago
parent
commit
95d95fe861
3 changed files with 24 additions and 0 deletions
  1. 11 0
      static/lc.js
  2. 8 0
      static/main.css
  3. 5 0
      templates/main.mustache

+ 11 - 0
static/lc.js

@@ -51,4 +51,15 @@ $(document).ready(() => {
                 .catch(err => window.location.href = url);
         });
     }
+
+    let searchText = $("#search_text");
+    console.log(`search text: ${searchText}`);
+    searchText.on('keypress', function (e) {
+        if (e.which == 13) {
+            let user = searchText.data('user');
+            let search = searchText.val();
+            window.location.href = `/u/${user}/search/${search}`
+            return false;
+        }
+    });
 });

+ 8 - 0
static/main.css

@@ -221,3 +221,11 @@ form > div {
     margin-left: 1em;
     padding-left: 0.3em;
 }
+
+.search {
+    padding: 0em 2em;
+}
+
+#search_text {
+    width: 20em;
+}

+ 5 - 0
templates/main.mustache

@@ -21,6 +21,11 @@
         {{/user}}
       </div>
       <div class="right">
+        {{#user}}
+        <div class="search">
+          <input data-user="{{name}}" type="text" id="search_text"/>
+        </div>
+        {{/user}}
         <div class="srclink">
           <a href="https://git.infinitenegativeutility.com/getty/lament-configuration">source</a>
         </div>