]> git.parisson.com Git - pdf.js.git/commitdiff
Use strict mode for js files
authorVivien Nicolas <21@vingtetun.org>
Sun, 19 Jun 2011 00:35:28 +0000 (02:35 +0200)
committerVivien Nicolas <21@vingtetun.org>
Sun, 19 Jun 2011 00:35:28 +0000 (02:35 +0200)
fonts.js
glyphlist.js
pdf.js
utils/fonts_utils.js
viewer.js

index 219ada8ca23e7fbdb82709c430735da3805fd671..576e35cb91cc48f6323c130307acdb9db880bcf8 100644 (file)
--- a/fonts.js
+++ b/fonts.js
@@ -1,6 +1,8 @@
 /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- /
 /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
 
+"use strict";
+
 /**
  * Maximum file size of the font.
  */
@@ -1092,7 +1094,8 @@ var Type1Parser = function() {
   this.extractFontProgram = function t1_extractFontProgram(aStream) {
     var eexecString = decrypt(aStream, kEexecEncryptionKey, 4);
     var subrs = [],  glyphs = [];
-    var inSubrs = inGlyphs = false;
+    var inSubrs = false;
+    var inGlyphs = false;
     var glyph = "";
 
     var token = "";
index 1a0190133c834cb2544dd7bcd07e188404a1702b..f638ff888d98060eef9697d563b757ff6b92829c 100644 (file)
@@ -1,3 +1,5 @@
+"use strict";
+
 var GlyphsUnicode = {
   A: 0x0041,
   AE: 0x00C6,
diff --git a/pdf.js b/pdf.js
index 9c4344fab6f8be15a63b47358f999503b88b4084..02159f94b0258be3e095084031fe0c662ffdbaaf 100644 (file)
--- a/pdf.js
+++ b/pdf.js
@@ -1,6 +1,8 @@
 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- /
 /* vim: set shiftwidth=4 tabstop=8 autoindent cindent expandtab: */
 
+"use strict";
+
 var ERRORS = 0, WARNINGS = 1, TODOS = 5;
 var verbosity = WARNINGS;
 
@@ -246,7 +248,7 @@ var FlateStream = (function() {
         this.eof = false;
         this.codeSize = 0;
         this.codeBuf = 0;
-        
+
         this.pos = 0;
         this.bufferLength = 0;
     }
@@ -432,6 +434,11 @@ var FlateStream = (function() {
                 litCodeTable = fixedLitCodeTab;
                 distCodeTable = fixedDistCodeTab;
             } else if (hdr == 2) { // compressed block, dynamic codes
+                var repeat = function repeat(stream, array, len, offset, what) {
+                  var repeat = stream.getBits(len) + offset;
+                    while (repeat-- > 0)
+                      array[i++] = what;
+                }
                 var numLitCodes = this.getBits(5) + 257;
                 var numDistCodes = this.getBits(5) + 1;
                 var numCodeLenCodes = this.getBits(4) + 4;
@@ -449,11 +456,6 @@ var FlateStream = (function() {
                 var codes = numLitCodes + numDistCodes;
                 var codeLengths = new Array(codes);
                 while (i < codes) {
-                    function repeat(stream, array, len, offset, what) {
-                        var repeat = stream.getBits(len) + offset;
-                        while (repeat-- > 0)
-                            array[i++] = what;
-                    }
                     var code = this.getCode(codeLenCodeTab);
                     if (code == 16) {
                         repeat(this, codeLengths, 2, 3, len);
@@ -725,6 +727,7 @@ var Lexer = (function() {
             var done = false;
             var str = "";
             var stream = this.stream;
+            var ch = null;
             do {
                 switch (ch = stream.getChar()) {
                 case undefined:
@@ -1429,7 +1432,7 @@ var Catalog = (function() {
             return shadow(this, "toplevelPagesDict", obj);
         },
         get numPages() {
-            obj = this.toplevelPagesDict.get("Count");
+            var obj = this.toplevelPagesDict.get("Count");
             assertWellFormed(IsInt(obj),
                              "page count in top level pages object is not an integer");
             // shadow the prototype getter
index 086648fe2615d92c0e68768860d613101bfe0083..45f92a28ba329425162c28d583a57754de5d4b35 100644 (file)
@@ -7,6 +7,7 @@
  * CharString or to understand the structure of the CFF format.
  */
 
+"use strict";
 
 /**
  * Build a charset by assigning the glyph name and the human readable form
index a8e7ae6e128f34772d26fc5eda121a731d63beec..41aaf354ca79db922c897a0e831f05013ffb78f2 100644 (file)
--- a/viewer.js
+++ b/viewer.js
@@ -1,12 +1,14 @@
 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- /
 /* vim: set shiftwidth=4 tabstop=8 autoindent cindent expandtab: */
 
-var pdfDocument, canvas, pageDisplay, pageNum, pageInterval;
+"use strict";
+
+var pdfDocument, canvas, pageDisplay, pageNum, numPages, pageInterval;
 function load(userInput) {
     canvas = document.getElementById("canvas");
     canvas.mozOpaque = true;
     pageNum = parseInt(queryParams().page) || 1;
-    fileName = userInput;
+    var fileName = userInput;
     if (!userInput) {
       fileName = queryParams().file || "compressed.tracemonkey-pldi-09.pdf";
     }
@@ -26,7 +28,7 @@ function queryParams() {
 
 function open(url) {
     document.title = url;
-    req = new XMLHttpRequest();
+    var req = new XMLHttpRequest();
     req.open("GET", url);
     req.mozResponseType = req.responseType = "arraybuffer";
     req.expected = (document.URL.indexOf("file:") == 0) ? 0 : 200;