[314dda]: / static / js / dynamicHtml.js

Download this file

114 lines (95 with data), 4.4 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/**************************************************************************************
* Project : Chest X-Ray Pathology Detection and Localization using Deep Learning
* Author Name : Rammuni Ravidu Suien Silva
* UoW No : 16267097
* IIT No : 2016134
* Module : Final Year Project 20/21
* Supervisor : Mr Pumudu Fernando
* Prototype : Web Interface - FrontEnd
* File : JS for creation of dynamic HTML UI elements
* University of Westminster, UK || IIT Sri Lanka
**************************************************************************************/
// consts for DOM objects
const detResults = $('#result');
let localized = false;
let symptoms_json;
// Displaying the dynamic detection table
function cxrResultsDisplayTable(dataJSON) {
let tableHTML = '<div class="limiter">';
tableHTML += '<div class="container-table100">';
tableHTML += '<div class="wrap-table100" style="margin: 20px auto auto;">';
tableHTML += '<div class="table">';
tableHTML += '<div class="row header">' +
'<div class="cell text-dark">Pathology</div>' +
'<div class="cell text-dark">Detection Rate</div>' +
'</div>';
let pathology_id = 0
// Dynamic table creation
Object.keys(dataJSON).forEach(function (key) {
let pathology = key;
$(cxrLocalizationPopup(pathology_id, pathology)).appendTo('#main-app-body');
$(cxrLocalizationPrint(pathology_id, pathology)).appendTo('.loc-result-print');
let detectionRate = dataJSON[pathology];
let cxr_popup_id = "#cxrPopup-" + pathology_id;
// Highlighting high probable diseases
if (parseFloat(detectionRate.split("%")[0]) >= 50) {
tableHTML += '<div class="row bg-warning det-row" data-toggle="modal" data-target="' + cxr_popup_id + '">';
} else {
tableHTML += '<div class="row det-row" data-toggle="modal" data-target="' + cxr_popup_id + '">';
}
tableHTML += '<div class="cell" data-title="Pathology">';
tableHTML += pathology;
tableHTML += '</div>';
tableHTML += '<div class="cell text-dark" data-title="Detection Rate (Max - Min)">';
tableHTML += detectionRate;
tableHTML += '</div>';
tableHTML += '</div>';
pathology_id += 1;
});
tableHTML += '</div>';
tableHTML += '</div>';
tableHTML += '</div>';
tableHTML += '</div>';
return tableHTML;
}
// Dynamic popup card builder for localized image display
function cxrLocalizationPopup(pathology_id, pathology) {
let popupCXRHTML =
'<div class="modal fade" id="cxrPopup-' + pathology_id + '" role="dialog">\n' +
' <div class="modal-dialog">\n' +
cxrLocalizationPrint(pathology_id, pathology) +
' </div>\n' +
' </div>';
return popupCXRHTML
}
// Print section UI creation
function cxrLocalizationPrint(pathology_id, pathology) {
let locCXRPrint =
'<div class="card print-cxr-card">\n' +
' <div class="card-img"><img id="cxrPopupImg-' + pathology_id +
'" class="img-fluid cxr-loc-img cxrPopupImg-' + pathology_id + '" ' +
' alt="Run/Click Localization to view the Localized CXR" ' +
' style="display: block; margin-left: auto; margin-right: auto;"></div>\n' +
' <div class="card-text">\n' +
' <p>Localization Result for:</p>\n' +
' <p><b>' + pathology + '</b></p>\n' +
' </div>\n' + symptomsAdd(pathology, symptoms_json) +
'</div>\n';
return locCXRPrint
}
// Displaying possible symptoms from the Symptoms.JSON from the server
function symptomsAdd(pathology, symptoms_json) {
let symptoms = symptoms_json[pathology]['Symptoms']
let listHTML = ' ' +
'<span class="list-group-item list-group-item-action flex-column align-items-start">\n' +
' <div class="d-flex w-100 justify-content-between">\n' +
' <h5 class="mb-1">Possible Symptoms</h5>\n' +
' <small class="text-muted">Confirm the findings</small>\n' +
' </div>';
for (let i = 0; i < symptoms.length; i++) {
listHTML += '<p class="mb-1">' + symptoms[i] + '</p>\n';
}
listHTML += '<small class="text-muted">These are indicative symptoms only!</small>\n' +
'</span>'
return listHTML;
}