/* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ var current_core = null; var cookie_name = 'schema-browser_autoload'; var luke_array_to_struct = function( array ) { var struct = { keys : [], values : [] }; for( var i = 0; i < array.length; i += 2 ) { struct.keys.push( array[i] ); struct.values.push( array[i+1] ); } return struct; } var luke_array_to_hash = function( array ) { var hash = {}; for( var i = 0; i < array.length; i += 2 ) { hash[ array[i] ] = array[i+1]; } return hash; } var load_terminfo = function( trigger_element, core_basepath, field, data_element, terminfo_element ) { var luke_url = core_basepath + '/admin/luke?wt=json&fl=' + field; var topterms_count_element = $( '.topterms-holder .head input', terminfo_element ); var term_load_count = parseInt( topterms_count_element.val(), 10 ); if( term_load_count ) { luke_url += '&numTerms=' + term_load_count; } $.ajax ( { url : luke_url, dataType : 'json', context : terminfo_element, beforeSend : function( xhr, settings ) { trigger_element .addClass( 'loader' ); }, success : function( response, text_status, xhr ) { trigger_element .removeClass( 'loader' ); var field_data = response.fields[field]; if( !field_data || !( field_data.topTerms && field_data.histogram ) ) { terminfo_element .addClass( 'disabled' ); return false; } var topterms_holder_element = $( '.topterms-holder', data_element ); var histogram_holder_element = $( '.histogram-holder', data_element ); if( !field_data.topTerms ) { topterms_holder_element .hide(); } else { topterms_holder_element .show(); var topterms_table_element = $( 'ul', topterms_holder_element ); var topterms = field_data.topTerms; var topterms_count = topterms.length; var topterms_content = ''; var topterms_frq_last = null; for( var i = 0; i < topterms_count; i += 2 ) { if( topterms_frq_last !== topterms[i+1] ) { if( topterms_frq_last ) { topterms_content += '' + "\n"; } topterms_frq_last = topterms[i+1]; topterms_content += '
  • ' + '

    ' + topterms_frq_last.esc() + '

    ' + "\n" + '