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