[Groonga-commit] groonga/groonga [master] admin: support completion

Back to archive index

null+****@clear***** null+****@clear*****
2012年 4月 6日 (金) 14:49:57 JST


Kouhei Sutou	2012-04-06 14:49:57 +0900 (Fri, 06 Apr 2012)

  New Revision: 2858e39ff8f8e1aba4d65d97603583eeaded8293

  Log:
    admin: support completion

  Modified files:
    data/html/admin/js/groonga-admin.js

  Modified: data/html/admin/js/groonga-admin.js (+36 -0)
===================================================================
--- data/html/admin/js/groonga-admin.js    2012-04-06 14:48:29 +0900 (d2d6a4e)
+++ data/html/admin/js/groonga-admin.js    2012-04-06 14:49:57 +0900 (3bca1ab)
@@ -270,6 +270,42 @@ jQuery.extend(GroongaAdmin.prototype, {
       show: function(e, ui) {
       }
     });
+    this._$suggestQuery = $("#suggest-query").autocomplete({
+      source: function (request, response) {
+	var dataset = $("#suggest-dataset").val();
+	$.ajax({
+	  url: "/d/suggest",
+	  data: {
+	    query: request.term,
+	    types: "complete",
+	    table: "item_" + dataset,
+	    column: "kana",
+	    limit: 25,
+	  },
+	  dataType: "jsonp",
+	  success: function (data, status) {
+	    var completions = data[1]["complete"];
+	    var items = [];
+	    console.dir(data[1]);
+	    if (completions && completions.length > 2) {
+	      completions.shift();
+	      completions.shift();
+	      $.each(completions, function(i, item) {
+		var key = item[0];
+		items.push(key);
+		if (items.length >= 3) {
+		  return false;
+		}
+		return true;
+	      });
+	    }
+	    response(items);
+	  },
+	  error: function(XMLHttpRequest, textStatus, errorThrown) {
+	  }
+	})
+      }
+    });
   },
   _selectTab: function(name) {
     this.stop_status_timer();




Groonga-commit メーリングリストの案内
Back to archive index