You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ry...@apache.org on 2012/03/13 17:43:48 UTC

svn commit: r1300232 [12/14] - in /lucene/dev/branches/lucene3795_lsp_spatial_module: ./ dev-tools/eclipse/ dev-tools/maven/ dev-tools/maven/lucene/contrib/demo/ dev-tools/maven/solr/contrib/clustering/ dev-tools/maven/solr/contrib/dataimporthandler/ d...

Modified: lucene/dev/branches/lucene3795_lsp_spatial_module/solr/webapp/web/js/scripts/plugins.js
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3795_lsp_spatial_module/solr/webapp/web/js/scripts/plugins.js?rev=1300232&r1=1300231&r2=1300232&view=diff
==============================================================================
--- lucene/dev/branches/lucene3795_lsp_spatial_module/solr/webapp/web/js/scripts/plugins.js (original)
+++ lucene/dev/branches/lucene3795_lsp_spatial_module/solr/webapp/web/js/scripts/plugins.js Tue Mar 13 16:43:38 2012
@@ -1,259 +1,274 @@
+/*
+ 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.
+*/
+
 sammy.bind
 (
-    'plugins_load',
-    function( event, params )
+  'plugins_load',
+  function( event, params )
+  {
+    var callback = function()
     {
-        var callback = function()
-        {
-            params.callback( app.plugin_data.plugin_data, app.plugin_data.sort_table, app.plugin_data.types );
-        }
+      params.callback( app.plugin_data.plugin_data, app.plugin_data.sort_table, app.plugin_data.types );
+    }
         
-        if( app.plugin_data )
-        {
-            callback( app.plugin_data );
-            return true;
-        }
+    if( app.plugin_data )
+    {
+      callback( app.plugin_data );
+      return true;
+    }
 
-        var core_basepath = params.active_core.attr( 'data-basepath' );
-        $.ajax
-        (
+    var core_basepath = params.active_core.attr( 'data-basepath' );
+    $.ajax
+    (
+      {
+        url : core_basepath + '/admin/mbeans?stats=true&wt=json',
+        dataType : 'json',
+        beforeSend : function( xhr, settings )
+        {
+        },
+        success : function( response, text_status, xhr )
+        {
+          var types = [];
+          var sort_table = {};
+          var plugin_data = {};
+
+          var types_obj = {};
+          var plugin_key = null;
+
+          for( var i = 0; i < response['solr-mbeans'].length; i++ )
+          {
+            if( !( i % 2 ) )
             {
-                url : core_basepath + '/admin/mbeans?stats=true&wt=json',
-                dataType : 'json',
-                beforeSend : function( xhr, settings )
-                {
-                },
-                success : function( response, text_status, xhr )
-                {
-                    var types = [];
-                    var sort_table = {};
-                    var plugin_data = {};
-
-                    var types_obj = {};
-                    var plugin_key = null;
-
-                    for( var i = 0; i < response['solr-mbeans'].length; i++ )
-                    {
-                        if( !( i % 2 ) )
-                        {
-                            plugin_key = response['solr-mbeans'][i];
-                        }
-                        else
-                        {
-                            plugin_data[plugin_key] = response['solr-mbeans'][i];
-                        }
-                    }
+              plugin_key = response['solr-mbeans'][i];
+            }
+            else
+            {
+              plugin_data[plugin_key] = response['solr-mbeans'][i];
+            }
+          }
 
-                    for( var key in plugin_data )
-                    {
-                        sort_table[key] = {
-                            url : [],
-                            component : [],
-                            handler : []
-                        };
-                        for( var part_key in plugin_data[key] )
-                        {
-                            if( 0 < part_key.indexOf( '.' ) )
-                            {
-                                types_obj[key] = true;
-                                sort_table[key]['handler'].push( part_key );
-                            }
-                            else if( 0 === part_key.indexOf( '/' ) )
-                            {
-                                types_obj[key] = true;
-                                sort_table[key]['url'].push( part_key );
-                            }
-                            else
-                            {
-                                types_obj[key] = true;
-                                sort_table[key]['component'].push( part_key );
-                            }
-                        }
-                    }
+          for( var key in plugin_data )
+          {
+            sort_table[key] = {
+              url : [],
+              component : [],
+              handler : []
+            };
+            for( var part_key in plugin_data[key] )
+            {
+              if( 0 < part_key.indexOf( '.' ) )
+              {
+                types_obj[key] = true;
+                sort_table[key]['handler'].push( part_key );
+              }
+              else if( 0 === part_key.indexOf( '/' ) )
+              {
+                types_obj[key] = true;
+                sort_table[key]['url'].push( part_key );
+              }
+              else
+              {
+                types_obj[key] = true;
+                sort_table[key]['component'].push( part_key );
+              }
+            }
+          }
 
-                    for( var type in types_obj )
-                    {
-                        types.push( type );
-                    }
-                    types.sort();
+          for( var type in types_obj )
+          {
+            types.push( type );
+          }
+          types.sort();
                     
-                    app.plugin_data = {
-                        'plugin_data' : plugin_data,
-                        'sort_table' : sort_table,
-                        'types' : types
-                    }
-
-                    $.get
-                    (
-                        'tpl/plugins.html',
-                        function( template )
-                        {
-                            $( '#content' )
-                                .html( template );
+          app.plugin_data = {
+            'plugin_data' : plugin_data,
+            'sort_table' : sort_table,
+            'types' : types
+          }
+
+          $.get
+          (
+            'tpl/plugins.html',
+            function( template )
+            {
+              $( '#content' )
+                .html( template );
                             
-                            callback( app.plugin_data );
-                        }
-                    );
-                },
-                error : function( xhr, text_status, error_thrown)
-                {
-                },
-                complete : function( xhr, text_status )
-                {
-                }
+              callback( app.plugin_data );
             }
-        );
-    }
+          );
+        },
+        error : function( xhr, text_status, error_thrown)
+        {
+        },
+        complete : function( xhr, text_status )
+        {
+        }
+      }
+    );
+  }
 );
 
 // #/:core/plugins/$type
 sammy.get
 (
-    /^#\/([\w\d-]+)\/(plugins)\/(\w+)$/,
-    function( context )
-    {
-        var content_element = $( '#content' );
-        var type = context.params.splat[2].toUpperCase();
-        var context_path = context.path.split( '?' ).shift();
-
-        sammy.trigger
-        (
-            'plugins_load',
-            {
-                active_core : this.active_core,
-                callback : function( plugin_data, plugin_sort, types )
-                {
-                    var frame_element = $( '#frame', content_element );
-                    var navigation_element = $( '#navigation ul', content_element );
+  /^#\/([\w\d-]+)\/(plugins)\/(\w+)$/,
+  function( context )
+  {
+    var content_element = $( '#content' );
+    var type = context.params.splat[2].toUpperCase();
+    var context_path = context.path.split( '?' ).shift();
+
+    sammy.trigger
+    (
+      'plugins_load',
+      {
+        active_core : this.active_core,
+        callback : function( plugin_data, plugin_sort, types )
+        {
+          var frame_element = $( '#frame', content_element );
+          var navigation_element = $( '#navigation ul', content_element );
 
-                    var navigation_content = [];
-                    for( var i = 0; i < types.length; i++ )
-                    {
-                        var type_url = context.params.splat[0] + '/' + 
-                                       context.params.splat[1] + '/' +
-                                       types[i].toLowerCase();
-
-                        navigation_content.push
-                        (
-                            '<li class="' + types[i].toLowerCase() + '">' +
-                            '<a href="#/' + type_url + '">' + types[i] + '</a>' +
-                            '</li>'
-                        );
-                    }
+          var navigation_content = [];
+          for( var i = 0; i < types.length; i++ )
+          {
+            var type_url = context.params.splat[0] + '/' + context.params.splat[1] + '/' + types[i].toLowerCase();
+
+            navigation_content.push
+            (
+              '<li class="' + types[i].toLowerCase() + '">' +
+              '<a href="#/' + type_url + '">' + types[i] + '</a>' +
+              '</li>'
+            );
+          }
 
-                    navigation_element
-                        .html( navigation_content.join( "\n" ) );
+          navigation_element
+            .html( navigation_content.join( "\n" ) );
                     
-                    $( 'a[href="' + context_path + '"]', navigation_element )
-                        .parent().addClass( 'current' );
+          $( 'a[href="' + context_path + '"]', navigation_element )
+            .parent().addClass( 'current' );
                     
-                    var content = '<ul>';
-                    for( var sort_key in plugin_sort[type] )
-                    {
-                        plugin_sort[type][sort_key].sort();
-                        var plugin_type_length = plugin_sort[type][sort_key].length;
+          var content = '<ul>';
+          for( var sort_key in plugin_sort[type] )
+          {
+            plugin_sort[type][sort_key].sort();
+            var plugin_type_length = plugin_sort[type][sort_key].length;
                         
-                        for( var i = 0; i < plugin_type_length; i++ )
-                        {
-                            content += '<li class="entry">' + "\n";
-                            content += '<a href="' + context_path + '?entry=' + plugin_sort[type][sort_key][i] + '">';
-                            content += plugin_sort[type][sort_key][i]
-                            content += '</a>' + "\n";
-                            content += '<ul class="detail">' + "\n";
-                            
-                            var details = plugin_data[type][ plugin_sort[type][sort_key][i] ];
-                            for( var detail_key in details )
-                            {
-                                if( 'stats' !== detail_key )
-                                {
-                                    var detail_value = details[detail_key];
-
-                                    if( 'description' === detail_key )
-                                    {
-                                        detail_value = detail_value.replace( /,/g, ',&#8203;' );
-                                    }
-                                    else if( 'src' === detail_key )
-                                    {
-                                        detail_value = detail_value.replace( /\//g, '/&#8203;' );
-                                    }
-
-                                    content += '<li><dl class="clearfix">' + "\n";
-                                    content += '<dt>' + detail_key + ':</dt>' + "\n";
-                                    content += '<dd>' + detail_value + '</dd>' + "\n";
-                                    content += '</dl></li>' + "\n";
-                                }
-                                else if( 'stats' === detail_key && details[detail_key] )
-                                {
-                                    content += '<li class="stats clearfix">' + "\n";
-                                    content += '<span>' + detail_key + ':</span>' + "\n";
-                                    content += '<ul>' + "\n";
-
-                                    for( var stats_key in details[detail_key] )
-                                    {
-                                        var stats_value = details[detail_key][stats_key];
-
-                                        if( 'readerDir' === stats_key )
-                                        {
-                                            stats_value = stats_value.replace( /@/g, '@&#8203;' );
-                                        }
-
-                                        content += '<li><dl class="clearfix">' + "\n";
-                                        content += '<dt>' + stats_key + ':</dt>' + "\n";
-                                        content += '<dd>' + stats_value + '</dd>' + "\n";
-                                        content += '</dl></li>' + "\n";
-                                    }
-
-                                    content += '</ul></li>' + "\n";
-                                }
-                            }
+            for( var i = 0; i < plugin_type_length; i++ )
+            {
+              content += '<li class="entry">' + "\n";
+              content += '<a href="' + context_path + '?entry=' + plugin_sort[type][sort_key][i] + '">';
+              content += plugin_sort[type][sort_key][i]
+              content += '</a>' + "\n";
+              content += '<ul class="detail">' + "\n";
                             
-                            content += '</ul>' + "\n";
-                        }
+              var details = plugin_data[type][ plugin_sort[type][sort_key][i] ];
+              for( var detail_key in details )
+              {
+                if( 'stats' !== detail_key )
+                {
+                  var detail_value = details[detail_key];
+
+                  if( 'description' === detail_key )
+                  {
+                    detail_value = detail_value.replace( /,/g, ',&#8203;' );
+                  }
+                  else if( 'src' === detail_key )
+                  {
+                    detail_value = detail_value.replace( /\//g, '/&#8203;' );
+                  }
+
+                  content += '<li><dl class="clearfix">' + "\n";
+                  content += '<dt>' + detail_key + ':</dt>' + "\n";
+                  content += '<dd>' + detail_value + '</dd>' + "\n";
+                  content += '</dl></li>' + "\n";
+                }
+                else if( 'stats' === detail_key && details[detail_key] )
+                {
+                  content += '<li class="stats clearfix">' + "\n";
+                  content += '<span>' + detail_key + ':</span>' + "\n";
+                  content += '<ul>' + "\n";
+
+                  for( var stats_key in details[detail_key] )
+                  {
+                    var stats_value = details[detail_key][stats_key];
+
+                    if( 'readerDir' === stats_key )
+                    {
+                      stats_value = stats_value.replace( /@/g, '@&#8203;' );
                     }
-                    content += '</ul>' + "\n";
 
-                    frame_element
-                        .html( content );
+                    content += '<li><dl class="clearfix">' + "\n";
+                    content += '<dt>' + stats_key + ':</dt>' + "\n";
+                    content += '<dd>' + stats_value + '</dd>' + "\n";
+                    content += '</dl></li>' + "\n";
+                  }
 
-                    $( 'a[href="' + decodeURIComponent( context.path ) + '"]', frame_element )
-                        .parent().addClass( 'expanded' );
-                    
-                    $( '.entry', frame_element )
-                        .each
-                        (
-                            function( i, entry )
-                            {
-                                $( '.detail > li', entry ).not( '.stats' ).filter( ':even' )
-                                    .addClass( 'odd' );
-
-                                $( '.stats li:odd', entry )
-                                    .addClass( 'odd' );
-                            }
-                        );
+                  content += '</ul></li>' + "\n";
                 }
+              }
+                            
+              content += '</ul>' + "\n";
             }
-        );                
-    }
+          }
+          content += '</ul>' + "\n";
+
+          frame_element
+            .html( content );
+
+          $( 'a[href="' + decodeURIComponent( context.path ) + '"]', frame_element )
+            .parent().addClass( 'expanded' );
+                    
+          $( '.entry', frame_element )
+            .each
+            (
+              function( i, entry )
+              {
+                $( '.detail > li', entry ).not( '.stats' ).filter( ':even' )
+                  .addClass( 'odd' );
+
+                $( '.stats li:odd', entry )
+                  .addClass( 'odd' );
+              }
+            );
+        }
+      }
+    );                
+  }
 );
 
 // #/:core/plugins
 sammy.get
 (
-    /^#\/([\w\d-]+)\/(plugins)$/,
-    function( context )
-    {
-        delete app.plugin_data;
-
-        sammy.trigger
-        (
-            'plugins_load',
-            {
-                active_core : this.active_core,
-                callback :  function( plugin_data, plugin_sort, types )
-                {
-                    context.redirect( context.path + '/' + types[0].toLowerCase() );
-                }
-            }
-        );
-    }
+  /^#\/([\w\d-]+)\/(plugins)$/,
+  function( context )
+  {
+    delete app.plugin_data;
+
+    sammy.trigger
+    (
+      'plugins_load',
+      {
+        active_core : this.active_core,
+        callback :  function( plugin_data, plugin_sort, types )
+        {
+          context.redirect( context.path + '/' + types[0].toLowerCase() );
+        }
+      }
+    );
+  }
 );
\ No newline at end of file

Modified: lucene/dev/branches/lucene3795_lsp_spatial_module/solr/webapp/web/js/scripts/query.js
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3795_lsp_spatial_module/solr/webapp/web/js/scripts/query.js?rev=1300232&r1=1300231&r2=1300232&view=diff
==============================================================================
--- lucene/dev/branches/lucene3795_lsp_spatial_module/solr/webapp/web/js/scripts/query.js (original)
+++ lucene/dev/branches/lucene3795_lsp_spatial_module/solr/webapp/web/js/scripts/query.js Tue Mar 13 16:43:38 2012
@@ -1,142 +1,155 @@
+/*
+ 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/query
 sammy.get
 (
-    /^#\/([\w\d-]+)\/(query)$/,
-    function( context )
-    {
-        var core_basepath = this.active_core.attr( 'data-basepath' );
-        var content_element = $( '#content' );
+  /^#\/([\w\d-]+)\/(query)$/,
+  function( context )
+  {
+    var core_basepath = this.active_core.attr( 'data-basepath' );
+    var content_element = $( '#content' );
         
-        $.get
-        (
-            'tpl/query.html',
-            function( template )
+    $.get
+    (
+      'tpl/query.html',
+      function( template )
+      {
+        content_element
+          .html( template );
+
+        var query_element = $( '#query', content_element );
+        var query_form = $( '#form form', query_element );
+        var url_element = $( '#url', query_element );
+        var result_element = $( '#result', query_element );
+        var response_element = $( '#response iframe', result_element );
+
+        url_element
+          .die( 'change' )
+          .live
+          (
+            'change',
+            function( event )
             {
-                content_element
-                    .html( template );
+              var check_iframe_ready_state = function()
+              {
+                var iframe_element = response_element.get(0).contentWindow.document || response_element.get(0).document;
 
-                var query_element = $( '#query', content_element );
-                var query_form = $( '#form form', query_element );
-                var url_element = $( '#url', query_element );
-                var result_element = $( '#result', query_element );
-                var response_element = $( '#response iframe', result_element );
+                if( !iframe_element )
+                {
+                  console.debug( 'no iframe_element found', response_element );
+                  return false;
+                }
 
                 url_element
-                    .die( 'change' )
-                    .live
-                    (
-                        'change',
-                        function( event )
-                        {
-                            var check_iframe_ready_state = function()
-                            {
-                                var iframe_element = response_element.get(0).contentWindow.document || 
-                                                     response_element.get(0).document;
-
-                                if( !iframe_element )
-                                {
-                                    console.debug( 'no iframe_element found', response_element );
-                                    return false;
-                                }
-
-                                url_element
-                                    .addClass( 'loader' );
-
-                                if( 'complete' === iframe_element.readyState )
-                                {
-                                    url_element
-                                        .removeClass( 'loader' );
-                                }
-                                else
-                                {
-                                    window.setTimeout( check_iframe_ready_state, 100 );
-                                }
-                            }
-                            check_iframe_ready_state();
+                  .addClass( 'loader' );
 
-                            response_element
-                                .attr( 'src', this.href );
+                if( 'complete' === iframe_element.readyState )
+                {
+                  url_element
+                    .removeClass( 'loader' );
+                }
+                else
+                {
+                  window.setTimeout( check_iframe_ready_state, 100 );
+                }
+              }
+              check_iframe_ready_state();
+
+              response_element
+                .attr( 'src', this.href );
                             
-                            if( !response_element.hasClass( 'resized' ) )
-                            {
-                                response_element
-                                    .addClass( 'resized' )
-                                    .css( 'height', $( '#main' ).height() - 60 );
-                            }
-                        }
-                    )
-
-                $( '.optional legend input[type=checkbox]', query_form )
-                    .die( 'change' )
-                    .live
-                    (
-                        'change',
-                        function( event )
-                        {
-                            var fieldset = $( this ).parents( 'fieldset' );
-
-                            this.checked
-                                ? fieldset.addClass( 'expanded' )
-                                : fieldset.removeClass( 'expanded' );
-                        }
-                    )
+              if( !response_element.hasClass( 'resized' ) )
+              {
+                response_element
+                  .addClass( 'resized' )
+                  .css( 'height', $( '#main' ).height() - 60 );
+              }
+            }
+          )
 
-                for( var key in context.params )
+        $( '.optional legend input[type=checkbox]', query_form )
+          .die( 'change' )
+          .live
+          (
+            'change',
+            function( event )
+            {
+              var fieldset = $( this ).parents( 'fieldset' );
+
+              this.checked
+                ? fieldset.addClass( 'expanded' )
+                : fieldset.removeClass( 'expanded' );
+            }
+          )
+
+        for( var key in context.params )
+        {
+          if( 'string' === typeof context.params[key] )
+          {
+            $( '[name="' + key + '"]', query_form )
+              .val( context.params[key] );
+          }
+        }
+
+        query_form
+          .die( 'submit' )
+          .live
+          (
+            'submit',
+            function( event )
+            {
+              var form_map = {};
+              var form_values = [];
+              var all_form_values = query_form.formToArray();
+
+              for( var i = 0; i < all_form_values.length; i++ )
+              {
+                if( !all_form_values[i].value || 0 === all_form_values[i].value.length )
                 {
-                    if( 'string' === typeof context.params[key] )
-                    {
-                        $( '[name="' + key + '"]', query_form )
-                            .val( context.params[key] );
-                    }
+                  continue;
                 }
 
-                query_form
-                    .die( 'submit' )
-                    .live
-                    (
-                        'submit',
-                        function( event )
-                        {
-                            var form_map = {};
-                            var form_values = [];
-                            var all_form_values = query_form.formToArray();
-
-                            for( var i = 0; i < all_form_values.length; i++ )
-                            {
-                                if( !all_form_values[i].value || 0 === all_form_values[i].value.length )
-                                {
-                                    continue;
-                                }
-
-                                var name_parts = all_form_values[i].name.split( '.' );
-                                if( 1 < name_parts.length && !form_map[name_parts[0]] )
-                                {
-                                    console.debug( 'skip "' + all_form_values[i].name + '", parent missing' );
-                                    continue;
-                                }
-
-                                form_map[all_form_values[i].name] = all_form_values[i].value;
-                                form_values.push( all_form_values[i] );
-                            }
-
-                            var query_url = window.location.protocol + '//' +
-                                            window.location.host +
-                                            core_basepath +
-                                            '/select?' +
-                                            $.param( form_values );
+                var name_parts = all_form_values[i].name.split( '.' );
+                if( 1 < name_parts.length && !form_map[name_parts[0]] )
+                {
+                  console.debug( 'skip "' + all_form_values[i].name + '", parent missing' );
+                  continue;
+                }
+
+                form_map[all_form_values[i].name] = all_form_values[i].value;
+                form_values.push( all_form_values[i] );
+              }
+
+              var query_url = window.location.protocol + '//' + window.location.host
+                            + core_basepath + '/select?' + $.param( form_values );
                             
-                            url_element
-                                .attr( 'href', query_url )
-                                .text( query_url )
-                                .trigger( 'change' );
+              url_element
+                .attr( 'href', query_url )
+                .text( query_url )
+                .trigger( 'change' );
                             
-                            result_element
-                                .show();
+              result_element
+                .show();
                             
-                            return false;
-                        }
-                    );
+              return false;
             }
-        );
-    }
+          );
+      }
+    );
+  }
 );
\ No newline at end of file

Modified: lucene/dev/branches/lucene3795_lsp_spatial_module/solr/webapp/web/js/scripts/replication.js
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3795_lsp_spatial_module/solr/webapp/web/js/scripts/replication.js?rev=1300232&r1=1300231&r2=1300232&view=diff
==============================================================================
--- lucene/dev/branches/lucene3795_lsp_spatial_module/solr/webapp/web/js/scripts/replication.js (original)
+++ lucene/dev/branches/lucene3795_lsp_spatial_module/solr/webapp/web/js/scripts/replication.js Tue Mar 13 16:43:38 2012
@@ -1,443 +1,557 @@
-// #/:core/replication
-sammy.get
-(
-    /^#\/([\w\d-]+)\/(replication)$/,
-    function( context )
+/*
+ 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 timer_element = null;
+var timer_timeout = null;
+
+var core_basepath = null;
+var navigation_element = null;
+var replication_element = null;
+
+var convert_duration_to_seconds = function( str )
+{
+  var ret = 0;
+  var parts = new String( str ).split( ':' ).reverse();
+  var parts_count = parts.length;
+    
+  for( var i = 0; i < parts_count; i++ )
+  {
+    ret += parseInt( parts[i], 10 ) * Math.pow( 60, i );
+  }
+
+  return ret;
+}
+
+var convert_seconds_to_readable_time = function( value )
+{
+  var text = [];
+  value = parseInt( value );
+
+  var minutes = Math.floor( value / 60 );
+  var hours = Math.floor( minutes / 60 );
+
+  if( 0 !== hours )
+  {
+    text.push( hours + 'h' );
+    value -= hours * 60 * 60;
+    minutes -= hours * 60;
+  }
+
+  if( 0 !== minutes )
+  {
+    text.push( minutes + 'm' );
+    value -= minutes * 60;
+  }
+
+  if( 0 !== value )
+  {
+    text.push( value + 's' );
+  }
+
+  return text.join( ' ' );
+}
+
+var init_timer = function( next_tick )
+{
+  if( timer_timeout )
+  {
+    window.clearTimeout( timer_timeout );
+  }
+  update_timer( next_tick );
+}
+
+var update_timer = function( next_tick )
+{
+  if( 0 === next_tick )
+  {
+    replication_fetch_status();
+    return false;
+  }
+
+  $( 'p .tick', timer_element )
+    .text( convert_seconds_to_readable_time( next_tick ) );
+
+  timer_timeout = window.setTimeout
+  (
+    'update_timer( ' + --next_tick + ' )',
+    1000
+  );
+}
+
+var clear_timer = function()
+{
+  if( timer_timeout )
+  {
+    window.clearTimeout( timer_timeout );
+    timer_element.hide();
+  }
+}
+
+var replication_fetch_status = function()
+{
+  $.ajax
+  (
     {
-        var core_basepath = this.active_core.attr( 'data-basepath' );
-        var content_element = $( '#content' );
-        
-        $.get
-        (
-            'tpl/replication.html',
-            function( template )
-            {
-                content_element
-                    .html( template );
+      url : core_basepath + '/replication?command=details&wt=json',
+      dataType : 'json',
+      beforeSend : function( xhr, settings )
+      {
+        $( '.refresh-status', navigation_element )
+          .addClass( 'loader' );
+
+        clear_timer();
+      },
+      success : function( response, text_status, xhr )
+      {
+        $( '.refresh-status', navigation_element )
+          .removeClass( 'loader' );
                 
-                var replication_element = $( '#replication', content_element );
-                var navigation_element = $( '#navigation', replication_element );
+        var data = response.details;
+        var is_slave = 'true' === data.isSlave;
 
-                function convert_seconds_to_readable_time( value )
-                {
-                    var text = [];
-                    value = parseInt( value );
+        replication_element
+          .addClass( is_slave ? 'slave' : 'master' );
 
-                    var minutes = Math.floor( value / 60 );
-                    var hours = Math.floor( minutes / 60 );
+        if( is_slave )
+        {
+          var error_element = $( '#error', replication_element );
+
+          if( data.slave.ERROR )
+          {
+            error_element
+              .html( data.slave.ERROR )
+              .show();
+          }
+          else
+          {
+            error_element
+              .hide()
+              .empty();
+          }
+
+          var progress_element = $( '#progress', replication_element );
+
+          var start_element = $( '#start', progress_element );
+          $( 'span', start_element )
+            .text( data.slave.replicationStartTime );
+
+          var eta_element = $( '#eta', progress_element );
+          $( 'span', eta_element )
+            .text( convert_seconds_to_readable_time( data.slave.timeRemaining ) );
+
+          var bar_element = $( '#bar', progress_element );
+          $( '.files span', bar_element )
+            .text( data.slave.numFilesToDownload );
+          $( '.size span', bar_element )
+            .text( data.slave.bytesToDownload );
+
+          var speed_element = $( '#speed', progress_element );
+          $( 'span', speed_element )
+            .text( data.slave.downloadSpeed );
+
+          var done_element = $( '#done', progress_element );
+          $( '.files span', done_element )
+            .text( data.slave.numFilesDownloaded );
+          $( '.size span', done_element )
+            .text( data.slave.bytesDownloaded );
+          $( '.percent span', done_element )
+            .text( parseInt(data.slave.totalPercent ) );
+
+          var percent = parseInt( data.slave.totalPercent );
+          if( 0 === percent )
+          {
+            done_element
+              .css( 'width', '1px' ); 
+          }
+          else
+          {
+            done_element
+              .css( 'width', percent + '%' );
+          }
+
+          var current_file_element = $( '#current-file', replication_element );
+          $( '.file', current_file_element )
+            .text( data.slave.currentFile );
+          $( '.done', current_file_element )
+            .text( data.slave.currentFileSizeDownloaded );
+          $( '.total', current_file_element )
+            .text( data.slave.currentFileSize );
+          $( '.percent', current_file_element )
+            .text( parseInt( data.slave.currentFileSizePercent ) );
+
+          if( !data.slave.indexReplicatedAtList )
+          {
+            data.slave.indexReplicatedAtList = [];
+          }
+
+          if( !data.slave.replicationFailedAtList )
+          {
+            data.slave.replicationFailedAtList = [];
+          }
+
+          var iterations_element = $( '#iterations', replication_element );
+          var iterations_list = $( '.iterations ul', iterations_element );
+
+          var iterations_data = [];
+          var iterations_obj = {};
+
+          for( var i in data.slave.indexReplicatedAtList )
+          {
+            var date = data.slave.indexReplicatedAtList[i];
+            if( !iterations_obj[date] )
+            {
+              iterations_obj[date] = true;
+              iterations_data.push( date );
+            }
+          }
 
-                    if( 0 !== hours )
-                    {
-                        text.push( hours + 'h' );
-                        value -= hours * 60 * 60;
-                        minutes -= hours * 60;
-                    }
-
-                    if( 0 !== minutes )
-                    {
-                        text.push( minutes + 'm' );
-                        value -= minutes * 60;
-                    }
+          for( var i in data.slave.replicationFailedAtList )
+          {
+            var date = data.slave.replicationFailedAtList[i];
+            if( !iterations_obj[date] )
+            {
+              iterations_obj[date] = true;
+              iterations_data.push( date );
+            }
+          }
 
-                    text.push( value + 's' );
+          iterations_data.sort().reverse();
 
-                    return text.join( ' ' );
+          if( 0 !== iterations_data.length )
+          {
+            var iterations = [];
+            for( var i = 0; i < iterations_data.length; i++ )
+            {
+              iterations.push( '<li data-date="' + iterations_data[i] + '">' + iterations_data[i] + '</li>' );
+            }
+                        
+            iterations_list
+              .html( iterations.join( "\n" ) )
+              .show();
+                        
+            $( data.slave.indexReplicatedAtList )
+              .each
+              (
+                function( key, value )
+                {
+                  $( 'li[data-date="' + value + '"]', iterations_list )
+                    .addClass( 'replicated' );
+                }
+              );
+                        
+            if( data.slave.indexReplicatedAt )
+            {
+              $( 'li[data-date="' + data.slave.indexReplicatedAt + '"]', iterations_list )
+                .addClass( 'latest' );
+            }
+                        
+            $( data.slave.replicationFailedAtList )
+              .each
+              (
+                function( key, value )
+                {
+                  $( 'li[data-date="' + value + '"]', iterations_list )
+                    .addClass( 'failed' );
                 }
+              );
+                        
+            if( data.slave.replicationFailedAt )
+            {
+              $( 'li[data-date="' + data.slave.replicationFailedAt + '"]', iterations_list )
+                .addClass( 'latest' );
+            }
+
+            if( 0 !== $( 'li:hidden', iterations_list ).size() )
+            {
+              $( 'a', iterations_element )
+                .show();
+            }
+            else
+            {
+              $( 'a', iterations_element )
+                .hide();
+            }
+          }
+        }
+
+        var details_element = $( '#details', replication_element );
+        var current_type_element = $( ( is_slave ? '.slave' : '.master' ), details_element );
+
+        $( '.version div', current_type_element )
+          .html( data.indexVersion );
+        $( '.generation div', current_type_element )
+          .html( data.generation );
+        $( '.size div', current_type_element )
+          .html( data.indexSize );
+                
+        if( is_slave )
+        {
+          var master_element = $( '.master', details_element );
+          $( '.version div', master_element )
+            .html( data.slave.masterDetails.indexVersion );
+          $( '.generation div', master_element )
+            .html( data.slave.masterDetails.generation );
+          $( '.size div', master_element )
+            .html( data.slave.masterDetails.indexSize );
+                    
+          if( data.indexVersion !== data.slave.masterDetails.indexVersion )
+          {
+            $( '.version', details_element )
+              .addClass( 'diff' );
+          }
+          else
+          {
+            $( '.version', details_element )
+              .removeClass( 'diff' );
+          }
+                    
+          if( data.generation !== data.slave.masterDetails.generation )
+          {
+            $( '.generation', details_element )
+              .addClass( 'diff' );
+          }
+          else
+          {
+            $( '.generation', details_element )
+              .removeClass( 'diff' );
+          }
+        }
+
+        if( is_slave )
+        {
+          var settings_element = $( '#settings', replication_element );
+
+          if( data.slave.masterUrl )
+          {
+            $( '.masterUrl dd', settings_element )
+              .html( response.details.slave.masterUrl )
+              .parents( 'li' ).show();
+          }
+
+          var polling_content = '&nbsp;';
+          var polling_ico = 'ico-1';
+
+          if( 'true' === data.slave.isPollingDisabled )
+          {
+            polling_ico = 'ico-0';
+
+            $( '.disable-polling', navigation_element ).hide();
+            $( '.enable-polling', navigation_element ).show();
+          }
+          else
+          {
+            $( '.disable-polling', navigation_element ).show();
+            $( '.enable-polling', navigation_element ).hide();
+
+            if( data.slave.pollInterval )
+            {
+              polling_content = '(interval: ' + data.slave.pollInterval + ')';
+            }
+          }
+
+          $( '.isPollingDisabled dd', settings_element )
+            .removeClass( 'ico-0' )
+            .removeClass( 'ico-1' )
+            .addClass( polling_ico )
+            .html( polling_content )
+            .parents( 'li' ).show();
+                
+          if( 'true' === data.slave.isReplicating )
+          {
+            replication_element
+              .addClass( 'replicating' );
+                        
+            $( '.replicate-now', navigation_element ).hide();
+            $( '.abort-replication', navigation_element ).show();
+                        
+            window.setTimeout( replication_fetch_status, 1000 );
+          }
+          else
+          {
+            replication_element
+              .removeClass( 'replicating' );
+                        
+            $( '.replicate-now', navigation_element ).show();
+            $( '.abort-replication', navigation_element ).hide();
 
-                function replication_fetch_status()
+
+            if( 'false' === data.slave.isPollingDisabled && data.slave.pollInterval )
+            {
+              timer_element = $( '.timer', navigation_element );
+              approx_element = $( '.approx', timer_element );
+
+              var next_tick = convert_duration_to_seconds( data.slave.pollInterval );
+              approx_element.show();
+
+              if( data.slave.nextExecutionAt )
+              {
+                var nextExecutionAt = new SolrDate( data.slave.nextExecutionAt );
+                var currentDate = new SolrDate( data.slave.currentDate );
+
+                if( nextExecutionAt.getTime() > currentDate.getTime() )
                 {
-                    $.ajax
-                    (
-                        {
-                            url : core_basepath + '/replication?command=details&wt=json',
-                            dataType : 'json',
-                            beforeSend : function( xhr, settings )
-                            {
-                                $( '.refresh-status', navigation_element )
-                                    .addClass( 'loader' );
-                            },
-                            success : function( response, text_status, xhr )
-                            {
-                                $( '.refresh-status', navigation_element )
-                                    .removeClass( 'loader' );
-                                
-                                var data = response.details;
-                                var is_slave = 'true' === data.isSlave;
-
-                                replication_element
-                                    .addClass( is_slave ? 'slave' : 'master' );
-
-                                if( is_slave )
-                                {
-                                    var error_element = $( '#error', replication_element );
-
-                                    if( data.slave.ERROR )
-                                    {
-                                        error_element
-                                            .html( data.slave.ERROR )
-                                            .show();
-                                    }
-                                    else
-                                    {
-                                        error_element
-                                            .hide()
-                                            .empty();
-                                    }
-
-                                    var progress_element = $( '#progress', replication_element );
-
-                                    var start_element = $( '#start', progress_element );
-                                    $( 'span', start_element )
-                                        .text( data.slave.replicationStartTime );
-
-                                    var eta_element = $( '#eta', progress_element );
-                                    $( 'span', eta_element )
-                                        .text( convert_seconds_to_readable_time( data.slave.timeRemaining ) );
-
-                                    var bar_element = $( '#bar', progress_element );
-                                    $( '.files span', bar_element )
-                                        .text( data.slave.numFilesToDownload );
-                                    $( '.size span', bar_element )
-                                        .text( data.slave.bytesToDownload );
-
-                                    var speed_element = $( '#speed', progress_element );
-                                    $( 'span', speed_element )
-                                        .text( data.slave.downloadSpeed );
-
-                                    var done_element = $( '#done', progress_element );
-                                    $( '.files span', done_element )
-                                        .text( data.slave.numFilesDownloaded );
-                                    $( '.size span', done_element )
-                                        .text( data.slave.bytesDownloaded );
-                                    $( '.percent span', done_element )
-                                        .text( parseInt(data.slave.totalPercent ) );
-
-                                    var percent = parseInt( data.slave.totalPercent );
-                                    if( 0 === percent )
-                                    {
-                                        done_element
-                                            .css( 'width', '1px' ); 
-                                    }
-                                    else
-                                    {
-                                        done_element
-                                            .css( 'width', percent + '%' );
-                                    }
-
-                                    var current_file_element = $( '#current-file', replication_element );
-                                    $( '.file', current_file_element )
-                                        .text( data.slave.currentFile );
-                                    $( '.done', current_file_element )
-                                        .text( data.slave.currentFileSizeDownloaded );
-                                    $( '.total', current_file_element )
-                                        .text( data.slave.currentFileSize );
-                                    $( '.percent', current_file_element )
-                                        .text( parseInt( data.slave.currentFileSizePercent ) );
-
-                                    if( !data.slave.indexReplicatedAtList )
-                                    {
-                                        data.slave.indexReplicatedAtList = [];
-                                    }
-
-                                    if( !data.slave.replicationFailedAtList )
-                                    {
-                                        data.slave.replicationFailedAtList = [];
-                                    }
-
-                                    var iterations_element = $( '#iterations', replication_element );
-                                    var iterations_list = $( '.iterations ul', iterations_element );
-
-                                    var iterations_data = [];
-                                    $.merge( iterations_data, data.slave.indexReplicatedAtList );
-                                    $.merge( iterations_data, data.slave.replicationFailedAtList );
-
-                                    if( 0 !== iterations_data.length )
-                                    {
-                                        var iterations = [];
-                                        for( var i = 0; i < iterations_data.length; i++ )
-                                        {
-                                            iterations.push
-                                            (
-                                                '<li data-date="' + iterations_data[i] + '">' +
-                                                iterations_data[i] + '</li>'
-                                            );
-                                        }
-                                        
-                                        iterations_list
-                                            .html( iterations.join( "\n" ) )
-                                            .show();
-                                        
-                                        $( data.slave.indexReplicatedAtList )
-                                            .each
-                                            (
-                                                function( key, value )
-                                                {
-                                                    $( 'li[data-date="' + value + '"]', iterations_list )
-                                                        .addClass( 'replicated' );
-                                                }
-                                            );
-                                        
-                                        if( data.slave.indexReplicatedAt )
-                                        {
-                                            $(
-                                                'li[data-date="' + data.slave.indexReplicatedAt + '"]',
-                                                iterations_list
-                                            )
-                                                .addClass( 'latest' );
-                                        }
-                                        
-                                        $( data.slave.replicationFailedAtList )
-                                            .each
-                                            (
-                                                function( key, value )
-                                                {
-                                                    $( 'li[data-date="' + value + '"]', iterations_list )
-                                                        .addClass( 'failed' );
-                                                }
-                                            );
-                                        
-                                        if( data.slave.replicationFailedAt )
-                                        {
-                                            $(
-                                                'li[data-date="' + data.slave.replicationFailedAt + '"]',
-                                                iterations_list
-                                            )
-                                                .addClass( 'latest' );
-                                        }
-
-                                        if( 0 !== $( 'li:hidden', iterations_list ).size() )
-                                        {
-                                            $( 'a', iterations_element )
-                                                .show();
-                                        }
-                                        else
-                                        {
-                                            $( 'a', iterations_element )
-                                                .hide();
-                                        }
-                                    }
-                                }
-
-                                var details_element = $( '#details', replication_element );
-                                var current_type_element = $( ( is_slave ? '.slave' : '.master' ), details_element );
-
-                                $( '.version div', current_type_element )
-                                    .html( data.indexVersion );
-                                $( '.generation div', current_type_element )
-                                    .html( data.generation );
-                                $( '.size div', current_type_element )
-                                    .html( data.indexSize );
-                                
-                                if( is_slave )
-                                {
-                                    var master_element = $( '.master', details_element );
-                                    $( '.version div', master_element )
-                                        .html( data.slave.masterDetails.indexVersion );
-                                    $( '.generation div', master_element )
-                                        .html( data.slave.masterDetails.generation );
-                                    $( '.size div', master_element )
-                                        .html( data.slave.masterDetails.indexSize );
-                                    
-                                    if( data.indexVersion !== data.slave.masterDetails.indexVersion )
-                                    {
-                                        $( '.version', details_element )
-                                            .addClass( 'diff' );
-                                    }
-                                    else
-                                    {
-                                        $( '.version', details_element )
-                                            .removeClass( 'diff' );
-                                    }
-                                    
-                                    if( data.generation !== data.slave.masterDetails.generation )
-                                    {
-                                        $( '.generation', details_element )
-                                            .addClass( 'diff' );
-                                    }
-                                    else
-                                    {
-                                        $( '.generation', details_element )
-                                            .removeClass( 'diff' );
-                                    }
-                                }
-
-                                if( is_slave )
-                                {
-                                    var settings_element = $( '#settings', replication_element );
-
-                                    if( data.slave.masterUrl )
-                                    {
-                                        $( '.masterUrl dd', settings_element )
-                                            .html( response.details.slave.masterUrl )
-                                            .parents( 'li' ).show();
-                                    }
-
-                                    var polling_content = '&nbsp;';
-                                    var polling_ico = 'ico-1';
-
-                                    if( 'true' === data.slave.isPollingDisabled )
-                                    {
-                                        polling_ico = 'ico-0';
-
-                                        $( '.disable-polling', navigation_element ).hide();
-                                        $( '.enable-polling', navigation_element ).show();
-                                    }
-                                    else
-                                    {
-                                        $( '.disable-polling', navigation_element ).show();
-                                        $( '.enable-polling', navigation_element ).hide();
-
-                                        if( data.slave.pollInterval )
-                                        {
-                                            polling_content = '(interval: ' + data.slave.pollInterval + ')';
-                                        }
-                                    }
-
-                                    $( '.isPollingDisabled dd', settings_element )
-                                        .removeClass( 'ico-0' )
-                                        .removeClass( 'ico-1' )
-                                        .addClass( polling_ico )
-                                        .html( polling_content )
-                                        .parents( 'li' ).show();
-                                }
-
-                                var master_settings_element = $( '#master-settings', replication_element );
-
-                                var master_data = is_slave
-                                                         ? data.slave.masterDetails.master
-                                                         : data.master;
-
-                                var replication_icon = 'ico-0';
-                                if( 'true' === master_data.replicationEnabled )
-                                {
-                                    replication_icon = 'ico-1';
-
-                                    $( '.disable-replication', navigation_element ).show();
-                                    $( '.enable-replication', navigation_element ).hide();
-                                }
-                                else
-                                {
-                                    $( '.disable-replication', navigation_element ).hide();
-                                    $( '.enable-replication', navigation_element ).show();
-                                }
-
-                                $( '.replicationEnabled dd', master_settings_element )
-                                    .removeClass( 'ico-0' )
-                                    .removeClass( 'ico-1' )
-                                    .addClass( replication_icon )
-                                    .parents( 'li' ).show();
-
-                                $( '.replicateAfter dd', master_settings_element )
-                                    .html( master_data.replicateAfter.join( ', ' ) )
-                                    .parents( 'li' ).show();
-
-                                if( master_data.confFiles )
-                                {
-                                    var conf_files = [];
-                                    var conf_data = master_data.confFiles.split( ',' );
-                                    
-                                    for( var i = 0; i < conf_data.length; i++ )
-                                    {
-                                        var item = conf_data[i];
-
-                                        if( - 1 !== item.indexOf( ':' ) )
-                                        {
-                                            info = item.split( ':' );
-                                            item = '<abbr title="' + info[0] + ' » ' + info[1] + '">'
-                                                 + ( is_slave ? info[1] : info[0] )
-                                                 + '</abbr>';
-                                        }
-
-                                        conf_files.push( item );
-                                    }
-
-                                    $( '.confFiles dd', master_settings_element )
-                                        .html( conf_files.join( ', ' ) )
-                                        .parents( 'li' ).show();
-                                }
-
-
-                                $( '.block', replication_element ).last()
-                                    .addClass( 'last' );
-                                
-
-
-
-                                if( 'true' === data.slave.isReplicating )
-                                {
-                                    replication_element
-                                        .addClass( 'replicating' );
-                                    
-                                    $( '.replicate-now', navigation_element ).hide();
-                                    $( '.abort-replication', navigation_element ).show();
-                                    
-                                    window.setTimeout( replication_fetch_status, 1000 );
-                                }
-                                else
-                                {
-                                    replication_element
-                                        .removeClass( 'replicating' );
-                                    
-                                    $( '.replicate-now', navigation_element ).show();
-                                    $( '.abort-replication', navigation_element ).hide();
-                                }
-                            },
-                            error : function( xhr, text_status, error_thrown )
-                            {
-                                $( '#content' )
-                                    .html( 'sorry, no replication-handler defined!' );
-                            },
-                            complete : function( xhr, text_status )
-                            {
-                            }
-                        }
-                    );
+                  next_tick = ( nextExecutionAt.getTime() - currentDate.getTime() ) / 1000;
+                  approx_element.hide();
+
+                  $( 'small', timer_element )
+                    .text( data.slave.nextExecutionAt )
+                    .show();
                 }
-                replication_fetch_status();
+              }
 
-                $( '#iterations a', content_element )
-                    .die( 'click' )
-                    .live
-                    (
-                        'click',
-                        function( event )
-                        {
-                            $( this ).parents( '.iterations' )
-                                .toggleClass( 'expanded' );
-                            
-                            return false;
-                        }
-                    );
-
-                $( 'button', navigation_element )
-                    .die( 'click' )
-                    .live
-                    (
-                        'click',
-                        function( event )
-                        {
-                            var button = $( this );
-                            var command = button.data( 'command' );
-
-                            if( button.hasClass( 'refresh-status' ) && !button.hasClass( 'loader' ) )
-                            {
-                                replication_fetch_status();
-                            }
-                            else if( command )
-                            {
-                                $.get
-                                (
-                                    core_basepath + '/replication?command=' + command + '&wt=json',
-                                    function()
-                                    {
-                                        replication_fetch_status();
-                                    }
-                                );
-                            }
-                            return false;
-                        }
-                    );
+              init_timer( next_tick );
+
+              timer_element
+                .show();
+            }
+          }
+        }
+
+        var master_settings_element = $( '#master-settings', replication_element );
+        var master_data = is_slave ? data.slave.masterDetails.master : data.master;
+
+        var replication_icon = 'ico-0';
+        if( 'true' === master_data.replicationEnabled )
+        {
+          replication_icon = 'ico-1';
+
+          $( '.disable-replication', navigation_element ).show();
+          $( '.enable-replication', navigation_element ).hide();
+        }
+        else
+        {
+          $( '.disable-replication', navigation_element ).hide();
+          $( '.enable-replication', navigation_element ).show();
+        }
+
+        $( '.replicationEnabled dd', master_settings_element )
+          .removeClass( 'ico-0' )
+          .removeClass( 'ico-1' )
+          .addClass( replication_icon )
+          .parents( 'li' ).show();
+
+        $( '.replicateAfter dd', master_settings_element )
+          .html( master_data.replicateAfter.join( ', ' ) )
+          .parents( 'li' ).show();
+
+        if( master_data.confFiles )
+        {
+          var conf_files = [];
+          var conf_data = master_data.confFiles.split( ',' );
+                    
+          for( var i = 0; i < conf_data.length; i++ )
+          {
+            var item = conf_data[i];
+
+            if( - 1 !== item.indexOf( ':' ) )
+            {
+              info = item.split( ':' );
+              item = '<abbr title="' + info[0] + ' » ' + info[1] + '">' + ( is_slave ? info[1] : info[0] ) + '</abbr>';
             }
-        );
+
+            conf_files.push( item );
+          }
+
+          $( '.confFiles dd', master_settings_element )
+            .html( conf_files.join( ', ' ) )
+            .parents( 'li' ).show();
+        }
+
+
+        $( '.block', replication_element ).last()
+          .addClass( 'last' );
+      },
+      error : function( xhr, text_status, error_thrown )
+      {
+        $( '#content' )
+          .html( 'sorry, no replication-handler defined!' );
+      },
+      complete : function( xhr, text_status )
+      {
+      }
     }
+  );
+}
+
+// #/:core/replication
+sammy.get
+(
+  /^#\/([\w\d-]+)\/(replication)$/,
+  function( context )
+  {
+    core_basepath = this.active_core.attr( 'data-basepath' );
+    var content_element = $( '#content' );
+        
+    $.get
+    (
+      'tpl/replication.html',
+      function( template )
+      {
+        content_element
+          .html( template );
+                
+        replication_element = $( '#replication', content_element );
+        navigation_element = $( '#navigation', replication_element );
+
+        replication_fetch_status();
+
+        $( '#iterations a', content_element )
+          .die( 'click' )
+          .live
+          (
+            'click',
+            function( event )
+            {
+              $( this ).parents( '.iterations' )
+                .toggleClass( 'expanded' );
+                            
+              return false;
+            }
+          );
+
+        $( 'button', navigation_element )
+          .die( 'click' )
+          .live
+          (
+            'click',
+            function( event )
+            {
+              var button = $( this );
+              var command = button.data( 'command' );
+
+              if( button.hasClass( 'refresh-status' ) && !button.hasClass( 'loader' ) )
+              {
+                replication_fetch_status();
+              }
+              else if( command )
+              {
+                $.get
+                (
+                  core_basepath + '/replication?command=' + command + '&wt=json',
+                  function()
+                  {
+                    replication_fetch_status();
+                  }
+                );
+              }
+              return false;
+            }
+          );
+      }
+    );
+  }
 );
\ No newline at end of file