Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions src/main/resources/au/com/funkworks/jmp/mini_profiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ var MiniProfiler = ( function() {
function init( options ) {
baseURL = options.baseURL;

$( document.body ).append( '<div id="@@prefix@@" style="display: none;"></div><div id="@@prefix@@-req" style="display: none;"></div>' );
jQuery( document.body ).append( '<div id="@@prefix@@" style="display: none;"></div><div id="@@prefix@@-req" style="display: none;"></div>' );

// Initialize the HTML templates
$.template( 'requestTemplate', $( '#@@prefix@@-request-tmpl' ).html() );
$.template( 'resultTemplate', $( '#@@prefix@@-result-tmpl' ).html() );
$.template( 'resultTreeTemplate', $( '#@@prefix@@-result-tree-tmpl' ).html() );
jQuery.template( 'requestTemplate', jQuery( '#@@prefix@@-request-tmpl' ).html() );
jQuery.template( 'resultTemplate', jQuery( '#@@prefix@@-result-tmpl' ).html() );
jQuery.template( 'resultTreeTemplate', jQuery( '#@@prefix@@-result-tree-tmpl' ).html() );

var requestIds = getRedirectRequests( window.location.href );
requestIds.push( options.requestId );
getProfileInformation( requestIds, 'normal' );

// Dynamically add profile information for any Ajax requets that happen on
// this page
$( document ).ajaxComplete( function( e, xhr, settings ) {
jQuery( document ).ajaxComplete( function( e, xhr, settings ) {
if ( xhr ) {
var requestId = xhr.getResponseHeader( 'X-Mini-Profile-Request-Id' );
if ( requestId ) {
Expand All @@ -30,7 +30,7 @@ var MiniProfiler = ( function() {
} );

// Display profile details when one of the request times is clicked on
$( '#@@prefix@@' ).delegate( 'a', 'click', displayProfileDetails );
jQuery( '#@@prefix@@' ).delegate( 'a', 'click', displayProfileDetails );
}

/**
Expand All @@ -55,7 +55,7 @@ var MiniProfiler = ( function() {
* Get profile information for the specified request id via an Ajax request.
*/
function getProfileInformation( requestIds, type, callback ) {
$.get( baseURL + 'results', {
jQuery.get( baseURL + 'results', {
ids : requestIds.join( ',' )
}, function( data ) {
if ( data.ok ) {
Expand All @@ -67,7 +67,7 @@ var MiniProfiler = ( function() {
// Store the request data for later
requestData[ '@@prefix@@-req-' + request.id ] = request;
// Add the request to the display
$( '#@@prefix@@' ).show().append( $.tmpl( 'requestTemplate', {
jQuery( '#@@prefix@@' ).show().append( jQuery.tmpl( 'requestTemplate', {
type : request.redirect ? 'redirect' : type, requestId : request.id, totalTime : ( request.profile.duration / 1000000 ).toFixed( 2 )
} ) );
}
Expand All @@ -85,13 +85,13 @@ var MiniProfiler = ( function() {
function toggleLinkDetails( e ) {
e.preventDefault();
e.stopPropagation();
var el = $( this );
var el = jQuery( this );
if ( el.hasClass( 'expand' ) ) {
$( '#' + this.id + '-d' ).slideDown();
jQuery( '#' + this.id + '-d' ).slideDown();
el.removeClass( 'expand' ).addClass( 'collapse' );
}
else {
$( '#' + this.id + '-d' ).slideUp();
jQuery( '#' + this.id + '-d' ).slideUp();
el.removeClass( 'collapse' ).addClass( 'expand' );
}
}
Expand All @@ -103,9 +103,9 @@ var MiniProfiler = ( function() {
e.preventDefault();
e.stopPropagation();
var data = requestData[ this.id ];
var resultDiv = $( '#@@prefix@@-req' );
var resultDiv = jQuery( '#@@prefix@@-req' );
resultDiv.undelegate();
resultDiv.html( $.tmpl( 'resultTemplate', data ) ).slideDown();
resultDiv.html( jQuery.tmpl( 'resultTemplate', data ) ).slideDown();
resultDiv.delegate( '#@@prefix@@-req-close', 'click', function( e ) {
e.preventDefault();
e.stopPropagation();
Expand Down