"use strict"; const formOptions = document.querySelector("#options-form-compare"); let compareBtn = document.querySelector('#compare-btn'); let metricsDashboardContainer = document.querySelector("#metrics-dashboard-container"); let vtContainer = document.querySelector("#main-vt-container"); const inputExactMatch = document.querySelector("#exact-match"); const inputInsert = document.querySelector("#insertion"); const inputDelSubts = document.querySelector("#delSubts"); function showHideSpinner() { let spinnerLoad = document.querySelector("#spinner-compare"); const currentState = () => { spinnerLoad.style['display'] = "none"; document.querySelector('#message-compare-btn').textContent = " Compare"; compareBtn.removeAttribute('disabled'); } const loadState = () => { spinnerLoad.style['display'] = ""; document.querySelector('#message-compare-btn').textContent = " Release the Kraken...! 🐙"; compareBtn.setAttribute('disabled', "true"); } return (spinnerLoad.style['display'] === "none") ? loadState() : currentState() } function getTextAreaValue() { return [document.querySelector('#reference').value, document.querySelector('#prediction').value]; } function serializeFormData(reference, prediction) { let inputs = formOptions.getElementsByTagName('input'); let data = { reference: reference, prediction: prediction, preprocessingOpts: "", vtOpt:0 }; Object.values(inputs).forEach(input =>{ input.checked ? input.name !== "optVT" ? data.preprocessingOpts += input.value : data.vtOpt = 1 : input; }); return data } function tabulate(columns, scores){ let table = d3.select('#table-result-container').append('table').attr('class', 'dataframe data table table-hover table-bordered'); let thead = table.append('thead'); let tbody = table.append('tbody'); // append the header row thead.append('tr').selectAll('th').data(columns).enter().append('th').text(function (column) { return column; }); let rows = tbody.selectAll('tr').data(scores).enter().append('tr'); // create a cell in each row for each column rows.selectAll('td').data(function (row, i) { return row; }).enter().append('td').html(function (d) { if ((typeof d === "string") && (d !== "Ø")) { d = "" + d + ""; } return d; }); } function populateVersusText(reference, comparaison, prediction){ [{reference:reference}, {comparaison: comparaison}, {prediction: prediction}].forEach(version => { document.querySelector(`#vt-${Object.keys(version)[0]}`).innerHTML = Object.values(version)[0].join(''); }); } function versusTextSelector(){ [inputExactMatch, inputInsert, inputDelSubts].forEach(btn => { btn.addEventListener('click', function (event) { document.querySelectorAll("."+event.target.id).forEach(item => { (event.target.checked) ? item.classList.remove('clear') : item.classList.add('clear'); }); }) }) } function fileJSLoader (file, id){ // remove the old script in header if exists try{ document.querySelector("#"+id).remove(); }catch (e) {} // create a