| 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 * Requests the database from the backend. | 6 * Requests the database from the backend. |
| 7 */ | 7 */ |
| 8 function requestNetworkActionPredictorDb() { | 8 function requestAutocompleteActionPredictorDb() { |
| 9 console.debug('Requesting NAP DB'); | 9 console.debug('Requesting NAP DB'); |
| 10 chrome.send('requestNetworkActionPredictorDb', []) | 10 chrome.send('requestAutocompleteActionPredictorDb', []) |
| 11 } | 11 } |
| 12 | 12 |
| 13 | 13 |
| 14 /** | 14 /** |
| 15 * Callback from backend with the database contents. Sets up some globals and | 15 * Callback from backend with the database contents. Sets up some globals and |
| 16 * calls to create the UI. | 16 * calls to create the UI. |
| 17 * @param {Dictionary} database Information about NetworkActionPredictor | 17 * @param {Dictionary} database Information about AutocompleteActionPredictor |
| 18 * including the database as a flattened list, a boolean indicating if the | 18 * including the database as a flattened list, a boolean indicating if the |
| 19 * system is enabled and the current hit weight. | 19 * system is enabled and the current hit weight. |
| 20 */ | 20 */ |
| 21 function updateDatabaseTable(database) { | 21 function updateDatabaseTable(database) { |
| 22 console.debug('Updating Table NAP DB'); | 22 console.debug('Updating Table NAP DB'); |
| 23 | 23 |
| 24 var filter = $('filter'); | 24 var filter = $('filter'); |
| 25 filter.disabled = false; | 25 filter.disabled = false; |
| 26 filter.onchange = function() { | 26 filter.onchange = function() { |
| 27 updateDatabaseView(database); | 27 updateDatabaseView(database); |
| 28 }; | 28 }; |
| 29 | 29 |
| 30 updateDatabaseView(database); | 30 updateDatabaseView(database); |
| 31 } | 31 } |
| 32 | 32 |
| 33 /** | 33 /** |
| 34 * Updates the table from the database. | 34 * Updates the table from the database. |
| 35 * @param {Dictionary} database Information about NetworkActionPredictor | 35 * @param {Dictionary} database Information about AutocompleteActionPredictor |
| 36 * including the database as a flattened list, a boolean indicating if the | 36 * including the database as a flattened list, a boolean indicating if the |
| 37 * system is enabled and the current hit weight. | 37 * system is enabled and the current hit weight. |
| 38 */ | 38 */ |
| 39 function updateDatabaseView(database) { | 39 function updateDatabaseView(database) { |
| 40 var databaseSection = $('databaseTableBody'); | 40 var databaseSection = $('databaseTableBody'); |
| 41 var showEnabled = database.enabled && database.db; | 41 var autocompletePredictorEnabled = database.autocompletePredictorEnabled && |
| 42 database.db; |
| 42 | 43 |
| 43 $('enabledMode').hidden = !showEnabled; | 44 $('autocompletePredictorEnabledMode').hidden = !autocompletePredictorEnabled; |
| 44 $('disabledMode').hidden = showEnabled; | 45 $('autocompletePredictorDisabledMode').hidden = autocompletePredictorEnabled; |
| 45 | 46 |
| 46 if (!showEnabled) | 47 if (!autocompletePredictorEnabled) |
| 47 return; | 48 return; |
| 48 | 49 |
| 49 var filter = $('filter'); | 50 var filter = $('filter'); |
| 50 | 51 |
| 51 // Clear any previous list. | 52 // Clear any previous list. |
| 52 databaseSection.textContent = ''; | 53 databaseSection.textContent = ''; |
| 53 | 54 |
| 54 for (var i = 0; i < database.db.length; ++i) { | 55 for (var i = 0; i < database.db.length; ++i) { |
| 55 var entry = database.db[i]; | 56 var entry = database.db[i]; |
| 56 | 57 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 70 row.appendChild(document.createElement('td')).textContent = | 71 row.appendChild(document.createElement('td')).textContent = |
| 71 entry.confidence; | 72 entry.confidence; |
| 72 | 73 |
| 73 databaseSection.appendChild(row); | 74 databaseSection.appendChild(row); |
| 74 } | 75 } |
| 75 } | 76 } |
| 76 $('countBanner').textContent = 'Entries: ' + databaseSection.children.length; | 77 $('countBanner').textContent = 'Entries: ' + databaseSection.children.length; |
| 77 $('countBanner').textContent += ' Hit Weight: ' + database.hit_weight; | 78 $('countBanner').textContent += ' Hit Weight: ' + database.hit_weight; |
| 78 } | 79 } |
| 79 | 80 |
| 80 document.addEventListener('DOMContentLoaded', requestNetworkActionPredictorDb); | 81 document.addEventListener('DOMContentLoaded', |
| 82 requestAutocompleteActionPredictorDb); |
| OLD | NEW |