OLD | NEW |
---|---|
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 /** | 5 /** |
6 * Javascript for omnibox.html, served from chrome://omnibox/ | 6 * Javascript for omnibox.html, served from chrome://omnibox/ |
7 * This is used to debug omnibox ranking. The user enters some text | 7 * This is used to debug omnibox ranking. The user enters some text |
8 * into a box, submits it, and then sees lots of debug information | 8 * into a box, submits it, and then sees lots of debug information |
9 * from the autocompleter that shows what omnibox would do with that | 9 * from the autocompleter that shows what omnibox would do with that |
10 * input. | 10 * input. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
56 /** | 56 /** |
57 * Returns a simple object with information about how to display an | 57 * Returns a simple object with information about how to display an |
58 * autocomplete result data field. | 58 * autocomplete result data field. |
59 * @param {string} header the label for the top of the column/table. | 59 * @param {string} header the label for the top of the column/table. |
60 * @param {string} urlLabelForHeader the URL that the header should point | 60 * @param {string} urlLabelForHeader the URL that the header should point |
61 * to (if non-empty). | 61 * to (if non-empty). |
62 * @param {string} propertyName the name of the property in the autocomplete | 62 * @param {string} propertyName the name of the property in the autocomplete |
63 * result record that we lookup. | 63 * result record that we lookup. |
64 * @param {boolean} displayAlways whether the property should be displayed | 64 * @param {boolean} displayAlways whether the property should be displayed |
65 * regardless of whether we're in detailed more. | 65 * regardless of whether we're in detailed more. |
66 * @param {string} tooltip a description of the property that will be | |
67 * presented as a tooltip when the mouse is hovered over the column title. | |
66 * @constructor | 68 * @constructor |
67 */ | 69 */ |
68 function PresentationInfoRecord(header, url, propertyName, displayAlways) { | 70 function PresentationInfoRecord(header, url, propertyName, displayAlways, |
71 tooltip) { | |
69 this.header = header; | 72 this.header = header; |
70 this.urlLabelForHeader = url; | 73 this.urlLabelForHeader = url; |
71 this.propertyName = propertyName; | 74 this.propertyName = propertyName; |
72 this.displayAlways = displayAlways; | 75 this.displayAlways = displayAlways; |
76 this.tooltip = tooltip; | |
73 } | 77 } |
74 | 78 |
75 /** | 79 /** |
76 * A constant that's used to decide what autocomplete result | 80 * A constant that's used to decide what autocomplete result |
77 * properties to output in what order. This is an array of | 81 * properties to output in what order. This is an array of |
78 * PresentationInfoRecord() objects; for details see that | 82 * PresentationInfoRecord() objects; for details see that |
79 * function. | 83 * function. |
80 * @type {Array.<Object>} | 84 * @type {Array.<Object>} |
81 * @const | 85 * @const |
82 */ | 86 */ |
83 var PROPERTY_OUTPUT_ORDER = [ | 87 var PROPERTY_OUTPUT_ORDER = [ |
84 new PresentationInfoRecord('Provider', '', 'provider_name', true), | 88 new PresentationInfoRecord('Provider', '', 'provider_name', true, |
85 new PresentationInfoRecord('Type', '', 'type', true), | 89 'The AutocompleteProvider suggesting this result.'), |
86 new PresentationInfoRecord('Relevance', '', 'relevance', true), | 90 new PresentationInfoRecord('Type', '', 'type', true, |
87 new PresentationInfoRecord('Contents', '', 'contents', true), | 91 'The type of the result.'), |
88 new PresentationInfoRecord('Starred', '', 'starred', false), | 92 new PresentationInfoRecord('Relevance', '', 'relevance', true, |
93 'The result score. Higher is more relevant.'), | |
94 new PresentationInfoRecord('Contents', '', 'contents', true, | |
95 'The text that is presented identifying the result.'), | |
96 new PresentationInfoRecord('Starred', '', 'starred', false, | |
97 'If checked the result has been bookmarked.'), | |
Mark P
2012/07/10 19:41:12
Optional nit: sometimes below the tooltips are
If
mrossetti
2012/07/14 02:34:06
Done.
| |
89 new PresentationInfoRecord( | 98 new PresentationInfoRecord( |
90 'Is History What You Typed Match', '', | 99 'HWYT', '', 'is_history_what_you_typed_match', false, |
91 'is_history_what_you_typed_match', false), | 100 'If checked the result is an History What You Typed Match'), |
92 new PresentationInfoRecord('Description', '', 'description', false), | 101 new PresentationInfoRecord('Description', '', 'description', false, |
93 new PresentationInfoRecord('URL', '', 'destination_url', true), | 102 'The page title or suggestion provider name.'), |
Mark P
2012/07/10 19:41:12
This doesn't seem accurate.
mrossetti
2012/07/14 02:34:06
Fixed.
| |
94 new PresentationInfoRecord('Fill Into Edit', '', 'fill_into_edit', false), | 103 new PresentationInfoRecord('URL', '', 'destination_url', true, |
104 'The URL for the result.'), | |
105 new PresentationInfoRecord('Fill Into Edit', '', 'fill_into_edit', false, | |
106 'The text shown in the omnibox when the suggestion is selected.'), | |
95 new PresentationInfoRecord( | 107 new PresentationInfoRecord( |
96 'Inline Autocomplete Offset', '', 'inline_autocomplete_offset', false), | 108 'IAO', '', 'inline_autocomplete_offset', false, |
97 new PresentationInfoRecord('Deletable', '', 'deletable', false), | 109 'The Inline Autocomplete Offset.'), |
98 new PresentationInfoRecord('From Previous', '', 'from_previous', false), | 110 new PresentationInfoRecord('Del', '', 'deletable', false, |
111 'Checked when the results can be deleted from the visit history.'), | |
112 new PresentationInfoRecord('Prev', '', 'from_previous', false, | |
113 'A green checkmkark indicates that the result was'), | |
Mark P
2012/07/10 19:41:12
This doesn't actually say much of anything.
mrossetti
2012/07/14 02:34:06
I actually don't know what this column means so I
| |
99 new PresentationInfoRecord( | 114 new PresentationInfoRecord( |
100 'Transition Type', | 115 'Tran', |
101 'http://code.google.com/codesearch#OAMlx_jo-ck/src/content/public/' + | 116 'http://code.google.com/codesearch#OAMlx_jo-ck/src/content/public/' + |
102 'common/page_transition_types.h&exact_package=chromium&l=24', | 117 'common/page_transition_types.h&exact_package=chromium&l=24', |
103 'transition', false), | 118 'transition', false, |
119 'How the user got to the result.'), | |
104 new PresentationInfoRecord( | 120 new PresentationInfoRecord( |
105 'Is This Provider Done', '', 'provider_done', false), | 121 'Done', '', 'provider_done', false, |
122 'Checked when the provider is done looking for more suggestions.'), | |
106 new PresentationInfoRecord( | 123 new PresentationInfoRecord( |
107 'Template URL', '', 'template_url', false) | 124 'Template URL', '', 'template_url', false, ''), |
125 new PresentationInfoRecord( | |
126 'Diagnostics', '', 'diagnostics', false, | |
127 'Provider-specific information about each suggestion.') | |
Mark P
2012/07/10 19:41:12
I'd prefer result instead of suggestion here.
Act
mrossetti
2012/07/14 02:34:06
Done.
| |
108 ]; | 128 ]; |
109 | 129 |
110 /** | 130 /** |
111 * Returns an HTML Element of type table row that contains the | 131 * Returns an HTML Element of type table row that contains the |
112 * headers we'll use for labeling the columns. If we're in | 132 * headers we'll use for labeling the columns. If we're in |
113 * detailed_mode, we use all the headers. If not, we only use ones | 133 * detailed_mode, we use all the headers. If not, we only use ones |
114 * marked displayAlways. | 134 * marked displayAlways. |
115 */ | 135 */ |
116 function createAutocompleteResultTableHeader() { | 136 function createAutocompleteResultTableHeader() { |
117 var row = document.createElement('tr'); | 137 var row = document.createElement('tr'); |
118 var inDetailedMode = $('show-details').checked; | 138 var inDetailedMode = $('show-details').checked; |
119 for (var i = 0; i < PROPERTY_OUTPUT_ORDER.length; i++) { | 139 for (var i = 0; i < PROPERTY_OUTPUT_ORDER.length; i++) { |
120 if (inDetailedMode || PROPERTY_OUTPUT_ORDER[i].displayAlways) { | 140 if (inDetailedMode || PROPERTY_OUTPUT_ORDER[i].displayAlways) { |
121 var headerCell = document.createElement('th'); | 141 var headerCell = document.createElement('th'); |
122 if (PROPERTY_OUTPUT_ORDER[i].urlLabelForHeader != '') { | 142 if (PROPERTY_OUTPUT_ORDER[i].urlLabelForHeader != '') { |
123 // Wrap header text in URL. | 143 // Wrap header text in URL. |
124 var linkNode = document.createElement('a'); | 144 var linkNode = document.createElement('a'); |
125 linkNode.href = PROPERTY_OUTPUT_ORDER[i].urlLabelForHeader; | 145 linkNode.href = PROPERTY_OUTPUT_ORDER[i].urlLabelForHeader; |
126 linkNode.textContent = PROPERTY_OUTPUT_ORDER[i].header; | 146 linkNode.textContent = PROPERTY_OUTPUT_ORDER[i].header; |
127 headerCell.appendChild(linkNode); | 147 headerCell.appendChild(linkNode); |
128 } else { | 148 } else { |
129 // Output header text without a URL. | 149 // Output header text without a URL. |
130 headerCell.textContent = PROPERTY_OUTPUT_ORDER[i].header; | 150 headerCell.textContent = PROPERTY_OUTPUT_ORDER[i].header; |
131 headerCell.className = 'table-header'; | 151 headerCell.className = 'table-header'; |
152 headerCell.title = PROPERTY_OUTPUT_ORDER[i].tooltip; | |
132 } | 153 } |
133 row.appendChild(headerCell); | 154 row.appendChild(headerCell); |
134 } | 155 } |
135 } | 156 } |
136 return row; | 157 return row; |
137 } | 158 } |
138 | 159 |
139 /** | 160 /** |
140 * @param {Object} autocompleteSuggestion the particular autocomplete | 161 * @param {Object} autocompleteSuggestion the particular autocomplete |
141 * suggestion we're in the process of displaying. | 162 * suggestion we're in the process of displaying. |
142 * @param {string} propertyName the particular property of the autocomplete | 163 * @param {string} propertyName the particular property of the autocomplete |
143 * suggestion that should go in this cell. | 164 * suggestion that should go in this cell. |
144 * @return {HTMLTableCellElement} that contains the value within this | 165 * @return {HTMLTableCellElement} that contains the value within this |
145 * autocompleteSuggestion associated with propertyName. | 166 * autocompleteSuggestion associated with propertyName. |
146 */ | 167 */ |
147 function createCellForPropertyAndRemoveProperty(autocompleteSuggestion, | 168 function createCellForPropertyAndRemoveProperty(autocompleteSuggestion, |
148 propertyName) { | 169 propertyName) { |
149 var cell = document.createElement('td'); | 170 var cell = document.createElement('td'); |
150 if (propertyName in autocompleteSuggestion) { | 171 if (propertyName in autocompleteSuggestion) { |
151 if (typeof autocompleteSuggestion[propertyName] == 'boolean') { | 172 if (propertyName == 'diagnostics') { |
173 // |diagnostics| presents a two-column table of provider-specific data. | |
Mark P
2012/07/10 19:41:12
Perhaps:
presents -> embeds
and append:
within thi
mrossetti
2012/07/14 02:34:06
Done.
| |
174 var diagnostic_table = document.createElement('table'); | |
175 for (var diagnostic_key in autocompleteSuggestion[propertyName]) { | |
176 var diagnostic_row = document.createElement('tr'); | |
177 var property_cell = document.createElement('td'); | |
178 property_cell.textContent = diagnostic_key + ':'; | |
Mark P
2012/07/10 19:41:12
Does the ':' add to readability of the table?
mrossetti
2012/07/14 02:34:06
Yes.
| |
179 property_cell.className = 'diagnostic-property'; | |
180 diagnostic_row.appendChild(property_cell); | |
181 var value_cell = document.createElement('td'); | |
182 value_cell.textContent = | |
183 autocompleteSuggestion[propertyName][diagnostic_key]; | |
184 value_cell.className = 'diagnostic-value'; | |
185 diagnostic_row.appendChild(value_cell); | |
186 diagnostic_table.appendChild(diagnostic_row); | |
187 } | |
188 cell.appendChild(diagnostic_table); | |
189 } else if (typeof autocompleteSuggestion[propertyName] == 'boolean') { | |
152 // If this is a boolean, display a checkmark or an X instead of | 190 // If this is a boolean, display a checkmark or an X instead of |
153 // the strings true or false. | 191 // the strings true or false. |
154 if (autocompleteSuggestion[propertyName]) { | 192 if (autocompleteSuggestion[propertyName]) { |
155 cell.className = 'check-mark'; | 193 cell.className = 'check-mark'; |
156 cell.textContent = '✔'; | 194 cell.textContent = '✔'; |
157 } else { | 195 } else { |
158 cell.className = 'x-mark'; | 196 cell.className = 'x-mark'; |
159 cell.textContent = '✗'; | 197 cell.textContent = '✗'; |
160 } | 198 } |
161 } else { | 199 } else { |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
363 } | 401 } |
364 | 402 |
365 return { | 403 return { |
366 initialize: initialize, | 404 initialize: initialize, |
367 startOmniboxQuery: startOmniboxQuery, | 405 startOmniboxQuery: startOmniboxQuery, |
368 handleNewAutocompleteResult: handleNewAutocompleteResult | 406 handleNewAutocompleteResult: handleNewAutocompleteResult |
369 }; | 407 }; |
370 }); | 408 }); |
371 | 409 |
372 document.addEventListener('DOMContentLoaded', omniboxDebug.initialize); | 410 document.addEventListener('DOMContentLoaded', omniboxDebug.initialize); |
OLD | NEW |