@@ -49,8 +49,7 @@ var FontInspector = (function FontInspectorClosure() {
49
49
}
50
50
const fontName = e . target . dataset . fontName ;
51
51
const selects = document . getElementsByTagName ( "input" ) ;
52
- for ( let i = 0 ; i < selects . length ; ++ i ) {
53
- const select = selects [ i ] ;
52
+ for ( const select of selects ) {
54
53
if ( select . dataset . fontName !== fontName ) {
55
54
continue ;
56
55
}
@@ -65,7 +64,7 @@ var FontInspector = (function FontInspectorClosure() {
65
64
name : "Font Inspector" ,
66
65
panel : null ,
67
66
manager : null ,
68
- init : function init ( pdfjsLib ) {
67
+ init ( pdfjsLib ) {
69
68
const panel = this . panel ;
70
69
const tmp = document . createElement ( "button" ) ;
71
70
tmp . addEventListener ( "click" , resetSelection ) ;
@@ -75,7 +74,7 @@ var FontInspector = (function FontInspectorClosure() {
75
74
fonts = document . createElement ( "div" ) ;
76
75
panel . appendChild ( fonts ) ;
77
76
} ,
78
- cleanup : function cleanup ( ) {
77
+ cleanup ( ) {
79
78
fonts . textContent = "" ;
80
79
} ,
81
80
enabled : false ,
@@ -93,16 +92,16 @@ var FontInspector = (function FontInspectorClosure() {
93
92
}
94
93
} ,
95
94
// FontInspector specific functions.
96
- fontAdded : function fontAdded ( fontObj , url ) {
95
+ fontAdded ( fontObj , url ) {
97
96
function properties ( obj , list ) {
98
97
const moreInfo = document . createElement ( "table" ) ;
99
- for ( let i = 0 ; i < list . length ; i ++ ) {
98
+ for ( const entry of list ) {
100
99
const tr = document . createElement ( "tr" ) ;
101
100
const td1 = document . createElement ( "td" ) ;
102
- td1 . textContent = list [ i ] ;
101
+ td1 . textContent = entry ;
103
102
tr . appendChild ( td1 ) ;
104
103
const td2 = document . createElement ( "td" ) ;
105
- td2 . textContent = obj [ list [ i ] ] . toString ( ) ;
104
+ td2 . textContent = obj [ entry ] . toString ( ) ;
106
105
tr . appendChild ( td2 ) ;
107
106
moreInfo . appendChild ( tr ) ;
108
107
}
@@ -172,7 +171,7 @@ var StepperManager = (function StepperManagerClosure() {
172
171
name : "Stepper" ,
173
172
panel : null ,
174
173
manager : null ,
175
- init : function init ( pdfjsLib ) {
174
+ init ( pdfjsLib ) {
176
175
const self = this ;
177
176
stepperControls = document . createElement ( "div" ) ;
178
177
stepperChooser = document . createElement ( "select" ) ;
@@ -192,15 +191,15 @@ var StepperManager = (function StepperManagerClosure() {
192
191
opMap [ pdfjsLib . OPS [ key ] ] = key ;
193
192
}
194
193
} ,
195
- cleanup : function cleanup ( ) {
194
+ cleanup ( ) {
196
195
stepperChooser . textContent = "" ;
197
196
stepperDiv . textContent = "" ;
198
197
steppers = [ ] ;
199
198
} ,
200
199
enabled : false ,
201
200
active : false ,
202
201
// Stepper specific functions.
203
- create : function create ( pageIndex ) {
202
+ create ( pageIndex ) {
204
203
const debug = document . createElement ( "div" ) ;
205
204
debug . id = "stepper" + pageIndex ;
206
205
debug . hidden = true ;
@@ -218,23 +217,19 @@ var StepperManager = (function StepperManagerClosure() {
218
217
}
219
218
return stepper ;
220
219
} ,
221
- selectStepper : function selectStepper ( pageIndex , selectPanel ) {
222
- let i ;
220
+ selectStepper ( pageIndex , selectPanel ) {
223
221
pageIndex |= 0 ;
224
222
if ( selectPanel ) {
225
223
this . manager . selectPanel ( this ) ;
226
224
}
227
- for ( i = 0 ; i < steppers . length ; ++ i ) {
228
- const stepper = steppers [ i ] ;
225
+ for ( const stepper of steppers ) {
229
226
stepper . panel . hidden = stepper . pageIndex !== pageIndex ;
230
227
}
231
- const options = stepperChooser . options ;
232
- for ( i = 0 ; i < options . length ; ++ i ) {
233
- const option = options [ i ] ;
228
+ for ( const option of stepperChooser . options ) {
234
229
option . selected = ( option . value | 0 ) === pageIndex ;
235
230
}
236
231
} ,
237
- saveBreakPoints : function saveBreakPoints ( pageIndex , bps ) {
232
+ saveBreakPoints ( pageIndex , bps ) {
238
233
breakPoints [ pageIndex ] = bps ;
239
234
sessionStorage . setItem ( "pdfjsBreakPoints" , JSON . stringify ( breakPoints ) ) ;
240
235
} ,
@@ -361,8 +356,7 @@ const Stepper = (function StepperClosure() {
361
356
const charCodeRow = c ( "tr" ) ;
362
357
const fontCharRow = c ( "tr" ) ;
363
358
const unicodeRow = c ( "tr" ) ;
364
- for ( let j = 0 ; j < glyphs . length ; j ++ ) {
365
- const glyph = glyphs [ j ] ;
359
+ for ( const glyph of glyphs ) {
366
360
if ( typeof glyph === "object" && glyph !== null ) {
367
361
charCodeRow . appendChild ( c ( "td" , glyph . originalCharCode ) ) ;
368
362
fontCharRow . appendChild ( c ( "td" , glyph . fontChar ) ) ;
@@ -410,9 +404,9 @@ const Stepper = (function StepperClosure() {
410
404
this . breakPoints . sort ( function ( a , b ) {
411
405
return a - b ;
412
406
} ) ;
413
- for ( let i = 0 ; i < this . breakPoints . length ; i ++ ) {
414
- if ( this . breakPoints [ i ] > this . currentIdx ) {
415
- return this . breakPoints [ i ] ;
407
+ for ( const breakPoint of this . breakPoints ) {
408
+ if ( breakPoint > this . currentIdx ) {
409
+ return breakPoint ;
416
410
}
417
411
}
418
412
return null ;
@@ -444,8 +438,7 @@ const Stepper = (function StepperClosure() {
444
438
445
439
goTo ( idx ) {
446
440
const allRows = this . panel . getElementsByClassName ( "line" ) ;
447
- for ( let x = 0 , xx = allRows . length ; x < xx ; ++ x ) {
448
- const row = allRows [ x ] ;
441
+ for ( const row of allRows ) {
449
442
if ( ( row . dataset . idx | 0 ) === idx ) {
450
443
row . style . backgroundColor = "rgb(251,250,207)" ;
451
444
row . scrollIntoView ( ) ;
@@ -465,8 +458,8 @@ var Stats = (function Stats() {
465
458
node . textContent = "" ; // Remove any `node` contents from the DOM.
466
459
}
467
460
function getStatIndex ( pageNumber ) {
468
- for ( let i = 0 , ii = stats . length ; i < ii ; ++ i ) {
469
- if ( stats [ i ] . pageNumber === pageNumber ) {
461
+ for ( const [ i , stat ] of stats . entries ( ) ) {
462
+ if ( stat . pageNumber === pageNumber ) {
470
463
return i ;
471
464
}
472
465
}
@@ -505,8 +498,8 @@ var Stats = (function Stats() {
505
498
return a . pageNumber - b . pageNumber ;
506
499
} ) ;
507
500
clear ( this . panel ) ;
508
- for ( let i = 0 , ii = stats . length ; i < ii ; ++ i ) {
509
- this . panel . appendChild ( stats [ i ] . div ) ;
501
+ for ( const entry of stats ) {
502
+ this . panel . appendChild ( entry . div ) ;
510
503
}
511
504
} ,
512
505
cleanup ( ) {
@@ -527,8 +520,7 @@ window.PDFBug = (function PDFBugClosure() {
527
520
enable ( ids ) {
528
521
const all = ids . length === 1 && ids [ 0 ] === "all" ;
529
522
const tools = this . tools ;
530
- for ( let i = 0 ; i < tools . length ; ++ i ) {
531
- const tool = tools [ i ] ;
523
+ for ( const tool of tools ) {
532
524
if ( all || ids . includes ( tool . id ) ) {
533
525
tool . enabled = true ;
534
526
}
@@ -570,22 +562,14 @@ window.PDFBug = (function PDFBugClosure() {
570
562
container . style . right = panelWidth + "px" ;
571
563
572
564
// Initialize all the debugging tools.
573
- const tools = this . tools ;
574
- const self = this ;
575
- for ( let i = 0 ; i < tools . length ; ++ i ) {
576
- const tool = tools [ i ] ;
565
+ for ( const [ i , tool ] of this . tools . entries ( ) ) {
577
566
const panel = document . createElement ( "div" ) ;
578
567
const panelButton = document . createElement ( "button" ) ;
579
568
panelButton . textContent = tool . name ;
580
- panelButton . addEventListener (
581
- "click" ,
582
- ( function ( selected ) {
583
- return function ( event ) {
584
- event . preventDefault ( ) ;
585
- self . selectPanel ( selected ) ;
586
- } ;
587
- } ) ( i )
588
- ) ;
569
+ panelButton . addEventListener ( "click" , event => {
570
+ event . preventDefault ( ) ;
571
+ this . selectPanel ( i ) ;
572
+ } ) ;
589
573
controls . appendChild ( panelButton ) ;
590
574
panels . appendChild ( panel ) ;
591
575
tool . panel = panel ;
@@ -602,9 +586,9 @@ window.PDFBug = (function PDFBugClosure() {
602
586
this . selectPanel ( 0 ) ;
603
587
} ,
604
588
cleanup ( ) {
605
- for ( let i = 0 , ii = this . tools . length ; i < ii ; i ++ ) {
606
- if ( this . tools [ i ] . enabled ) {
607
- this . tools [ i ] . cleanup ( ) ;
589
+ for ( const tool of this . tools ) {
590
+ if ( tool . enabled ) {
591
+ tool . cleanup ( ) ;
608
592
}
609
593
}
610
594
} ,
@@ -616,12 +600,11 @@ window.PDFBug = (function PDFBugClosure() {
616
600
return ;
617
601
}
618
602
activePanel = index ;
619
- const tools = this . tools ;
620
- for ( let j = 0 ; j < tools . length ; ++ j ) {
603
+ for ( const [ j , tool ] of this . tools . entries ( ) ) {
621
604
const isActive = j === index ;
622
605
buttons [ j ] . classList . toggle ( "active" , isActive ) ;
623
- tools [ j ] . active = isActive ;
624
- tools [ j ] . panel . hidden = ! isActive ;
606
+ tool . active = isActive ;
607
+ tool . panel . hidden = ! isActive ;
625
608
}
626
609
} ,
627
610
} ;
0 commit comments