From 953972009ece17b7858efef5562f0cdf51532290 Mon Sep 17 00:00:00 2001 From: Sakshi Dhamija Date: Tue, 18 May 2021 20:40:02 +0530 Subject: [PATCH] Alerts user when loading custom ontology fails! (#180) closes #137 * Alerts user when loading ontology fails! * Indented and changed alert message. * Simplified code by adding return statement. * Removed extra parenthesis and added space! * Added code to remove details section while loading custom. --- js/tree-edam-stand-alone.js | 2 ++ js/tree-reusable-d3.js | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/js/tree-edam-stand-alone.js b/js/tree-edam-stand-alone.js index 2be63b80..80e5bddb 100644 --- a/js/tree-edam-stand-alone.js +++ b/js/tree-edam-stand-alone.js @@ -109,6 +109,8 @@ function interactive_edam_browser(){ reader.readAsText(file); reader.onload = function(event) { json = JSON.parse(event.target.result); + if(json == null) + return; if(typeof json.meta=="undefined"){ json.meta={"version":"v n/a"}; } diff --git a/js/tree-reusable-d3.js b/js/tree-reusable-d3.js index d1e2b18f..5fb9199f 100644 --- a/js/tree-reusable-d3.js +++ b/js/tree-reusable-d3.js @@ -811,13 +811,16 @@ function interactive_tree() { identifierToElement={}; data_url = value; d3.json(value, function(json) { + if(json==null) { + alert('Unable to read content of "' + data_url + '"'); + }else{ if(typeof json.meta=="undefined"){ json.meta={"version":"v n/a", "date":"n/a"}; } json.meta.data_url=data_url; chart.data(json); } - ); + }); return chart; }; /**