Merge with master
This commit is contained in:
commit
4710028b14
@ -1,4 +1,5 @@
|
|||||||
<html>
|
<html>
|
||||||
|
<<<<<<< HEAD
|
||||||
<head>
|
<head>
|
||||||
<title>Simple pdf.js page viewer</title>
|
<title>Simple pdf.js page viewer</title>
|
||||||
<link rel="stylesheet" href="test.css"></link>
|
<link rel="stylesheet" href="test.css"></link>
|
||||||
@ -13,6 +14,9 @@
|
|||||||
|
|
||||||
<body onload="load();">
|
<body onload="load();">
|
||||||
<div id="controls">
|
<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="prevPage();">Previous</button>
|
||||||
<button onclick="nextPage();">Next</button>
|
<button onclick="nextPage();">Next</button>
|
||||||
<input type="text" id="pageNumber" onchange="gotoPage(this.value);"
|
<input type="text" id="pageNumber" onchange="gotoPage(this.value);"
|
||||||
|
18
test.js
18
test.js
@ -2,11 +2,14 @@
|
|||||||
/* vim: set shiftwidth=4 tabstop=8 autoindent cindent expandtab: */
|
/* vim: set shiftwidth=4 tabstop=8 autoindent cindent expandtab: */
|
||||||
|
|
||||||
var pdfDocument, canvas, pageDisplay, pageNum, pageInterval;
|
var pdfDocument, canvas, pageDisplay, pageNum, pageInterval;
|
||||||
function load() {
|
function load(userInput) {
|
||||||
canvas = document.getElementById("canvas");
|
canvas = document.getElementById("canvas");
|
||||||
canvas.mozOpaque = true;
|
canvas.mozOpaque = true;
|
||||||
pageNum = parseInt(queryParams().page) || 1;
|
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);
|
open(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,10 +71,17 @@ function displayPage(num) {
|
|||||||
// page.compile will collect all fonts for us, once we have loaded them
|
// page.compile will collect all fonts for us, once we have loaded them
|
||||||
// we can trigger the actual page rendering with page.display
|
// we can trigger the actual page rendering with page.display
|
||||||
var fonts = [];
|
var fonts = [];
|
||||||
|
|
||||||
page.compile(gfx, fonts);
|
page.compile(gfx, fonts);
|
||||||
var t2 = Date.now();
|
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
|
// FIXME This need to be replaced by an event
|
||||||
pageInterval = setInterval(function() {
|
pageInterval = setInterval(function() {
|
||||||
for (var i = 0; i < fonts.length; i++) {
|
for (var i = 0; i < fonts.length; i++) {
|
||||||
@ -87,7 +97,7 @@ function displayPage(num) {
|
|||||||
|
|
||||||
var infoDisplay = document.getElementById("info");
|
var infoDisplay = document.getElementById("info");
|
||||||
infoDisplay.innerHTML = "Time to load/compile/fonts/render: "+ (t1 - t0) + "/" + (t2 - t1) + "/" + (t3 - t2) + "/" + (t4 - t3) + " ms";
|
infoDisplay.innerHTML = "Time to load/compile/fonts/render: "+ (t1 - t0) + "/" + (t2 - t1) + "/" + (t3 - t2) + "/" + (t4 - t3) + " ms";
|
||||||
}, 10);
|
}, interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
function nextPage() {
|
function nextPage() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user