026d434cc46cf08b08091b879738bca9101f7b4d
1 function format_instance(inst)
2 {
3 return ("<li class=\"instance\"><a href=\"" + location.pathname + "?action=graph;" + inst.params + "\">" + inst.description + "</a></li>");
4 }
6 function format_instance_list(instances)
7 {
8 var ret = "<ul class=\"instance_list\">";
9 var i;
11 if (instances.length == 0)
12 return ("");
14 for (i = 0; i < instances.length; i++)
15 ret += format_instance (instances[i]);
17 ret += "</ul>";
19 return (ret);
20 }
22 function format_graph(graph)
23 {
24 return ("<li class=\"graph\">" + graph.title + format_instance_list (graph.instances) + "</li>");
25 }
27 $(document).ready(function() {
28 $("#search-input").keyup (function()
29 {
30 var term = $("#search-input").val ();
31 $.getJSON ("collection.fcgi",
32 { "action": "search_json", "q": term},
33 function(data)
34 {
35 var i;
36 $("#search-output").html ("");
37 for (i = 0; i < data.length; i++)
38 {
39 var graph = data[i];
40 $("#search-output").append (format_graph (graph));
41 }
42 });
43 });
44 });
46 /* vim: set sw=2 sts=2 et fdm=marker : */