1
0
Fork 0
mirror of https://github.com/gorhill/uMatrix.git synced 2024-06-03 02:44:57 +12:00

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

source:
* 02a79ea9fc
* 235d1266e8
* 3b41237e4b
This commit is contained in:
gorhill 2016-12-02 12:15:54 -05:00 committed by xofe
parent 9adc29318e
commit 396f4fc78e

View file

@ -50,18 +50,6 @@ var prettyRequestTypes = {
'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.
@ -220,6 +208,12 @@ var createHiddenTextNode = function(text) {
/******************************************************************************/
var padTo2 = function(v) {
return v < 10 ? '0' + v : v;
};
/******************************************************************************/
var createGap = function(tabId, url) {
var tr = createRow('1');
tr.classList.add('doc');
@ -276,9 +270,11 @@ var renderLogEntry = function(entry) {
}
// 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 ) {
tr.classList.add('tab');
@ -296,6 +292,10 @@ var renderLogEntry = function(entry) {
tbody.insertBefore(tr, tbody.firstChild);
};
// Reuse date objects.
var logDate = new Date(),
logDateTimezoneOffset = logDate.getTimezoneOffset() * 60000;
/******************************************************************************/
var renderLogEntries = function(response) {