1
0
mirror of https://github.com/gsi-upm/senpy synced 2024-11-25 01:22:28 +00:00

Grouped plugins by plugin Type with and optgroup. This ought to close #42

This commit is contained in:
militarpancho 2017-07-17 14:28:31 +02:00
parent 7fd16a17fb
commit ad2051307a

View File

@ -31,51 +31,65 @@ $(document).ready(function() {
html=""; html="";
var availablePlugins = document.getElementById('availablePlugins'); var availablePlugins = document.getElementById('availablePlugins');
plugins = response.plugins; plugins = response.plugins;
for (r in plugins){ gplugins = {};
plugin = plugins[r] for (r in plugins){
if (plugin["name"]){ ptype = plugins[r]['@type'];
if (plugin["name"] == defaultPlugin["name"]){ if(gplugins[ptype] == undefined){
if (plugin["is_activated"]){ gplugins[ptype] = [r]
html+= "<option value=\""+plugin["name"]+"\" selected=\"selected\">"+plugin["name"]+"</option>" }else{
}else{ gplugins[ptype].push(r)
html+= "<option value=\""+plugin["name"]+"\" selected=\"selected\" disabled=\"disabled\">"+plugin["name"]+"</option>" }
} }
} for (g in gplugins){
else{ html += "<optgroup label=\""+g+"\">"
if (plugin["is_activated"]){ for (r in gplugins[g]){
html+= "<option value=\""+plugin["name"]+"\">"+plugin["name"]+"</option>" plugin = plugins[r]
} if (plugin["name"]){
else{ if (plugin["name"] == defaultPlugin["name"]){
html+= "<option value=\""+plugin["name"]+"\" disabled=\"disabled\">"+plugin["name"]+"</option>" if (plugin["is_activated"]){
} html+= "<option value=\""+plugin["name"]+"\" selected=\"selected\">"+plugin["name"]+"</option>"
} }else{
} html+= "<option value=\""+plugin["name"]+"\" selected=\"selected\" disabled=\"disabled\">"+plugin["name"]+"</option>"
if (plugin["extra_params"]){ }
plugins_params[plugin["name"]]={}; }
for (param in plugin["extra_params"]){ else{
if (typeof plugin["extra_params"][param] !="string"){ if (plugin["is_activated"]){
var params = new Array(); html+= "<option value=\""+plugin["name"]+"\">"+plugin["name"]+"</option>"
var alias = plugin["extra_params"][param]["aliases"][0]; }
params[alias]=new Array(); else{
for (option in plugin["extra_params"][param]["options"]){ html+= "<option value=\""+plugin["name"]+"\" disabled=\"disabled\">"+plugin["name"]+"</option>"
params[alias].push(plugin["extra_params"][param]["options"][option]) }
} }
plugins_params[plugin["name"]][alias] = (params[alias]) }
}
}
}
var pluginList = document.createElement('li');
newHtml = "" if (plugin["extra_params"]){
if(plugin.url) { plugins_params[plugin["name"]]={};
newHtml= "<a href="+plugin.url+">" + plugin.name + "</a>"; for (param in plugin["extra_params"]){
}else { if (typeof plugin["extra_params"][param] !="string"){
newHtml= plugin["name"]; var params = new Array();
} var alias = plugin["extra_params"][param]["aliases"][0];
newHtml += ": " + replaceURLWithHTMLLinks(plugin.description); params[alias]=new Array();
pluginList.innerHTML = newHtml; for (option in plugin["extra_params"][param]["options"]){
availablePlugins.appendChild(pluginList) params[alias].push(plugin["extra_params"][param]["options"][option])
} }
plugins_params[plugin["name"]][alias] = (params[alias])
}
}
}
var pluginList = document.createElement('li');
newHtml = ""
if(plugin.url) {
newHtml= "<a href="+plugin.url+">" + plugin.name + "</a>";
}else {
newHtml= plugin["name"];
}
newHtml += ": " + replaceURLWithHTMLLinks(plugin.description);
pluginList.innerHTML = newHtml;
availablePlugins.appendChild(pluginList)
}
html += "</optgroup>"
}
document.getElementById('plugins').innerHTML = html; document.getElementById('plugins').innerHTML = html;
change_params(); change_params();