import { jDataView } from "./jdataview"; import { pesRead } from "../format-readers/pes"; import { dstRead } from "../format-readers/dst"; import { Pattern } from "./pattern"; String.prototype.endsWith = function (suffix) { return this.indexOf(suffix, this.length - suffix.length) !== -1; }; function displayFileText(filename, evt, canvas) { const view = jDataView(evt.target.result, 0, evt.size); const pattern = new Pattern(); filename = filename.toLowerCase(); if (filename.endsWith("pes")) { pesRead(view, pattern); } else if (filename.endsWith("dst")) { dstRead(view, pattern); } pattern.moveToPositive(); pattern.drawShape(canvas); } function handleFileReadAbort(evt) { alert("File read aborted."); } function handleFileReadError(evt) { let message; switch (evt.target.error.name) { case "NotFoundError": alert("The file could not be found at the time the read was processed."); break; case "SecurityError": message = "
A file security error occured. This can be due to:
"; message += "