diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2014-02-05 15:42:01 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2014-02-13 16:11:51 +0100 |
commit | 2f5833b27d744e5f1933062c2cb3f73a4416722b (patch) | |
tree | f7d36e3e40001db9dda64e112a79b9314c441be9 /source/pdf/js/pdf-util.js | |
parent | c35cb0acc020538eeff4d9c0ac39244b09b47017 (diff) | |
download | mupdf-2f5833b27d744e5f1933062c2cb3f73a4416722b.tar.xz |
pdf-util.js: Hoist var statements out of for statements.
Make the scoping clearer, since Javascript doesn't have block scoping.
Diffstat (limited to 'source/pdf/js/pdf-util.js')
-rw-r--r-- | source/pdf/js/pdf-util.js | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/source/pdf/js/pdf-util.js b/source/pdf/js/pdf-util.js index 21a6f065..359563e1 100644 --- a/source/pdf/js/pdf-util.js +++ b/source/pdf/js/pdf-util.js @@ -57,6 +57,7 @@ util.printd = function(fmt, d) { var regexp = /(m+|d+|y+|H+|h+|M+|s+|t+|[^mdyHhMst]+)/g; var res = ''; + var i; if (!d) return null; @@ -64,7 +65,7 @@ util.printd = function(fmt, d) var tokens = fmt.match(regexp); var length = tokens ? tokens.length : 0; - for (var i = 0; i < length; i++) + for (i = 0; i < length; i++) { switch(tokens[i]) { @@ -164,6 +165,8 @@ util.printx = function(fmt, val) util.printf = function() { + var i; + if (arguments.length < 1) return ""; @@ -173,7 +176,7 @@ util.printf = function() var tokens = arguments[0].match(regexp); var length = tokens ? tokens.length : 0; - for (var i = 0; i < length; i++) + for (i = 0; i < length; i++) { var tok = tokens[i]; if (tok.match(/^%/)) @@ -345,12 +348,13 @@ function AFExtractTime(dt) function AFParseDateOrder(fmt) { + var i; var order = ''; // Ensure all present with those not added in default order fmt += "mdy"; - for (var i = 0; i < fmt.length; i++) + for (i = 0; i < fmt.length; i++) { var c = fmt.charAt(i); @@ -415,6 +419,7 @@ function AFParseTime(str, d) function AFParseDateEx(d, fmt) { + var i; var dt = AFExtractTime(d); var nums = dt[0].match(/\d+/g); var order = AFParseDateOrder(fmt); @@ -442,7 +447,7 @@ function AFParseDateEx(d, fmt) if (order === "ym" || (order === "y" && text_month)) date = 1; - for (var i = 0; i < nums.length; i++) + for (i = 0; i < nums.length; i++) { switch (order.charAt(i)) { @@ -794,7 +799,7 @@ function AFPercent_Format(nDec, sepStyle) function AFSimple_Calculate(op, list) { - var res; + var i, res; switch (op) { @@ -812,7 +817,7 @@ function AFSimple_Calculate(op, list) if (typeof list === 'string') list = list.split(/ *, */); - for (var i = 0; i < list.length; i++) + for (i = 0; i < list.length; i++) { var field = getField(list[i]); var value = Number(field.value); |