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

Side by Side Diff: chrome/browser/resources/about_stats.js

Issue 10690137: Fix stats counters (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update Created 8 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/resources/about_stats.html ('k') | content/app/content_main_runner.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /* Counter accessor for Name Node. */ 5 /* Counter accessor for Name Node. */
6 function getCounterNameFromCounterNode(node) { 6 function getCounterNameFromCounterNode(node) {
7 return node.childNodes[1]; 7 return node.childNodes[1];
8 } 8 }
9 9
10 /* Counter accessor for Value Node. */ 10 /* Counter accessor for Value Node. */
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 var name = functionToGetNameNode(node).innerHTML.toLowerCase(); 44 var name = functionToGetNameNode(node).innerHTML.toLowerCase();
45 if (showAll || name.indexOf(text) >= 0) 45 if (showAll || name.indexOf(text) >= 0)
46 node.style.display = 'table-row'; 46 node.style.display = 'table-row';
47 else 47 else
48 node.style.display = 'none'; 48 node.style.display = 'none';
49 } 49 }
50 } 50 }
51 51
52 /* Hides or shows counters based on the user's current filter selection. */ 52 /* Hides or shows counters based on the user's current filter selection. */
53 function doFilter() { 53 function doFilter() {
54 var filter = document.getElementById('filter'); 54 var filter = $('filter');
55 var text = filter.value.toLowerCase(); 55 var text = filter.value.toLowerCase();
56 var nodes = document.getElementsByName('counter'); 56 var nodes = document.getElementsByName('counter');
57 filterMatching(text, nodes, getCounterNameFromCounterNode); 57 filterMatching(text, nodes, getCounterNameFromCounterNode);
58 var nodes = document.getElementsByName('timer'); 58 var nodes = document.getElementsByName('timer');
59 filterMatching(text, nodes, getTimerNameFromTimerNode); 59 filterMatching(text, nodes, getTimerNameFromTimerNode);
60 } 60 }
61 61
62 /* Colors the counters based on increasing or decreasing value. */ 62 /* Colors the counters based on increasing or decreasing value. */
63 function doColor() { 63 function doColor() {
64 var nodes = document.getElementsByName('counter'); 64 var nodes = document.getElementsByName('counter');
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 var avg = getTimerAvgTimeFromTimerNode(node); 101 var avg = getTimerAvgTimeFromTimerNode(node);
102 avg.innerHTML = Math.round(time / count * 100) / 100; 102 avg.innerHTML = Math.round(time / count * 100) / 100;
103 } 103 }
104 } 104 }
105 } 105 }
106 106
107 /* All the work we do onload. */ 107 /* All the work we do onload. */
108 function onLoadWork() { 108 function onLoadWork() {
109 // This is the javascript code that processes the template: 109 // This is the javascript code that processes the template:
110 var input = new JsEvalContext(templateData); 110 var input = new JsEvalContext(templateData);
111 var output = document.getElementById('t'); 111 var output = $('t');
112 jstProcess(input, output); 112 jstProcess(input, output);
113 113
114 // Add handlers to dynamically created HTML elements. 114 // Add handlers to dynamically created HTML elements.
115 var elements = document.getElementsByName('string-sort'); 115 var elements = document.getElementsByName('string-sort');
116 for (var i = 0; i < elements.length; ++i) 116 for (var i = 0; i < elements.length; ++i)
117 elements[i].onclick = function() { sort_table('string'); }; 117 elements[i].onclick = function() { sort_table('string'); };
118 118
119 elements = document.getElementsByName('number-sort'); 119 elements = document.getElementsByName('number-sort');
120 for (i = 0; i < elements.length; ++i) 120 for (i = 0; i < elements.length; ++i)
121 elements[i].onclick = function() { sort_table('number'); }; 121 elements[i].onclick = function() { sort_table('number'); };
122 122
123 doColor(); 123 doColor();
124 removeNullValues(); 124 removeNullValues();
125 computeTimes(); 125 computeTimes();
126 document.getElementById('filter').focus(); 126
127 var filter = $('filter');
128 filter.onkeyup = doFilter;
129 filter.focus();
127 } 130 }
128 131
129 // The function should only be used as the event handler 132 // The function should only be used as the event handler
130 // on a table cell element. To use it, put it in a <td> element: 133 // on a table cell element. To use it, put it in a <td> element:
131 // <td onclick="sort('string')" ...> 134 // <td onclick="sort('string')" ...>
132 // 135 //
133 // The function sorts rows after the row with onclick event handler. 136 // The function sorts rows after the row with onclick event handler.
134 // 137 //
135 // type: the data type, 'string', 'number' 138 // type: the data type, 'string', 'number'
136 function sort_table(type) { 139 function sort_table(type) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 tbody.appendChild(rows[i]); 191 tbody.appendChild(rows[i]);
189 cell._reverse = false; 192 cell._reverse = false;
190 } else { 193 } else {
191 for (var i = 0; i < rows.length; i++) 194 for (var i = 0; i < rows.length; i++)
192 tbody.appendChild(rows[i]); 195 tbody.appendChild(rows[i]);
193 cell._reverse = true; 196 cell._reverse = true;
194 } 197 }
195 } 198 }
196 199
197 document.addEventListener('DOMContentLoaded', onLoadWork); 200 document.addEventListener('DOMContentLoaded', onLoadWork);
OLDNEW
« no previous file with comments | « chrome/browser/resources/about_stats.html ('k') | content/app/content_main_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698