Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Lista de Pedidos</title>
- <meta charset="UTF-8" />
- <meta name="viewport" content="width=device-width, initial-scale=1" />
- <link
- rel="stylesheet"
- href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css"
- integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS"
- crossorigin="anonymous"
- />
- </head>
- <body>
- <script type="text/javascript" src="https://github.com/mde/ejs/releases/download/v2.5.8/ejs.js"></script>
- <script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
- <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js" integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k" crossorigin="anonymous"></script>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.2.0/socket.io.js" type="text/javascript"></script>
- <h1>Painel do Motorista</h1>
- <div class="container">
- <div class="row">
- <div class="col-xs-6">
- <form id="driverForm">
- <select class="form-control" id="bookingStatus">
- <option value="confirmed">Confirmar</option>
- <option value="canceled">Cancelar</option>
- </select>
- <br />
- <input
- type="button"
- name="submit"
- value="Enviar"
- Booking”
- class="btn btn-danger"
- />
- </form>
- </div>
- </div>
- </br>
- <div class="row"><div id="wrapper"></div></div>
- </div>
- <script type="text/ejs" id="template">
- <% var passangerData = passangerData; %>
- <% if(passangerData) { %>
- <div class="col-xs-6">
- <div class="card mb-4 shadow-sm">
- <div class="card-header">
- <h2 class="my-0 font-weight-normal">Passageiro: <%= passangerData.userId %></h2>
- <h4 class="my-0 font-weight-normal">Hora do pedido: <%= passangerData.created_at %></h4>
- </div>
- <div class="card-body">
- <ul class="list-unstyled mt-3 mb-4">
- <li>Partida: <%= passangerData.pickUp.name %></li>
- <li>Destino: <%= passangerData.dropOff.name %></li>
- </ul>
- </div>
- </div>
- </div>
- <% } else { %>
- <div class="col-xs-6">
- <div class="card mb-4 shadow-sm">
- <div class="card-header">
- <h2 class="my-0 font-weight-normal">Passageiro: </h2>
- <h4 class="my-0 font-weight-normal">Hora do pedido: </h4>
- </div>
- <div class="card-body">
- <ul class="list-unstyled mt-3 mb-4">
- <li>Partida: </li>
- <li>Destino: </li>
- </ul>
- </div>
- </div>
- </div>
- <% } %>
- </script>
- <script>
- var socket = io();
- socket.on("connect", () => {
- //on emited by user on random nearby driver
- var driverRequest = socket.id + "driverRequest";
- socket.on(driverRequest, function(passangerData) {
- console.log("Passanger looking for a driver", passangerData);
- var templateString = document.getElementById("template").innerHTML;
- var compiled = ejs.compile(templateString);
- var html = compiled({ passangerData: passangerData });
- document.getElementById("wrapper").innerHTML = html;
- });
- });
- });
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement