Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Side by Side Diff: chrome/browser/resources/snippets_internals.js

Issue 2757663002: ntp-snippets-internals: add fields, indent JSON (Closed)
Patch Set: Make llx work Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/webui/snippets_internals_message_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 function initialize() { 11 function initialize() {
12 $('submit-download').addEventListener('click', function(event) { 12 $('submit-download').addEventListener('click', function(event) {
13 chrome.send('download'); 13 chrome.send('download');
14 event.preventDefault(); 14 event.preventDefault();
15 }); 15 });
16 16
17 $('submit-dump').addEventListener('click', function(event) { 17 $('submit-dump').addEventListener('click', function(event) {
18 downloadJson(JSON.stringify(lastSuggestions)); 18 downloadJson(JSON.stringify(lastSuggestions, null, 2));
19 event.preventDefault(); 19 event.preventDefault();
20 }); 20 });
21 21
22 $('last-json-button').addEventListener('click', function(event) { 22 $('last-json-button').addEventListener('click', function(event) {
23 $('last-json-container').classList.toggle('hidden'); 23 $('last-json-container').classList.toggle('hidden');
24 }); 24 });
25 25
26 $('last-json-dump').addEventListener('click', function(event) { 26 $('last-json-dump').addEventListener('click', function(event) {
27 downloadJson($('last-json-text').innerText); 27 downloadJson($('last-json-text').innerText);
28 event.preventDefault(); 28 event.preventDefault();
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 receiveProperty('last-background-fetch-time-label', 118 receiveProperty('last-background-fetch-time-label',
119 lastRemoteSuggestionsBackgroundFetchTime); 119 lastRemoteSuggestionsBackgroundFetchTime);
120 } 120 }
121 121
122 function downloadJson(json) { 122 function downloadJson(json) {
123 // Redirect the browser to download data in |json| as a file "snippets.json" 123 // Redirect the browser to download data in |json| as a file "snippets.json"
124 // (Setting Content-Disposition: attachment via a data: URL is not possible; 124 // (Setting Content-Disposition: attachment via a data: URL is not possible;
125 // create a link with download attribute and simulate a click, instead.) 125 // create a link with download attribute and simulate a click, instead.)
126 var link = document.createElement('a'); 126 var link = document.createElement('a');
127 link.download = 'snippets.json'; 127 link.download = 'snippets.json';
128 link.href = 'data:,' + json; 128 link.href = 'data:application/json,' + encodeURI(json);
129 link.click(); 129 link.click();
130 } 130 }
131 131
132 function refreshContent() { 132 function refreshContent() {
133 chrome.send('refreshContent'); 133 chrome.send('refreshContent');
134 } 134 }
135 135
136 function toggleHidden(event) { 136 function toggleHidden(event) {
137 var id = event.currentTarget.getAttribute('hidden-id'); 137 var id = event.currentTarget.getAttribute('hidden-id');
138 $(id).classList.toggle('hidden'); 138 $(id).classList.toggle('hidden');
(...skipping 29 matching lines...) Expand all
168 receiveContentSuggestions: receiveContentSuggestions, 168 receiveContentSuggestions: receiveContentSuggestions,
169 receiveJson: receiveJson, 169 receiveJson: receiveJson,
170 receiveClassification: receiveClassification, 170 receiveClassification: receiveClassification,
171 receiveLastRemoteSuggestionsBackgroundFetchTime: 171 receiveLastRemoteSuggestionsBackgroundFetchTime:
172 receiveLastRemoteSuggestionsBackgroundFetchTime, 172 receiveLastRemoteSuggestionsBackgroundFetchTime,
173 }; 173 };
174 }); 174 });
175 175
176 document.addEventListener('DOMContentLoaded', 176 document.addEventListener('DOMContentLoaded',
177 chrome.SnippetsInternals.initialize); 177 chrome.SnippetsInternals.initialize);
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/webui/snippets_internals_message_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698