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