[7588] | 1 | /* |
---|
| 2 | Licensed to the Apache Software Foundation (ASF) under one or more |
---|
| 3 | contributor license agreements. See the NOTICE file distributed with |
---|
| 4 | this work for additional information regarding copyright ownership. |
---|
| 5 | The ASF licenses this file to You under the Apache License, Version 2.0 |
---|
| 6 | (the "License"); you may not use this file except in compliance with |
---|
| 7 | the License. You may obtain a copy of the License at |
---|
| 8 | |
---|
| 9 | http://www.apache.org/licenses/LICENSE-2.0 |
---|
| 10 | |
---|
| 11 | Unless required by applicable law or agreed to in writing, software |
---|
| 12 | distributed under the License is distributed on an "AS IS" BASIS, |
---|
| 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
| 14 | See the License for the specific language governing permissions and |
---|
| 15 | limitations under the License. |
---|
| 16 | */ |
---|
| 17 | |
---|
| 18 | $( '.ping a', app.menu_element ) |
---|
| 19 | .live |
---|
| 20 | ( |
---|
| 21 | 'click', |
---|
| 22 | function( event ) |
---|
| 23 | { |
---|
| 24 | $.ajax |
---|
| 25 | ( |
---|
| 26 | { |
---|
| 27 | url : $( this ).attr( 'rel' ) + '?wt=json&ts=' + (new Date).getTime(), |
---|
| 28 | dataType : 'json', |
---|
| 29 | context: this, |
---|
| 30 | beforeSend : function( arr, form, options ) |
---|
| 31 | { |
---|
| 32 | loader.show( this ); |
---|
| 33 | }, |
---|
| 34 | success : function( response, text_status, xhr ) |
---|
| 35 | { |
---|
| 36 | $( this ) |
---|
| 37 | .removeAttr( 'title' ); |
---|
| 38 | |
---|
| 39 | $( this ).parents( 'li' ) |
---|
| 40 | .removeClass( 'error' ); |
---|
| 41 | |
---|
| 42 | var qtime_element = $( '.qtime', this ); |
---|
| 43 | |
---|
| 44 | if( 0 === qtime_element.size() ) |
---|
| 45 | { |
---|
| 46 | qtime_element = $( '<small class="qtime"> (<span></span>)</small>' ); |
---|
| 47 | |
---|
| 48 | $( this ) |
---|
| 49 | .append( qtime_element ); |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | $( 'span', qtime_element ) |
---|
| 53 | .html( response.responseHeader.QTime + 'ms' ); |
---|
| 54 | }, |
---|
| 55 | error : function( xhr, text_status, error_thrown ) |
---|
| 56 | { |
---|
| 57 | $( this ) |
---|
| 58 | .attr( 'title', '/admin/ping is not configured (' + xhr.status + ': ' + error_thrown + ')' ); |
---|
| 59 | |
---|
| 60 | $( this ).parents( 'li' ) |
---|
| 61 | .addClass( 'error' ); |
---|
| 62 | }, |
---|
| 63 | complete : function( xhr, text_status ) |
---|
| 64 | { |
---|
| 65 | loader.hide( this ); |
---|
| 66 | } |
---|
| 67 | } |
---|
| 68 | ); |
---|
| 69 | |
---|
| 70 | return false; |
---|
| 71 | } |
---|
| 72 | ); |
---|