<!-- shared/_copy_basic_info.js.erb begins -->
<script>
"use strict";

document.addEventListener("DOMContentLoaded", () => {
    document.querySelector("button#copyBasicInfo")?.addEventListener("click", () => {
        let parts = [];

        parts.push("<%= t('activeldap.attributes.device.puavoHostname') %>: <%= device.puavoHostname %>");
        parts.push("FQDN: <%= @fqdn %>");
        parts.push("URL: <%= request.original_url %>");
        parts.push("<%= t('activeldap.attributes.device.puavoDeviceModel') %>: <%= device.puavoDeviceModel %>");
        parts.push("<%= t('activeldap.attributes.device.puavoDeviceManufacturer') %>: <%= device.puavoDeviceManufacturer %>");
        parts.push("<%= t('activeldap.attributes.device.serialNumber') %>: <%= device.serialNumber %>");
        parts.push("<%= t('activeldap.attributes.device.macAddress') %>: <%= Array(device.macAddress).join(', ') %>");

        const full = parts.join("\n") + "\n";

        copyTextToClipboard(full);
    });

<% if @fqdn %>
    document.querySelector("button#copyFQDN")?.addEventListener("click", () => {
        copyTextToClipboard("<%= @fqdn %>");
    });
<% end %>
});
</script>
<!-- shared/_copy_basic_info.js.erb ends -->
