import { statusProxy } from './main.js'

export async function loadStatus(){
  let res = await fetch('/status/index.html');

  let html_text = await res.text()
  let html = new DOMParser().parseFromString(html_text, "text/html");

  let target = document.querySelector('#statuSection');

  let hiddenBtn = target.querySelector('a');

  hiddenBtn.style.visibility = 'collapse';

  let status = html.querySelector('#lolStatus');
  console.log('current status:', status.innerText);


  if (status.innerText.includes('ouvert')){
    statusProxy.lolStatus = true;
  }else{
    statusProxy.lolStatus = false;
  }


  let icon = html.querySelector('link[rel="icon"]');
  let style = html.querySelectorAll('link[rel="stylesheet"]')[0];
  //console.log("selected script: ", script);

  document.head.append(icon);
  document.head.append(style);

  target.appendChild(status);
}
