Make viewer.js compatible with the content type handler addon
This commit is contained in:
parent
1af6732ba9
commit
f1a8a98757
@ -29,6 +29,9 @@ function queryParams() {
|
||||
|
||||
function open(url) {
|
||||
document.title = url;
|
||||
if (url.indexOf("http") == 0)
|
||||
return;
|
||||
|
||||
var req = new XMLHttpRequest();
|
||||
req.open('GET', url);
|
||||
req.mozResponseType = req.responseType = 'arraybuffer';
|
||||
@ -37,15 +40,23 @@ function open(url) {
|
||||
if (req.readyState == 4 && req.status == req.expected) {
|
||||
var data = (req.mozResponseArrayBuffer || req.mozResponse ||
|
||||
req.responseArrayBuffer || req.response);
|
||||
pdfDocument = new PDFDoc(new Stream(data));
|
||||
numPages = pdfDocument.numPages;
|
||||
document.getElementById('numPages').innerHTML = numPages.toString();
|
||||
goToPage(pageNum);
|
||||
loadDocument(data);
|
||||
}
|
||||
};
|
||||
req.send(null);
|
||||
}
|
||||
|
||||
window.addEventListener("pdfloaded", function(aEvent) {
|
||||
loadDocument(aEvent.detail);
|
||||
}, true);
|
||||
|
||||
function loadDocument(data) {
|
||||
pdfDocument = new PDFDoc(new Stream(data));
|
||||
numPages = pdfDocument.numPages;
|
||||
document.getElementById('numPages').innerHTML = numPages.toString();
|
||||
goToPage(pageNum);
|
||||
}
|
||||
|
||||
function gotoPage(num) {
|
||||
if (0 <= num && num <= numPages)
|
||||
pageNum = num;
|
||||
|
Loading…
Reference in New Issue
Block a user