var loader = { show : function( element ) { $( element ) .addClass( 'loader' ); }, hide : function( element ) { $( element ) .removeClass( 'loader' ); } }; var sammy = $.sammy ( function() { this.bind ( 'run', function( event, config ) { if( 0 === config.start_url.length ) { location.href = '#/'; return false; } } ); this.bind ( 'ping', function( event ) { $.ajax ( { url : $( this.params.element ).attr( 'href' ) + '?wt=json', dataType : 'json', context: this.params.element, beforeSend : function( arr, form, options ) { loader.show( this ); }, success : function( response, text_status, xhr ) { $( this ) .removeAttr( 'title' ); $( this ).parents( 'li' ) .removeClass( 'error' ); var qtime_element = $( '.qtime', this ); if( 0 === qtime_element.size() ) { qtime_element = $( ' ()' ); $( this ) .append ( qtime_element ); } $( 'span', qtime_element ) .html( response.responseHeader.QTime + 'ms' ); }, error : function( xhr, text_status, error_thrown ) { $( this ) .attr( 'title', '/admin/ping is not configured (' + xhr.status + ': ' + error_thrown + ')' ); $( this ).parents( 'li' ) .addClass( 'error' ); }, complete : function( xhr, text_status ) { loader.hide( this ); } } ); return false; } ); // activate_core this.before ( {}, function() { $( 'li[id].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 ); 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; } } } ); // #/cloud this.get ( /^#\/(cloud)$/, function( context ) { var content_element = $( '#content' ); $.get ( 'tpl/cloud.html', function( template ) { content_element .html( template ); var zookeeper_element = $( '#zookeeper', content_element ); $.ajax ( { url : app.config.zookeeper_path, dataType : 'json', context : $( '.content', zookeeper_element ), beforeSend : function( xhr, settings ) { this .html( '
Loading ...
' ); }, success : function( response, text_status, xhr ) { this .html( '
' ); $( '#zookeeper-tree', this ) .jstree ( { "plugins" : [ "json_data" ], "json_data" : { "data" : response.tree, "progressive_render" : true }, "core" : { "animation" : 0 } } ); }, error : function( xhr, text_status, error_thrown ) { }, complete : function( xhr, text_status ) { } } ); } ); } ); this.bind ( 'cores_load_data', function( event, params ) { if( app.cores_data ) { params.callback( app.cores_data ); return true; } $.ajax ( { url : app.config.solr_path + app.config.core_admin_path + '?wt=json', dataType : 'json', beforeSend : function( xhr, settings ) { }, success : function( response, text_status, xhr ) { app.cores_data = response.status; params.callback( app.cores_data ); }, error : function( xhr, text_status, error_thrown) { }, complete : function( xhr, text_status ) { } } ); } ); this.bind ( 'cores_build_navigation', function( event, params ) { var navigation_content = ['