/*
var deviceData = {
  device1: {
    title: "Rock 5A",
    text: "The ROCK 5A board is based around the scaled down Rockchip RK3588S octa-core processor with quad Cortex A76 and a quad Cortex A55 and ARM Mali G610MC4 GPU and custom neural processor unit (NPU) and supports 8Kp60 video. It also has up to 16GB of 64bits LPDDR4x RAM on the board to support large AI frameworks.",
    dlLink: "https://github.com/BredOS/tobedone",
    dlLink2: "https://repo.bredos.org/BredOS-ARM-rock5b-2023-06-10.img.xz",
    img: "/assets/img/devices/Rock5A.png"
  },
  device2: {
    title: "Rock 5B",
    text: "The ROCK5 Model B, equipped with the RK3588 SoC and 8 cores, delivers exceptional power-efficient performance in a compact Pico ITX form factor.",
    dlLink: "https://us.repo.bredos.org/BredOS-ARM-rock5b-2023-06-10.img.xz",
    dlLink2: "https://sw.repo.bredos.org/BredOS-ARM-rock5b-2023-06-10.img.xz",
    checksum: "6d29506193cc09f5d0b938e1a9bf57bc",
    img: "/assets/img/devices/ROCK5B.png"
  },
  device3: {
    title: "Orange Pi 5 plus",
    text: "The Orange Pi 5 plus is a single-board computer that features an upgraded Rockchip SoC, up to 32GB of RAM, faster WiFi, and other improvements over earlier versions of the Orange Pi ARM64 SBCs.",
    dlLink: "https://us.repo.bredos.org/BredOS-ARM-opi-5-plus-2023-06-18.img.xz",
    dlLink2: "https://sw.repo.bredos.org/BredOS-ARM-opi-5-plus-2023-06-18.img.xz",
    checksum: "7f741f8028165b6fc567b577be7123d2",
    img: "/assets/img/devices/pi5-plus-5.png"
  },
  device4: {
    title: "Mekotronics R58X",
    text: "Mekotronics R58X is a low power, high performance processor for ARM-based PC and Edge Computing device, personal mobile internet device and other digital multimedia applications, and integrates quad-core Cortex-A76 and quad-core Cortex-A55 with separately NEON coprocessor.",
    dlLink: "https://us.repo.bredos.org/images/BredOS-ARM-r58x-2023-07-03.img.xz",
    dlLink2: "https://sw.repo.bredos.org/images/BredOS-ARM-r58x-2023-07-03.img.xz",
    checksum: "0ac78eed4501632b19477e8593e716ee",
    img: "/assets/img/devices/MekotronicsRK58X.png"
  },
  device5: {
    title: "Mekotronics R58X 4G",
    text: "Mekotronics R58X-4G is using Rockchip RK3588 chipset, which is 8nm made and 8-core CPU, 4 cores Cortex A76 and 4 cores of Cortex A55. With its HDMI2.1 output, the max video output resolution is up to 8K 60Hz (7680*4320 60Hz).The biggest feature the R58X-4G is adding adding POE, mini PCIe for 4G LTE/GPS module, SIM card slot, M.2 PCIe NVMe SSD slot.",
    dlLink: "https://sw.repo.bredos.org/images/BredOS-ARM-r58x-4g-2023-07-03.img.xz",
    dlLink2: "https://us.repo.bredos.org/images/BredOS-ARM-r58x-4g-2023-07-03.img.xz",
    checksum: "36c5c9ebe6fb33a50dfd738efc945751",
    img: "/assets/img/devices/MekotronicsR58X-4G.png"
  },
  device6: {
    title: "Mekotronics R58X Pro",
    text: "Mekotronics R58X-Pro is using Rockchip RK3588 that has 8 cores. The biggest feature the R58X-Pro is adding adding POE, mini PCIe for 4G LTE/GPS module, SIM card slot, M.2 PCIe NVMe SSD slot, Micro SD card slot, and 10G Ethernet port.",
    dlLink: "https://us.repo.bredos.org/images/BredOS-ARM-r58x-pro-2023-07-03.img.xz",
    dlLink2: "https://sw.repo.bredos.org/images/BredOS-ARM-r58x-pro-2023-07-03.img.xz",
    checksum: "a73ffcbe260e338840b53b2616042090",
    img: "/assets/img/devices/r58x-pro.png"
  },
  device7: {
    title: "Mekotronics R58S (Mini PC)",
    text: "The Mekotronics Mini PC, equipped with the Rockchip RK3588, supports output resolutions up to 8K@60Hz and input resolutions up to 4k60Hz",
    dlLink: "https://us.repo.bredos.org/images/BredOS-ARM-r58s-2023-07-03.img.xz",
    dlLink2: "https://sw.repo.bredos.org/images/BredOS-ARM-r58s-2023-07-03.img.xz",
    checksum: "e0bd0de82e38a254132aab4c7f8a4334",
    img: "/assets/img/devices/r58s.png"
  },
  device8: {
    title: "Apple Macbook M1",
    text: "",
    dlLink: "https://github.com/BredOS/tobedone",
    dlLink2: "https://repo.bredos.org/BredOS-ARM-rock5b-2023-06-10.img.xz",
    checksum: "N\A",
    img: "/assets/img/devices/macbook-m1.png"
  },
  device9: {
    title: "Apple Macbook M2",
    text: "",
    dlLink: "https://github.com/BredOS/tobedone",
    dlLink2: "https://repo.bredos.org/BredOS-ARM-rock5b-2023-06-10.img.xz",
    checksum: "N\A",
    img: "/assets/img/devices/macbook-m2.png"
  },
  device10: {
    title: "Khadas Edge 2",
    text: "Edge2 is powered by the RK3588S, a next generation 8-core 64-bit SoC from Rockchip. The RK3588S is Rockchip's newest flagship IoT SoC utilizing the 8 nanometer lithography process.",
    dlLink: "https://us.repo.bredos.org/BredOS-ARM-edge2-2023-06-10.img.xz",
    dlLink2: "https://sw.repo.bredos.org/BredOS-ARM-edge2-2023-06-10.img.xz",
    checksum: "1ec70e039ca1f854eda1b58df750a577",
    img: "/assets/img/devices/khadas-edge2.png"
  },
  // Add as many devices as u want.
};

// Search function
function filterDevices() {
  var input = document.getElementById("searchInput");
  var filter = input.value.toUpperCase();
  var deviceList = document.getElementById("deviceList");
  var devices = deviceList.getElementsByTagName("li");
  
  for (var i = 0; i < devices.length; i++) {
    var deviceName = devices[i].textContent || devices[i].innerText;
    if (deviceName.toUpperCase().indexOf(filter) > -1) {
      devices[i].classList.remove("hidden");
    } else {
      devices[i].classList.add("hidden");
    }
  }
}

function removeActive(){
  var deviceList = document.getElementById("deviceList");
  var devices = deviceList.getElementsByTagName("li");
  
  for (var i = 0; i < devices.length; i++) {
     devices[i].classList.remove("active");
     devices[i].classList.add("bg-dark");
  }
}

// Card sellector function
function changeCard(selectedDevice) {
  var cardContainer = document.getElementById("cardContainer");
  removeActive();
  var element = document.getElementById(selectedDevice);
  element.classList.add("active");
  element.classList.remove("bg-dark");
  
  // Clear existing cards
  cardContainer.innerHTML = "";
  
  // Create and append the new card based on the selected device
  var card = document.createElement("div");
  card.className = "card bg-dark";
  
  // Retrieve device data from the dictionary
  var device = deviceData[selectedDevice];
  
  // Create card body
  var cardBody = document.createElement("div");
  cardBody.className = "dev-card-body p-4 bg-dark";
  
  
  // Create card title
  var cardTitle = document.createElement("h4");
  cardTitle.className = "dev-card-title bg-dark";
  cardTitle.textContent = device.title;
  
  // Create card text
  var cardText = document.createElement("p");
  cardText.className = "dev-card-text bg-dark";
  cardText.textContent = device.text;
    
  var cardText2 = document.createElement("p");
  cardText2.className = "dev-card-text bg-dark bold";
  cardText2.textContent = "The download for "+ device.title + " has a checksum of " + device.checksum;
  
  // Create download link
  var downloadLink = document.createElement("a");
  downloadLink.onclick = function () {
      javascript:$('#downloadprompt').modal('show');
  }
  downloadLink.textContent = "Download";
  downloadLink.className = "btn btn-primary ";
  downloadLink.style = "background: rgb(153,186,221);border-radius: 10px;";
  
  // Create card image
  var cardImage = document.createElement("img");
  cardImage.src = device.img;
  cardImage.className = "card-img-top bg-dark";
  
  // Append card elements
  cardBody.appendChild(cardTitle);
  cardBody.appendChild(cardText);
  cardBody.appendChild(downloadLink);
  card.appendChild(cardImage);
  card.appendChild(cardBody);
  cardContainer.appendChild(card);
    
  element = document.getElementById("checksum");
  element.innerText = "The download for "+ device.title + " has a checksum of " + device.checksum;
  
  element = document.getElementById("active_download");
  element.href = device.dlLink;
  element = document.getElementById("active_download2");
  element.href = device.dlLink2;
}
// Make Device 1 presellected
changeCard('device2');
*/
