Merge with master

This commit is contained in:
Vivien Nicolas 2011-06-17 09:06:19 +02:00
commit 4710028b14
2 changed files with 18 additions and 4 deletions

View File

@ -1,4 +1,5 @@
<html>
<<<<<<< HEAD
<head>
<title>Simple pdf.js page viewer</title>
<link rel="stylesheet" href="test.css"></link>
@ -13,6 +14,9 @@
<body onload="load();">
<div id="controls">
<input type="file" style="float: right; margin: auto 32px;" onChange="load(this.value.toString());"></input>
<!-- This only opens supported PDFs from the source path...
-- Can we use JSONP to overcome the same-origin restrictions? -->
<button onclick="prevPage();">Previous</button>
<button onclick="nextPage();">Next</button>
<input type="text" id="pageNumber" onchange="gotoPage(this.value);"

18
test.js
View File

@ -2,11 +2,14 @@
/* vim: set shiftwidth=4 tabstop=8 autoindent cindent expandtab: */
var pdfDocument, canvas, pageDisplay, pageNum, pageInterval;
function load() {
function load(userInput) {
canvas = document.getElementById("canvas");
canvas.mozOpaque = true;
pageNum = parseInt(queryParams().page) || 1;
fileName = queryParams().file || "compressed.tracemonkey-pldi-09.pdf";
fileName = userInput;
if (!userInput) {
fileName = queryParams().file || "compressed.tracemonkey-pldi-09.pdf";
}
open(fileName);
}
@ -68,10 +71,17 @@ function displayPage(num) {
// page.compile will collect all fonts for us, once we have loaded them
// we can trigger the actual page rendering with page.display
var fonts = [];
page.compile(gfx, fonts);
var t2 = Date.now();
var interval = 0;
for (var i = 0; i < fonts.length; i++) {
if (fonts[i].loading) {
interval = 10;
break;
}
};
// FIXME This need to be replaced by an event
pageInterval = setInterval(function() {
for (var i = 0; i < fonts.length; i++) {
@ -87,7 +97,7 @@ function displayPage(num) {
var infoDisplay = document.getElementById("info");
infoDisplay.innerHTML = "Time to load/compile/fonts/render: "+ (t1 - t0) + "/" + (t2 - t1) + "/" + (t3 - t2) + "/" + (t4 - t3) + " ms";
}, 10);
}, interval);
}
function nextPage() {