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,7 +31,18 @@ $(document).ready(function() {
html=""; html="";
var availablePlugins = document.getElementById('availablePlugins'); var availablePlugins = document.getElementById('availablePlugins');
plugins = response.plugins; plugins = response.plugins;
gplugins = {};
for (r in plugins){ for (r in plugins){
ptype = plugins[r]['@type'];
if(gplugins[ptype] == undefined){
gplugins[ptype] = [r]
}else{
gplugins[ptype].push(r)
}
}
for (g in gplugins){
html += "<optgroup label=\""+g+"\">"
for (r in gplugins[g]){
plugin = plugins[r] plugin = plugins[r]
if (plugin["name"]){ if (plugin["name"]){
if (plugin["name"] == defaultPlugin["name"]){ if (plugin["name"] == defaultPlugin["name"]){
@ -50,6 +61,7 @@ $(document).ready(function() {
} }
} }
} }
if (plugin["extra_params"]){ if (plugin["extra_params"]){
plugins_params[plugin["name"]]={}; plugins_params[plugin["name"]]={};
for (param in plugin["extra_params"]){ for (param in plugin["extra_params"]){
@ -76,6 +88,8 @@ $(document).ready(function() {
pluginList.innerHTML = newHtml; pluginList.innerHTML = newHtml;
availablePlugins.appendChild(pluginList) availablePlugins.appendChild(pluginList)
} }
html += "</optgroup>"
}
document.getElementById('plugins').innerHTML = html; document.getElementById('plugins').innerHTML = html;
change_params(); change_params();