Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(410)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/console/ConsoleViewMessage.js

Issue 2683713004: DevTools: revert of timestamp format dropdown (Closed)
Patch Set: wrong upstream Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 3 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
4 * Copyright (C) 2009 Joseph Pecoraro 4 * Copyright (C) 2009 Joseph Pecoraro
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 */ 827 */
828 matchesFilterText(filter) { 828 matchesFilterText(filter) {
829 var text = this.contentElement().deepTextContent(); 829 var text = this.contentElement().deepTextContent();
830 return text.toLowerCase().includes(filter.toLowerCase()); 830 return text.toLowerCase().includes(filter.toLowerCase());
831 } 831 }
832 832
833 updateTimestamp() { 833 updateTimestamp() {
834 if (!this._contentElement) 834 if (!this._contentElement)
835 return; 835 return;
836 836
837 var format = Common.moduleSetting('consoleTimestampFormat').get(); 837 if (Common.moduleSetting('consoleTimestampsEnabled').get()) {
838 if (format !== Console.ConsoleViewMessage.TimestampFormat.None) {
839 var timestampText = formatTimestamp(this._message.timestamp, format);
840 if (!this._timestampElement) 838 if (!this._timestampElement)
841 this._timestampElement = createElementWithClass('span', 'console-timesta mp'); 839 this._timestampElement = createElementWithClass('span', 'console-timesta mp');
842 this._timestampElement.textContent = timestampText + ' '; 840 this._timestampElement.textContent = formatTimestamp(this._message.timesta mp, false) + ' ';
843 this._timestampElement.title = timestampText; 841 this._timestampElement.title = formatTimestamp(this._message.timestamp, tr ue);
844 this._contentElement.insertBefore(this._timestampElement, this._contentEle ment.firstChild); 842 this._contentElement.insertBefore(this._timestampElement, this._contentEle ment.firstChild);
845 } else if (this._timestampElement) { 843 } else if (this._timestampElement) {
846 this._timestampElement.remove(); 844 this._timestampElement.remove();
847 delete this._timestampElement; 845 delete this._timestampElement;
848 } 846 }
849 847
850 /** 848 /**
851 * @param {number} timestamp 849 * @param {number} timestamp
852 * @param {!Console.ConsoleViewMessage.TimestampFormat} format 850 * @param {boolean} full
853 * @return {string} 851 * @return {string}
854 */ 852 */
855 function formatTimestamp(timestamp, format) { 853 function formatTimestamp(timestamp, full) {
856 var date = new Date(timestamp); 854 var date = new Date(timestamp);
857 var yymmdd = date.getFullYear() + '-' + leadZero(date.getMonth() + 1, 2) + '-' + leadZero(date.getDate(), 2); 855 var yymmdd = date.getFullYear() + '-' + leadZero(date.getMonth() + 1, 2) + '-' + leadZero(date.getDate(), 2);
858 var hhmmssfff = leadZero(date.getHours(), 2) + ':' + leadZero(date.getMinu tes(), 2) + ':' + 856 var hhmmssfff = leadZero(date.getHours(), 2) + ':' + leadZero(date.getMinu tes(), 2) + ':' +
859 leadZero(date.getSeconds(), 2) + '.' + leadZero(date.getMilliseconds() , 3); 857 leadZero(date.getSeconds(), 2) + '.' + leadZero(date.getMilliseconds() , 3);
860 if (format === Console.ConsoleViewMessage.TimestampFormat.Full) 858 return full ? (yymmdd + ' ' + hhmmssfff) : hhmmssfff;
861 return yymmdd + ' ' + hhmmssfff;
862 return hhmmssfff;
863 859
864 /** 860 /**
865 * @param {number} value 861 * @param {number} value
866 * @param {number} length 862 * @param {number} length
867 * @return {string} 863 * @return {string}
868 */ 864 */
869 function leadZero(value, length) { 865 function leadZero(value, length) {
870 var valueString = value.toString(); 866 var valueString = value.toString();
871 var padding = length - valueString.length; 867 var padding = length - valueString.length;
872 return padding <= 0 ? valueString : '0'.repeat(padding) + valueString; 868 return padding <= 0 ? valueString : '0'.repeat(padding) + valueString;
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
1205 } 1201 }
1206 1202
1207 if (start !== string.length) 1203 if (start !== string.length)
1208 formattedResult.appendChild(Components.linkifyStringAsFragment(string.subs tring(start))); 1204 formattedResult.appendChild(Components.linkifyStringAsFragment(string.subs tring(start)));
1209 1205
1210 return formattedResult; 1206 return formattedResult;
1211 } 1207 }
1212 }; 1208 };
1213 1209
1214 /** 1210 /**
1215 * @enum {string}
1216 */
1217 Console.ConsoleViewMessage.TimestampFormat = {
1218 None: 'none',
1219 Full: 'full',
1220 Short: 'short'
1221 };
1222
1223 /**
1224 * @unrestricted 1211 * @unrestricted
1225 */ 1212 */
1226 Console.ConsoleGroupViewMessage = class extends Console.ConsoleViewMessage { 1213 Console.ConsoleGroupViewMessage = class extends Console.ConsoleViewMessage {
1227 /** 1214 /**
1228 * @param {!SDK.ConsoleMessage} consoleMessage 1215 * @param {!SDK.ConsoleMessage} consoleMessage
1229 * @param {!Components.Linkifier} linkifier 1216 * @param {!Components.Linkifier} linkifier
1230 * @param {number} nestingLevel 1217 * @param {number} nestingLevel
1231 */ 1218 */
1232 constructor(consoleMessage, linkifier, nestingLevel) { 1219 constructor(consoleMessage, linkifier, nestingLevel) {
1233 console.assert(consoleMessage.isGroupStartMessage()); 1220 console.assert(consoleMessage.isGroupStartMessage());
(...skipping 26 matching lines...) Expand all
1260 toMessageElement() { 1247 toMessageElement() {
1261 if (!this._element) { 1248 if (!this._element) {
1262 super.toMessageElement(); 1249 super.toMessageElement();
1263 this._expandGroupIcon = UI.Icon.create('', 'expand-group-icon'); 1250 this._expandGroupIcon = UI.Icon.create('', 'expand-group-icon');
1264 this._contentElement.insertBefore(this._expandGroupIcon, this._contentElem ent.firstChild); 1251 this._contentElement.insertBefore(this._expandGroupIcon, this._contentElem ent.firstChild);
1265 this.setCollapsed(this._collapsed); 1252 this.setCollapsed(this._collapsed);
1266 } 1253 }
1267 return this._element; 1254 return this._element;
1268 } 1255 }
1269 }; 1256 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698