From 8c5f894843609918bad9cc3cd7495cd739f3eb18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Tue, 18 Jul 2017 18:25:00 +0200 Subject: [PATCH] Fixed turtle outformat in playground --- senpy/static/js/main.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/senpy/static/js/main.js b/senpy/static/js/main.js index e676504..330dc95 100644 --- a/senpy/static/js/main.js +++ b/senpy/static/js/main.js @@ -159,15 +159,22 @@ function load_JSON(){ } } - var response = JSON.parse($.ajax({type: "GET", url: url , async: false}).responseText); + var response = $.ajax({type: "GET", url: url , async: false}).responseText; + rawcontainer.innerHTML = replaceURLWithHTMLLinks(response) + + document.getElementById("input_request").innerHTML = ""+url+"" + document.getElementById("results-div").style.display = 'block'; + try { + response = JSON.parse(response); var options = { mode: 'view' }; var editor = new JSONEditor(container, options, response); editor.expandAll(); - rawcontainer.innerHTML = replaceURLWithHTMLLinks(JSON.stringify(response, undefined, 2)) - document.getElementById("input_request").innerHTML = ""+url+"" - document.getElementById("results-div").style.display = 'block'; + } + catch(err){ + console.log("Error decoding JSON (got turtle?)"); + } }