import { jDataView } from "./jdataview"; import { supportedFormats } from "../format-readers"; import { Pattern } from "./pattern"; function renderFile(filename, evt, canvas, colorView, stitchesView, sizeView, localizedStrings) { const fileExtension = filename.toLowerCase().split(".").pop(); const view = jDataView(evt.target.result, 0, evt.size); const pattern = new Pattern(); supportedFormats[fileExtension].read(view, pattern); pattern.moveToPositive(); pattern.drawShapeTo(canvas); pattern.drawColorsTo(colorView); pattern.drawStitchesCountTo(stitchesView, localizedStrings.stitches); pattern.drawSizeValuesTo(stitchesView, localizedStrings.dimensions); } function renderAbortMessage(errorMessageRef) { errorMessageRef.innerHTML = "Render aborted!"; } function renderErrorMessage(errorName, errorMessageRef) { let message; switch (errorName) { case "NotFoundError": message = "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 += "