Skip to content

Commit

Permalink
Added instructions for layout & coordinates.
Browse files Browse the repository at this point in the history
Fixed pb copy alert alignment.
Ignore coordinate header row, if present.
Maintain coordinate precision.
Added analytics.
  • Loading branch information
jasoncoon committed Feb 4, 2022
1 parent 1bfaed5 commit 916f92a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 15 deletions.
39 changes: 31 additions & 8 deletions index.htm
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,21 @@
<link href="index.css" rel="stylesheet" />

<title>LED Mapper</title>

<!-- Global site tag (gtag.js) - Google Analytics -->
<script
async
src="https://www.googletagmanager.com/gtag/js?id=G-68S25LC05F"
></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag("js", new Date());

gtag("config", "G-68S25LC05F");
</script>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
Expand Down Expand Up @@ -176,6 +191,10 @@ <h6 class="mb-2 text-muted">
role="tabpanel"
aria-labelledby="layout-tab"
>
<div class="text-muted">
Layout should have a unique LED index in each cell. Cells
without an LED should be empty.
</div>
<textarea class="form-control" id="textAreaLayout" rows="7">
0 1 2 3 4 5 6 7 8 9 10 11 12 13
30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14
Expand Down Expand Up @@ -216,6 +235,10 @@ <h6 class="mb-2 text-muted">
role="tabpanel"
aria-labelledby="coordinates-tab"
>
<div class="text-muted">
Coordinates should have three columns: index, x, and y, with
or without column headers.
</div>
<textarea
class="form-control"
id="textAreaCoordinates"
Expand Down Expand Up @@ -545,12 +568,12 @@ <h6 class="mb-2 text-muted">
>
Copy
</button>
</div>
<div class="input-group ms-2">
<div
class="invisible input-group-text"
id="divCopyPixelblaze"
></div>
<div class="input-group ms-2">
<div
class="invisible input-group-text"
id="divCopyPixelblaze"
></div>
</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -664,10 +687,10 @@ <h2 class="accordion-header" id="headingStats">
data-bs-parent="#accordionStats"
>
<div class="accordion-body">
Layout:
Parsed Layout:
<pre><code id="codeParsedLayout"></code></pre>

Coordinates:
Parsed Coordinates:
<pre><code id="codeParsedCoordinates"></code></pre>

Stats:
Expand Down
12 changes: 5 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,6 @@ function onTextLayoutChange() {
function onWindowResize() {
const min = Math.min(window.innerWidth, window.innerHeight) - 48;

console.log({ min });

canvasPreview.width = min;
canvasPreview.height = min;
canvasPreview.style.width = `${min}px`;
Expand Down Expand Up @@ -229,7 +227,7 @@ function copyLayoutValueToClipboard(element) {
function parseCoordinates() {
rows = textAreaCoordinates.value
?.split("\n")
.map((line) => line.split("\t").map((s) => parseInt(s)));
.map((line) => line.split("\t").map((s) => parseFloat(s)));

codeParsedCoordinates.innerText = JSON.stringify(rows);

Expand All @@ -243,11 +241,11 @@ function parseCoordinates() {
for (let r = 0; r < rows.length; r++) {
const row = rows[r];

if (row[0] == "i" || row[1] == "x" || row[2] == "y") continue;

const index = parseInt(row[0]);
const x = parseInt(row[1]);
const y = parseInt(row[2]);
const x = row[1];
const y = row[2];

if (isNaN(index) || isNaN(x) || isNaN(y)) continue;

if (x < minX) minX = x;
if (x > maxX) maxX = x;
Expand Down

0 comments on commit 916f92a

Please sign in to comment.