mirror of
https://github.com/gsi-upm/senpy
synced 2024-11-22 08:12:27 +00:00
Accept string inputs if no options are available
The javascript code should be cleaned up at some point!
This commit is contained in:
parent
390225df45
commit
e8413fb645
@ -1,7 +1,7 @@
|
|||||||
var ONYX = "http://www.gsi.dit.upm.es/ontologies/onyx/ns#";
|
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 RDF_TYPE = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
|
||||||
var plugins_params={};
|
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) {
|
function replaceURLWithHTMLLinks(text) {
|
||||||
console.log('Text: ' + text);
|
console.log('Text: ' + text);
|
||||||
var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
|
var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
|
||||||
@ -106,6 +106,10 @@ function change_params(){
|
|||||||
for (param in default_params){
|
for (param in default_params){
|
||||||
if ((default_params[param]['options']) && (['help','conversion'].indexOf(param) < 0)){
|
if ((default_params[param]['options']) && (['help','conversion'].indexOf(param) < 0)){
|
||||||
html+= "<label> "+param+"</label>"
|
html+= "<label> "+param+"</label>"
|
||||||
|
if (default_params[param]['options'].length < 1) {
|
||||||
|
html +="<input></input>";
|
||||||
|
}
|
||||||
|
else {
|
||||||
html+= "<select id=\""+param+"\" name=\""+param+"\">"
|
html+= "<select id=\""+param+"\" name=\""+param+"\">"
|
||||||
for (option in default_params[param]['options']){
|
for (option in default_params[param]['options']){
|
||||||
if (default_params[param]['options'][option] == default_params[param]['default']){
|
if (default_params[param]['options'][option] == default_params[param]['default']){
|
||||||
@ -116,19 +120,26 @@ function change_params(){
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
html+="</select><br>"
|
html+="</select><br>"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (param in plugins_params[plugin]){
|
for (param in plugins_params[plugin]){
|
||||||
if (param || plugins_params[plugin][param].length > 1){
|
if (param || plugins_params[plugin][param].length > 1){
|
||||||
html+= "<label> Parameter "+param+"</label>"
|
html+= "<label> Parameter "+param+"</label>"
|
||||||
|
param_opts = plugins_params[plugin][param]
|
||||||
|
if (param_opts.length > 0) {
|
||||||
html+= "<select id=\""+param+"\" name=\""+param+"\">"
|
html+= "<select id=\""+param+"\" name=\""+param+"\">"
|
||||||
for (option in plugins_params[plugin][param]){
|
for (option in param_opts){
|
||||||
html+="<option value \""+plugins_params[plugin][param][option]+"\">"+plugins_params[plugin][param][option]+"</option>"
|
html+="<option value \""+param_opts[option]+"\">"+param_opts[option]+"</option>"
|
||||||
}
|
|
||||||
}
|
}
|
||||||
html+="</select>"
|
html+="</select>"
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
html +="<input id=\""+param+"\" name=\""+param+"\"></input>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
document.getElementById("params").innerHTML = html
|
document.getElementById("params").innerHTML = html
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -143,8 +154,12 @@ function load_JSON(){
|
|||||||
url += "?algo="+plugin+"&i="+input
|
url += "?algo="+plugin+"&i="+input
|
||||||
for (param in plugins_params[plugin]){
|
for (param in plugins_params[plugin]){
|
||||||
if (param != null){
|
if (param != null){
|
||||||
|
if (plugins_params[plugin].length > 0){
|
||||||
var param_value = encodeURIComponent(document.getElementById(param).options[document.getElementById(param).selectedIndex].text);
|
var param_value = encodeURIComponent(document.getElementById(param).options[document.getElementById(param).selectedIndex].text);
|
||||||
if (param_value){
|
} else {
|
||||||
|
var param_value = encodeURIComponent(document.getElementById(param).value);
|
||||||
|
}
|
||||||
|
if (param_value !== "undefined" && param_value.length > 0){
|
||||||
url+="&"+param+"="+param_value
|
url+="&"+param+"="+param_value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user