| 1 | import { consume } from "../libclienteweb/consume.js" |
| 2 | import { descargaVista } from "../libclienteweb/descargaVista.js" |
| 3 | import { recibeJson } from "../libclienteweb/recibeJson.js" |
| 4 | |
| 5 | descargaDatos() |
| 6 | |
| 7 | async function descargaDatos() { |
| 8 | await descargaVista("api/vista-administrador.php") |
| 9 | const botonSaludo = document.querySelector("#botonSaludo") |
| 10 | if (botonSaludo) { |
| 11 | botonSaludo.addEventListener("click", saludo) |
| 12 | } |
| 13 | } |
| 14 | |
| 15 | async function saludo() { |
| 16 | const respuesta = await consume(recibeJson('api/saludo-cliente.php')) |
| 17 | const json = await respuesta.json() |
| 18 | alert(json) |
| 19 | } |
| 20 |
| 1 | import { consume } from "../libclienteweb/consume.js" |
| 2 | import { descargaVista } from "../libclienteweb/descargaVista.js" |
| 3 | import { recibeJson } from "../libclienteweb/recibeJson.js" |
| 4 | |
| 5 | descargaDatos() |
| 6 | |
| 7 | async function descargaDatos() { |
| 8 | await descargaVista("api/vista-cliente.php") |
| 9 | const botonSaludo = document.querySelector("#botonSaludo") |
| 10 | if (botonSaludo) { |
| 11 | botonSaludo.addEventListener("click", saludo) |
| 12 | } |
| 13 | } |
| 14 | |
| 15 | async function saludo() { |
| 16 | const respuesta = await consume(recibeJson('api/saludo-cliente.php')) |
| 17 | const json = await respuesta.json() |
| 18 | alert(json) |
| 19 | } |
| 20 |
| 1 | import { descargaVista } from "../libclienteweb/descargaVista.js" |
| 2 | |
| 3 | descargaVista("api/vista-index.php") |
| 1 | import { |
| 2 | configuraSubmitAccion |
| 3 | } from "../libclienteweb/configuraSubmitAccion.js" |
| 4 | import { descargaVista } from "../libclienteweb/descargaVista.js" |
| 5 | |
| 6 | descargaDatos() |
| 7 | |
| 8 | async function descargaDatos() { |
| 9 | await descargaVista("api/vista-login.php") |
| 10 | const formulario = document.querySelector("form") |
| 11 | if (formulario) { |
| 12 | configuraSubmitAccion("api/login.php", formulario, "perfil.html") |
| 13 | } |
| 14 | } |
| 1 | import { consume } from "../libclienteweb/consume.js" |
| 2 | import { descargaVista } from "../libclienteweb/descargaVista.js" |
| 3 | import { recibeJson } from "../libclienteweb/recibeJson.js" |
| 4 | |
| 5 | descargaDatos() |
| 6 | |
| 7 | async function descargaDatos() { |
| 8 | await descargaVista("api/vista-perfil.php") |
| 9 | const botonLogout = document.querySelector("#botonLogout") |
| 10 | if (botonLogout) { |
| 11 | botonLogout.addEventListener("click", logout) |
| 12 | } |
| 13 | } |
| 14 | |
| 15 | async function logout() { |
| 16 | await consume(recibeJson('api/logout.php')) |
| 17 | location.reload() |
| 18 | } |
| 1 | export class MiNav extends HTMLElement { |
| 2 | |
| 3 | constructor() { |
| 4 | super() |
| 5 | this.cargado = false |
| 6 | } |
| 7 | |
| 8 | connectedCallback() { |
| 9 | |
| 10 | this.style.display = "block" |
| 11 | |
| 12 | if (this.cargado === false) { |
| 13 | this.innerHTML = /* html */ |
| 14 | `<nav> |
| 15 | <ul> |
| 16 | <li><a href="index.html">Inicio</a></li> |
| 17 | <li id="ocupado"><progress max="100">Cargando…</progress></li> |
| 18 | <li id="aAdmin" hidden> |
| 19 | <a href="administrador.html">Para administradores</a> |
| 20 | </li> |
| 21 | <li id="aCliente" hidden><a href="cliente.html">Para clientes</a></li> |
| 22 | <li id="san" hidden></li> |
| 23 | <li id="aPerfil"><a href="perfil.html">Perfil</a></li> |
| 24 | </ul> |
| 25 | </nav>` |
| 26 | |
| 27 | this.cargado = true |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | } |
| 32 | |
| 33 | customElements.define("mi-nav", MiNav) |