| OLD | NEW |
| (Empty) | |
| 1 <!DOCTYPE HTML> |
| 2 <!-- |
| 3 -- Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 4 -- Use of this source code is governed by a BSD-style license that can be |
| 5 -- found in the LICENSE file. |
| 6 --> |
| 7 <html> |
| 8 <head> |
| 9 <style> |
| 10 body { |
| 11 margin: 0; |
| 12 } |
| 13 |
| 14 iframe { |
| 15 border: none; |
| 16 height: 100%; |
| 17 position: absolute; |
| 18 width: 100%; |
| 19 } |
| 20 </style> |
| 21 |
| 22 <script src='js/harness.js'></script> |
| 23 <script src='js/util.js'></script> |
| 24 |
| 25 <script> |
| 26 // Put the images in this directory next to this html file. |
| 27 var IMPORT_SOURCE = 'harness_images'; |
| 28 |
| 29 var GALLERY_ROOT = 'images'; |
| 30 |
| 31 var IMPORTED_KEY = 'galleryDataImported'; |
| 32 |
| 33 function initGallery(galleryWindow) { |
| 34 galleryWindow.chrome.fileBrowserPrivate.FS_TYPE = window.TEMPORARY; |
| 35 galleryWindow.Gallery.openStandalone(GALLERY_ROOT); |
| 36 } |
| 37 |
| 38 function loadGallery() { |
| 39 var iframe = document.createElement('iframe'); |
| 40 document.body.appendChild(iframe); |
| 41 iframe.onload = function() { initGallery(iframe.contentWindow) }; |
| 42 iframe.src = "gallery.html"; |
| 43 } |
| 44 |
| 45 function importImages(filesystem) { |
| 46 var fileCount = 0; |
| 47 var byteCount = 0; |
| 48 var time = Date.now(); |
| 49 |
| 50 function displayProgress(blob) { |
| 51 fileCount++; |
| 52 byteCount += blob.size; |
| 53 var speed = (byteCount / 1000 / (Date.now() - time)).toFixed(1); |
| 54 document.body.innerHTML = |
| 55 'Imported ' + fileCount + ' files<br>' + |
| 56 (byteCount / 1000 / 1000).toFixed(1) + ' Mb total<br>' + |
| 57 speed + ' Mb/sec'; |
| 58 } |
| 59 |
| 60 harness.importWebDirectory(filesystem, GALLERY_ROOT, IMPORT_SOURCE, |
| 61 displayProgress, |
| 62 function() { |
| 63 console.log('Imported ' + byteCount + ' bytes'); |
| 64 if (fileCount) |
| 65 localStorage[IMPORTED_KEY] = 'true'; |
| 66 document.body.textContent = ''; |
| 67 loadGallery(); |
| 68 }); |
| 69 } |
| 70 |
| 71 function getFilesystem(callback) { |
| 72 window.webkitRequestFileSystem(window.TEMPORARY, 0, callback, |
| 73 util.flog('Error requesting filesystem')); |
| 74 } |
| 75 |
| 76 function onPageLoad() { |
| 77 if (localStorage[IMPORTED_KEY]) |
| 78 loadGallery(); |
| 79 else |
| 80 getFilesystem(importImages); |
| 81 } |
| 82 |
| 83 // Call this from the console to re-import the images. |
| 84 function reset() { |
| 85 delete localStorage[IMPORTED_KEY]; |
| 86 getFilesystem(function(filesystem) { |
| 87 harness.resetFilesystem(filesystem, onPageLoad); |
| 88 }); |
| 89 } |
| 90 |
| 91 document.addEventListener('DOMContentLoaded', onPageLoad); |
| 92 </script> |
| 93 </head> |
| 94 <body></body> |
| 95 </html> |
| OLD | NEW |