From e8413fb64508ff9c0a819df6f4891b699cb617f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Tue, 3 Oct 2017 19:21:17 +0200 Subject: [PATCH] Accept string inputs if no options are available The javascript code should be cleaned up at some point! --- senpy/static/js/main.js | 61 +++++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 23 deletions(-) diff --git a/senpy/static/js/main.js b/senpy/static/js/main.js index 330dc95..01c30ab 100644 --- a/senpy/static/js/main.js +++ b/senpy/static/js/main.js @@ -1,7 +1,7 @@ var ONYX = "http://www.gsi.dit.upm.es/ontologies/onyx/ns#"; var RDF_TYPE = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"; var plugins_params={}; -var default_params = JSON.parse($.ajax({type: "GET", url: "/api?help=True" , async: false}).responseText); +var default_params = JSON.parse($.ajax({type: "GET", url: "/api?help=true" , async: false}).responseText); function replaceURLWithHTMLLinks(text) { console.log('Text: ' + text); var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; @@ -105,29 +105,40 @@ function change_params(){ html="" for (param in default_params){ if ((default_params[param]['options']) && (['help','conversion'].indexOf(param) < 0)){ - html+= "" - html+= "
" - } + html+= "" + if (default_params[param]['options'].length < 1) { + html +=""; + } + else { + html+= "
" + } } for (param in plugins_params[plugin]){ if (param || plugins_params[plugin][param].length > 1){ - html+= "" - html+= "" + for (option in param_opts){ + html+="" + } + html+="" + } + else { + html +=""; + } } - html+="" } document.getElementById("params").innerHTML = html }; @@ -143,9 +154,13 @@ function load_JSON(){ url += "?algo="+plugin+"&i="+input for (param in plugins_params[plugin]){ if (param != null){ - var param_value = encodeURIComponent(document.getElementById(param).options[document.getElementById(param).selectedIndex].text); - if (param_value){ - url+="&"+param+"="+param_value + if (plugins_params[plugin].length > 0){ + var param_value = encodeURIComponent(document.getElementById(param).options[document.getElementById(param).selectedIndex].text); + } else { + var param_value = encodeURIComponent(document.getElementById(param).value); + } + if (param_value !== "undefined" && param_value.length > 0){ + url+="&"+param+"="+param_value } } }