| |
| |
| |
| |
| |
| |
| document.addEventListener("DOMContentLoaded", function () { |
| var $table = $("#moabb-macro-table"); |
| if (!$table.length) return; |
|
|
| |
| var columns = [ |
| |
| { name: "Dataset", visible: true, type: "string" }, |
| { name: "Paradigm", visible: true, type: "string", pane: true }, |
| { name: "#Subj", visible: true, type: "num" }, |
| { name: "#Chan", visible: true, type: "num" }, |
| { name: "#EEG", visible: true, type: "num" }, |
| { name: "#Classes", visible: true, type: "num" }, |
| { name: "Freq", visible: true, type: "num" }, |
| { name: "Trial", visible: true, type: "num" }, |
| { name: "#Sess", visible: true, type: "num" }, |
| { name: "#Runs", visible: true, type: "num" }, |
| { name: "Health", visible: true, type: "string", pane: true }, |
| { name: "#Trials", visible: true, type: "string" }, |
| { name: "Country", visible: true, type: "string", pane: true }, |
| { name: "Year", visible: true, type: "num" }, |
| { name: "DOI", visible: true, type: "string" }, |
| |
| { name: "Class Labels", visible: false, type: "string" }, |
| { name: "Stimulus", visible: false, type: "string", pane: true }, |
| { name: "Modality", visible: false, type: "string", pane: true }, |
| { name: "Feedback", visible: false, type: "string", pane: true }, |
| { name: "Sync", visible: false, type: "string", pane: true }, |
| { name: "Mode", visible: false, type: "string", pane: true }, |
| { name: "Study Design", visible: false, type: "string" }, |
| { name: "Hardware", visible: false, type: "string", pane: true }, |
| { name: "Reference", visible: false, type: "string" }, |
| { name: "Sensor Type", visible: false, type: "string", pane: true }, |
| { name: "Montage", visible: false, type: "string" }, |
| { name: "Line Freq", visible: false, type: "num" }, |
| { name: "Filters", visible: false, type: "string" }, |
| { name: "Cap Mfr", visible: false, type: "string" }, |
| { name: "Software", visible: false, type: "string" }, |
| { name: "Clinical Pop.", visible: false, type: "string" }, |
| { name: "Age Mean", visible: false, type: "num" }, |
| { name: "Age Min", visible: false, type: "num" }, |
| { name: "Age Max", visible: false, type: "num" }, |
| { name: "Gender", visible: false, type: "string" }, |
| { name: "Handedness", visible: false, type: "string" }, |
| { name: "BCI Exp.", visible: false, type: "string", pane: true }, |
| { name: "License", visible: false, type: "string", pane: true }, |
| { name: "Institution", visible: false, type: "string" }, |
| { name: "Repository", visible: false, type: "string", pane: true }, |
| { name: "Duration (h)", visible: false, type: "num" }, |
| { name: "Author", visible: false, type: "string" }, |
| { name: "Data URL", visible: false, type: "string" }, |
| { name: "Pathology Tags",visible: false, type: "string", pane: true }, |
| { name: "Modality Tags", visible: false, type: "string", pane: true }, |
| { name: "Type Tags", visible: false, type: "string", pane: true }, |
| { name: "File Format", visible: false, type: "string", pane: true }, |
| { name: "EOG", visible: false, type: "string" }, |
| { name: "EMG", visible: false, type: "string" }, |
| { name: "#Blocks", visible: false, type: "num" }, |
| { name: "Trials Context",visible: false, type: "string" }, |
| { name: "Stim. Freqs", visible: false, type: "string" }, |
| { name: "Code Type", visible: false, type: "string", pane: true }, |
| { name: "#Targets", visible: false, type: "num" }, |
| { name: "#Repetitions", visible: false, type: "num" }, |
| { name: "ISI (ms)", visible: false, type: "num" }, |
| { name: "SOA (ms)", visible: false, type: "num" }, |
| { name: "MI Tasks", visible: false, type: "string" }, |
| ]; |
|
|
| var COL_PARADIGM = 1; |
| var COL_SUBJ = 2; |
| var COL_HEALTH = 10; |
| var COL_COUNTRY = 12; |
|
|
| |
| var hiddenCols = []; |
| var numericCols = []; |
| var paneCols = []; |
|
|
| columns.forEach(function (col, i) { |
| if (!col.visible) hiddenCols.push(i); |
| if (col.type === "num") numericCols.push(i); |
| if (col.pane) paneCols.push(i); |
| }); |
|
|
| |
| var htmlCols = [COL_PARADIGM, COL_HEALTH]; |
|
|
| function stripHtml(html) { |
| var tmp = document.createElement("div"); |
| tmp.innerHTML = html; |
| return (tmp.textContent || tmp.innerText || "").trim(); |
| } |
|
|
| var columnDefs = [ |
| { targets: hiddenCols, visible: false }, |
| { targets: numericCols, type: "num" }, |
| { |
| targets: htmlCols, |
| render: function (data, type) { |
| if (type === "display") return data; |
| return stripHtml(data); |
| }, |
| }, |
| { targets: "_all", searchPanes: { show: false } }, |
| { targets: paneCols, searchPanes: { show: true } }, |
| ]; |
|
|
| var table = $table.DataTable({ |
| dom: "Blfrtip", |
| paging: false, |
| ordering: true, |
| orderMulti: true, |
| order: [[0, "asc"]], |
| fixedHeader: true, |
| columnDefs: columnDefs, |
| buttons: [ |
| { |
| extend: "searchPanes", |
| text: "Filter", |
| config: { |
| cascadePanes: true, |
| viewTotal: true, |
| layout: "columns-4", |
| orderable: false, |
| columns: paneCols, |
| }, |
| }, |
| { |
| extend: "colvis", |
| text: "Columns", |
| columns: ":gt(0)", |
| }, |
| { |
| extend: "csv", |
| text: "CSV", |
| exportOptions: { orthogonal: "export" }, |
| }, |
| { |
| extend: "print", |
| text: "Print", |
| exportOptions: { orthogonal: "export" }, |
| }, |
| ], |
| language: { |
| searchPanes: { |
| title: { _: "%d Filters Active", 0: "" }, |
| }, |
| }, |
| }); |
|
|
| |
|
|
| document.querySelectorAll(".mt-bar-seg").forEach(function (seg) { |
| seg.style.cursor = "pointer"; |
| seg.addEventListener("click", function () { |
| var title = seg.getAttribute("title") || ""; |
| |
| var label = title.split(":")[0].trim(); |
| if (label) { |
| table.column(COL_PARADIGM).search(label).draw(); |
| } |
| }); |
| }); |
|
|
| document.querySelectorAll(".mt-bar-legend-item").forEach(function (item) { |
| item.style.cursor = "pointer"; |
| item.addEventListener("click", function () { |
| var text = item.textContent.trim(); |
| |
| var label = text.replace(/\s*\(\d+\)$/, "").trim(); |
| if (label) { |
| table.column(COL_PARADIGM).search(label).draw(); |
| } |
| }); |
| }); |
|
|
| |
|
|
| $table.on("click", ".mt-tag[data-paradigm]", function () { |
| var paradigm = stripHtml(this.innerHTML); |
| table.column(COL_PARADIGM).search(paradigm).draw(); |
| }); |
|
|
| |
| $table.find(".mt-tag[data-paradigm]").css("cursor", "pointer"); |
|
|
| |
|
|
| function updateSummaryCards() { |
| var filteredData = table.rows({ search: "applied" }).data(); |
| var totalDatasets = filteredData.length; |
| var totalSubjects = 0; |
| var paradigms = {}; |
| var countries = {}; |
|
|
| filteredData.each(function (row) { |
| totalSubjects += parseFloat(row[COL_SUBJ]) || 0; |
|
|
| var p = stripHtml(row[COL_PARADIGM]); |
| if (p) paradigms[p] = (paradigms[p] || 0) + 1; |
|
|
| var c = (row[COL_COUNTRY] || "").trim(); |
| if (c) countries[c] = true; |
| }); |
|
|
| |
| var cards = document.querySelectorAll("#mt-cards .mt-card"); |
| if (cards.length >= 4) { |
| cards[0].querySelector(".mt-card-value").textContent = totalDatasets; |
| cards[1].querySelector(".mt-card-value").textContent = |
| totalSubjects.toLocaleString(); |
| cards[2].querySelector(".mt-card-value").textContent = |
| Object.keys(paradigms).length; |
| cards[3].querySelector(".mt-card-value").textContent = |
| Object.keys(countries).length; |
| } |
|
|
| |
| var barSegs = document.querySelectorAll(".mt-bar-seg"); |
| var legendItems = document.querySelectorAll(".mt-bar-legend-item"); |
| if (barSegs.length > 0) { |
| barSegs.forEach(function (seg) { |
| var title = seg.getAttribute("title") || ""; |
| var label = title.split(":")[0].trim(); |
| var count = paradigms[label] || 0; |
| var pct = totalDatasets > 0 ? (count / totalDatasets) * 100 : 0; |
| seg.style.width = pct.toFixed(1) + "%"; |
| seg.setAttribute( |
| "title", |
| label + ": " + count + " datasets (" + Math.round(pct) + "%)" |
| ); |
| }); |
| } |
| legendItems.forEach(function (item) { |
| var text = item.textContent.trim(); |
| var label = text.replace(/\s*\(\d+\)$/, "").trim(); |
| var count = paradigms[label] || 0; |
| |
| var dot = item.querySelector(".mt-bar-dot"); |
| if (dot) { |
| item.textContent = ""; |
| item.appendChild(dot); |
| item.appendChild(document.createTextNode(" " + label + " (" + count + ")")); |
| } |
| }); |
| } |
|
|
| table.on("search.dt", updateSummaryCards); |
|
|
| |
|
|
| document.querySelectorAll(".mt-bar-seg, .mt-bar-legend-item").forEach(function (el) { |
| el.addEventListener("dblclick", function () { |
| table.column(COL_PARADIGM).search("").draw(); |
| }); |
| }); |
| }); |
|
|