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

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

Issue 10382220: Adds favicon and thumbnail columns to the chrome://suggestions-internals/ page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 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 | « no previous file | no next file » | 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 /** 5 /**
6 * Javascript for suggestions_internals.html, served from 6 * Javascript for suggestions_internals.html, served from
7 * chrome://suggestions-internals/. This is used to debug suggestions ranking. 7 * chrome://suggestions-internals/. This is used to debug suggestions ranking.
8 * When loaded, the page will show the current set of suggestions, along with a 8 * When loaded, the page will show the current set of suggestions, along with a
9 * large set of information (e.g. all the signals that were taken into 9 * large set of information (e.g. all the signals that were taken into
10 * consideration for deciding which pages were selected to be shown to the user) 10 * consideration for deciding which pages were selected to be shown to the user)
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 return IGNORED_COLUMNS.indexOf(column) < 0; 81 return IGNORED_COLUMNS.indexOf(column) < 0;
82 }); 82 });
83 83
84 // Move the preferred columns to the start of the column list. 84 // Move the preferred columns to the start of the column list.
85 for (var i = PREFERRED_COLUMN_ORDER.length - 1; i >= 0; i--) { 85 for (var i = PREFERRED_COLUMN_ORDER.length - 1; i >= 0; i--) {
86 var index = columns.indexOf(PREFERRED_COLUMN_ORDER[i]); 86 var index = columns.indexOf(PREFERRED_COLUMN_ORDER[i]);
87 if (index >= 0) 87 if (index >= 0)
88 columns.unshift(columns.splice(index, 1)[0]); 88 columns.unshift(columns.splice(index, 1)[0]);
89 } 89 }
90 90
91 // Prepend a "Rank" column. 91 // Special columns.
92 columns.unshift('favicon');
93 columns.unshift('screenshot');
92 columns.unshift('rank'); 94 columns.unshift('rank');
93 95
94 // Erase whatever is currently being displayed. 96 // Erase whatever is currently being displayed.
95 var output = $('suggestions-debug-text'); 97 var output = $('suggestions-debug-text');
96 output.innerHTML = ''; 98 output.innerHTML = '';
97 99
98 // Create the container table and add the header row. 100 // Create the container table and add the header row.
99 var table = document.createElement('table'); 101 var table = document.createElement('table');
100 table.className = 'suggestions-debug-table'; 102 table.className = 'suggestions-debug-table';
101 var header = document.createElement('tr'); 103 var header = document.createElement('tr');
(...skipping 18 matching lines...) Expand all
120 if (/^https?:\/\/.+$/.test(data)) { 122 if (/^https?:\/\/.+$/.test(data)) {
121 var anchor = document.createElement('a'); 123 var anchor = document.createElement('a');
122 anchor.href = data; 124 anchor.href = data;
123 anchor.innerText = data; 125 anchor.innerText = data;
124 column.appendChild(anchor); 126 column.appendChild(anchor);
125 } else { 127 } else {
126 column.innerText = data; 128 column.innerText = data;
127 } 129 }
128 } else if (column_name == 'rank') { 130 } else if (column_name == 'rank') {
129 column.innerText = rank++; 131 column.innerText = rank++;
132 } else if (column_name == 'screenshot') {
133 var thumbnailUrl = 'chrome://thumb/' + entry.url;
134 var img = document.createElement('img');
135 img.onload = function() { column.innerText = 'Y'; }
136 img.onerror = function() { column.innerText = 'N'; }
137 img.src = thumbnailUrl;
138 } else if (column_name == 'favicon') {
139 var faviconUrl = 'chrome://favicon/size/16/' + entry.url;
140 column.style.backgroundImage = url(faviconUrl);
141 column.style.backgroundRepeat = 'no-repeat';
142 column.style.backgroundPosition = 'center center';
130 } 143 }
131 row.appendChild(column); 144 row.appendChild(column);
132 }); 145 });
133 table.appendChild(row); 146 table.appendChild(row);
134 }); 147 });
135 148
136 output.appendChild(table); 149 output.appendChild(table);
137 } 150 }
138 151
139 return { 152 return {
140 initialize: initialize, 153 initialize: initialize,
141 setSuggestions: setSuggestions 154 setSuggestions: setSuggestions
142 }; 155 };
143 }); 156 });
144 157
145 document.addEventListener('DOMContentLoaded', suggestionsInternals.initialize); 158 document.addEventListener('DOMContentLoaded', suggestionsInternals.initialize);
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698