Browse Source

Lower the common denominator

Chris Jones 14 years ago
parent
commit
e655fd0adb
  1. 15
      pdf.js
  2. 4
      test.html

15
pdf.js

@ -72,14 +72,14 @@ var Obj = (function() {
]; ];
for (var i = 0; i < types.length; ++i) { for (var i = 0; i < types.length; ++i) {
let type = i; var typeName = types[i];
var typeName = types[type]; constructor[typeName] = i;
constructor[typeName] = type;
constructor.prototype["is" + typeName] = constructor.prototype["is" + typeName] =
(function (value) { (function is(value) {
return this.type == type && return this.type == is.type &&
(typeof value == "undefined" || value == this.value); (typeof value == "undefined" || value == this.value);
}); });
constructor.prototype["is" + typeName].type = i;
} }
constructor.prototype.isNum = function(value) { constructor.prototype.isNum = function(value) {
@ -99,7 +99,7 @@ var Obj = (function() {
} else if (this.isNull()) { } else if (this.isNull()) {
return null; return null;
} else if (this.isArray()) { } else if (this.isArray()) {
return this.value.map(function (e) e.lowerToJS()); return this.value.map(function (e) { return e.lowerToJS(); });
} else { } else {
return undefined; return undefined;
} }
@ -777,7 +777,8 @@ var Interpreter = (function() {
if (!this.typeCheck(op.params, args)) if (!this.typeCheck(op.params, args))
this.error("Wrong arguments for command '"+ cmd +"'"); this.error("Wrong arguments for command '"+ cmd +"'");
op.op.call(this, args.map(function (a) a.lowerToJS())); op.op.call(this,
args.map(function (a) { return a.lowerToJS() }));
args.length = 0; args.length = 0;
} else if (MAX_ARGS == args.length) { } else if (MAX_ARGS == args.length) {
this.error("Too many arguments"); this.error("Too many arguments");

4
test.html

@ -1,7 +1,7 @@
<html> <html>
<head> <head>
<title>Simple pdf.js page viewer</title> <title>Simple pdf.js page viewer</title>
<script type="application/javascript;version=1.8" <script type="text/javascript"
src="pdf.js"></script> src="pdf.js"></script>
<style type"text/css"> <style type"text/css">
body { body {
@ -20,7 +20,7 @@ body {
} }
</style> </style>
<script type="application/javascript;version=1.8"> <script type="text/javascript">
var canvas, numPages, pageDisplay, pageNum; var canvas, numPages, pageDisplay, pageNum;
function load() { function load() {
canvas = document.getElementById("canvas"); canvas = document.getElementById("canvas");

Loading…
Cancel
Save