OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 /** | 5 /** |
6 * Converts a number in bytes to a string in megabytes split by comma into | 6 * Converts a number in bytes to a string in megabytes split by comma into |
7 * three digit block. | 7 * three digit block. |
8 * @param {number} bytes The number in bytes. | 8 * @param {number} bytes The number in bytes. |
9 * @return {string} Formatted string in megabytes. | 9 * @return {string} Formatted string in megabytes. |
10 */ | 10 */ |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 if (item.value != '') | 244 if (item.value != '') |
245 text += ': ' + item.value; | 245 text += ': ' + item.value; |
246 | 246 |
247 var li = createElementFromText('li', text); | 247 var li = createElementFromText('li', text); |
248 if (item.class) | 248 if (item.class) |
249 li.classList.add(item.class); | 249 li.classList.add(item.class); |
250 ul.appendChild(li); | 250 ul.appendChild(li); |
251 } | 251 } |
252 } | 252 } |
253 | 253 |
| 254 /** |
| 255 * Updates the text next to the 'reload' button to update the status. |
| 256 * @param {boolean} success whether or not reloading has succeeded. |
| 257 */ |
| 258 function updateReloadStatus(success) { |
| 259 $('reload-status-text').textContent = (success ? 'success' : 'failed'); |
| 260 } |
| 261 |
254 document.addEventListener('DOMContentLoaded', function() { | 262 document.addEventListener('DOMContentLoaded', function() { |
255 chrome.send('pageLoaded'); | 263 chrome.send('pageLoaded'); |
256 | 264 |
257 // Update the table of contents. | 265 // Update the table of contents. |
258 var toc = $('toc'); | 266 var toc = $('toc'); |
259 var sections = document.getElementsByTagName('h2'); | 267 var sections = document.getElementsByTagName('h2'); |
260 for (var i = 0; i < sections.length; i++) { | 268 for (var i = 0; i < sections.length; i++) { |
261 var section = sections[i]; | 269 var section = sections[i]; |
262 var a = createElementFromText('a', section.textContent); | 270 var a = createElementFromText('a', section.textContent); |
263 a.href = '#' + section.id; | 271 a.href = '#' + section.id; |
264 var li = document.createElement('li'); | 272 var li = document.createElement('li'); |
265 li.appendChild(a); | 273 li.appendChild(a); |
266 toc.appendChild(li); | 274 toc.appendChild(li); |
267 } | 275 } |
268 | 276 |
269 $('button-clear-access-token').addEventListener('click', function() { | 277 $('button-clear-access-token').addEventListener('click', function() { |
270 chrome.send('clearAccessToken'); | 278 chrome.send('clearAccessToken'); |
271 }); | 279 }); |
272 | 280 |
273 $('button-clear-refresh-token').addEventListener('click', function() { | 281 $('button-clear-refresh-token').addEventListener('click', function() { |
274 chrome.send('clearRefreshToken'); | 282 chrome.send('clearRefreshToken'); |
275 }); | 283 }); |
276 | 284 |
| 285 $('button-reload-drive-filesystem').addEventListener('click', function() { |
| 286 $('reload-status-text').textContent = 'reloading...'; |
| 287 chrome.send('reloadDriveFileSystem'); |
| 288 }); |
| 289 |
277 $('button-show-file-entries').addEventListener('click', function() { | 290 $('button-show-file-entries').addEventListener('click', function() { |
278 var button = $('button-show-file-entries'); | 291 var button = $('button-show-file-entries'); |
279 button.parentNode.removeChild(button); | 292 button.parentNode.removeChild(button); |
280 chrome.send('listFileEntries'); | 293 chrome.send('listFileEntries'); |
281 }); | 294 }); |
282 | 295 |
283 window.setInterval(function() { | 296 window.setInterval(function() { |
284 chrome.send('periodicUpdate'); | 297 chrome.send('periodicUpdate'); |
285 }, 1000); | 298 }, 1000); |
286 }); | 299 }); |
OLD | NEW |