Browse Source

prenota: vagamente usabile

boyska 2 years ago
parent
commit
a82b082a2f

+ 1 - 1
pizzicore/pages/index.html

@@ -27,7 +27,7 @@ img, svg, text {
     </head>
     <body data-cid="0">
         <nav>
-            <a href="/">Home</a>
+            <a class="active" href="/">Home</a>
             <a href="/prenota">Prenotati</a>
         </nav>
         <!--h1 id="counter">asd</h1-->

+ 8 - 4
pizzicore/pages/prenotati.html

@@ -7,16 +7,20 @@
     <body>
         <nav>
             <a href="/">Home</a>
-            <a href="/prenota">Prenotati</a>
+            <a class="active" href="/prenota">Prenotati</a>
         </nav>
 
-        <div id="form-section">
+        <section id="form-section">
             <form id="form" class="hide">
                 <label for="tuonumero">Imposta una notifica al numero</label>
                 <input type="number" id="tuonumero" name="tuonumero" min="1" max="5000">
-                <a href="#" id="btn-prenotati"  >Prenotati</button>
+                <a href="#" class="btn btn-default" id="btn-prenotati"  >Prenotati</a>
             </form>
-        </div>
+        </section>
+        <section id="now-section" class="hide">
+            <header><h2>Serviamo il numero</h2>
+            <div id="now"></div>
+        </section>
         <div id="errors"> </div>
         <script src="/static/js/common.js"></script>
         <script src="/static/js/prenota.js"></script>

+ 1 - 1
pizzicore/pizzicore.py

@@ -171,5 +171,5 @@ async def root_page():
     return await get_page("pages/index.html")
 
 @app.get("/prenota")
-async def root_page():
+async def prenota_page():
     return await get_page("pages/prenotati.html")

+ 22 - 2
pizzicore/static/css/common.css

@@ -1,3 +1,23 @@
 body { font-family: sans-serif;  }
-nav { font-size: 200%; margin-bottom: 0.5em; }
-nav a { padding-right: 2em; }
+nav { font-size: 200%; margin-bottom: 0.5em; background-color: black; }
+nav a { margin-right: 2em; padding: 0 0.5em; color: white; text-decoration: none; }
+nav a.active { color: black; background-color: white; }
+
+.btn {
+    margin-right: 0.5em;
+    padding: 0.2em 0.5em;
+    text-decoration: none;
+    border-radius: 0.2em;
+}
+.btn-default {
+    background-color: green;
+    color: white;
+    font-weight: bold;
+}
+.btn[disabled] {
+    background-color: gray;
+    color: darkgray;
+} 
+a[disabled] {
+    pointer-events: none;
+}

+ 6 - 4
pizzicore/static/js/prenota.js

@@ -49,8 +49,8 @@ function prenotatiWorker(worker, prenotato) {
             notify("sbrigati: siamo al " + e.data)
             worker.postMessage({cmd: "close"})
         } else {
-            var field = document.querySelector('#tuonumero');
-            field.value = e.data
+            var field = document.querySelector('#now');
+            field.textContent = e.data
         }
     }
 
@@ -100,18 +100,20 @@ function inizializzaNumero() {
 
     inizializzaNumero()
 
-    document.getElementById('btn-prenotati').onclick = function () {
+    var btn = document.getElementById('btn-prenotati')
+    btn.onclick = function () {
         var val = document.querySelector('#form > input').value
         initNotify() 
         var field = document.querySelector('#tuonumero');
         field.setAttribute('disabled', 'disabled')
+        document.getElementById('now-section').classList.remove('hide')
+        btn.setAttribute('disabled', 'disabled')
         var value = parseInt(val,10)
         if(SERVICEWORKER) {
             prenotatiWorker(webSocketWorker, value)
         } else {
             prenotati(value)
         }
-        field.value = ""
     }
 })()