Skip to content

Commit

Permalink
Updating in real time the amount of xhr requests done in the history …
Browse files Browse the repository at this point in the history
…panel
  • Loading branch information
lorenzo committed Apr 26, 2015
1 parent 92a6e6b commit 10a97a9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/Panel/HistoryPanel.php
Expand Up @@ -37,4 +37,14 @@ public function data()
'requests' => $recent->toArray(),
];
}

/**
* Gets the initial text for the history summary
*
* @return string
*/
public function summary()
{
return '0 xhr';
}
}
7 changes: 6 additions & 1 deletion webroot/js/toolbar-app.js
Expand Up @@ -224,10 +224,15 @@ Toolbar.prototype = {

onMessage: function(event) {
if (event.data.startsWith('ajax-completed$$')) {
this.ajaxRequests.push(JSON.parse(event.data.split('$$')[1]));
this.onRequest(JSON.parse(event.data.split('$$')[1]))
}
},

onRequest: function(request) {
this.ajaxRequests.push(request);
$(".panel-summary:contains(xhr)").text("" + this.ajaxRequests.length + ' xhr');
},

initialize: function() {
this.windowOrigin();
this.mouseListener();
Expand Down

0 comments on commit 10a97a9

Please sign in to comment.