function format_instance(inst)
{
- return ("<li class=\"instance\"><a href=\"" + location.pathname + "?action=graph;" + inst.params + "\">" + inst.description + "</a></li>");
+ return ("<li class=\"instance\"><a href=\"" + location.pathname
+ + "?action=show_graph;" + inst.params + "\">" + inst.description
+ + "</a></li>");
}
function format_instance_list(instances)
return ("<li class=\"graph\">" + graph.title + format_instance_list (graph.instances) + "</li>");
}
+function update_search_suggestions ()
+{
+ var term = $("#search-input").val ();
+ if (term.length < 2)
+ {
+ $("#search-suggest").hide ();
+ return (true);
+ }
+
+ $("#search-suggest").show ();
+ $.getJSON ("collection.fcgi",
+ { "action": "search_json", "q": term},
+ function(data)
+ {
+ var i;
+ $("#search-suggest").html ("");
+ for (i = 0; i < data.length; i++)
+ {
+ var graph = data[i];
+ $("#search-suggest").append (format_graph (graph));
+ }
+ }
+ );
+} /* update_search_suggestions */
+
$(document).ready(function() {
- $("#search-input").keyup (function()
+ /* $("#layout-middle-right").html ("<ul id=\"search-suggest\" class=\"graph_list\"></ul>"); */
+ $("#search-form").append ("<ul id=\"search-suggest\" class=\"graph_list\"></ul>");
+ $("#search-suggest").hide ();
+
+ $("#search-input").blur (function()
+ {
+ $("#search-suggest").hide ();
+ });
+
+ $("#search-input").focus (function()
{
var term = $("#search-input").val ();
- $.getJSON ("collection.fcgi",
- { "action": "search_json", "q": term},
- function(data)
- {
- var i;
- $("#search-output").html ("");
- for (i = 0; i < data.length; i++)
- {
- var graph = data[i];
- $("#search-output").append (format_graph (graph));
- }
- });
+ if (term.length < 2)
+ {
+ $("#search-suggest").hide ();
+ }
+ else
+ {
+ $("#search-suggest").show ();
+ }
+ });
+
+ $("#search-input").keyup (function()
+ {
+ update_search_suggestions ();
});
});
vertical-align: top;
}
-ul.graph_list
+#search-form
+{
+ position: relative;
+}
+
+#search-suggest
+{
+ position: absolute;
+}
+
+#search-output ul.graph_list
{
margin: 0;
padding: 1ex;
}
-li.graph
+#search-output li.graph
{
display: block;
border: 1px solid gray;
background-color: rgb(245,245,255);
}
-ul.instance_list
+#search-output ul.instance_list
{
margin: 0;
padding: 1ex;
background-color: rgb(252,252,252);
}
-li.instance
+#search-output li.instance
{
display: block;