| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 cr.define('chrome.SnippetsInternals', function() { | 5 cr.define('chrome.SnippetsInternals', function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 // Stores the list of suggestions we received in receiveContentSuggestions. | 8 // Stores the list of suggestions we received in receiveContentSuggestions. |
| 9 var lastSuggestions = []; | 9 var lastSuggestions = []; |
| 10 | 10 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 document.getElementsByClassName('submit-clear-cached-suggestions'); | 61 document.getElementsByClassName('submit-clear-cached-suggestions'); |
| 62 for (var button of clearCachedButtons) { | 62 for (var button of clearCachedButtons) { |
| 63 button.addEventListener('click', onClearCachedButtonClicked); | 63 button.addEventListener('click', onClearCachedButtonClicked); |
| 64 } | 64 } |
| 65 | 65 |
| 66 var clearDismissedButtons = | 66 var clearDismissedButtons = |
| 67 document.getElementsByClassName('submit-clear-dismissed-suggestions'); | 67 document.getElementsByClassName('submit-clear-dismissed-suggestions'); |
| 68 for (var button of clearDismissedButtons) { | 68 for (var button of clearDismissedButtons) { |
| 69 button.addEventListener('click', onClearDismissedButtonClicked); | 69 button.addEventListener('click', onClearDismissedButtonClicked); |
| 70 } | 70 } |
| 71 |
| 72 var toggleDismissedButtons = |
| 73 document.getElementsByClassName('toggle-dismissed-suggestions'); |
| 74 for (var button of toggleDismissedButtons) { |
| 75 button.addEventListener('click', onToggleDismissedButtonClicked); |
| 76 } |
| 71 } | 77 } |
| 72 | 78 |
| 73 function onClearCachedButtonClicked(event) { | 79 function onClearCachedButtonClicked(event) { |
| 74 event.preventDefault(); | 80 event.preventDefault(); |
| 75 var id = parseInt(event.currentTarget.getAttribute('category-id'), 10); | 81 var id = parseInt(event.currentTarget.getAttribute('category-id'), 10); |
| 76 chrome.send('clearCachedSuggestions', [id]); | 82 chrome.send('clearCachedSuggestions', [id]); |
| 77 } | 83 } |
| 78 | 84 |
| 79 function onClearDismissedButtonClicked(event) { | 85 function onClearDismissedButtonClicked(event) { |
| 80 event.preventDefault(); | 86 event.preventDefault(); |
| 81 var id = parseInt(event.currentTarget.getAttribute('category-id'), 10); | 87 var id = parseInt(event.currentTarget.getAttribute('category-id'), 10); |
| 82 chrome.send('clearDismissedSuggestions', [id]); | 88 chrome.send('clearDismissedSuggestions', [id]); |
| 83 } | 89 } |
| 84 | 90 |
| 91 function onToggleDismissedButtonClicked(event) { |
| 92 event.preventDefault(); |
| 93 var id = parseInt(event.currentTarget.getAttribute('category-id'), 10); |
| 94 var table = $('dismissed-suggestions-' + id); |
| 95 table.classList.toggle('hidden'); |
| 96 chrome.send('toggleDismissedSuggestions', |
| 97 [id, !table.classList.contains('hidden')]); |
| 98 } |
| 99 |
| 85 function receiveJson(json) { | 100 function receiveJson(json) { |
| 86 var trimmed = json.trim(); | 101 var trimmed = json.trim(); |
| 87 var hasContent = (trimmed && trimmed != '{}'); | 102 var hasContent = (trimmed && trimmed != '{}'); |
| 88 | 103 |
| 89 if (hasContent) { | 104 if (hasContent) { |
| 90 receiveProperty('last-json-text', trimmed); | 105 receiveProperty('last-json-text', trimmed); |
| 91 $('last-json').classList.remove('hidden'); | 106 $('last-json').classList.remove('hidden'); |
| 92 } else { | 107 } else { |
| 93 $('last-json').classList.add('hidden'); | 108 $('last-json').classList.add('hidden'); |
| 94 } | 109 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 setHostRestricted: setHostRestricted, | 157 setHostRestricted: setHostRestricted, |
| 143 receiveProperty: receiveProperty, | 158 receiveProperty: receiveProperty, |
| 144 receiveHosts: receiveHosts, | 159 receiveHosts: receiveHosts, |
| 145 receiveContentSuggestions: receiveContentSuggestions, | 160 receiveContentSuggestions: receiveContentSuggestions, |
| 146 receiveJson: receiveJson, | 161 receiveJson: receiveJson, |
| 147 }; | 162 }; |
| 148 }); | 163 }); |
| 149 | 164 |
| 150 document.addEventListener('DOMContentLoaded', | 165 document.addEventListener('DOMContentLoaded', |
| 151 chrome.SnippetsInternals.initialize); | 166 chrome.SnippetsInternals.initialize); |
| OLD | NEW |