2011-07-06 15:06:45 +09:00
|
|
|
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- /
|
|
|
|
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
2011-05-26 23:02:52 +09:00
|
|
|
|
2011-07-06 15:06:45 +09:00
|
|
|
'use strict';
|
2011-06-19 09:35:28 +09:00
|
|
|
|
2011-07-29 02:48:05 +09:00
|
|
|
var kDefaultURL = 'compressed.tracemonkey-pldi-09.pdf';
|
|
|
|
var kDefaultScale = 150;
|
2011-07-29 20:26:43 +09:00
|
|
|
var kCacheSize = 20;
|
|
|
|
|
|
|
|
var Cache = function(size) {
|
|
|
|
var data = [];
|
|
|
|
this.push = function(view) {
|
|
|
|
data.push(view);
|
|
|
|
if (data.length > size)
|
|
|
|
data.shift().update();
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
var cache = new Cache(kCacheSize);
|
|
|
|
|
2011-07-29 02:48:05 +09:00
|
|
|
var PDFView = {
|
|
|
|
pages: [],
|
|
|
|
thumbnails: [],
|
|
|
|
|
|
|
|
set scale(val) {
|
|
|
|
var pages = this.pages;
|
|
|
|
var cssUnits = 96.0 / 72.0;
|
|
|
|
for (var i = 0; i < pages.length; i++)
|
|
|
|
pages[i].update(val / 100 * cssUnits);
|
2011-08-26 02:20:19 +09:00
|
|
|
|
|
|
|
if (document.location.hash == '#' + this.page)
|
|
|
|
this.pages[this.page - 1].draw();
|
2011-08-24 09:46:11 +09:00
|
|
|
else
|
|
|
|
// Jump the scroll position to the correct page.
|
|
|
|
document.location.hash = this.page;
|
2011-07-30 01:17:04 +09:00
|
|
|
|
2011-08-26 02:20:19 +09:00
|
|
|
var event = document.createEvent('UIEvents');
|
|
|
|
event.initUIEvent('scalechange', false, false, window, val);
|
2011-07-30 01:17:04 +09:00
|
|
|
window.dispatchEvent(event);
|
2011-07-29 02:48:05 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
set page(val) {
|
|
|
|
var pages = this.pages;
|
2011-08-09 05:13:32 +09:00
|
|
|
var input = document.getElementById('pageNumber');
|
2011-08-30 11:11:46 +09:00
|
|
|
if (!(0 < val && val <= pages.length)) {
|
2011-07-29 02:48:05 +09:00
|
|
|
input.value = this.page;
|
|
|
|
return;
|
|
|
|
}
|
2011-08-09 05:13:32 +09:00
|
|
|
|
2011-07-29 02:48:05 +09:00
|
|
|
document.location.hash = val;
|
2011-08-09 05:13:32 +09:00
|
|
|
document.getElementById('previous').disabled = (val == 1);
|
|
|
|
document.getElementById('next').disabled = (val == pages.length);
|
2011-07-29 02:48:05 +09:00
|
|
|
if (input.value == val)
|
|
|
|
return;
|
|
|
|
|
|
|
|
input.value = val;
|
|
|
|
pages[val - 1].draw();
|
|
|
|
},
|
|
|
|
|
|
|
|
get page() {
|
2011-08-30 11:11:46 +09:00
|
|
|
return parseInt(document.location.hash.substring(1)) || 1;
|
2011-07-29 02:48:05 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
open: function(url, scale) {
|
2011-08-09 05:13:32 +09:00
|
|
|
if (url.indexOf('http') == 0)
|
2011-07-29 02:48:05 +09:00
|
|
|
return;
|
|
|
|
|
|
|
|
document.title = url;
|
|
|
|
|
|
|
|
var xhr = new XMLHttpRequest();
|
|
|
|
xhr.open('GET', url);
|
|
|
|
xhr.mozResponseType = xhr.responseType = 'arraybuffer';
|
|
|
|
xhr.expected = (document.URL.indexOf('file:') === 0) ? 0 : 200;
|
|
|
|
|
|
|
|
xhr.onreadystatechange = function() {
|
|
|
|
if (xhr.readyState === 4 && xhr.status === xhr.expected) {
|
|
|
|
var data = (xhr.mozResponseArrayBuffer || xhr.mozResponse ||
|
|
|
|
xhr.responseArrayBuffer || xhr.response);
|
|
|
|
|
|
|
|
PDFView.load(data, scale);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
xhr.send(null);
|
|
|
|
},
|
|
|
|
|
2011-08-23 04:30:22 +09:00
|
|
|
navigateTo: function(dest) {
|
2011-08-20 23:51:44 +09:00
|
|
|
if (typeof dest === 'string')
|
|
|
|
dest = this.destinations[dest];
|
2011-08-27 12:58:03 +09:00
|
|
|
if (!(dest instanceof Array))
|
|
|
|
return; // invalid destination
|
2011-08-20 23:51:44 +09:00
|
|
|
// dest array looks like that: <page-ref> </XYZ|FitXXX> <args..>
|
2011-08-20 12:41:56 +09:00
|
|
|
var destRef = dest[0];
|
2011-08-30 10:59:38 +09:00
|
|
|
var pageNumber = destRef instanceof Object ?
|
|
|
|
this.pagesRefMap[destRef.num + ' ' + destRef.gen + ' R'] : (destRef + 1);
|
2011-08-20 23:51:44 +09:00
|
|
|
if (pageNumber) {
|
|
|
|
this.page = pageNumber;
|
2011-08-23 04:30:22 +09:00
|
|
|
// TODO scroll to specific region on the page, the precise scaling
|
|
|
|
// required.
|
2011-08-20 12:41:56 +09:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2011-07-29 02:48:05 +09:00
|
|
|
load: function(data, scale) {
|
|
|
|
var sidebar = document.getElementById('sidebarView');
|
|
|
|
sidebar.parentNode.scrollTop = 0;
|
|
|
|
|
|
|
|
while (sidebar.hasChildNodes())
|
|
|
|
sidebar.removeChild(sidebar.lastChild);
|
|
|
|
clearInterval(sidebar._loadingInterval);
|
|
|
|
|
|
|
|
var container = document.getElementById('viewer');
|
|
|
|
while (container.hasChildNodes())
|
|
|
|
container.removeChild(container.lastChild);
|
|
|
|
|
|
|
|
var pdf = new PDFDoc(new Stream(data));
|
|
|
|
var pagesCount = pdf.numPages;
|
|
|
|
document.getElementById('numPages').innerHTML = pagesCount;
|
|
|
|
|
|
|
|
var pages = this.pages = [];
|
2011-08-20 23:51:44 +09:00
|
|
|
var pagesRefMap = {};
|
2011-07-29 02:48:05 +09:00
|
|
|
var thumbnails = this.thumbnails = [];
|
|
|
|
for (var i = 1; i <= pagesCount; i++) {
|
|
|
|
var page = pdf.getPage(i);
|
2011-08-10 05:42:50 +09:00
|
|
|
pages.push(new PageView(container, page, i, page.width, page.height,
|
2011-08-20 12:41:56 +09:00
|
|
|
page.stats, this.navigateTo.bind(this)));
|
2011-07-29 02:48:05 +09:00
|
|
|
thumbnails.push(new ThumbnailView(sidebar, pages[i - 1]));
|
2011-08-20 23:51:44 +09:00
|
|
|
var pageRef = page.ref;
|
|
|
|
pagesRefMap[pageRef.num + ' ' + pageRef.gen + ' R'] = i;
|
2011-08-09 05:13:32 +09:00
|
|
|
}
|
2011-07-29 02:48:05 +09:00
|
|
|
|
|
|
|
this.scale = (scale || kDefaultScale);
|
|
|
|
this.page = parseInt(document.location.hash.substring(1)) || 1;
|
2011-08-20 23:51:44 +09:00
|
|
|
this.pagesRefMap = pagesRefMap;
|
|
|
|
this.destinations = pdf.catalog.destinations;
|
2011-08-22 11:05:10 +09:00
|
|
|
if (pdf.catalog.documentOutline) {
|
|
|
|
this.outline = new DocumentOutlineView(pdf.catalog.documentOutline);
|
|
|
|
var outlineSwitchButton = document.getElementById('outlineSwitch');
|
|
|
|
outlineSwitchButton.removeAttribute('disabled');
|
|
|
|
this.switchSidebarView('outline');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
switchSidebarView: function(view) {
|
|
|
|
var thumbsScrollView = document.getElementById('sidebarScrollView');
|
|
|
|
var outlineScrollView = document.getElementById('outlineScrollView');
|
|
|
|
var thumbsSwitchButton = document.getElementById('thumbsSwitch');
|
|
|
|
var outlineSwitchButton = document.getElementById('outlineSwitch');
|
2011-08-26 02:20:19 +09:00
|
|
|
switch (view) {
|
2011-08-22 11:05:10 +09:00
|
|
|
case 'thumbs':
|
|
|
|
thumbsScrollView.style.display = 'block';
|
|
|
|
outlineScrollView.style.display = 'none';
|
|
|
|
thumbsSwitchButton.setAttribute('data-selected', true);
|
|
|
|
outlineSwitchButton.removeAttribute('data-selected');
|
|
|
|
break;
|
|
|
|
case 'outline':
|
|
|
|
thumbsScrollView.style.display = 'none';
|
|
|
|
outlineScrollView.style.display = 'block';
|
|
|
|
thumbsSwitchButton.removeAttribute('data-selected');
|
|
|
|
outlineSwitchButton.setAttribute('data-selected', true);
|
|
|
|
break;
|
|
|
|
}
|
2011-07-29 02:48:05 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
getVisiblePages: function() {
|
|
|
|
var pages = this.pages;
|
|
|
|
var kBottomMargin = 10;
|
|
|
|
var visiblePages = [];
|
|
|
|
|
|
|
|
var currentHeight = kBottomMargin;
|
|
|
|
var windowTop = window.pageYOffset;
|
|
|
|
for (var i = 1; i <= pages.length; i++) {
|
|
|
|
var page = pages[i - 1];
|
|
|
|
var pageHeight = page.height * page.scale + kBottomMargin;
|
|
|
|
if (currentHeight + pageHeight > windowTop)
|
|
|
|
break;
|
|
|
|
|
|
|
|
currentHeight += pageHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
var windowBottom = window.pageYOffset + window.innerHeight;
|
|
|
|
for (; i <= pages.length && currentHeight < windowBottom; i++) {
|
|
|
|
var page = pages[i - 1];
|
2011-07-29 20:26:43 +09:00
|
|
|
visiblePages.push({ id: page.id, y: currentHeight, view: page });
|
2011-07-29 02:48:05 +09:00
|
|
|
currentHeight += page.height * page.scale + kBottomMargin;
|
|
|
|
}
|
|
|
|
|
|
|
|
return visiblePages;
|
2011-08-09 05:13:32 +09:00
|
|
|
}
|
2011-07-29 02:48:05 +09:00
|
|
|
};
|
|
|
|
|
2011-08-20 12:41:56 +09:00
|
|
|
var PageView = function(container, content, id, width, height,
|
|
|
|
stats, navigateTo) {
|
2011-07-29 02:48:05 +09:00
|
|
|
this.width = width;
|
|
|
|
this.height = height;
|
|
|
|
this.id = id;
|
|
|
|
this.content = content;
|
|
|
|
|
|
|
|
var anchor = document.createElement('a');
|
|
|
|
anchor.name = '' + this.id;
|
|
|
|
|
|
|
|
var div = document.createElement('div');
|
|
|
|
div.id = 'pageContainer' + this.id;
|
|
|
|
div.className = 'page';
|
|
|
|
|
|
|
|
container.appendChild(anchor);
|
|
|
|
container.appendChild(div);
|
|
|
|
|
|
|
|
this.update = function(scale) {
|
2011-07-29 20:26:43 +09:00
|
|
|
this.scale = scale || this.scale;
|
2011-08-09 05:13:32 +09:00
|
|
|
div.style.width = (this.width * this.scale) + 'px';
|
2011-07-29 02:48:05 +09:00
|
|
|
div.style.height = (this.height * this.scale) + 'px';
|
|
|
|
|
|
|
|
while (div.hasChildNodes())
|
|
|
|
div.removeChild(div.lastChild);
|
2011-08-28 07:10:15 +09:00
|
|
|
div.removeAttribute('data-loaded');
|
2011-07-29 02:48:05 +09:00
|
|
|
};
|
|
|
|
|
2011-08-18 10:21:54 +09:00
|
|
|
function setupLinks(canvas, content, scale) {
|
2011-08-26 08:28:50 +09:00
|
|
|
function bindLink(link, dest) {
|
|
|
|
if (dest) {
|
|
|
|
link.onclick = function() {
|
|
|
|
PDFView.navigateTo(dest);
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
2011-08-19 12:48:07 +09:00
|
|
|
var links = content.getLinks();
|
2011-08-26 08:28:50 +09:00
|
|
|
for (var i = 0; i < links.length; i++) {
|
|
|
|
var link = document.createElement('a');
|
|
|
|
link.style.left = Math.floor(links[i].x * scale) + 'px';
|
|
|
|
link.style.top = Math.floor(links[i].y * scale) + 'px';
|
|
|
|
link.style.width = Math.ceil(links[i].width * scale) + 'px';
|
|
|
|
link.style.height = Math.ceil(links[i].height * scale) + 'px';
|
|
|
|
link.href = links[i].url || '';
|
|
|
|
bindLink(link, links[i].dest);
|
|
|
|
div.appendChild(link);
|
2011-08-18 10:21:54 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-29 02:48:05 +09:00
|
|
|
this.draw = function() {
|
|
|
|
if (div.hasChildNodes()) {
|
|
|
|
this.updateStats();
|
2011-07-29 20:26:43 +09:00
|
|
|
return false;
|
2011-07-29 02:48:05 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
var canvas = document.createElement('canvas');
|
|
|
|
canvas.id = 'page' + this.id;
|
|
|
|
canvas.mozOpaque = true;
|
|
|
|
|
|
|
|
canvas.width = this.width * this.scale;
|
|
|
|
canvas.height = this.height * this.scale;
|
|
|
|
div.appendChild(canvas);
|
|
|
|
|
|
|
|
var ctx = canvas.getContext('2d');
|
|
|
|
ctx.save();
|
|
|
|
ctx.fillStyle = 'rgb(255, 255, 255)';
|
|
|
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
|
|
ctx.restore();
|
|
|
|
|
|
|
|
stats.begin = Date.now();
|
|
|
|
this.content.startRendering(ctx, this.updateStats);
|
2011-07-29 20:26:43 +09:00
|
|
|
|
2011-08-18 10:21:54 +09:00
|
|
|
setupLinks(canvas, this.content, this.scale);
|
2011-08-28 07:10:15 +09:00
|
|
|
div.setAttribute('data-loaded', true);
|
2011-08-18 10:21:54 +09:00
|
|
|
|
2011-07-29 20:26:43 +09:00
|
|
|
return true;
|
2011-07-29 02:48:05 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
this.updateStats = function() {
|
|
|
|
var t1 = stats.compile, t2 = stats.fonts, t3 = stats.render;
|
2011-08-09 05:13:32 +09:00
|
|
|
var str = 'Time to compile/fonts/render: ' +
|
2011-07-29 02:48:05 +09:00
|
|
|
(t1 - stats.begin) + '/' + (t2 - t1) + '/' + (t3 - t2) + ' ms';
|
|
|
|
document.getElementById('info').innerHTML = str;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
var ThumbnailView = function(container, page) {
|
|
|
|
var anchor = document.createElement('a');
|
|
|
|
anchor.href = '#' + page.id;
|
|
|
|
|
|
|
|
var div = document.createElement('div');
|
|
|
|
div.id = 'thumbnailContainer' + page.id;
|
|
|
|
div.className = 'thumbnail';
|
|
|
|
|
|
|
|
anchor.appendChild(div);
|
|
|
|
container.appendChild(anchor);
|
|
|
|
|
|
|
|
this.draw = function() {
|
|
|
|
if (div.hasChildNodes())
|
|
|
|
return;
|
|
|
|
|
|
|
|
var canvas = document.createElement('canvas');
|
|
|
|
canvas.id = 'thumbnail' + page.id;
|
|
|
|
canvas.mozOpaque = true;
|
|
|
|
|
|
|
|
canvas.width = 104;
|
|
|
|
canvas.height = 134;
|
|
|
|
div.appendChild(canvas);
|
|
|
|
|
|
|
|
var ctx = canvas.getContext('2d');
|
|
|
|
ctx.save();
|
|
|
|
ctx.fillStyle = 'rgb(255, 255, 255)';
|
|
|
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
|
|
ctx.restore();
|
|
|
|
|
|
|
|
page.content.startRendering(ctx, function() { });
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2011-08-22 11:05:10 +09:00
|
|
|
var DocumentOutlineView = function(outline) {
|
|
|
|
var outlineView = document.getElementById('outlineView');
|
|
|
|
|
|
|
|
function bindItemLink(domObj, item) {
|
|
|
|
domObj.href = '';
|
|
|
|
domObj.onclick = function(e) {
|
|
|
|
PDFView.navigateTo(item.dest);
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
var queue = [{parent: outlineView, items: outline}];
|
|
|
|
while (queue.length > 0) {
|
|
|
|
var levelData = queue.shift();
|
|
|
|
var i, n = levelData.items.length;
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
var item = levelData.items[i];
|
|
|
|
var div = document.createElement('div');
|
|
|
|
div.className = 'outlineItem';
|
|
|
|
var a = document.createElement('a');
|
|
|
|
bindItemLink(a, item);
|
|
|
|
a.textContent = item.title;
|
|
|
|
div.appendChild(a);
|
|
|
|
|
|
|
|
if (item.items.length > 0) {
|
|
|
|
var itemsDiv = document.createElement('div');
|
|
|
|
itemsDiv.className = 'outlineItems';
|
|
|
|
div.appendChild(itemsDiv);
|
|
|
|
queue.push({parent: itemsDiv, items: item.items});
|
|
|
|
}
|
|
|
|
|
|
|
|
levelData.parent.appendChild(div);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-07-29 02:48:05 +09:00
|
|
|
window.addEventListener('load', function(evt) {
|
|
|
|
var params = document.location.search.substring(1).split('&');
|
|
|
|
for (var i = 0; i < params.length; i++) {
|
|
|
|
var param = params[i].split('=');
|
|
|
|
params[unescape(param[0])] = unescape(param[1]);
|
2011-07-06 15:06:45 +09:00
|
|
|
}
|
2011-06-14 02:16:03 +09:00
|
|
|
|
2011-07-29 02:48:05 +09:00
|
|
|
PDFView.open(params.file || kDefaultURL, parseInt(params.scale));
|
|
|
|
|
|
|
|
if (!window.File || !window.FileReader || !window.FileList || !window.Blob)
|
|
|
|
document.getElementById('fileInput').style.display = 'none';
|
|
|
|
else
|
|
|
|
document.getElementById('fileInput').value = null;
|
|
|
|
}, true);
|
|
|
|
|
|
|
|
window.addEventListener('pdfloaded', function(evt) {
|
|
|
|
PDFView.load(evt.detail);
|
|
|
|
}, true);
|
|
|
|
|
2011-07-30 01:17:04 +09:00
|
|
|
window.addEventListener('scroll', function onscroll(evt) {
|
2011-07-29 02:48:05 +09:00
|
|
|
var visiblePages = PDFView.getVisiblePages();
|
2011-07-29 20:26:43 +09:00
|
|
|
for (var i = 0; i < visiblePages.length; i++) {
|
|
|
|
var page = visiblePages[i];
|
|
|
|
if (PDFView.pages[page.id - 1].draw())
|
|
|
|
cache.push(page.view);
|
|
|
|
}
|
2011-07-29 02:48:05 +09:00
|
|
|
|
|
|
|
if (!visiblePages.length)
|
2011-07-26 23:11:09 +09:00
|
|
|
return;
|
|
|
|
|
2011-07-29 02:48:05 +09:00
|
|
|
var currentId = PDFView.page;
|
|
|
|
var firstPage = visiblePages[0];
|
|
|
|
var lastPage = visiblePages[visiblePages.length - 1];
|
|
|
|
if (currentId > lastPage.id && lastPage.y > window.pageYOffset)
|
|
|
|
PDFView.page = lastPage.id;
|
|
|
|
else if (currentId < firstPage.id)
|
|
|
|
PDFView.page = firstPage.id;
|
|
|
|
}, true);
|
|
|
|
|
2011-08-09 05:13:32 +09:00
|
|
|
window.addEventListener('hashchange', function(evt) {
|
2011-07-29 02:48:05 +09:00
|
|
|
PDFView.page = PDFView.page;
|
|
|
|
});
|
|
|
|
|
2011-08-09 05:13:32 +09:00
|
|
|
window.addEventListener('change', function(evt) {
|
2011-07-29 02:48:05 +09:00
|
|
|
var files = evt.target.files;
|
|
|
|
if (!files || files.length == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Read the local file into a Uint8Array.
|
|
|
|
var fileReader = new FileReader();
|
|
|
|
fileReader.onload = function(evt) {
|
|
|
|
var data = evt.target.result;
|
|
|
|
var buffer = new ArrayBuffer(data.length);
|
|
|
|
var uint8Array = new Uint8Array(buffer);
|
|
|
|
|
|
|
|
for (var i = 0; i < data.length; i++)
|
|
|
|
uint8Array[i] = data.charCodeAt(i);
|
|
|
|
PDFView.load(uint8Array);
|
2011-07-06 15:06:45 +09:00
|
|
|
};
|
2011-05-26 23:02:52 +09:00
|
|
|
|
2011-07-29 02:48:05 +09:00
|
|
|
// Read as a binary string since "readAsArrayBuffer" is not yet
|
|
|
|
// implemented in Firefox.
|
|
|
|
var file = files[0];
|
|
|
|
fileReader.readAsBinaryString(file);
|
|
|
|
|
|
|
|
document.title = file.name;
|
|
|
|
document.location.hash = 1;
|
|
|
|
}, true);
|
|
|
|
|
2011-08-09 05:13:32 +09:00
|
|
|
window.addEventListener('transitionend', function(evt) {
|
2011-07-29 02:48:05 +09:00
|
|
|
var pageIndex = 0;
|
|
|
|
var pagesCount = PDFView.pages.length;
|
|
|
|
|
|
|
|
var container = document.getElementById('sidebarView');
|
2011-08-31 07:37:39 +09:00
|
|
|
container._interval = window.setInterval(function interval() {
|
|
|
|
if (pageIndex >= pagesCount) {
|
|
|
|
window.clearInterval(container._interval);
|
|
|
|
return;
|
|
|
|
}
|
2011-08-09 05:13:32 +09:00
|
|
|
|
2011-07-29 02:48:05 +09:00
|
|
|
PDFView.thumbnails[pageIndex++].draw();
|
|
|
|
}, 500);
|
2011-07-26 23:11:09 +09:00
|
|
|
}, true);
|
|
|
|
|
2011-07-30 01:17:04 +09:00
|
|
|
|
2011-08-31 07:37:39 +09:00
|
|
|
window.addEventListener('scalechange', function scalechange(evt) {
|
2011-07-30 01:17:04 +09:00
|
|
|
var options = document.getElementById('scaleSelect').options;
|
|
|
|
for (var i = 0; i < options.length; i++) {
|
|
|
|
var option = options[i];
|
|
|
|
option.selected = (option.value == evt.detail);
|
|
|
|
}
|
|
|
|
}, true);
|
|
|
|
|
2011-08-31 07:37:39 +09:00
|
|
|
window.addEventListener('pagechange', function pagechange(evt) {
|
2011-07-30 01:17:04 +09:00
|
|
|
var page = evt.detail;
|
|
|
|
document.location.hash = page;
|
2011-08-26 02:20:19 +09:00
|
|
|
document.getElementById('pageNumber').value = page;
|
|
|
|
document.getElementById('previous').disabled = (page == 1);
|
|
|
|
document.getElementById('next').disabled = (page == PDFView.pages.length);
|
2011-07-30 01:17:04 +09:00
|
|
|
}, true);
|