Skip to content

Commit

Permalink
Removed "source" column from ajax panel table to provide more space
Browse files Browse the repository at this point in the history
  • Loading branch information
jellysandwich committed Mar 18, 2012
1 parent 289170d commit 422d70b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions yii-debug-toolbar/panels/YiiDebugToolbarPanelLogging.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public function getMenuTitle()
{
$time = round(Yii::getLogger()->getExecutionTime(),2);
$mem = round(Yii::getLogger()->getMemoryUsage()/1048576,1);

return "<span>$time</span>s / <span>$mem</span>mb";
}

Expand Down
20 changes: 10 additions & 10 deletions yii-debug-toolbar/views/panels/ajax.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

<h4>jQuery <script type="text/javascript">document.write(jQuery.fn.jquery);</script></h4>
<table id="yii-debug-toolbar-ajax-response">
<thead>
<tr>
<th>#</th>
<th><?php echo YiiDebug::t("Source"); ?></th>
<th><?php echo YiiDebug::t("Status"); ?></th>
<th><?php echo YiiDebug::t("Url"); ?></th>
<th><?php echo YiiDebug::t("Response"); ?></th>
Expand All @@ -13,15 +13,16 @@


<script type="text/javascript">
"use strict";

/**
* Encodes html string to display in log
* @param s
*/
function HtmlEncode(s) {
function htmlEncode(s) {
var el = document.createElement("div");
el.innerText = el.textContent = s;
s = el.innerHTML;
delete el;
return s;
}

Expand All @@ -31,24 +32,23 @@ function HtmlEncode(s) {
$('#yii-debug-toolbar').on("ajaxComplete", function(event, xmlrequest, ajaxOptions){
// compute text to put into response td
// html encode it, remove extra spaces and new lines, and reduce to 100 characters
var $text = HtmlEncode(xmlrequest.responseText).replace(/[\s\n\r]+/g, ' ').substr(0,100);
var $text = htmlEncode(xmlrequest.responseText).replace(/[\s\n\r]+/g, ' ').substr(0,200);

// add a new row to ajax table
$('#yii-debug-toolbar-ajax-response').append(
'<tr class="even">' +
'<td class="hilight">' + $('#yii-debug-toolbar-ajax-response tr').size() +'<\/td>' +
'<td class="hilight">jQuery ' + jQuery.fn.jquery + '<\/td>' +
'<td class="hilight">' + xmlrequest.statusText + ' (' + xmlrequest.status + ')<\/td>' +
'<td class="hilight">' + ajaxOptions.url + '<\/td>' +
'<td class="hilight">' + $text + '<\/td>' +
'<td>' + $('#yii-debug-toolbar-ajax-response tr').size() +'<\/td>' +
'<td>' + xmlrequest.statusText + ' (' + xmlrequest.status + ')<\/td>' +
'<td>' + ajaxOptions.url + '<\/td>' +
'<td>' + $text + '<\/td>' +
'<\/tr>'
);

// stripe table
$('#yii-debug-toolbar-ajax-response tbody tr:nth-child(even)').attr('class', 'odd');

// update count in toolbar
var currentNum = parseInt($('span#num_ajax').html());
var currentNum = parseInt($('span#num_ajax').html(), 10);
$('span#num_ajax').html(currentNum + 1);

});
Expand Down

0 comments on commit 422d70b

Please sign in to comment.