summaryrefslogtreecommitdiff
path: root/helper.rb
diff options
context:
space:
mode:
authormr <mr@mrautenberg.de>2011-09-23 10:34:34 +0200
committermr <mr@mrautenberg.de>2011-09-23 10:34:34 +0200
commitfad3229cca5d31670f1c1d99542f3d563e226d99 (patch)
tree79549e5f252358f1a7f5aa260912c7d53becbe1e /helper.rb
parent038c4563032f65f935f38ef6bffe426b2dd14c0c (diff)
endpoint selection for create model form
Diffstat (limited to 'helper.rb')
-rw-r--r--helper.rb33
1 files changed, 30 insertions, 3 deletions
diff --git a/helper.rb b/helper.rb
index 9b47142..234d612 100644
--- a/helper.rb
+++ b/helper.rb
@@ -108,12 +108,39 @@ helpers do
File.unlink(tmpfile)
end
end
- result = OpenTox::Ontology::Echa.endpoint_option_list()
+ result = endpoint_selection()
if result.lines.count > 3
f = File.new(tmpfile,"w")
f.print result
f.close
end
- return result
+ result
end
-end
+
+ def endpoint_level(endpoint="Endpoints", level=1)
+ results = OpenTox::Ontology::Echa.echa_endpoints(endpoint) rescue results = []
+ out = ""
+ out += "<ul id='list_#{endpoint}' class='endpoint level_#{level}'>\n" if results.size > 0
+ results.each do |result|
+ r = result.split(',')
+ endpointname = CGI.escape(r.first.split("#").last).gsub(".","")
+ title = r[1..r.size-1].to_s
+ out += " <li class='level_#{level}'><input type='radio' name='endpoint' value='#{result}' id='#{endpointname}' class='endpoint_list' /><label for='#{endpointname}' id='label_#{endpointname}'>#{title.gsub("\"","")}</label>\n"
+ out += endpoint_level(endpointname, level + 1)
+ out += "</li>\n"
+ end
+ out += "</ul>\n" if results.size > 0
+ return out
+ end
+
+ def endpoint_selection()
+ out = "<span id='endpoint_label'></span><input type='button' id='endpoint_list_button' value='select endpoint' /> \n
+ <div id='div_endpoint'>\n"
+ out += "<b>Please select:</b>\n"
+ out += endpoint_level
+ js = ""
+ out += "</div>\n"
+ return out
+ end
+
+end \ No newline at end of file