| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 // Globals: | 5 // Globals: |
| 6 /** @const */ var RESULTS_PER_PAGE = 150; | 6 /** @const */ var RESULTS_PER_PAGE = 150; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * Amount of time between pageviews that we consider a 'break' in browsing, | 9 * Amount of time between pageviews that we consider a 'break' in browsing, |
| 10 * measured in milliseconds. | 10 * measured in milliseconds. |
| 11 * @const | 11 * @const |
| 12 */ | 12 */ |
| 13 var BROWSING_GAP_TIME = 15 * 60 * 1000; | 13 var BROWSING_GAP_TIME = 15 * 60 * 1000; |
| 14 | 14 |
| 15 window.addEventListener('load', function() { | 15 window.addEventListener('load', function() { |
| 16 $('history-card-manager').loading = true; |
| 16 chrome.send('queryHistory', ['', 0, 0, 0, RESULTS_PER_PAGE]); | 17 chrome.send('queryHistory', ['', 0, 0, 0, RESULTS_PER_PAGE]); |
| 17 }); | 18 }); |
| 18 | 19 |
| 19 /** | 20 /** |
| 20 * Listens for history-item being selected or deselected (through checkbox) | 21 * Listens for history-item being selected or deselected (through checkbox) |
| 21 * and changes the view of the top toolbar. | 22 * and changes the view of the top toolbar. |
| 22 */ | 23 */ |
| 23 window.addEventListener('history-checkbox-select', function(e) { | 24 window.addEventListener('history-checkbox-select', function(e) { |
| 24 $('toolbar').count += e.detail.countAddition; | 25 $('toolbar').count += e.detail.countAddition; |
| 25 }); | 26 }); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 } | 61 } |
| 61 }); | 62 }); |
| 62 | 63 |
| 63 /** | 64 /** |
| 64 * Resizing browser window will cause the overflow menu to close. | 65 * Resizing browser window will cause the overflow menu to close. |
| 65 */ | 66 */ |
| 66 window.addEventListener('resize', function() { | 67 window.addEventListener('resize', function() { |
| 67 $('history-card-manager').closeMenu(); | 68 $('history-card-manager').closeMenu(); |
| 68 }); | 69 }); |
| 69 | 70 |
| 71 /** |
| 72 * When the search is changed refresh the results and load either search results |
| 73 * or normal history results. |
| 74 */ |
| 75 window.addEventListener('refresh-results', function(e) { |
| 76 $('history-card-manager').resetHistoryResults(); |
| 77 chrome.send('queryHistory', [e.detail.search, 0, 0, 0, RESULTS_PER_PAGE]); |
| 78 }); |
| 79 |
| 70 // Chrome Callbacks------------------------------------------------------------- | 80 // Chrome Callbacks------------------------------------------------------------- |
| 71 | 81 |
| 72 /** | 82 /** |
| 73 * Our history system calls this function with results from searches. | 83 * Our history system calls this function with results from searches. |
| 74 * @param {HistoryQuery} info An object containing information about the query. | 84 * @param {HistoryQuery} info An object containing information about the query. |
| 75 * @param {Array<HistoryEntry>} results A list of results. | 85 * @param {Array<HistoryEntry>} results A list of results. |
| 76 */ | 86 */ |
| 77 function historyResult(info, results) { | 87 function historyResult(info, results) { |
| 78 $('history-card-manager').addNewResults(results); | 88 $('history-card-manager').addNewResults(results, info.term); |
| 79 } | 89 } |
| 80 | 90 |
| 81 /** | 91 /** |
| 82 * Called by the history backend when deletion was succesful. | 92 * Called by the history backend when deletion was succesful. |
| 83 */ | 93 */ |
| 84 function deleteComplete() { | 94 function deleteComplete() { |
| 85 $('history-card-manager').removeDeletedHistory($('toolbar').count); | 95 $('history-card-manager').removeDeletedHistory($('toolbar').count); |
| 86 $('toolbar').count = 0; | 96 $('toolbar').count = 0; |
| 87 } | 97 } |
| 88 | 98 |
| 89 /** | 99 /** |
| 90 * Called by the history backend when the deletion failed. | 100 * Called by the history backend when the deletion failed. |
| 91 */ | 101 */ |
| 92 function deleteFailed() { | 102 function deleteFailed() { |
| 93 } | 103 } |
| 94 | 104 |
| 95 /** | 105 /** |
| 96 * Called when the history is deleted by someone else. | 106 * Called when the history is deleted by someone else. |
| 97 */ | 107 */ |
| 98 function historyDeleted() { | 108 function historyDeleted() { |
| 99 } | 109 } |
| OLD | NEW |