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 snippets we received in receiveSnippets. | 8 // Stores the list of snippets we received in receiveSnippets. |
9 var lastSnippets = []; | 9 var lastSnippets = []; |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 $('last-json-button').addEventListener('click', function(event) { | 27 $('last-json-button').addEventListener('click', function(event) { |
28 $('last-json-container').classList.toggle('hidden'); | 28 $('last-json-container').classList.toggle('hidden'); |
29 }); | 29 }); |
30 | 30 |
31 $('last-json-dump').addEventListener('click', function(event) { | 31 $('last-json-dump').addEventListener('click', function(event) { |
32 downloadJson($('last-json-text').innerText); | 32 downloadJson($('last-json-text').innerText); |
33 event.preventDefault(); | 33 event.preventDefault(); |
34 }); | 34 }); |
35 | 35 |
36 $('discarded-snippets-clear').addEventListener('click', function(event) { | 36 $('dismissed-snippets-clear').addEventListener('click', function(event) { |
37 chrome.send('clearDiscarded'); | 37 chrome.send('clearDismissed'); |
38 event.preventDefault(); | 38 event.preventDefault(); |
39 }); | 39 }); |
40 | 40 |
41 $('submit-clear-cached-suggestions') | 41 $('submit-clear-cached-suggestions') |
42 .addEventListener('click', function(event) { | 42 .addEventListener('click', function(event) { |
43 chrome.send('clearCachedSuggestions'); | 43 chrome.send('clearCachedSuggestions'); |
44 event.preventDefault(); | 44 event.preventDefault(); |
45 }); | 45 }); |
46 | 46 |
47 $('submit-clear-discarded-suggestions') | 47 $('submit-clear-dismissed-suggestions') |
48 .addEventListener('click', function(event) { | 48 .addEventListener('click', function(event) { |
49 chrome.send('clearDiscardedSuggestions'); | 49 chrome.send('clearDismissedSuggestions'); |
50 event.preventDefault(); | 50 event.preventDefault(); |
51 }); | 51 }); |
52 | 52 |
53 window.addEventListener('focus', refreshContent); | 53 window.addEventListener('focus', refreshContent); |
54 window.setInterval(refreshContent, 1000); | 54 window.setInterval(refreshContent, 1000); |
55 | 55 |
56 refreshContent(); | 56 refreshContent(); |
57 } | 57 } |
58 | 58 |
59 function setHostRestricted(restricted) { | 59 function setHostRestricted(restricted) { |
(...skipping 12 matching lines...) Expand all Loading... |
72 | 72 |
73 $('hosts-input').value = hosts.list.map( | 73 $('hosts-input').value = hosts.list.map( |
74 function(host) { return host.url;}).join(' '); | 74 function(host) { return host.url;}).join(' '); |
75 } | 75 } |
76 | 76 |
77 function receiveSnippets(snippets) { | 77 function receiveSnippets(snippets) { |
78 lastSnippets = snippets; | 78 lastSnippets = snippets; |
79 displayList(snippets, 'snippets', 'snippet-title'); | 79 displayList(snippets, 'snippets', 'snippet-title'); |
80 } | 80 } |
81 | 81 |
82 function receiveDiscardedSnippets(discardedSnippets) { | 82 function receiveDismissedSnippets(dismissedSnippets) { |
83 displayList(discardedSnippets, 'discarded-snippets', | 83 displayList(dismissedSnippets, 'dismissed-snippets', |
84 'discarded-snippet-title'); | 84 'dismissed-snippet-title'); |
85 } | 85 } |
86 | 86 |
87 function receiveContentSuggestions(categoriesList) { | 87 function receiveContentSuggestions(categoriesList) { |
88 displayList(categoriesList, 'content-suggestions', | 88 displayList(categoriesList, 'content-suggestions', |
89 'content-suggestion-title'); | 89 'content-suggestion-title'); |
90 } | 90 } |
91 | 91 |
92 function receiveJson(json) { | 92 function receiveJson(json) { |
93 var trimmed = json.trim(); | 93 var trimmed = json.trim(); |
94 var hasContent = (trimmed && trimmed != '{}'); | 94 var hasContent = (trimmed && trimmed != '{}'); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 } | 143 } |
144 } | 144 } |
145 | 145 |
146 // Return an object with all of the exports. | 146 // Return an object with all of the exports. |
147 return { | 147 return { |
148 initialize: initialize, | 148 initialize: initialize, |
149 setHostRestricted: setHostRestricted, | 149 setHostRestricted: setHostRestricted, |
150 receiveProperty: receiveProperty, | 150 receiveProperty: receiveProperty, |
151 receiveHosts: receiveHosts, | 151 receiveHosts: receiveHosts, |
152 receiveSnippets: receiveSnippets, | 152 receiveSnippets: receiveSnippets, |
153 receiveDiscardedSnippets: receiveDiscardedSnippets, | 153 receiveDismissedSnippets: receiveDismissedSnippets, |
154 receiveContentSuggestions: receiveContentSuggestions, | 154 receiveContentSuggestions: receiveContentSuggestions, |
155 receiveJson: receiveJson, | 155 receiveJson: receiveJson, |
156 }; | 156 }; |
157 }); | 157 }); |
158 | 158 |
159 document.addEventListener('DOMContentLoaded', | 159 document.addEventListener('DOMContentLoaded', |
160 chrome.SnippetsInternals.initialize); | 160 chrome.SnippetsInternals.initialize); |
OLD | NEW |