You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by er...@apache.org on 2012/03/07 17:30:22 UTC
svn commit: r1298010 [3/8] - in /lucene/dev/trunk/solr:
core/src/java/org/apache/solr/handler/
core/src/java/org/apache/solr/servlet/ webapp/web/ webapp/web/css/
webapp/web/css/styles/ webapp/web/js/ webapp/web/js/lib/
webapp/web/js/scripts/ webapp/web...
Modified: lucene/dev/trunk/solr/webapp/web/js/scripts/analysis.js
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/webapp/web/js/scripts/analysis.js?rev=1298010&r1=1298009&r2=1298010&view=diff
==============================================================================
--- lucene/dev/trunk/solr/webapp/web/js/scripts/analysis.js (original)
+++ lucene/dev/trunk/solr/webapp/web/js/scripts/analysis.js Wed Mar 7 16:30:20 2012
@@ -1,420 +1,441 @@
+/*
+ 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.
+*/
+
// #/:core/analysis
sammy.get
(
- /^#\/([\w\d-]+)\/(analysis)$/,
- function( context )
- {
- var core_basepath = this.active_core.attr( 'data-basepath' );
- var content_element = $( '#content' );
+ /^#\/([\w\d-]+)\/(analysis)$/,
+ function( context )
+ {
+ var core_basepath = this.active_core.attr( 'data-basepath' );
+ var content_element = $( '#content' );
- $.get
- (
- 'tpl/analysis.html',
- function( template )
- {
- content_element
- .html( template );
+ $.get
+ (
+ 'tpl/analysis.html',
+ function( template )
+ {
+ content_element
+ .html( template );
- var analysis_element = $( '#analysis', content_element );
- var analysis_form = $( 'form', analysis_element );
- var analysis_result = $( '#analysis-result', analysis_element );
- analysis_result.hide();
+ var analysis_element = $( '#analysis', content_element );
+ var analysis_form = $( 'form', analysis_element );
+ var analysis_result = $( '#analysis-result', analysis_element );
+ analysis_result.hide();
- $.ajax
- (
- {
- url : core_basepath + '/admin/luke?wt=json&show=schema',
- dataType : 'json',
- context : $( '#type_or_name', analysis_form ),
- beforeSend : function( xhr, settings )
- {
- this
- .html( '<option value="">Loading ... </option>' )
- .addClass( 'loader' );
- },
- success : function( response, text_status, xhr )
- {
- var content = '';
+ $.ajax
+ (
+ {
+ url : core_basepath + '/admin/luke?wt=json&show=schema',
+ dataType : 'json',
+ context : $( '#type_or_name', analysis_form ),
+ beforeSend : function( xhr, settings )
+ {
+ this
+ .html( '<option value="">Loading ... </option>' )
+ .addClass( 'loader' );
+ },
+ success : function( response, text_status, xhr )
+ {
+ var content = '';
- var fields = [];
- for( var field_name in response.schema.fields )
- {
- fields.push
- (
- '<option value="fieldname=' + field_name + '">' + field_name + '</option>'
- );
- }
- if( 0 !== fields.length )
- {
- content += '<optgroup label="Fields">' + "\n";
- content += fields.sort().join( "\n" ) + "\n";
- content += '</optgroup>' + "\n";
- }
+ var fields = [];
+ for( var field_name in response.schema.fields )
+ {
+ fields.push
+ (
+ '<option value="fieldname=' + field_name + '">' + field_name + '</option>'
+ );
+ }
+ if( 0 !== fields.length )
+ {
+ content += '<optgroup label="Fields">' + "\n";
+ content += fields.sort().join( "\n" ) + "\n";
+ content += '</optgroup>' + "\n";
+ }
- var types = [];
- for( var type_name in response.schema.types )
- {
- types.push
- (
- '<option value="fieldtype=' + type_name + '">' + type_name + '</option>'
- );
- }
- if( 0 !== types.length )
- {
- content += '<optgroup label="Types">' + "\n";
- content += types.sort().join( "\n" ) + "\n";
- content += '</optgroup>' + "\n";
- }
+ var types = [];
+ for( var type_name in response.schema.types )
+ {
+ types.push
+ (
+ '<option value="fieldtype=' + type_name + '">' + type_name + '</option>'
+ );
+ }
+ if( 0 !== types.length )
+ {
+ content += '<optgroup label="Types">' + "\n";
+ content += types.sort().join( "\n" ) + "\n";
+ content += '</optgroup>' + "\n";
+ }
- this
- .html( content );
+ this
+ .html( content );
- $( 'option[value="fieldname\=' + response.schema.defaultSearchField + '"]', this )
- .attr( 'selected', 'selected' );
- },
- error : function( xhr, text_status, error_thrown)
- {
- },
- complete : function( xhr, text_status )
- {
- this
- .removeClass( 'loader' );
- }
- }
- );
+ $( 'option[value="fieldname\=' + response.schema.defaultSearchField + '"]', this )
+ .attr( 'selected', 'selected' );
+ },
+ error : function( xhr, text_status, error_thrown)
+ {
+ },
+ complete : function( xhr, text_status )
+ {
+ this
+ .removeClass( 'loader' );
+ }
+ }
+ );
- $( '.analysis-error .head a', analysis_element )
- .die( 'click' )
- .live
- (
- 'click',
- function( event )
- {
- $( this ).parents( '.analysis-error' )
- .toggleClass( 'expanded' );
- }
- );
+ $( '.analysis-error .head a', analysis_element )
+ .die( 'click' )
+ .live
+ (
+ 'click',
+ function( event )
+ {
+ $( this ).parents( '.analysis-error' )
+ .toggleClass( 'expanded' );
+ }
+ );
- $( '.verbose_output a', analysis_element )
- .die( 'click' )
- .live
- (
- 'click',
- function( event )
- {
- $( this ).parent()
- .toggleClass( 'active' );
+ $( '.verbose_output a', analysis_element )
+ .die( 'click' )
+ .live
+ (
+ 'click',
+ function( event )
+ {
+ $( this ).parent()
+ .toggleClass( 'active' );
- analysis_result
- .toggleClass( 'verbose_output' );
+ analysis_result
+ .toggleClass( 'verbose_output' );
- check_empty_spacer();
- }
- );
+ check_empty_spacer();
+ }
+ );
- var check_empty_spacer = function()
- {
- var spacer_holder = $( 'td.part.data.spacer .holder', analysis_result );
+ var check_empty_spacer = function()
+ {
+ var spacer_holder = $( 'td.part.data.spacer .holder', analysis_result );
+
+ if( 0 === spacer_holder.size() )
+ {
+ return false;
+ }
+
+ var verbose_output = analysis_result.hasClass( 'verbose_output' );
+
+ spacer_holder
+ .each
+ (
+ function( index, element )
+ {
+ element = $( element );
- if( 0 === spacer_holder.size() )
- {
- return false;
- }
-
- var verbose_output = analysis_result.hasClass( 'verbose_output' );
-
- spacer_holder
- .each
- (
- function( index, element )
- {
- element = $( element );
-
- if( verbose_output )
- {
- var cell = element.parent();
- element.height( cell.height() );
- }
- else
- {
- element.removeAttr( 'style' );
- }
- }
- );
+ if( verbose_output )
+ {
+ var cell = element.parent();
+ element.height( cell.height() );
+ }
+ else
+ {
+ element.removeAttr( 'style' );
}
+ }
+ );
+ }
- var button = $( 'button', analysis_form )
+ var button = $( 'button', analysis_form )
- analysis_form
- .ajaxForm
- (
- {
- url : core_basepath + '/analysis/field?wt=json',
- dataType : 'json',
- beforeSubmit : function( array, form, options )
- {
- loader.show( button );
- button.attr( 'disabled', true );
+ analysis_form
+ .ajaxForm
+ (
+ {
+ url : core_basepath + '/analysis/field?wt=json',
+ dataType : 'json',
+ beforeSubmit : function( array, form, options )
+ {
+ loader.show( button );
+ button.attr( 'disabled', true );
- array.push( { name: 'analysis.showmatch', value: 'true' } );
+ array.push( { name: 'analysis.showmatch', value: 'true' } );
- var type_or_name = $( '#type_or_name', form ).val().split( '=' );
+ var type_or_name = $( '#type_or_name', form ).val().split( '=' );
- array.push( { name: 'analysis.' + type_or_name[0], value: type_or_name[1] } );
- },
- success : function( response, status_text, xhr, form )
- {
- $( '.analysis-error', analysis_element )
- .hide();
+ array.push( { name: 'analysis.' + type_or_name[0], value: type_or_name[1] } );
+ },
+ success : function( response, status_text, xhr, form )
+ {
+ $( '.analysis-error', analysis_element )
+ .hide();
- analysis_result
- .empty()
- .show();
+ analysis_result
+ .empty()
+ .show();
- for( var name in response.analysis.field_names )
- {
- build_analysis_table( 'name', name, response.analysis.field_names[name] );
- }
+ for( var name in response.analysis.field_names )
+ {
+ build_analysis_table( 'name', name, response.analysis.field_names[name] );
+ }
- for( var name in response.analysis.field_types )
- {
- build_analysis_table( 'type', name, response.analysis.field_types[name] );
- }
-
- check_empty_spacer();
- },
- error : function( xhr, text_status, error_thrown )
- {
- analysis_result
- .empty()
- .hide();
-
- if( 404 === xhr.status )
- {
- $( '#analysis-handler-missing', analysis_element )
- .show();
- }
- else
- {
- var error_message = error_thrown.match( /^(.+Exception):\s+(.*)$/ );
-
- $( '#analysis-error', analysis_element )
- .show();
-
- $( '#analysis-error .head a span', analysis_element )
- .text( error_message[1] );
-
- $( '#analysis-error .body', analysis_element )
- .text( error_message[2].replace( /(\s+at\s+)/g, " at\n" ) );
- }
- },
- complete : function()
- {
- loader.hide( $( 'button', analysis_form ) );
- button.removeAttr( 'disabled' );
- }
- }
- );
+ for( var name in response.analysis.field_types )
+ {
+ build_analysis_table( 'type', name, response.analysis.field_types[name] );
+ }
- var generate_class_name = function( type )
- {
- var classes = [type];
- if( 'text' !== type )
- {
- classes.push( 'verbose_output' );
- }
- return classes.join( ' ' );
- }
+ check_empty_spacer();
+ },
+ error : function( xhr, text_status, error_thrown )
+ {
+ analysis_result
+ .empty()
+ .hide();
+
+ if( 404 === xhr.status )
+ {
+ $( '#analysis-handler-missing', analysis_element )
+ .show();
+ }
+ else
+ {
+ var error_message = error_thrown.match( /^(.+Exception):\s+(.*)$/ );
+
+ $( '#analysis-error', analysis_element )
+ .show();
+
+ if( error_message )
+ {
+ $( '#analysis-error .head a span', analysis_element )
+ .text( error_message[1] );
+
+ $( '#analysis-error .body', analysis_element )
+ .text( error_message[2].replace( /(\s+at\s+)/g, " at\n" ) );
+ }
+ else
+ {
+ $( '#analysis-error .head a span', analysis_element )
+ .text( error_thrown );
+ }
+ }
+ },
+ complete : function()
+ {
+ loader.hide( $( 'button', analysis_form ) );
+ button.removeAttr( 'disabled' );
+ }
+ }
+ );
+
+ var generate_class_name = function( type )
+ {
+ var classes = [type];
+ if( 'text' !== type )
+ {
+ classes.push( 'verbose_output' );
+ }
+ return classes.join( ' ' );
+ }
- var build_analysis_table = function( field_or_name, name, analysis_data )
- {
- for( var type in analysis_data )
- {
- var type_length = analysis_data[type].length;
- if( 0 !== type_length )
- {
- var global_elements_count = 0;
- for( var i = 0; i < analysis_data[type].length; i += 2 )
- {
- if( 'string' === typeof analysis_data[type][i+1] )
- {
- analysis_data[type][i+1] = [{ 'text': analysis_data[type][i+1] }]
- }
- global_elements_count = Math.max( global_elements_count,
- analysis_data[type][i+1].length );
- }
+ var build_analysis_table = function( field_or_name, name, analysis_data )
+ {
+ for( var type in analysis_data )
+ {
+ var type_length = analysis_data[type].length;
+ if( 0 !== type_length )
+ {
+ var global_elements_count = 0;
+ for( var i = 0; i < analysis_data[type].length; i += 2 )
+ {
+ if( 'string' === typeof analysis_data[type][i+1] )
+ {
+ analysis_data[type][i+1] = [{ 'text': analysis_data[type][i+1] }]
+ }
+ global_elements_count = Math.max( global_elements_count, analysis_data[type][i+1].length );
+ }
- var content = '<div class="' + type + '">' + "\n";
- content += '<table border="0" cellspacing="0" cellpadding="0">' + "\n";
+ var content = '<div class="' + type + '">' + "\n";
+ content += '<table border="0" cellspacing="0" cellpadding="0">' + "\n";
- for( var i = 0; i < analysis_data[type].length; i += 2 )
- {
- var colspan = 1;
- var elements = analysis_data[type][i+1];
- var elements_count = global_elements_count;
+ for( var i = 0; i < analysis_data[type].length; i += 2 )
+ {
+ var colspan = 1;
+ var elements = analysis_data[type][i+1];
+ var elements_count = global_elements_count;
- if( !elements[0].positionHistory )
- {
- colspan = elements_count;
- elements_count = 1;
- }
-
- var legend = [];
- for( var key in elements[0] )
- {
- var key_parts = key.split( '#' );
- var used_key = key_parts.pop();
- var short_key = used_key;
-
- if( 1 === key_parts.length )
- {
- used_key = '<abbr title="' + key + '">' + used_key + '</abbr>';
- }
-
- if( 'positionHistory' === short_key || 'match' === short_key )
- {
- continue;
- }
-
- legend.push
- (
- '<tr class="' + generate_class_name( short_key ) + '">' +
- '<td>' + used_key + '</td>' +
- '</tr>'
- );
- }
+ if( !elements[0].positionHistory )
+ {
+ colspan = elements_count;
+ elements_count = 1;
+ }
+
+ var legend = [];
+ for( var key in elements[0] )
+ {
+ var key_parts = key.split( '#' );
+ var used_key = key_parts.pop();
+ var short_key = used_key;
- content += '<tbody>' + "\n";
- content += '<tr class="step">' + "\n";
+ if( 1 === key_parts.length )
+ {
+ used_key = '<abbr title="' + key + '">' + used_key + '</abbr>';
+ }
+
+ if( 'positionHistory' === short_key || 'match' === short_key )
+ {
+ continue;
+ }
- // analyzer
- var analyzer_name = analysis_data[type][i]
+ legend.push
+ (
+ '<tr class="' + generate_class_name( short_key ) + '">' +
+ '<td>' + used_key + '</td>' +
+ '</tr>'
+ );
+ }
+
+ content += '<tbody>' + "\n";
+ content += '<tr class="step">' + "\n";
+
+ // analyzer
+ var analyzer_name = analysis_data[type][i]
.replace( /(\$1)+$/g, '' );
- var analyzer_short = -1 !== analyzer_name.indexOf( '$' )
- ? analyzer_name.split( '$' )[1]
- : analyzer_name.split( '.' ).pop();
- analyzer_short = analyzer_short.match( /[A-Z]/g ).join( '' );
-
- content += '<td class="part analyzer"><div>' + "\n";
- content += '<abbr title="' + analysis_data[type][i] + '">' + "\n";
- content += analyzer_short + '</abbr></div></td>' + "\n";
-
- // legend
- content += '<td class="part legend"><div class="holder">' + "\n";
- content += '<table border="0" cellspacing="0" cellpadding="0">' + "\n";
- content += '<tr><td>' + "\n";
- content += '<table border="0" cellspacing="0" cellpadding="0">' + "\n";
- content += legend.join( "\n" ) + "\n";
- content += '</table></td></tr></table></td>' + "\n";
-
- // data
- var cell_content = '<td class="part data spacer" '
- + ' colspan="' + colspan + '">'
- + '<div class="holder"> </div>'
- + '</td>';
- var cells = new Array( elements_count + 1 ).join( cell_content );
- content += cells + "\n";
-
- content += '</tr>' + "\n";
- content += '</tbody>' + "\n";
- }
- content += '</table>' + "\n";
- content += '</div>' + "\n";
+ var analyzer_short = -1 !== analyzer_name.indexOf( '$' )
+ ? analyzer_name.split( '$' )[1]
+ : analyzer_name.split( '.' ).pop();
+ analyzer_short = analyzer_short.match( /[A-Z]/g ).join( '' );
+
+ content += '<td class="part analyzer"><div>' + "\n";
+ content += '<abbr title="' + analysis_data[type][i] + '">' + "\n";
+ content += analyzer_short + '</abbr></div></td>' + "\n";
+
+ // legend
+ content += '<td class="part legend"><div class="holder">' + "\n";
+ content += '<table border="0" cellspacing="0" cellpadding="0">' + "\n";
+ content += '<tr><td>' + "\n";
+ content += '<table border="0" cellspacing="0" cellpadding="0">' + "\n";
+ content += legend.join( "\n" ) + "\n";
+ content += '</table></td></tr></table></td>' + "\n";
+
+ // data
+ var cell_content = '<td class="part data spacer" colspan="' + colspan + '"><div class="holder"> </div></td>';
+ var cells = new Array( elements_count + 1 ).join( cell_content );
+ content += cells + "\n";
+
+ content += '</tr>' + "\n";
+ content += '</tbody>' + "\n";
+ }
+ content += '</table>' + "\n";
+ content += '</div>' + "\n";
- $( '.' + type, analysis_result )
- .remove();
+ $( '.' + type, analysis_result )
+ .remove();
- analysis_result
- .append( content );
+ analysis_result
+ .append( content );
- var analysis_result_type = $( '.' + type, analysis_result );
+ var analysis_result_type = $( '.' + type, analysis_result );
- for( var i = 0; i < analysis_data[type].length; i += 2 )
- {
- for( var j = 0; j < analysis_data[type][i+1].length; j += 1 )
- {
- var pos = analysis_data[type][i+1][j].positionHistory
- ? analysis_data[type][i+1][j].positionHistory[0]
- : 1;
- var selector = 'tr.step:eq(' + ( i / 2 ) +') '
- + 'td.data:eq(' + ( pos - 1 ) + ') '
- + '.holder';
- var cell = $( selector, analysis_result_type );
-
- cell.parent()
- .removeClass( 'spacer' );
-
- var table = $( 'table tr.details', cell );
- if( 0 === table.size() )
- {
- cell
- .html
- (
- '<table border="0" cellspacing="0" cellpadding="0">' +
- '<tr class="details"></tr></table>'
- );
- var table = $( 'table tr.details', cell );
- }
-
- var tokens = [];
- for( var key in analysis_data[type][i+1][j] )
- {
- var short_key = key.split( '#' ).pop();
+ for( var i = 0; i < analysis_data[type].length; i += 2 )
+ {
+ for( var j = 0; j < analysis_data[type][i+1].length; j += 1 )
+ {
+ var pos = analysis_data[type][i+1][j].positionHistory
+ ? analysis_data[type][i+1][j].positionHistory[0]
+ : 1;
+ var selector = 'tr.step:eq(' + ( i / 2 ) +') '
+ + 'td.data:eq(' + ( pos - 1 ) + ') '
+ + '.holder';
+ var cell = $( selector, analysis_result_type );
+
+ cell.parent()
+ .removeClass( 'spacer' );
+
+ var table = $( 'table tr.details', cell );
+ if( 0 === table.size() )
+ {
+ cell
+ .html
+ (
+ '<table border="0" cellspacing="0" cellpadding="0">' +
+ '<tr class="details"></tr></table>'
+ );
+ var table = $( 'table tr.details', cell );
+ }
+
+ var tokens = [];
+ for( var key in analysis_data[type][i+1][j] )
+ {
+ var short_key = key.split( '#' ).pop();
- if( 'positionHistory' === short_key || 'match' === short_key )
- {
- continue;
- }
-
- var classes = [];
- classes.push( generate_class_name( short_key ) );
-
- var data = analysis_data[type][i+1][j][key];
- if( 'object' === typeof data && data instanceof Array )
- {
- data = data.join( ' ' );
- }
- if( 'string' === typeof data )
- {
- data = data.esc();
- }
-
- if( null === data || 0 === data.length )
- {
- classes.push( 'empty' );
- data = '∅';
- }
-
- if( analysis_data[type][i+1][j].match &&
- ( 'text' === short_key || 'raw_bytes' === short_key ) )
- {
- classes.push( 'match' );
- }
-
- tokens.push
- (
- '<tr class="' + classes.join( ' ' ) + '">' +
- '<td>' + data + '</td>' +
- '</tr>'
- );
- }
- table
- .append
- (
- '<td class="details">' +
- '<table border="0" cellspacing="0" cellpadding="0">' +
- tokens.join( "\n" ) +
- '</table></td>'
- );
- }
- }
-
- }
- }
+ if( 'positionHistory' === short_key || 'match' === short_key )
+ {
+ continue;
+ }
+
+ var classes = [];
+ classes.push( generate_class_name( short_key ) );
+
+ var data = analysis_data[type][i+1][j][key];
+ if( 'object' === typeof data && data instanceof Array )
+ {
+ data = data.join( ' ' );
+ }
+ if( 'string' === typeof data )
+ {
+ data = data.esc();
+ }
+
+ if( null === data || 0 === data.length )
+ {
+ classes.push( 'empty' );
+ data = '∅';
+ }
+
+ if( analysis_data[type][i+1][j].match &&
+ ( 'text' === short_key || 'raw_bytes' === short_key ) )
+ {
+ classes.push( 'match' );
+ }
+
+ tokens.push
+ (
+ '<tr class="' + classes.join( ' ' ) + '">' +
+ '<td>' + data + '</td>' +
+ '</tr>'
+ );
}
-
+ table
+ .append
+ (
+ '<td class="details">' +
+ '<table border="0" cellspacing="0" cellpadding="0">' +
+ tokens.join( "\n" ) +
+ '</table></td>'
+ );
+ }
+ }
+
+ }
}
- );
- }
+ }
+
+ }
+ );
+ }
);
Modified: lucene/dev/trunk/solr/webapp/web/js/scripts/app.js
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/webapp/web/js/scripts/app.js?rev=1298010&r1=1298009&r2=1298010&view=diff
==============================================================================
--- lucene/dev/trunk/solr/webapp/web/js/scripts/app.js (original)
+++ lucene/dev/trunk/solr/webapp/web/js/scripts/app.js Wed Mar 7 16:30:20 2012
@@ -1,263 +1,308 @@
+/*
+ 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 loader = {
- show : function( element )
- {
- $( element )
- .addClass( 'loader' );
- },
+ show : function( element )
+ {
+ $( element )
+ .addClass( 'loader' );
+ },
- hide : function( element )
- {
- $( element )
- .removeClass( 'loader' );
- }
+ hide : function( element )
+ {
+ $( element )
+ .removeClass( 'loader' );
+ }
};
Number.prototype.esc = function()
{
- return new String( this ).esc();
+ return new String( this ).esc();
}
String.prototype.esc = function()
{
- return this.replace( /</g, '<' ).replace( />/g, '>' );
+ return this.replace( /</g, '<' ).replace( />/g, '>' );
+}
+
+SolrDate = function( date )
+{
+ // ["Sat Mar 03 11:00:00 CET 2012", "Sat", "Mar", "03", "11:00:00", "CET", "2012"]
+ var parts = date.match( /^(\w+)\s+(\w+)\s+(\d+)\s+(\d+\:\d+\:\d+)\s+(\w+)\s+(\d+)$/ );
+
+ // "Sat Mar 03 2012 10:37:33"
+ return new Date( parts[1] + ' ' + parts[2] + ' ' + parts[3] + ' ' + parts[6] + ' ' + parts[4] );
}
var sammy = $.sammy
(
- function()
- {
- this.bind
- (
- 'run',
- function( event, config )
- {
- if( 0 === config.start_url.length )
- {
- location.href = '#/';
- return false;
- }
- }
- );
+ function()
+ {
+ this.bind
+ (
+ 'run',
+ function( event, config )
+ {
+ if( 0 === config.start_url.length )
+ {
+ location.href = '#/';
+ return false;
+ }
+ }
+ );
- // activate_core
- this.before
- (
- {},
- function( context )
- {
- $( 'li[id].active', app.menu_element )
- .removeClass( 'active' );
+ // activate_core
+ this.before
+ (
+ {},
+ function( context )
+ {
+ $( 'li[id].active', app.menu_element )
+ .removeClass( 'active' );
- $( 'ul li.active', app.menu_element )
- .removeClass( 'active' );
+ $( 'ul li.active', app.menu_element )
+ .removeClass( 'active' );
- if( this.params.splat )
- {
- var active_element = $( '#' + this.params.splat[0], app.menu_element );
+ if( this.params.splat )
+ {
+ var active_element = $( '#' + this.params.splat[0], app.menu_element );
- if( 0 === active_element.size() )
- {
- var first_core = $( 'li[data-basepath]', app.menu_element ).attr( 'id' );
- var first_core_url = context.path.replace( new RegExp( '/' + this.params.splat[0] + '/' ), '/' + first_core + '/' );
-
- context.redirect( first_core_url );
- return false;
- }
-
- active_element
- .addClass( 'active' );
-
- if( this.params.splat[1] )
- {
- $( '.' + this.params.splat[1], active_element )
- .addClass( 'active' );
- }
-
- if( !active_element.hasClass( 'global' ) )
- {
- this.active_core = active_element;
- }
- }
- }
- );
- }
+ if( 0 === active_element.size() )
+ {
+ var first_core = $( 'li[data-basepath]', app.menu_element ).attr( 'id' );
+ var first_core_url = context.path.replace( new RegExp( '/' + this.params.splat[0] + '/' ), '/' + first_core + '/' );
+
+ context.redirect( first_core_url );
+ return false;
+ }
+
+ active_element
+ .addClass( 'active' );
+
+ if( this.params.splat[1] )
+ {
+ $( '.' + this.params.splat[1], active_element )
+ .addClass( 'active' );
+ }
+
+ if( !active_element.hasClass( 'global' ) )
+ {
+ this.active_core = active_element;
+ }
+ }
+ }
+ );
+ }
);
var solr_admin = function( app_config )
{
self = this,
- menu_element = null,
+ menu_element = null,
- is_multicore = null,
- cores_data = null,
- active_core = null,
- environment_basepath = null,
+ is_multicore = null,
+ cores_data = null,
+ active_core = null,
+ environment_basepath = null,
- config = app_config,
- params = null,
- dashboard_values = null,
- schema_browser_data = null,
+ config = app_config,
+ params = null,
+ dashboard_values = null,
+ schema_browser_data = null,
- plugin_data = null,
+ plugin_data = null,
- this.menu_element = $( '#menu ul' );
- this.config = config;
+ this.menu_element = $( '#menu ul' );
+ this.config = config;
+
+ this.run = function()
+ {
+ $.ajax
+ (
+ {
+ url : config.solr_path + config.core_admin_path + '?wt=json',
+ dataType : 'json',
+ beforeSend : function( arr, form, options )
+ {
+ $( '#content' )
+ .html( '<div id="index"><div class="loader">Loading ...</div></div>' );
+ },
+ success : function( response )
+ {
+ self.cores_data = response.status;
+ is_multicore = 'undefined' === typeof response.status[''];
+
+ if( is_multicore )
+ {
+ self.menu_element
+ .addClass( 'multicore' );
+
+ $( '#cores', menu_element )
+ .show();
+ }
+ else
+ {
+ self.menu_element
+ .addClass( 'singlecore' );
+ }
+
+ for( var core_name in response.status )
+ {
+ var core_path = config.solr_path + '/' + core_name;
+
+ if( !core_name )
+ {
+ core_name = 'singlecore';
+ core_path = config.solr_path
+ }
+
+ if( !environment_basepath )
+ {
+ environment_basepath = core_path;
+ }
+
+ var core_tpl = '<li id="' + core_name + '" data-basepath="' + core_path + '">' + "\n"
+ + ' <p><a href="#/' + core_name + '">' + core_name + '</a></p>' + "\n"
+ + ' <ul>' + "\n"
+
+ + ' <li class="ping"><a rel="' + core_path + '/admin/ping"><span>Ping</span></a></li>' + "\n"
+ + ' <li class="query"><a href="#/' + core_name + '/query"><span>Query</span></a></li>' + "\n"
+ + ' <li class="schema"><a href="#/' + core_name + '/schema"><span>Schema</span></a></li>' + "\n"
+ + ' <li class="config"><a href="#/' + core_name + '/config"><span>Config</span></a></li>' + "\n"
+ + ' <li class="replication"><a href="#/' + core_name + '/replication"><span>Replication</span></a></li>' + "\n"
+ + ' <li class="analysis"><a href="#/' + core_name + '/analysis"><span>Analysis</span></a></li>' + "\n"
+ + ' <li class="schema-browser"><a href="#/' + core_name + '/schema-browser"><span>Schema Browser</span></a></li>' + "\n"
+ + ' <li class="plugins"><a href="#/' + core_name + '/plugins"><span>Plugins</span></a></li>' + "\n"
+ + ' <li class="dataimport"><a href="#/' + core_name + '/dataimport"><span>Dataimport</span></a></li>' + "\n"
+
+ + ' </ul>' + "\n"
+ + '</li>';
+
+ self.menu_element
+ .append( core_tpl );
+ }
- this.run = function()
- {
- $.ajax
- (
+ $.ajax
+ (
{
- url : config.solr_path + config.core_admin_path + '?wt=json',
- dataType : 'json',
- beforeSend : function( arr, form, options )
- {
- $( '#content' )
- .html( '<div id="index"><div class="loader">Loading ...</div></div>' );
- },
- success : function( response )
+ url : environment_basepath + '/admin/system?wt=json',
+ dataType : 'json',
+ beforeSend : function( arr, form, options )
+ {
+ },
+ success : function( response )
+ {
+ self.dashboard_values = response;
+
+ var environment_args = null;
+ var cloud_args = null;
+
+ if( response.jvm && response.jvm.jmx && response.jvm.jmx.commandLineArgs )
+ {
+ var command_line_args = response.jvm.jmx.commandLineArgs.join( ' | ' );
+
+ environment_args = command_line_args.match( /-Dsolr.environment=((dev|test|prod)?[\w\d]*)/i );
+ cloud_args = command_line_args.match( /-Dzk/i );
+ }
+
+ // title
+
+ $( 'title', document )
+ .append( ' (' + response.core.host + ')' );
+
+ // environment
+
+ var environment_element = $( '#environment' );
+ if( environment_args )
{
- self.cores_data = response.status;
- is_multicore = 'undefined' === typeof response.status[''];
+ environment_element
+ .show();
- if( is_multicore )
- {
- self.menu_element
- .addClass( 'multicore' );
-
- $( '#cores', menu_element )
- .show();
- }
- else
- {
- self.menu_element
- .addClass( 'singlecore' );
- }
-
- for( var core_name in response.status )
- {
- var core_path = config.solr_path + '/' + core_name;
-
- if( !core_name )
- {
- core_name = 'singlecore';
- core_path = config.solr_path
- }
-
- if( !environment_basepath )
- {
- environment_basepath = core_path;
- }
-
- var core_tpl = '<li id="' + core_name + '" data-basepath="' + core_path + '">' + "\n"
- + ' <p><a href="#/' + core_name + '">' + core_name + '</a></p>' + "\n"
- + ' <ul>' + "\n"
-
- + ' <li class="ping"><a rel="' + core_path + '/admin/ping"><span>Ping</span></a></li>' + "\n"
- + ' <li class="query"><a href="#/' + core_name + '/query"><span>Query</span></a></li>' + "\n"
- + ' <li class="schema"><a href="#/' + core_name + '/schema"><span>Schema</span></a></li>' + "\n"
- + ' <li class="config"><a href="#/' + core_name + '/config"><span>Config</span></a></li>' + "\n"
- + ' <li class="replication"><a href="#/' + core_name + '/replication"><span>Replication</span></a></li>' + "\n"
- + ' <li class="analysis"><a href="#/' + core_name + '/analysis"><span>Analysis</span></a></li>' + "\n"
- + ' <li class="schema-browser"><a href="#/' + core_name + '/schema-browser"><span>Schema Browser</span></a></li>' + "\n"
- + ' <li class="plugins"><a href="#/' + core_name + '/plugins"><span>Plugins</span></a></li>' + "\n"
- + ' <li class="dataimport"><a href="#/' + core_name + '/dataimport"><span>Dataimport</span></a></li>' + "\n"
-
- + ' </ul>' + "\n"
- + '</li>';
-
- self.menu_element
- .append( core_tpl );
- }
-
- $.ajax
- (
- {
- url : environment_basepath + '/admin/system?wt=json',
- dataType : 'json',
- beforeSend : function( arr, form, options )
- {
- },
- success : function( response )
- {
- self.dashboard_values = response;
-
- var environment_args = null;
- var cloud_args = null;
-
- if( response.jvm && response.jvm.jmx && response.jvm.jmx.commandLineArgs )
- {
- var command_line_args = response.jvm.jmx.commandLineArgs.join( ' | ' );
-
- environment_args = command_line_args
- .match( /-Dsolr.environment=((dev|test|prod)?[\w\d]*)/i );
-
- cloud_args = command_line_args
- .match( /-Dzk/i );
- }
-
- // environment
-
- var environment_element = $( '#environment' );
- if( environment_args )
- {
- environment_element
- .show();
-
- if( environment_args[1] )
- {
- environment_element
- .html( environment_args[1] );
- }
-
- if( environment_args[2] )
- {
- environment_element
- .addClass( environment_args[2] );
- }
- }
- else
- {
- environment_element
- .remove();
- }
-
- // cloud
-
- var cloud_nav_element = $( '#menu #cloud' );
- if( cloud_args )
- {
- cloud_nav_element
- .show();
- }
-
- // sammy
-
- sammy.run( location.hash );
- },
- error : function()
- {
- },
- complete : function()
- {
- loader.hide( this );
- }
- }
- );
- },
- error : function()
+ if( environment_args[1] )
+ {
+ environment_element
+ .html( environment_args[1] );
+ }
+
+ if( environment_args[2] )
+ {
+ environment_element
+ .addClass( environment_args[2] );
+ }
+ }
+ else
{
- },
- complete : function()
+ environment_element
+ .remove();
+ }
+
+ // cloud
+
+ var cloud_nav_element = $( '#menu #cloud' );
+ if( cloud_args )
{
+ cloud_nav_element
+ .show();
}
+
+ // sammy
+
+ sammy.run( location.hash );
+ },
+ error : function()
+ {
+ var main = $( '#main' );
+
+ $( 'div[id$="-wrapper"]', main )
+ .remove();
+
+ main
+ .addClass( 'error' )
+ .append
+ (
+ '<div class="message">This interface requires that you activate the admin request handlers, add the following configuration to your <code>solrconfig.xml:</code></div>' +
+ '<div class="code"><pre class="syntax language-xml"><code>' +
+ '<!-- Admin Handlers - This will register all the standard admin RequestHandlers. -->'.esc() + "\n" +
+ '<requestHandler name="/admin/" class="solr.admin.AdminHandlers" />'.esc() +
+ '</code></pre></div>'
+ );
+
+ hljs.highlightBlock( $( 'pre', main ).get(0) );
+ },
+ complete : function()
+ {
+ loader.hide( this );
+ }
}
- );
- }
+ );
+ },
+ error : function()
+ {
+ },
+ complete : function()
+ {
+ }
+ }
+ );
+ }
};
-var app = new solr_admin( app_config );
\ No newline at end of file
+var app = new solr_admin( app_config );
Modified: lucene/dev/trunk/solr/webapp/web/js/scripts/cloud.js
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/webapp/web/js/scripts/cloud.js?rev=1298010&r1=1298009&r2=1298010&view=diff
==============================================================================
--- lucene/dev/trunk/solr/webapp/web/js/scripts/cloud.js (original)
+++ lucene/dev/trunk/solr/webapp/web/js/scripts/cloud.js Wed Mar 7 16:30:20 2012
@@ -1,174 +1,332 @@
+/*
+ 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.
+*/
+
// #/cloud
sammy.get
(
- /^#\/(cloud)$/,
- function( context )
- {
- var content_element = $( '#content' );
+ /^#\/(cloud)$/,
+ function( context )
+ {
+ var core_basepath = $( 'li[data-basepath]', app.menu_element ).attr( 'data-basepath' );
+ var content_element = $( '#content' );
+
+ $.get
+ (
+ 'tpl/cloud.html',
+ function( template )
+ {
+ content_element
+ .html( template );
+
+ var cloud_element = $( '#cloud', content_element );
+ var cloud_content = $( '.content', cloud_element );
+
+ var debug_element = $( '#debug', cloud_element );
+ var debug_button = $( 'a.debug', cloud_element );
+
+ var clipboard_element = $( '.clipboard', debug_element );
+ var clipboard_button = $( 'a', clipboard_element );
+
+ debug_button
+ .die( 'click' )
+ .live
+ (
+ 'click',
+ function( event )
+ {
+ debug_element.trigger( 'show' );
+ return false;
+ }
+ );
+
+ $( '.close', debug_element )
+ .die( 'click' )
+ .live
+ (
+ 'click',
+ function( event )
+ {
+ debug_element.trigger( 'hide' );
+ return false;
+ }
+ );
+
+ $( '.clipboard', debug_element )
+ .die( 'click' )
+ .live
+ (
+ 'click',
+ function( event )
+ {
+ return false;
+ }
+ );
+
+ debug_element
+ .die( 'show' )
+ .live
+ (
+ 'show',
+ function( event )
+ {
+ debug_button.hide();
+ debug_element.show();
+
+ $.ajax
+ (
+ {
+ url : core_basepath + '/zookeeper?wt=json&dump=true',
+ dataType : 'text',
+ context : debug_element,
+ beforeSend : function( xhr, settings )
+ {
+ $( '.debug', debug_element )
+ .html( '<span class="loader">Loading Dump ...</span>' );
+
+ ZeroClipboard.setMoviePath( 'img/ZeroClipboard.swf' );
+
+ clipboard_client = new ZeroClipboard.Client();
+
+ clipboard_client.addEventListener
+ (
+ 'load',
+ function( client )
+ {
+ }
+ );
+
+ clipboard_client.addEventListener
+ (
+ 'complete',
+ function( client, text )
+ {
+ clipboard_element
+ .addClass( 'copied' );
+
+ clipboard_button
+ .data( 'text', clipboard_button.text() )
+ .text( clipboard_button.data( 'copied' ) );
+ }
+ );
+ },
+ success : function( response, text_status, xhr )
+ {
+ clipboard_client.glue
+ (
+ clipboard_element.get(0),
+ clipboard_button.get(0)
+ );
+
+ clipboard_client.setText( response.replace( /\\/g, '\\\\' ) );
+
+ $( '.debug', debug_element )
+ .removeClass( 'loader' )
+ .text( response );
+ },
+ error : function( xhr, text_status, error_thrown )
+ {
+ },
+ complete : function( xhr, text_status )
+ {
+ }
+ }
+ );
+ }
+ )
+ .die( 'hide' )
+ .live
+ (
+ 'hide',
+ function( event )
+ {
+ $( '.debug', debug_element )
+ .empty();
+
+ clipboard_element
+ .removeClass( 'copied' );
+
+ clipboard_button
+ .data( 'copied', clipboard_button.text() )
+ .text( clipboard_button.data( 'text' ) );
+
+ clipboard_client.destroy();
+
+ debug_button.show();
+ debug_element.hide();
+ }
+ );
- $.get
+ $.ajax
(
- 'tpl/cloud.html',
- function( template )
+ {
+ url : core_basepath + '/zookeeper?wt=json',
+ dataType : 'json',
+ context : cloud_content,
+ beforeSend : function( xhr, settings )
+ {
+ //this
+ // .html( '<div class="loader">Loading ...</div>' );
+ },
+ success : function( response, text_status, xhr )
{
- content_element
- .html( template );
+ var self = this;
+
+ $( '#tree', this )
+ .jstree
+ (
+ {
+ "plugins" : [ "json_data" ],
+ "json_data" : {
+ "data" : response.tree,
+ "progressive_render" : true
+ },
+ "core" : {
+ "animation" : 0
+ }
+ }
+ )
+ .jstree
+ (
+ 'open_node',
+ 'li:first'
+ );
- var cloud_element = $( '#cloud', content_element );
- var cloud_content = $( '.content', cloud_element );
+ var tree_links = $( '#tree a', this );
- $.ajax
+ tree_links
+ .die( 'click' )
+ .live
(
- {
- url : app.config.zookeeper_path,
- dataType : 'json',
- context : cloud_content,
- beforeSend : function( xhr, settings )
- {
- //this
- // .html( '<div class="loader">Loading ...</div>' );
- },
- success : function( response, text_status, xhr )
- {
- var self = this;
-
- $( '#tree', this )
- .jstree
- (
- {
- "plugins" : [ "json_data" ],
- "json_data" : {
- "data" : response.tree,
- "progressive_render" : true
- },
- "core" : {
- "animation" : 0
- }
- }
- );
-
- var tree_links = $( '#tree a', this );
-
- tree_links
- .die( 'click' )
- .live
- (
- 'click',
- function( event )
- {
- $( 'a.active', $( this ).parents( '#tree' ) )
- .removeClass( 'active' );
+ 'click',
+ function( event )
+ {
+ $( 'a.active', $( this ).parents( '#tree' ) )
+ .removeClass( 'active' );
- $( this )
- .addClass( 'active' );
+ $( this )
+ .addClass( 'active' );
- cloud_content
- .addClass( 'show' );
+ cloud_content
+ .addClass( 'show' );
- var file_content = $( '#file-content' );
+ var file_content = $( '#file-content' );
- $( 'a.close', file_content )
- .die( 'click' )
- .live
- (
- 'click',
- function( event )
- {
- $( '#tree a.active' )
- .removeClass( 'active' );
+ $( 'a.close', file_content )
+ .die( 'click' )
+ .live
+ (
+ 'click',
+ function( event )
+ {
+ $( '#tree a.active' )
+ .removeClass( 'active' );
- cloud_content
- .removeClass( 'show' );
+ cloud_content
+ .removeClass( 'show' );
- return false;
- }
- );
-
- $.ajax
- (
- {
- url : this.href,
- dataType : 'json',
- context : file_content,
- beforeSend : function( xhr, settings )
- {
- //this
- // .html( 'loading' )
- // .show();
- },
- success : function( response, text_status, xhr )
- {
- //this
- // .html( '<pre>' + response.znode.data + '</pre>' );
-
- var props = [];
- for( var key in response.znode.prop )
- {
- props.push
- (
- '<li><dl class="clearfix">' + "\n" +
- '<dt>' + key.esc() + '</dt>' + "\n" +
- '<dd>' + response.znode.prop[key].esc() + '</dd>' + "\n" +
- '</dl></li>'
- );
- }
-
- $( '#prop ul', this )
- .empty()
- .html( props.join( "\n" ) );
-
- $( '#prop ul li:odd', this )
- .addClass( 'odd' );
-
- var data_element = $( '#data', this );
-
- if( 0 !== parseInt( response.znode.prop.children_count ) )
- {
- data_element.hide();
- }
- else
- {
- var data = response.znode.data
- ? '<pre>' + response.znode.data.esc() + '</pre>'
- : '<em>File "' + response.znode.path + '" has no Content</em>';
-
- data_element
- .show()
- .html( data );
- }
- },
- error : function( xhr, text_status, error_thrown)
- {
- },
- complete : function( xhr, text_status )
- {
- }
- }
- );
-
- return false;
- }
- );
+ return false;
+ }
+ );
+
+ $.ajax
+ (
+ {
+ url : this.href,
+ dataType : 'json',
+ context : file_content,
+ beforeSend : function( xhr, settings )
+ {
+ //this
+ // .html( 'loading' )
+ // .show();
},
- error : function( xhr, text_status, error_thrown )
+ success : function( response, text_status, xhr )
{
- var message = 'Loading of <code>' + app.config.zookeeper_path + '</code> failed with "' + text_status + '" '
- + '(<code>' + error_thrown.message + '</code>)';
+ //this
+ // .html( '<pre>' + response.znode.data + '</pre>' );
- if( 200 !== xhr.status )
- {
- message = 'Loading of <code>' + app.config.zookeeper_path + '</code> failed with HTTP-Status ' + xhr.status + ' ';
- }
-
- this
- .html( '<div class="block" id="error">' + message + '</div>' );
+ var props = [];
+ for( var key in response.znode.prop )
+ {
+ props.push
+ (
+ '<li><dl class="clearfix">' + "\n" +
+ '<dt>' + key.esc() + '</dt>' + "\n" +
+ '<dd>' + response.znode.prop[key].esc() + '</dd>' + "\n" +
+ '</dl></li>'
+ );
+ }
+
+ $( '#prop ul', this )
+ .empty()
+ .html( props.join( "\n" ) );
+
+ $( '#prop ul li:odd', this )
+ .addClass( 'odd' );
+
+ var data_element = $( '#data', this );
+
+ if( 0 !== parseInt( response.znode.prop.children_count ) )
+ {
+ data_element.hide();
+ }
+ else
+ {
+ var data = response.znode.data
+ ? '<pre>' + response.znode.data.esc() + '</pre>'
+ : '<em>File "' + response.znode.path + '" has no Content</em>';
+
+ data_element
+ .show()
+ .html( data );
+ }
+ },
+ error : function( xhr, text_status, error_thrown)
+ {
},
complete : function( xhr, text_status )
{
}
- }
+ }
+ );
+
+ return false;
+ }
);
+ },
+ error : function( xhr, text_status, error_thrown )
+ {
+ var message = 'Loading of <code>' + app.config.zookeeper_path + '</code> failed with "' + text_status + '" '
+ + '(<code>' + error_thrown.message + '</code>)';
+
+ if( 200 !== xhr.status )
+ {
+ message = 'Loading of <code>' + app.config.zookeeper_path + '</code> failed with HTTP-Status ' + xhr.status + ' ';
+ }
+
+ this
+ .html( '<div class="block" id="error">' + message + '</div>' );
+ },
+ complete : function( xhr, text_status )
+ {
}
+ }
);
- }
+ }
+ );
+ }
);
\ No newline at end of file