Untitled diff

Created Diff never expires
36 removals
Lines
Total
Removed
Words
Total
Removed
To continue using this feature, upgrade to
Diffchecker logo
Diffchecker Pro
48 lines
15 additions
Lines
Total
Added
Words
Total
Added
To continue using this feature, upgrade to
Diffchecker logo
Diffchecker Pro
33 lines
window.onload = function () {
window.onload = function () {
renderGrid();
renderGrid();
};
};

function renderGrid() {
function renderGrid() {
var dispW = document.getElementById('width-in').value
var blocksTall = document.getElementById('width-in').value;
var dispH = document.getElementById('height-in').value
var blocksWide = document.getElementById('height-in').value;
//alert("width = " + dispW + ", height = " + dispH);
var blocksTotal = blocksWide * blocksTall;
var full = Math.floor(dispH / 17);
var excessH = dispH % 17;
var excessW = dispW % full;
var blocksTall = 17;
var blocksWide = Math.floor(dispW / full);
var placeBlocks = document.getElementById('matrix-shell');
var placeBlocks = document.getElementById('matrix-shell');
var brk = document.createElement("br");

console.log(blocksWide + "/" + blocksTall);
console.log(blocksWide + "/" + blocksTall);

for (var i = 1; i <= blocksTotal; i++) {
for (var j = 1; j <= blocksTall; j++) {
var mb = document.createElement("div");

mb.className = 'matrix-block mb-off';
for (var i = 1; i <= blocksWide; i++) {
mb.setAttribute("class", "matrix-block mb-off");
var mb = document.createElement("div");
mb.onclick = select_mb;
//mb.setAttribute("id", "matblock-" + i + "-" + j);
placeBlocks.appendChild(mb);
mb.setAttribute("class", "matrix-block mb-off");
if (((i / blocksWide) % 1) === 0) {
mb.setAttribute("onClick", "select_mb('" + i + "," + j + "');");
var brk = document.createElement("br");
placeBlocks.appendChild(mb);
}

if (j = blocksWide) {
placeBlocks.appendChild(brk);
placeBlocks.appendChild(brk);
}
}

}
}
}
}

function select_mb(e) {
function select_mb(blockNum) {
var cur_mb = e.target;
var cur_mb = document.getElementById(blockNum);
// Turn cell on.
// Turn cell on.
if (cur_mb.getAttribute("class") == "matrix-block mb-off") {
if (cur_mb.className == "matrix-block mb-off") {
cur_mb.style.backgroundColor = "#00FF00";
cur_mb.style.backgroundColor = "#00FF00";
cur_mb.setAttribute("class", "matrix-block mb-on");
cur_mb.className = "matrix-block mb-on";

} else {
} else {
//Turn cell off.
//Turn cell off.
cur_mb.style.backgroundColor = "#000";
cur_mb.style.backgroundColor = "#000";
cur_mb.setAttribute("class", "matrix-block mb-off");
cur_mb.className = "matrix-block mb-off";
}
}
}
}