X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=share%2Fcollection.js;h=d3fb11c6244cf6789d9120e66cb77b9e9d63e8de;hb=d23e04f683e1b8e1aefb9d659cf30eec4881f66b;hp=026d434cc46cf08b08091b879738bca9101f7b4d;hpb=30478870f2afaf991ee19ab7b4c22d3ddcd7b8cd;p=collection4.git diff --git a/share/collection.js b/share/collection.js index 026d434..d3fb11c 100644 --- a/share/collection.js +++ b/share/collection.js @@ -1,6 +1,8 @@ function format_instance(inst) { - return ("
  • " + inst.description + "
  • "); + return ("
  • " + inst.description + + "
  • "); } function format_instance_list(instances) @@ -24,23 +26,77 @@ function format_graph(graph) return ("
  • " + graph.title + format_instance_list (graph.instances) + "
  • "); } +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 (""); */ + $("#search-form").append (""); + $("#search-suggest").hide (); + + $("#search-input").blur (function() + { + window.setTimeout (function () + { + $("#search-suggest").hide (); + }, 500); + }); + + $("#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 (); + }); + + $(".graph-img").append ("
    " + + "
    H
    " + + "
    D
    " + + "
    W
    " + + "
    M
    " + + "
    Y
    " + + "
    !
    " + + "
    " + + "
    " + + "
    ←
    " + + "
    −
    " + + "
    +
    " + + "
    →
    " + + "
    " + ); }); /* vim: set sw=2 sts=2 et fdm=marker : */