document.addEventListener('DOMContentLoaded', async function () {
    console.log(`Here there be dragons!! and ${package_object.package_uuid}`);
    let doc_md = document.getElementById("md_document");
    console.log(doc_md)
    var doc_tables = doc_md.getElementsByTagName('table');
    for (var i = 0; i < doc_tables.length; i++){
        doc_tables[i].setAttribute("class", "uk-table uk-table-striped uk-table-small");
    };
})



async function savePackage() {
    var package_name = document.getElementById("packageName").value;
    var package_description = document.getElementById("packageDescription").value;
    var package_type = document.getElementById('packageType').value;

    const response = await fetch(`/p/${package_object.package_uuid}/save`, {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json'
        },
        body: JSON.stringify({
            key: package_object.package_uuid,
            update: {
                package_name: package_name,
                package_description: package_description,
                package_type: package_type
            }
        })
    });

    data = await response.json();
    if (data.error){
        UIkit.notification({
            message: data.message,
            status: "danger",
            pos: 'bottom-right',
            timeout: 5000
        });
    } else if (!data.error) {
        window.location.href = `/p/${package_object.package_uuid}`;
    }
};