// -*- js2-basic-offset: 2; indent-tabs-mode: nil -*- "use strict"; function prim2html(prim, limit) { switch(typeof prim) { case 'undefined': return 'undefined'; case 'boolean': return prim ? 'true' : 'false'; case 'number': return String(prim); case 'string': if (prim.length > limit) { prim = prim.substring(0, limit) + '...'; } return escapeHTML(prim); case 'array': case 'object': if (prim == null) { return 'null'; } else if ($.isArray(prim)) { return 'array'; /* TODO: implement */ } else { return 'object'; /* TODO: implement */ } default: return 'ERROR'; } } function escapeHTML(str) { return str.replace(/&/g, "&") .replace(/"/g, """) .replace(//g, ">"); } var Groonga = { key_type_list: ['Int8', 'UInt8', 'Int16', 'UInt16', 'Int32', 'UInt32', 'Int64', 'UInt64', 'Float', 'Time', 'ShortText', 'TokyoGeoPoint', 'WGS84GeoPoint'], value_type_list: ['Object', 'Bool', 'Int8', 'UInt8', 'Int16', 'UInt16', 'Int32', 'UInt32', 'Int64', 'UInt64', 'Float', 'Time'], column_type_list: ['Object', 'Bool', 'Int8', 'UInt8', 'Int16', 'UInt16', 'Int32', 'UInt32', 'Int64', 'UInt64', 'Float', 'Time', 'ShortText', 'Text', 'LongText', 'TokyoGeoPoint', 'WGS84GeoPoint'], tokenizer_list: ['TokenDelimit', 'TokenUnigram', 'TokenBigram', 'TokenTrigram', 'TokenMecab'], GRN_OBJ_PERSISTENT: (0x01<<15), GRN_OBJ_TABLE_TYPE_MASK: (0x07), GRN_OBJ_TABLE_HASH_KEY: (0x00), GRN_OBJ_TABLE_PAT_KEY: (0x01), GRN_OBJ_TABLE_NO_KEY: (0x03), GRN_OBJ_KEY_WITH_SIS: (0x01<<6), GRN_OBJ_KEY_NORMALIZE: (0x01<<7), GRN_OBJ_COLUMN_TYPE_MASK: (0x07), GRN_OBJ_COLUMN_SCALAR: (0x00), GRN_OBJ_COLUMN_VECTOR: (0x01), GRN_OBJ_COLUMN_INDEX: (0x02), GRN_OBJ_COMPRESS_MASK: (0x07<<4), GRN_OBJ_COMPRESS_NONE: (0x00<<4), GRN_OBJ_COMPRESS_ZLIB: (0x01<<4), GRN_OBJ_COMPRESS_LZO: (0x02<<4), GRN_OBJ_WITH_SECTION: (0x01<<7), GRN_OBJ_WITH_WEIGHT: (0x01<<8), GRN_OBJ_WITH_POSITION: (0x01<<9) }; $.widget("ui.paginate", { version: "1.0", options: { total: 0, nItemsPerPage: 10, currentPage: 0, nShowLinks: 10, callback: null }, _create: function() { var that = this; var element = this.element; element.addClass("pager"); var total = this.options.total; var nItemsPerPage = this.options.nItemsPerPage; var currentPage = this.options.currentPage; var nShowLinks = this.options.nShowLinks; var lastPage = Math.floor((total - 1) / nItemsPerPage) + 1; var start = currentPage - Math.floor(nShowLinks / 2); start = (start < 1) ? 1 : start; var end = start + nShowLinks - 1; end = (end > lastPage) ? lastPage : end; var callback = this.options.callback; if (start > 1) { element.append($('') .addClass('pager') .append($('') .attr('href', '#') .text('1') .click(function () {callback(0)}))); element.append($('').text('....')); } for (var i = start; i <= end; i++) { var page = $('').append($('') .attr('href', '#') .text(String(i)) .click(function () { callback(Number($(this).text()) - 1); })); if (i == currentPage) { page.addClass('pager-current'); } else { page.addClass('pager'); } element.append(page); } if (end < lastPage) { element.append($('') .text('....')); element.append($('') .addClass('pager') .append($('') .attr('href', '#') .text(String(lastPage)) .click(function () {callback(lastPage - 1);}))); } } }); function GroongaAdmin() { this.current_table = null; this.statusTimer = null; this.semaphore = new Array(); this.current_status = 0; this.reload_record_func = function(){}; var that = this; this._initializeTabs(); $('#tab-tablelist-link').click(function() { that.tablelist(); }); $('#tab-columnlist-link').click(function() { that.columnlist(that.current_table); }); $('#tab-createrecord-link').click(function() { that.update_createrecord(that.current_table); }); $('#tab-recordlist-link').click(function() { that.reload_record_func(); }); $('#createtable-add-table').click(function() { that.createtable(); }); $('#createrecord-add-record').click(function() { that.createrecord(); }); $('#createcolumn-add-column').click(function() { that.createcolumn(); }); $('#recordlist-remove-record').click(function() { that.removerecord(); }); $('#columnlist-remove-column').click(function() { that.removecolumn(); }); $('#tablelist-remove-table').click(function() { that.removetable(); }); $('#tab-recordlist-form').submit(function() { if ($('#table-tab-recordlist-full-checkbox').attr('checked')) { // full var d = { 'table': that.current_table } $.each(that.SELECT_PARAMS, function(i, val) { var e = $('#tab-recordlist-' + val); if (e.val()) { d[val] = e.val(); } }); that.recordlist(d, true); } else { // simple that.recordlist_simple( that.current_table, $('#tab-recordlist-simplequery').val(), $('#tab-recordlist-simplequerytype').val(), 1); } return false; }); this._initializeSideMenu(); this.update_tablelist(); var e1 = $('#createtable-key-type-builtin'); $.each(Groonga.key_type_list, function(i, val) { e1.append($('