OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // require: cr.js | 5 // require: cr.js |
6 // require: cr/ui.js | 6 // require: cr/ui.js |
7 // require: cr/ui/tree.js | 7 // require: cr/ui/tree.js |
8 | 8 |
9 (function() { | 9 (function() { |
10 /** | 10 /** |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
171 | 171 |
172 /** | 172 /** |
173 * Fetch the latest set of nodes and refresh the UI. | 173 * Fetch the latest set of nodes and refresh the UI. |
174 */ | 174 */ |
175 function refresh() { | 175 function refresh() { |
176 $('node-browser-refresh-button').disabled = true; | 176 $('node-browser-refresh-button').disabled = true; |
177 | 177 |
178 clear(); | 178 clear(); |
179 setLastRefreshTime('In progress since ' + (new Date()).toLocaleString()); | 179 setLastRefreshTime('In progress since ' + (new Date()).toLocaleString()); |
180 | 180 |
181 chrome.sync.getAllNodes(function(nodes) { | 181 chrome.sync.getAllNodes(function(nodeMap) { |
182 // Put all nodes into one big list that ignores the type. | |
183 var nodes = nodeMap | |
184 .map(function(x) { return x.nodes; }) | |
185 .reduce(function(a, b) { return a.concat(b); }); | |
Dan Beam
2014/04/05 00:19:25
. at end
rlarocque
2014/04/05 00:27:29
Done.
| |
186 | |
182 var treeContainer = $('sync-node-tree-container'); | 187 var treeContainer = $('sync-node-tree-container'); |
183 var tree = document.createElement('tree'); | 188 var tree = document.createElement('tree'); |
184 tree.setAttribute('id', 'sync-node-tree'); | 189 tree.setAttribute('id', 'sync-node-tree'); |
185 tree.setAttribute('icon-visibility', 'parent'); | 190 tree.setAttribute('icon-visibility', 'parent'); |
186 treeContainer.appendChild(tree); | 191 treeContainer.appendChild(tree); |
187 | 192 |
188 cr.ui.decorate(tree, SyncNodeTree); | 193 cr.ui.decorate(tree, SyncNodeTree); |
189 tree.populate(nodes); | 194 tree.populate(nodes); |
190 | 195 |
191 setLastRefreshTime((new Date()).toLocaleString()); | 196 setLastRefreshTime((new Date()).toLocaleString()); |
192 $('node-browser-refresh-button').disabled = false; | 197 $('node-browser-refresh-button').disabled = false; |
193 }); | 198 }); |
194 } | 199 } |
195 | 200 |
196 document.addEventListener('DOMContentLoaded', function(e) { | 201 document.addEventListener('DOMContentLoaded', function(e) { |
197 $('node-browser-refresh-button').addEventListener('click', refresh); | 202 $('node-browser-refresh-button').addEventListener('click', refresh); |
198 cr.ui.decorate('#sync-node-splitter', cr.ui.Splitter); | 203 cr.ui.decorate('#sync-node-splitter', cr.ui.Splitter); |
199 | 204 |
200 // Automatically trigger a refresh the first time this tab is selected. | 205 // Automatically trigger a refresh the first time this tab is selected. |
201 $('sync-browser-tab').addEventListener('selectedChange', function f(e) { | 206 $('sync-browser-tab').addEventListener('selectedChange', function f(e) { |
202 if (this.selected) { | 207 if (this.selected) { |
203 $('sync-browser-tab').removeEventListener('selectedChange', f); | 208 $('sync-browser-tab').removeEventListener('selectedChange', f); |
204 refresh(); | 209 refresh(); |
205 } | 210 } |
206 }); | 211 }); |
207 }); | 212 }); |
208 | 213 |
209 })(); | 214 })(); |
OLD | NEW |