

export default function parseTable(table) {
    let outputElement = document.getElementById('output');
    outputElement.innerHTML = "";
    let divWrapper = document.createElement('div');
    divWrapper.classList.add("w3-responsive");
    let t = document.createElement('table');
    t.classList.add("w3-table-all");
    for (let entry of table) {
        let tr = document.createElement('tr');
        for (let element of entry) {
            let td = document.createElement('td');
            element = element.toString();
            
            if (element.substring(0,4) != 'http') {
                td.innerText = element;
            } else {
                let a = document.createElement("a");

                a.setAttribute("href", element);
                a.style.textDecoration = "underline";
                a.innerHTML = 'Link';
                td.appendChild(a);
            }


            tr.appendChild(td);
        }
        t.appendChild(tr)
    }
    divWrapper.appendChild(t)
    outputElement.appendChild(divWrapper);
}