// Init:
setQls();

async function sidebarOpen() {
  document.getElementById("sidebar").style.width = "50%";
  document.getElementById("sidebar_open_short").style.display = "none";
  document.getElementById("sidebar_close_short").style.display = "block";
}

async function sidebarClose() {
  document.getElementById("sidebar").style.width = "0%"
  document.getElementById("sidebar_open_short").style.display = "block";
  document.getElementById("sidebar_close_short").style.display = "none";
}

async function gotoBoard(station){
  window.location.assign(`${window.location.origin}/board.html?stn=${station}`)
}

async function setQls(){
  var qlOpt = JSON.parse(localStorage.getItem("qlOpt"))
  var qlDef = ["bri","lwh","srd","mtp","rda","cfn","sml","shh","pri","avn"]
  if (qlOpt) {
    for(var i = 0; i < qlOpt.length; i++) {
        console.log(`Button: ${qlOpt[i]}`)
        var btn = `<button class="actionbutton" onclick="gotoBoard(${qlOpt[i]})">${qlOpt[i].toUpperCase()}</button>`
        document.getElementById("quick_links").insertAdjacentHTML("beforeend", btn) // Append btn
        }
  } else {
    for(var i = 0; i < qlDef.length; i++) {
      console.log(`Button: ${qlDef[i]}`)
      var btn = `<button class="actionbutton" onclick="gotoBoard(${qlDef[i]})">${qlDef[i].toUpperCase()}</button>`
      document.getElementById("quick_links").insertAdjacentHTML("beforeend", btn) // Append btn
    }
  }
}