import {WebWebSocketHandler} from "./WebWebSocketHandler";
import {Modal} from "./Modal";
import {WebHandler} from "./WebHandler";
import {Pane} from "./Pane";

const main = document.getElementById("main");
const time = document.getElementById("right");

document.addEventListener("DOMContentLoaded", () => {
   console.log("DOM Loaded");
   WebHandler.openPane(Pane.MAIN);

   let modal = new Modal("start", "iTender");
   let txt = document.createElement("p");
   txt.innerText = "Willkommen"
   modal.addContent(txt);
   modal.loader = true;
   //modal.open();
   connect();

   setTimeout( load, 1000);
});


function load()
{
   if(!main||!time)
      return;

   setInterval( () => {
      let currentDate = new Date();
      time.innerText = "" + ( currentDate.getHours() < 10 ? "0" + currentDate.getHours() : currentDate.getHours() ) + ":" + ( currentDate.getMinutes() < 10 ? "0" + currentDate.getMinutes() : currentDate.getMinutes() );
   }, 1000 );
}

let wsHandler;
function connect()
{
   wsHandler = new WebWebSocketHandler();
}
