Browse Source

avoid CPU-costly Date.toLocale(Date|Time)String() in logger page

source:
* 02a79ea9fc
* 235d1266e8
* 3b41237e4b
pull/2/head
gorhill 8 years ago
committed by xofe
parent
commit
396f4fc78e
  1. 30
      src/js/logger-ui.js

30
src/js/logger-ui.js

@ -50,18 +50,6 @@ var prettyRequestTypes = {
'xmlhttprequest': 'xhr' 'xmlhttprequest': 'xhr'
}; };
var timeOptions = {
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
hour12: false
};
var dateOptions = {
month: 'short',
day: '2-digit'
};
/******************************************************************************/ /******************************************************************************/
// Adjust top padding of content table, to match that of toolbar height. // Adjust top padding of content table, to match that of toolbar height.
@ -220,6 +208,12 @@ var createHiddenTextNode = function(text) {
/******************************************************************************/ /******************************************************************************/
var padTo2 = function(v) {
return v < 10 ? '0' + v : v;
};
/******************************************************************************/
var createGap = function(tabId, url) { var createGap = function(tabId, url) {
var tr = createRow('1'); var tr = createRow('1');
tr.classList.add('doc'); tr.classList.add('doc');
@ -276,9 +270,11 @@ var renderLogEntry = function(entry) {
} }
// Fields common to all rows. // Fields common to all rows.
var time = new Date(entry.tstamp);
tr.cells[0].textContent = time.toLocaleTimeString('fullwide', timeOptions);
tr.cells[0].title = time.toLocaleDateString('fullwide', dateOptions);
var time = logDate;
time.setTime(entry.tstamp - logDateTimezoneOffset);
tr.cells[0].textContent = padTo2(time.getUTCHours()) + ':' +
padTo2(time.getUTCMinutes()) + ':' +
padTo2(time.getSeconds());
if ( entry.tab ) { if ( entry.tab ) {
tr.classList.add('tab'); tr.classList.add('tab');
@ -296,6 +292,10 @@ var renderLogEntry = function(entry) {
tbody.insertBefore(tr, tbody.firstChild); tbody.insertBefore(tr, tbody.firstChild);
}; };
// Reuse date objects.
var logDate = new Date(),
logDateTimezoneOffset = logDate.getTimezoneOffset() * 60000;
/******************************************************************************/ /******************************************************************************/
var renderLogEntries = function(response) { var renderLogEntries = function(response) {

Loading…
Cancel
Save