|
@@ -12,14 +12,14 @@
|
|
* See the License for the specific language governing permissions and
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
* limitations under the License.
|
|
*/
|
|
*/
|
|
-/* eslint-disable no-var */
|
|
|
|
|
|
|
|
"use strict";
|
|
"use strict";
|
|
|
|
|
|
|
|
+// eslint-disable-next-line no-var
|
|
var FontInspector = (function FontInspectorClosure() {
|
|
var FontInspector = (function FontInspectorClosure() {
|
|
- var fonts;
|
|
|
|
- var active = false;
|
|
|
|
- var fontAttribute = "data-font-name";
|
|
|
|
|
|
+ let fonts;
|
|
|
|
+ let active = false;
|
|
|
|
+ const fontAttribute = "data-font-name";
|
|
function removeSelection() {
|
|
function removeSelection() {
|
|
const divs = document.querySelectorAll(`span[${fontAttribute}]`);
|
|
const divs = document.querySelectorAll(`span[${fontAttribute}]`);
|
|
for (const div of divs) {
|
|
for (const div of divs) {
|
|
@@ -47,10 +47,10 @@ var FontInspector = (function FontInspectorClosure() {
|
|
) {
|
|
) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- var fontName = e.target.dataset.fontName;
|
|
|
|
- var selects = document.getElementsByTagName("input");
|
|
|
|
- for (var i = 0; i < selects.length; ++i) {
|
|
|
|
- var select = selects[i];
|
|
|
|
|
|
+ const fontName = e.target.dataset.fontName;
|
|
|
|
+ const selects = document.getElementsByTagName("input");
|
|
|
|
+ for (let i = 0; i < selects.length; ++i) {
|
|
|
|
+ const select = selects[i];
|
|
if (select.dataset.fontName !== fontName) {
|
|
if (select.dataset.fontName !== fontName) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
@@ -66,8 +66,8 @@ var FontInspector = (function FontInspectorClosure() {
|
|
panel: null,
|
|
panel: null,
|
|
manager: null,
|
|
manager: null,
|
|
init: function init(pdfjsLib) {
|
|
init: function init(pdfjsLib) {
|
|
- var panel = this.panel;
|
|
|
|
- var tmp = document.createElement("button");
|
|
|
|
|
|
+ const panel = this.panel;
|
|
|
|
+ const tmp = document.createElement("button");
|
|
tmp.addEventListener("click", resetSelection);
|
|
tmp.addEventListener("click", resetSelection);
|
|
tmp.textContent = "Refresh";
|
|
tmp.textContent = "Refresh";
|
|
panel.appendChild(tmp);
|
|
panel.appendChild(tmp);
|
|
@@ -95,27 +95,27 @@ var FontInspector = (function FontInspectorClosure() {
|
|
// FontInspector specific functions.
|
|
// FontInspector specific functions.
|
|
fontAdded: function fontAdded(fontObj, url) {
|
|
fontAdded: function fontAdded(fontObj, url) {
|
|
function properties(obj, list) {
|
|
function properties(obj, list) {
|
|
- var moreInfo = document.createElement("table");
|
|
|
|
- for (var i = 0; i < list.length; i++) {
|
|
|
|
- var tr = document.createElement("tr");
|
|
|
|
- var td1 = document.createElement("td");
|
|
|
|
|
|
+ const moreInfo = document.createElement("table");
|
|
|
|
+ for (let i = 0; i < list.length; i++) {
|
|
|
|
+ const tr = document.createElement("tr");
|
|
|
|
+ const td1 = document.createElement("td");
|
|
td1.textContent = list[i];
|
|
td1.textContent = list[i];
|
|
tr.appendChild(td1);
|
|
tr.appendChild(td1);
|
|
- var td2 = document.createElement("td");
|
|
|
|
|
|
+ const td2 = document.createElement("td");
|
|
td2.textContent = obj[list[i]].toString();
|
|
td2.textContent = obj[list[i]].toString();
|
|
tr.appendChild(td2);
|
|
tr.appendChild(td2);
|
|
moreInfo.appendChild(tr);
|
|
moreInfo.appendChild(tr);
|
|
}
|
|
}
|
|
return moreInfo;
|
|
return moreInfo;
|
|
}
|
|
}
|
|
- var moreInfo = properties(fontObj, ["name", "type"]);
|
|
|
|
|
|
+ const moreInfo = properties(fontObj, ["name", "type"]);
|
|
const fontName = fontObj.loadedName;
|
|
const fontName = fontObj.loadedName;
|
|
- var font = document.createElement("div");
|
|
|
|
- var name = document.createElement("span");
|
|
|
|
|
|
+ const font = document.createElement("div");
|
|
|
|
+ const name = document.createElement("span");
|
|
name.textContent = fontName;
|
|
name.textContent = fontName;
|
|
- var download = document.createElement("a");
|
|
|
|
|
|
+ const download = document.createElement("a");
|
|
if (url) {
|
|
if (url) {
|
|
- url = /url\(['"]?([^\)"']+)/.exec(url);
|
|
|
|
|
|
+ url = /url\(['"]?([^)"']+)/.exec(url);
|
|
download.href = url[1];
|
|
download.href = url[1];
|
|
} else if (fontObj.data) {
|
|
} else if (fontObj.data) {
|
|
download.href = URL.createObjectURL(
|
|
download.href = URL.createObjectURL(
|
|
@@ -123,17 +123,17 @@ var FontInspector = (function FontInspectorClosure() {
|
|
);
|
|
);
|
|
}
|
|
}
|
|
download.textContent = "Download";
|
|
download.textContent = "Download";
|
|
- var logIt = document.createElement("a");
|
|
|
|
|
|
+ const logIt = document.createElement("a");
|
|
logIt.href = "";
|
|
logIt.href = "";
|
|
logIt.textContent = "Log";
|
|
logIt.textContent = "Log";
|
|
- logIt.addEventListener("click", function(event) {
|
|
|
|
|
|
+ logIt.addEventListener("click", function (event) {
|
|
event.preventDefault();
|
|
event.preventDefault();
|
|
console.log(fontObj);
|
|
console.log(fontObj);
|
|
});
|
|
});
|
|
const select = document.createElement("input");
|
|
const select = document.createElement("input");
|
|
select.setAttribute("type", "checkbox");
|
|
select.setAttribute("type", "checkbox");
|
|
select.dataset.fontName = fontName;
|
|
select.dataset.fontName = fontName;
|
|
- select.addEventListener("click", function() {
|
|
|
|
|
|
+ select.addEventListener("click", function () {
|
|
selectFont(fontName, select.checked);
|
|
selectFont(fontName, select.checked);
|
|
});
|
|
});
|
|
font.appendChild(select);
|
|
font.appendChild(select);
|
|
@@ -155,15 +155,17 @@ var FontInspector = (function FontInspectorClosure() {
|
|
};
|
|
};
|
|
})();
|
|
})();
|
|
|
|
|
|
-var opMap;
|
|
|
|
|
|
+let opMap;
|
|
|
|
|
|
// Manages all the page steppers.
|
|
// Manages all the page steppers.
|
|
|
|
+//
|
|
|
|
+// eslint-disable-next-line no-var
|
|
var StepperManager = (function StepperManagerClosure() {
|
|
var StepperManager = (function StepperManagerClosure() {
|
|
- var steppers = [];
|
|
|
|
- var stepperDiv = null;
|
|
|
|
- var stepperControls = null;
|
|
|
|
- var stepperChooser = null;
|
|
|
|
- var breakPoints = Object.create(null);
|
|
|
|
|
|
+ let steppers = [];
|
|
|
|
+ let stepperDiv = null;
|
|
|
|
+ let stepperControls = null;
|
|
|
|
+ let stepperChooser = null;
|
|
|
|
+ let breakPoints = Object.create(null);
|
|
return {
|
|
return {
|
|
// Properties/functions needed by PDFBug.
|
|
// Properties/functions needed by PDFBug.
|
|
id: "Stepper",
|
|
id: "Stepper",
|
|
@@ -171,10 +173,10 @@ var StepperManager = (function StepperManagerClosure() {
|
|
panel: null,
|
|
panel: null,
|
|
manager: null,
|
|
manager: null,
|
|
init: function init(pdfjsLib) {
|
|
init: function init(pdfjsLib) {
|
|
- var self = this;
|
|
|
|
|
|
+ const self = this;
|
|
stepperControls = document.createElement("div");
|
|
stepperControls = document.createElement("div");
|
|
stepperChooser = document.createElement("select");
|
|
stepperChooser = document.createElement("select");
|
|
- stepperChooser.addEventListener("change", function(event) {
|
|
|
|
|
|
+ stepperChooser.addEventListener("change", function (event) {
|
|
self.selectStepper(this.value);
|
|
self.selectStepper(this.value);
|
|
});
|
|
});
|
|
stepperControls.appendChild(stepperChooser);
|
|
stepperControls.appendChild(stepperChooser);
|
|
@@ -186,7 +188,7 @@ var StepperManager = (function StepperManagerClosure() {
|
|
}
|
|
}
|
|
|
|
|
|
opMap = Object.create(null);
|
|
opMap = Object.create(null);
|
|
- for (var key in pdfjsLib.OPS) {
|
|
|
|
|
|
+ for (const key in pdfjsLib.OPS) {
|
|
opMap[pdfjsLib.OPS[key]] = key;
|
|
opMap[pdfjsLib.OPS[key]] = key;
|
|
}
|
|
}
|
|
},
|
|
},
|
|
@@ -199,17 +201,17 @@ var StepperManager = (function StepperManagerClosure() {
|
|
active: false,
|
|
active: false,
|
|
// Stepper specific functions.
|
|
// Stepper specific functions.
|
|
create: function create(pageIndex) {
|
|
create: function create(pageIndex) {
|
|
- var debug = document.createElement("div");
|
|
|
|
|
|
+ const debug = document.createElement("div");
|
|
debug.id = "stepper" + pageIndex;
|
|
debug.id = "stepper" + pageIndex;
|
|
- debug.setAttribute("hidden", true);
|
|
|
|
|
|
+ debug.hidden = true;
|
|
debug.className = "stepper";
|
|
debug.className = "stepper";
|
|
stepperDiv.appendChild(debug);
|
|
stepperDiv.appendChild(debug);
|
|
- var b = document.createElement("option");
|
|
|
|
|
|
+ const b = document.createElement("option");
|
|
b.textContent = "Page " + (pageIndex + 1);
|
|
b.textContent = "Page " + (pageIndex + 1);
|
|
b.value = pageIndex;
|
|
b.value = pageIndex;
|
|
stepperChooser.appendChild(b);
|
|
stepperChooser.appendChild(b);
|
|
- var initBreakPoints = breakPoints[pageIndex] || [];
|
|
|
|
- var stepper = new Stepper(debug, pageIndex, initBreakPoints);
|
|
|
|
|
|
+ const initBreakPoints = breakPoints[pageIndex] || [];
|
|
|
|
+ const stepper = new Stepper(debug, pageIndex, initBreakPoints);
|
|
steppers.push(stepper);
|
|
steppers.push(stepper);
|
|
if (steppers.length === 1) {
|
|
if (steppers.length === 1) {
|
|
this.selectStepper(pageIndex, false);
|
|
this.selectStepper(pageIndex, false);
|
|
@@ -217,22 +219,18 @@ var StepperManager = (function StepperManagerClosure() {
|
|
return stepper;
|
|
return stepper;
|
|
},
|
|
},
|
|
selectStepper: function selectStepper(pageIndex, selectPanel) {
|
|
selectStepper: function selectStepper(pageIndex, selectPanel) {
|
|
- var i;
|
|
|
|
|
|
+ let i;
|
|
pageIndex = pageIndex | 0;
|
|
pageIndex = pageIndex | 0;
|
|
if (selectPanel) {
|
|
if (selectPanel) {
|
|
this.manager.selectPanel(this);
|
|
this.manager.selectPanel(this);
|
|
}
|
|
}
|
|
for (i = 0; i < steppers.length; ++i) {
|
|
for (i = 0; i < steppers.length; ++i) {
|
|
- var stepper = steppers[i];
|
|
|
|
- if (stepper.pageIndex === pageIndex) {
|
|
|
|
- stepper.panel.removeAttribute("hidden");
|
|
|
|
- } else {
|
|
|
|
- stepper.panel.setAttribute("hidden", true);
|
|
|
|
- }
|
|
|
|
|
|
+ const stepper = steppers[i];
|
|
|
|
+ stepper.panel.hidden = stepper.pageIndex !== pageIndex;
|
|
}
|
|
}
|
|
- var options = stepperChooser.options;
|
|
|
|
|
|
+ const options = stepperChooser.options;
|
|
for (i = 0; i < options.length; ++i) {
|
|
for (i = 0; i < options.length; ++i) {
|
|
- var option = options[i];
|
|
|
|
|
|
+ const option = options[i];
|
|
option.selected = (option.value | 0) === pageIndex;
|
|
option.selected = (option.value | 0) === pageIndex;
|
|
}
|
|
}
|
|
},
|
|
},
|
|
@@ -243,11 +241,11 @@ var StepperManager = (function StepperManagerClosure() {
|
|
};
|
|
};
|
|
})();
|
|
})();
|
|
|
|
|
|
-// The stepper for each page's IRQueue.
|
|
|
|
-var Stepper = (function StepperClosure() {
|
|
|
|
|
|
+// The stepper for each page's operatorList.
|
|
|
|
+const Stepper = (function StepperClosure() {
|
|
// Shorter way to create element and optionally set textContent.
|
|
// Shorter way to create element and optionally set textContent.
|
|
function c(tag, textContent) {
|
|
function c(tag, textContent) {
|
|
- var d = document.createElement(tag);
|
|
|
|
|
|
+ const d = document.createElement(tag);
|
|
if (textContent) {
|
|
if (textContent) {
|
|
d.textContent = textContent;
|
|
d.textContent = textContent;
|
|
}
|
|
}
|
|
@@ -256,7 +254,7 @@ var Stepper = (function StepperClosure() {
|
|
|
|
|
|
function simplifyArgs(args) {
|
|
function simplifyArgs(args) {
|
|
if (typeof args === "string") {
|
|
if (typeof args === "string") {
|
|
- var MAX_STRING_LENGTH = 75;
|
|
|
|
|
|
+ const MAX_STRING_LENGTH = 75;
|
|
return args.length <= MAX_STRING_LENGTH
|
|
return args.length <= MAX_STRING_LENGTH
|
|
? args
|
|
? args
|
|
: args.substring(0, MAX_STRING_LENGTH) + "...";
|
|
: args.substring(0, MAX_STRING_LENGTH) + "...";
|
|
@@ -266,10 +264,9 @@ var Stepper = (function StepperClosure() {
|
|
}
|
|
}
|
|
if ("length" in args) {
|
|
if ("length" in args) {
|
|
// array
|
|
// array
|
|
- var simpleArgs = [],
|
|
|
|
- i,
|
|
|
|
- ii;
|
|
|
|
- var MAX_ITEMS = 10;
|
|
|
|
|
|
+ const MAX_ITEMS = 10,
|
|
|
|
+ simpleArgs = [];
|
|
|
|
+ let i, ii;
|
|
for (i = 0, ii = Math.min(MAX_ITEMS, args.length); i < ii; i++) {
|
|
for (i = 0, ii = Math.min(MAX_ITEMS, args.length); i < ii; i++) {
|
|
simpleArgs.push(simplifyArgs(args[i]));
|
|
simpleArgs.push(simplifyArgs(args[i]));
|
|
}
|
|
}
|
|
@@ -278,30 +275,32 @@ var Stepper = (function StepperClosure() {
|
|
}
|
|
}
|
|
return simpleArgs;
|
|
return simpleArgs;
|
|
}
|
|
}
|
|
- var simpleObj = {};
|
|
|
|
- for (var key in args) {
|
|
|
|
|
|
+ const simpleObj = {};
|
|
|
|
+ for (const key in args) {
|
|
simpleObj[key] = simplifyArgs(args[key]);
|
|
simpleObj[key] = simplifyArgs(args[key]);
|
|
}
|
|
}
|
|
return simpleObj;
|
|
return simpleObj;
|
|
}
|
|
}
|
|
|
|
|
|
- function Stepper(panel, pageIndex, initialBreakPoints) {
|
|
|
|
- this.panel = panel;
|
|
|
|
- this.breakPoint = 0;
|
|
|
|
- this.nextBreakPoint = null;
|
|
|
|
- this.pageIndex = pageIndex;
|
|
|
|
- this.breakPoints = initialBreakPoints;
|
|
|
|
- this.currentIdx = -1;
|
|
|
|
- this.operatorListIdx = 0;
|
|
|
|
- }
|
|
|
|
- Stepper.prototype = {
|
|
|
|
- init: function init(operatorList) {
|
|
|
|
- var panel = this.panel;
|
|
|
|
- var content = c("div", "c=continue, s=step");
|
|
|
|
- var table = c("table");
|
|
|
|
|
|
+ // eslint-disable-next-line no-shadow
|
|
|
|
+ class Stepper {
|
|
|
|
+ constructor(panel, pageIndex, initialBreakPoints) {
|
|
|
|
+ this.panel = panel;
|
|
|
|
+ this.breakPoint = 0;
|
|
|
|
+ this.nextBreakPoint = null;
|
|
|
|
+ this.pageIndex = pageIndex;
|
|
|
|
+ this.breakPoints = initialBreakPoints;
|
|
|
|
+ this.currentIdx = -1;
|
|
|
|
+ this.operatorListIdx = 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ init(operatorList) {
|
|
|
|
+ const panel = this.panel;
|
|
|
|
+ const content = c("div", "c=continue, s=step");
|
|
|
|
+ const table = c("table");
|
|
content.appendChild(table);
|
|
content.appendChild(table);
|
|
table.cellSpacing = 0;
|
|
table.cellSpacing = 0;
|
|
- var headerRow = c("tr");
|
|
|
|
|
|
+ const headerRow = c("tr");
|
|
table.appendChild(headerRow);
|
|
table.appendChild(headerRow);
|
|
headerRow.appendChild(c("th", "Break"));
|
|
headerRow.appendChild(c("th", "Break"));
|
|
headerRow.appendChild(c("th", "Idx"));
|
|
headerRow.appendChild(c("th", "Idx"));
|
|
@@ -310,12 +309,13 @@ var Stepper = (function StepperClosure() {
|
|
panel.appendChild(content);
|
|
panel.appendChild(content);
|
|
this.table = table;
|
|
this.table = table;
|
|
this.updateOperatorList(operatorList);
|
|
this.updateOperatorList(operatorList);
|
|
- },
|
|
|
|
- updateOperatorList: function updateOperatorList(operatorList) {
|
|
|
|
- var self = this;
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ updateOperatorList(operatorList) {
|
|
|
|
+ const self = this;
|
|
|
|
|
|
function cboxOnClick() {
|
|
function cboxOnClick() {
|
|
- var x = +this.dataset.idx;
|
|
|
|
|
|
+ const x = +this.dataset.idx;
|
|
if (this.checked) {
|
|
if (this.checked) {
|
|
self.breakPoints.push(x);
|
|
self.breakPoints.push(x);
|
|
} else {
|
|
} else {
|
|
@@ -324,26 +324,26 @@ var Stepper = (function StepperClosure() {
|
|
StepperManager.saveBreakPoints(self.pageIndex, self.breakPoints);
|
|
StepperManager.saveBreakPoints(self.pageIndex, self.breakPoints);
|
|
}
|
|
}
|
|
|
|
|
|
- var MAX_OPERATORS_COUNT = 15000;
|
|
|
|
|
|
+ const MAX_OPERATORS_COUNT = 15000;
|
|
if (this.operatorListIdx > MAX_OPERATORS_COUNT) {
|
|
if (this.operatorListIdx > MAX_OPERATORS_COUNT) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- var chunk = document.createDocumentFragment();
|
|
|
|
- var operatorsToDisplay = Math.min(
|
|
|
|
|
|
+ const chunk = document.createDocumentFragment();
|
|
|
|
+ const operatorsToDisplay = Math.min(
|
|
MAX_OPERATORS_COUNT,
|
|
MAX_OPERATORS_COUNT,
|
|
operatorList.fnArray.length
|
|
operatorList.fnArray.length
|
|
);
|
|
);
|
|
- for (var i = this.operatorListIdx; i < operatorsToDisplay; i++) {
|
|
|
|
- var line = c("tr");
|
|
|
|
|
|
+ for (let i = this.operatorListIdx; i < operatorsToDisplay; i++) {
|
|
|
|
+ const line = c("tr");
|
|
line.className = "line";
|
|
line.className = "line";
|
|
line.dataset.idx = i;
|
|
line.dataset.idx = i;
|
|
chunk.appendChild(line);
|
|
chunk.appendChild(line);
|
|
- var checked = this.breakPoints.includes(i);
|
|
|
|
- var args = operatorList.argsArray[i] || [];
|
|
|
|
|
|
+ const checked = this.breakPoints.includes(i);
|
|
|
|
+ const args = operatorList.argsArray[i] || [];
|
|
|
|
|
|
- var breakCell = c("td");
|
|
|
|
- var cbox = c("input");
|
|
|
|
|
|
+ const breakCell = c("td");
|
|
|
|
+ const cbox = c("input");
|
|
cbox.type = "checkbox";
|
|
cbox.type = "checkbox";
|
|
cbox.className = "points";
|
|
cbox.className = "points";
|
|
cbox.checked = checked;
|
|
cbox.checked = checked;
|
|
@@ -353,14 +353,14 @@ var Stepper = (function StepperClosure() {
|
|
breakCell.appendChild(cbox);
|
|
breakCell.appendChild(cbox);
|
|
line.appendChild(breakCell);
|
|
line.appendChild(breakCell);
|
|
line.appendChild(c("td", i.toString()));
|
|
line.appendChild(c("td", i.toString()));
|
|
- var fn = opMap[operatorList.fnArray[i]];
|
|
|
|
- var decArgs = args;
|
|
|
|
|
|
+ const fn = opMap[operatorList.fnArray[i]];
|
|
|
|
+ let decArgs = args;
|
|
if (fn === "showText") {
|
|
if (fn === "showText") {
|
|
- var glyphs = args[0];
|
|
|
|
- var newArgs = [];
|
|
|
|
- var str = [];
|
|
|
|
- for (var j = 0; j < glyphs.length; j++) {
|
|
|
|
- var glyph = glyphs[j];
|
|
|
|
|
|
+ const glyphs = args[0];
|
|
|
|
+ const newArgs = [];
|
|
|
|
+ let str = [];
|
|
|
|
+ for (let j = 0; j < glyphs.length; j++) {
|
|
|
|
+ const glyph = glyphs[j];
|
|
if (typeof glyph === "object" && glyph !== null) {
|
|
if (typeof glyph === "object" && glyph !== null) {
|
|
str.push(glyph.fontChar);
|
|
str.push(glyph.fontChar);
|
|
} else {
|
|
} else {
|
|
@@ -380,54 +380,54 @@ var Stepper = (function StepperClosure() {
|
|
line.appendChild(c("td", JSON.stringify(simplifyArgs(decArgs))));
|
|
line.appendChild(c("td", JSON.stringify(simplifyArgs(decArgs))));
|
|
}
|
|
}
|
|
if (operatorsToDisplay < operatorList.fnArray.length) {
|
|
if (operatorsToDisplay < operatorList.fnArray.length) {
|
|
- line = c("tr");
|
|
|
|
- var lastCell = c("td", "...");
|
|
|
|
|
|
+ const lastCell = c("td", "...");
|
|
lastCell.colspan = 4;
|
|
lastCell.colspan = 4;
|
|
chunk.appendChild(lastCell);
|
|
chunk.appendChild(lastCell);
|
|
}
|
|
}
|
|
this.operatorListIdx = operatorList.fnArray.length;
|
|
this.operatorListIdx = operatorList.fnArray.length;
|
|
this.table.appendChild(chunk);
|
|
this.table.appendChild(chunk);
|
|
- },
|
|
|
|
- getNextBreakPoint: function getNextBreakPoint() {
|
|
|
|
- this.breakPoints.sort(function(a, b) {
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ getNextBreakPoint() {
|
|
|
|
+ this.breakPoints.sort(function (a, b) {
|
|
return a - b;
|
|
return a - b;
|
|
});
|
|
});
|
|
- for (var i = 0; i < this.breakPoints.length; i++) {
|
|
|
|
|
|
+ for (let i = 0; i < this.breakPoints.length; i++) {
|
|
if (this.breakPoints[i] > this.currentIdx) {
|
|
if (this.breakPoints[i] > this.currentIdx) {
|
|
return this.breakPoints[i];
|
|
return this.breakPoints[i];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
return null;
|
|
- },
|
|
|
|
- breakIt: function breakIt(idx, callback) {
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ breakIt(idx, callback) {
|
|
StepperManager.selectStepper(this.pageIndex, true);
|
|
StepperManager.selectStepper(this.pageIndex, true);
|
|
- var self = this;
|
|
|
|
- var dom = document;
|
|
|
|
- self.currentIdx = idx;
|
|
|
|
- var listener = function(e) {
|
|
|
|
- switch (e.keyCode) {
|
|
|
|
|
|
+ this.currentIdx = idx;
|
|
|
|
+
|
|
|
|
+ const listener = evt => {
|
|
|
|
+ switch (evt.keyCode) {
|
|
case 83: // step
|
|
case 83: // step
|
|
- dom.removeEventListener("keydown", listener);
|
|
|
|
- self.nextBreakPoint = self.currentIdx + 1;
|
|
|
|
- self.goTo(-1);
|
|
|
|
|
|
+ document.removeEventListener("keydown", listener);
|
|
|
|
+ this.nextBreakPoint = this.currentIdx + 1;
|
|
|
|
+ this.goTo(-1);
|
|
callback();
|
|
callback();
|
|
break;
|
|
break;
|
|
case 67: // continue
|
|
case 67: // continue
|
|
- dom.removeEventListener("keydown", listener);
|
|
|
|
- var breakPoint = self.getNextBreakPoint();
|
|
|
|
- self.nextBreakPoint = breakPoint;
|
|
|
|
- self.goTo(-1);
|
|
|
|
|
|
+ document.removeEventListener("keydown", listener);
|
|
|
|
+ this.nextBreakPoint = this.getNextBreakPoint();
|
|
|
|
+ this.goTo(-1);
|
|
callback();
|
|
callback();
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
};
|
|
};
|
|
- dom.addEventListener("keydown", listener);
|
|
|
|
- self.goTo(idx);
|
|
|
|
- },
|
|
|
|
- goTo: function goTo(idx) {
|
|
|
|
- var allRows = this.panel.getElementsByClassName("line");
|
|
|
|
- for (var x = 0, xx = allRows.length; x < xx; ++x) {
|
|
|
|
- var row = allRows[x];
|
|
|
|
|
|
+ document.addEventListener("keydown", listener);
|
|
|
|
+ this.goTo(idx);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ goTo(idx) {
|
|
|
|
+ const allRows = this.panel.getElementsByClassName("line");
|
|
|
|
+ for (let x = 0, xx = allRows.length; x < xx; ++x) {
|
|
|
|
+ const row = allRows[x];
|
|
if ((row.dataset.idx | 0) === idx) {
|
|
if ((row.dataset.idx | 0) === idx) {
|
|
row.style.backgroundColor = "rgb(251,250,207)";
|
|
row.style.backgroundColor = "rgb(251,250,207)";
|
|
row.scrollIntoView();
|
|
row.scrollIntoView();
|
|
@@ -435,20 +435,21 @@ var Stepper = (function StepperClosure() {
|
|
row.style.backgroundColor = null;
|
|
row.style.backgroundColor = null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- },
|
|
|
|
- };
|
|
|
|
|
|
+ }
|
|
|
|
+ }
|
|
return Stepper;
|
|
return Stepper;
|
|
})();
|
|
})();
|
|
|
|
|
|
|
|
+// eslint-disable-next-line no-var
|
|
var Stats = (function Stats() {
|
|
var Stats = (function Stats() {
|
|
- var stats = [];
|
|
|
|
|
|
+ let stats = [];
|
|
function clear(node) {
|
|
function clear(node) {
|
|
while (node.hasChildNodes()) {
|
|
while (node.hasChildNodes()) {
|
|
node.removeChild(node.lastChild);
|
|
node.removeChild(node.lastChild);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function getStatIndex(pageNumber) {
|
|
function getStatIndex(pageNumber) {
|
|
- for (var i = 0, ii = stats.length; i < ii; ++i) {
|
|
|
|
|
|
+ for (let i = 0, ii = stats.length; i < ii; ++i) {
|
|
if (stats[i].pageNumber === pageNumber) {
|
|
if (stats[i].pageNumber === pageNumber) {
|
|
return i;
|
|
return i;
|
|
}
|
|
}
|
|
@@ -469,27 +470,27 @@ var Stats = (function Stats() {
|
|
if (!stat) {
|
|
if (!stat) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- var statsIndex = getStatIndex(pageNumber);
|
|
|
|
|
|
+ const statsIndex = getStatIndex(pageNumber);
|
|
if (statsIndex !== false) {
|
|
if (statsIndex !== false) {
|
|
const b = stats[statsIndex];
|
|
const b = stats[statsIndex];
|
|
this.panel.removeChild(b.div);
|
|
this.panel.removeChild(b.div);
|
|
stats.splice(statsIndex, 1);
|
|
stats.splice(statsIndex, 1);
|
|
}
|
|
}
|
|
- var wrapper = document.createElement("div");
|
|
|
|
|
|
+ const wrapper = document.createElement("div");
|
|
wrapper.className = "stats";
|
|
wrapper.className = "stats";
|
|
- var title = document.createElement("div");
|
|
|
|
|
|
+ const title = document.createElement("div");
|
|
title.className = "title";
|
|
title.className = "title";
|
|
title.textContent = "Page: " + pageNumber;
|
|
title.textContent = "Page: " + pageNumber;
|
|
- var statsDiv = document.createElement("div");
|
|
|
|
|
|
+ const statsDiv = document.createElement("div");
|
|
statsDiv.textContent = stat.toString();
|
|
statsDiv.textContent = stat.toString();
|
|
wrapper.appendChild(title);
|
|
wrapper.appendChild(title);
|
|
wrapper.appendChild(statsDiv);
|
|
wrapper.appendChild(statsDiv);
|
|
stats.push({ pageNumber, div: wrapper });
|
|
stats.push({ pageNumber, div: wrapper });
|
|
- stats.sort(function(a, b) {
|
|
|
|
|
|
+ stats.sort(function (a, b) {
|
|
return a.pageNumber - b.pageNumber;
|
|
return a.pageNumber - b.pageNumber;
|
|
});
|
|
});
|
|
clear(this.panel);
|
|
clear(this.panel);
|
|
- for (var i = 0, ii = stats.length; i < ii; ++i) {
|
|
|
|
|
|
+ for (let i = 0, ii = stats.length; i < ii; ++i) {
|
|
this.panel.appendChild(stats[i].div);
|
|
this.panel.appendChild(stats[i].div);
|
|
}
|
|
}
|
|
},
|
|
},
|
|
@@ -502,30 +503,27 @@ var Stats = (function Stats() {
|
|
|
|
|
|
// Manages all the debugging tools.
|
|
// Manages all the debugging tools.
|
|
window.PDFBug = (function PDFBugClosure() {
|
|
window.PDFBug = (function PDFBugClosure() {
|
|
- var panelWidth = 300;
|
|
|
|
- var buttons = [];
|
|
|
|
- var activePanel = null;
|
|
|
|
|
|
+ const panelWidth = 300;
|
|
|
|
+ const buttons = [];
|
|
|
|
+ let activePanel = null;
|
|
|
|
|
|
return {
|
|
return {
|
|
tools: [FontInspector, StepperManager, Stats],
|
|
tools: [FontInspector, StepperManager, Stats],
|
|
enable(ids) {
|
|
enable(ids) {
|
|
- var all = false,
|
|
|
|
- tools = this.tools;
|
|
|
|
- if (ids.length === 1 && ids[0] === "all") {
|
|
|
|
- all = true;
|
|
|
|
- }
|
|
|
|
- for (var i = 0; i < tools.length; ++i) {
|
|
|
|
- var tool = tools[i];
|
|
|
|
|
|
+ const all = ids.length === 1 && ids[0] === "all";
|
|
|
|
+ const tools = this.tools;
|
|
|
|
+ for (let i = 0; i < tools.length; ++i) {
|
|
|
|
+ const tool = tools[i];
|
|
if (all || ids.includes(tool.id)) {
|
|
if (all || ids.includes(tool.id)) {
|
|
tool.enabled = true;
|
|
tool.enabled = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (!all) {
|
|
if (!all) {
|
|
// Sort the tools by the order they are enabled.
|
|
// Sort the tools by the order they are enabled.
|
|
- tools.sort(function(a, b) {
|
|
|
|
- var indexA = ids.indexOf(a.id);
|
|
|
|
|
|
+ tools.sort(function (a, b) {
|
|
|
|
+ let indexA = ids.indexOf(a.id);
|
|
indexA = indexA < 0 ? tools.length : indexA;
|
|
indexA = indexA < 0 ? tools.length : indexA;
|
|
- var indexB = ids.indexOf(b.id);
|
|
|
|
|
|
+ let indexB = ids.indexOf(b.id);
|
|
indexB = indexB < 0 ? tools.length : indexB;
|
|
indexB = indexB < 0 ? tools.length : indexB;
|
|
return indexA - indexB;
|
|
return indexA - indexB;
|
|
});
|
|
});
|
|
@@ -541,14 +539,14 @@ window.PDFBug = (function PDFBugClosure() {
|
|
* Panel
|
|
* Panel
|
|
* ...
|
|
* ...
|
|
*/
|
|
*/
|
|
- var ui = document.createElement("div");
|
|
|
|
|
|
+ const ui = document.createElement("div");
|
|
ui.id = "PDFBug";
|
|
ui.id = "PDFBug";
|
|
|
|
|
|
- var controls = document.createElement("div");
|
|
|
|
|
|
+ const controls = document.createElement("div");
|
|
controls.setAttribute("class", "controls");
|
|
controls.setAttribute("class", "controls");
|
|
ui.appendChild(controls);
|
|
ui.appendChild(controls);
|
|
|
|
|
|
- var panels = document.createElement("div");
|
|
|
|
|
|
+ const panels = document.createElement("div");
|
|
panels.setAttribute("class", "panels");
|
|
panels.setAttribute("class", "panels");
|
|
ui.appendChild(panels);
|
|
ui.appendChild(panels);
|
|
|
|
|
|
@@ -556,17 +554,17 @@ window.PDFBug = (function PDFBugClosure() {
|
|
container.style.right = panelWidth + "px";
|
|
container.style.right = panelWidth + "px";
|
|
|
|
|
|
// Initialize all the debugging tools.
|
|
// Initialize all the debugging tools.
|
|
- var tools = this.tools;
|
|
|
|
- var self = this;
|
|
|
|
- for (var i = 0; i < tools.length; ++i) {
|
|
|
|
- var tool = tools[i];
|
|
|
|
- var panel = document.createElement("div");
|
|
|
|
- var panelButton = document.createElement("button");
|
|
|
|
|
|
+ const tools = this.tools;
|
|
|
|
+ const self = this;
|
|
|
|
+ for (let i = 0; i < tools.length; ++i) {
|
|
|
|
+ const tool = tools[i];
|
|
|
|
+ const panel = document.createElement("div");
|
|
|
|
+ const panelButton = document.createElement("button");
|
|
panelButton.textContent = tool.name;
|
|
panelButton.textContent = tool.name;
|
|
panelButton.addEventListener(
|
|
panelButton.addEventListener(
|
|
"click",
|
|
"click",
|
|
- (function(selected) {
|
|
|
|
- return function(event) {
|
|
|
|
|
|
+ (function (selected) {
|
|
|
|
+ return function (event) {
|
|
event.preventDefault();
|
|
event.preventDefault();
|
|
self.selectPanel(selected);
|
|
self.selectPanel(selected);
|
|
};
|
|
};
|
|
@@ -592,7 +590,7 @@ window.PDFBug = (function PDFBugClosure() {
|
|
this.selectPanel(0);
|
|
this.selectPanel(0);
|
|
},
|
|
},
|
|
cleanup() {
|
|
cleanup() {
|
|
- for (var i = 0, ii = this.tools.length; i < ii; i++) {
|
|
|
|
|
|
+ for (let i = 0, ii = this.tools.length; i < ii; i++) {
|
|
if (this.tools[i].enabled) {
|
|
if (this.tools[i].enabled) {
|
|
this.tools[i].cleanup();
|
|
this.tools[i].cleanup();
|
|
}
|
|
}
|
|
@@ -606,17 +604,12 @@ window.PDFBug = (function PDFBugClosure() {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
activePanel = index;
|
|
activePanel = index;
|
|
- var tools = this.tools;
|
|
|
|
- for (var j = 0; j < tools.length; ++j) {
|
|
|
|
- if (j === index) {
|
|
|
|
- buttons[j].setAttribute("class", "active");
|
|
|
|
- tools[j].active = true;
|
|
|
|
- tools[j].panel.removeAttribute("hidden");
|
|
|
|
- } else {
|
|
|
|
- buttons[j].setAttribute("class", "");
|
|
|
|
- tools[j].active = false;
|
|
|
|
- tools[j].panel.setAttribute("hidden", "true");
|
|
|
|
- }
|
|
|
|
|
|
+ const tools = this.tools;
|
|
|
|
+ for (let j = 0; j < tools.length; ++j) {
|
|
|
|
+ const isActive = j === index;
|
|
|
|
+ buttons[j].classList.toggle("active", isActive);
|
|
|
|
+ tools[j].active = isActive;
|
|
|
|
+ tools[j].panel.hidden = !isActive;
|
|
}
|
|
}
|
|
},
|
|
},
|
|
};
|
|
};
|