Fixing 'compatibility.js' load order; add Object.keys emulation

This commit is contained in:
notmasteryet 2011-10-29 16:00:13 -05:00
parent a7a6e41ec6
commit 0912959503
2 changed files with 16 additions and 1 deletions

View File

@ -83,6 +83,21 @@
};
})();
// Object.keys() ?
(function checkObjectKeysCompatibility() {
if (typeof Object.keys !== 'undefined')
return;
Object.keys = function objectKeys(obj) {
var result = [];
for (var i in obj) {
if (obj.hasOwnProperty(i))
result.push(i);
}
return result;
};
})();
// No XMLHttpRequest.response ?
(function checkXMLHttpRequestResponseCompatibility() {
var xhrPrototype = XMLHttpRequest.prototype;

View File

@ -3,6 +3,7 @@
<head>
<title>Simple pdf.js page viewer</title>
<link rel="stylesheet" href="viewer.css"/>
<script type="text/javascript" src="compatibility.js"></script>
<!-- PDFJSSCRIPT_INCLUDE_BUILD -->
@ -25,7 +26,6 @@
<script type="text/javascript" src="../src/stream.js"></script> <!-- PDFJSSCRIPT_REMOVE -->
<script type="text/javascript" src="../src/worker.js"></script> <!-- PDFJSSCRIPT_REMOVE -->
<script type="text/javascript" src="compatibility.js"></script>
<script type="text/javascript" src="viewer.js"></script>
</head>