';
// console.log(foundone);
// if(foundone){
// document.getElementById("foundPathways").innerHTML += content;
// // Show the modal using native dialog API
// const modal = document.getElementById("foundMatching");
// if (modal && modal.showModal) {
// modal.showModal();
// }
// } else {
// document.getElementById("index-form").submit();
// }
// }
// FIXME: marked for removal
// class Setting {
// constructor(nameInputId, selectedPackagesId, relativeReasoningSelectId, cutoffInputId, evaluationTypeSelectId,
// availableTSSelectId, formsId, tableId, summaryTableId) {
// this.nameInputId = nameInputId;
// this.selectedPackagesId = selectedPackagesId;
// this.relativeReasoningSelectId = relativeReasoningSelectId;
// this.cutoffInputId = cutoffInputId;
// this.evaluationTypeSelectId = evaluationTypeSelectId;
// this.availableTSSelectId = availableTSSelectId;
// this.formsId = formsId;
// this.tableId = tableId;
// this.summaryTableId = summaryTableId;
// // General settings
// this.name = null;
// this.selectedPackages = [];
// // Relative Reasoning related
// this.selectedRelativeReasoning = null;
// this.cutoff = null;
// this.evaluationType = null;
// // parameters such as { "lowPH": 7, "highPH": 8 }
// this.tsParams = {};
// }
// FIXME: marked for removal
// extractName() {
// var tempName = $('#' + this.nameInputId).val()
// if (tempName == '') {
// console.log("Name was empty...");
// return;
// }
// this.name = tempName;
// }
// extractSelectedPackages() {
// var selPacks = $("#" + this.selectedPackagesId + " :selected");
// var ref = this;
// ref.selectedPackages = [];
// selPacks.each(function () {
// var obj = {}
// obj['id'] = this.value;
// obj['name'] = this.text;
// ref.selectedPackages.push(obj);
// });
// }
// extractRelativeReasoning() {
// var tempRR = $('#' + this.relativeReasoningSelectId + " :selected").val()
// if (tempRR == '') {
// console.log("RR was empty...");
// return;
// }
// var obj = {}
// obj['id'] = $('#' + this.relativeReasoningSelectId + " :selected").val()
// obj['name'] = $('#' + this.relativeReasoningSelectId + " :selected").text()
// this.selectedRelativeReasoning = obj;
// }
// extractCutoff() {
// var tempCutoff = $('#' + this.cutoffInputId).val()
// if (tempCutoff == '') {
// console.log("Cutoff was empty...");
// return;
// }
// this.cutoff = tempCutoff;
// }
// extractEvaluationType() {
// var tempEvaluationType = $('#' + this.evaluationTypeSelectId).val()
// if (tempEvaluationType == '') {
// console.log("EvaluationType was empty...");
// return;
// }
// this.evaluationType = tempEvaluationType;
// }
// addTruncator() {
// // triggered by "Add"
// // will extract values and afterwards updates table + summary
// var type = $("#" + this.availableTSSelectId + " :selected").val();
// var text = $("#" + this.availableTSSelectId + " :selected").text();
// var form = $("#" + type + "_form > :input")
// // flag to check whether at least one input had a valid value
// var addedValue = false;
// // reference being used in each
// var ref = this;
// form.each(function() {
// if(this.value == "" || this.value === "undefined"){
// console.log(this);
// console.log("Skipping " + this.name);
// } else {
// var obj = {}
// obj[this.name] = this.value;
// obj['text'] = text;
// ref.tsParams[type] = obj
// }
// });
// this.updateTable();
// this.updateSummaryTable();
// }
// removeTruncator(rowId) {
// var summary = rowId.startsWith("sum") ? true : false;
// // plain key
// var key = rowId.replace(summary ? "sum" : "trunc", "").replace("row", "");
// console.log("Removing " + key);
// // remove the rows
// $("#trunc"+ key + "row").remove();
// if($("#sum"+ key + "row").length > 0) {
// $("#sum"+ key + "row").remove();
// }
// delete this.tsParams[key];
// }
// updateTable() {
// // remove all children
// $('#'+this.tableId + "Body").empty()
// var innerHTML = "
" +
// "
Name
" +
// "
Value
" +
// "
Action
" +
// "
";
// for (var x in this.tsParams) {
// var val = "";
// for (var y in this.tsParams[x]){
// if (y == 'text') {
// continue;
// }
// val += this.tsParams[x][y]
// }
// innerHTML += "
" +
// "
" + this.tsParams[x]['text'] + "
" +
// "
" + val + "
" +
// "
"+
// "" +
// "
" +
// "
";
// }
// $('#'+this.tableId + "Body").append(innerHTML);
// }
// packageRows() {
// var res = '';
// for(var p in this.selectedPackages) {
// var obj = this.selectedPackages[p];
// res += "
";
// }
// updateSummaryTable() {
// // remove all children
// $('#'+this.summaryTableId + "Body").empty()
// var innerHTML = "
" +
// "
Name
" +
// "
Value
" +
// "
Action
" +
// "
";
// innerHTML += this.packageRows();
// innerHTML += this.modelRow();
// // var innerHTML = ''
// for (var x in this.tsParams) {
// var val = "";
// for (var y in this.tsParams[x]){
// if (y == 'text') {
// continue;
// }
// val += this.tsParams[x][y]
// }
// innerHTML += "
" +
// "
" + this.tsParams[x]['text'] + "
" +
// "
" + val + "
" +
// "
"+
// "" +
// "
" +
// "
";
// }
// $('#'+this.summaryTableId + "Body").append(innerHTML);
// }
// }
// TODO
function queryResultToTable(appendId, result) {
const container = document.getElementById(appendId);
container.innerHTML = '';
var table = '
' +
'' +
'
';
var header = '';
for (var r in result['result']) {
var keys = Object.keys(result['result'][r]);
for (var k in keys) {
header += '
' + keys[k] + '
';
}
break;
}
table += header;
table += '
';
table += '';
table += '';
var body = '';
for (var r in result['result']) {
body += '
';
for (var k in result['result'][r]) {
body += '
' + result['result'][r][k] + '
';
}
body += '
';
}
table += body;
table += '';
table += '
';
container.innerHTML = table;
}
function showLoadingSpinner(attachOb) {
// Benzene ring spinner - hexagon with rotating double bonds
const spinnerHtml = `
`;
// Handle both ID selectors and DOM elements
let element;
if (typeof attachOb === 'string') {
element = attachOb.startsWith('#')
? document.querySelector(attachOb)
: document.getElementById(attachOb);
} else {
element = attachOb;
}
if (element) {
element.innerHTML = spinnerHtml;
}
}
// Keep old function name for backwards compatibility
function makeLoadingGif(attachOb) {
showLoadingSpinner(attachOb);
}
// FIXME: marked for removal
// function cleanIdName(idName) {
// return idName.replace(/[ \-()]/g, "")
// }
// FIXME: marked for removal
// function makeAccordionHead(accordionId, accordionTitle, reviewStatus) {
// return "
';
// plotDiv.innerHTML += content;
// return
// }
// var chartPanel = '';
// plotDiv.innerHTML += chartPanel;
// // Labels
// var x = ['Recall'];
// var y = ['Precision'];
// var thres = ['threshold'];
// // Compare function for the given array
// function compare(a, b) {
// if (a.threshold < b.threshold)
// return -1;
// else if (a.threshold > b.threshold)
// return 1;
// else
// return 0;
// }
// // gets the index for a certain value
// function getIndexForValue(data, val, val_name) {
// for(var idx in data) {
// if(data[idx][val_name] == val) {
// return idx;
// }
// }
// return -1;
// }
// var data = result.prdata;
// var dataLength = Object.keys(data).length;
// data.sort(compare);
// // collect data in 3 individual arrays
// for (var idx in data) {
// var d = data[idx];
// x.push(d.recall);
// y.push(d.precision);
// thres.push(d.threshold);
// }
// // generate the actual chart with values collected above
// var chart = c3.generate({
// bindto: '#chart',
// data: {
// onclick: function (d, e) {
// var idx = d.index;
// var thresh = data[dataLength-idx-1].threshold;
// onclick(thresh)
// },
// x: 'Recall',
// y: 'Precision',
// columns: [
// x,
// y,
// //thres
// ]
// },
// size: {
// height: 400, // TODO: Make variable to current modal width
// width: 480
// },
// axis: {
// x: {
// max: 1,
// min: 0,
// label: 'Recall',
// padding: 0,
// tick: {
// fit: true,
// values: [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]
// }
// },
// y: {
// max: 1,
// min: 0,
// label: 'Precision',
// padding: 0,
// tick: {
// fit: true,
// values: [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]
// }
// }
// },
// point: {
// r: 4
// },
// tooltip: {
// format: {
// title: function (recall) {
// idx = getIndexForValue(data, recall, "recall");
// if(idx != -1) {
// return "Threshold: " + data[idx].threshold;
// }
// return "";
// },
// value: function (precision, ratio, id) {
// return undefined;
// }
// }
// },
// zoom: {
// enabled: true
// }
// });
// } catch (error) {
// console.error('Error loading PR curve:', error);
// const plotDiv = document.getElementById('plotDiv');
// plotDiv.innerHTML = '
Error loading PR curve data.
';
// }
// }
function handleAssessmentResponse(depict_url, data) {
var inside_app_domain = "
This compound is " + (data["assessment"]["inside_app_domain"] ? "inside" : "outside") + " the Applicability Domain derived from the chemical (PCA) space constructed using the training data.
`
var transformations = '';
for (t in data['assessment']['transformations']) {
transObj = data['assessment']['transformations'][t];
var neighbors = '';
for (n in transObj['neighbors']) {
neighObj = transObj['neighbors'][n];
var neighImg = "";
var pwLinksHtml = '';
if (neighObj['related_pathways'] && Object.keys(neighObj['related_pathways']).length > 0) {
pwLinksHtml = '
';
for (pw in neighObj['related_pathways']) {
var pwObj = neighObj['related_pathways'][pw];
pwLinksHtml += `
Local Compatibility: ${transObj['local_compatibility'].toFixed(2)} (${(transObj['local_compatibility'] > data['ad_params']['local_compatibility_threshold'] ? ">" : "<")} Local Compatibility Threshold of ${data['ad_params']['local_compatibility_threshold']})