var nums = [[[[1,2],[1,3],[2,3]],[[0,2],[2,2],[0,2]],[[0,2],[0,2],[0,2]],[[0,2],[0,2],[0,2]],[[0,2],[0,0],[0,2]],[[0,1],[1,3],[0,3]]],[[[0,0],[1,2],[2,3]],[[0,0],[0,2],[0,2]],[[0,0],[0,2],[0,2]],[[0,0],[0,2],[0,2]],[[0,0],[0,2],[0,2]],[[0,0],[0,1],[0,3]]],[[[1,2],[1,3],[2,3]],[[0,1],[2,3],[0,2]],[[1,2],[0,3],[0,2]],[[0,2],[1,2],[0,3]],[[0,2],[0,1],[2,3]],[[0,1],[1,3],[0,3]]],[[[1,2],[1,3],[2,3]],[[0,1],[2,3],[0,2]],[[1,2],[0,3],[0,2]],[[0,1],[2,3],[0,2]],[[1,2],[0,3],[0,2]],[[0,1],[1,3],[0,3]]],[[[1,2],[2,3],[2,3]],[[0,2],[0,2],[0,2]],[[0,2],[0,1],[0,2]],[[0,1],[2,3],[0,2]],[[0,0],[0,2],[0,2]],[[0,0],[0,1],[0,3]]],[[[1,2],[1,3],[2,3]],[[0,2],[1,2],[0,3]],[[0,2],[0,1],[2,3]],[[0,1],[2,3],[0,2]],[[1,2],[0,3],[0,2]],[[0,1],[1,3],[0,3]]],[[[1,2],[1,3],[2,3]],[[0,2],[1,2],[0,3]],[[0,2],[0,1],[2,3]],[[0,2],[2,2],[0,2]],[[0,2],[0,0],[0,2]],[[0,1],[1,3],[0,3]]],[[[1,2],[1,3],[2,3]],[[0,1],[2,3],[0,2]],[[0,0],[0,2],[0,2]],[[0,0],[0,2],[0,2]],[[0,0],[0,2],[0,2]],[[0,0],[0,1],[0,3]]],[[[1,2],[1,3],[2,3]],[[0,2],[2,2],[0,2]],[[0,2],[0,0],[0,2]],[[0,2],[2,2],[0,2]],[[0,2],[0,0],[0,2]],[[0,1],[1,3],[0,3]]],[[[1,2],[1,3],[2,3]],[[0,2],[2,2],[0,2]],[[0,2],[0,0],[0,2]],[[0,1],[2,3],[0,2]],[[1,2],[0,3],[0,2]],[[0,1],[1,3],[0,3]]]]; function showTime() { function pad(num) { return num.toString().length < 2 ? '0' + num.toString() : num.toString(); } function mergeMatrix (matrixA, matrixB) { var newMatrix = []; for (var i = 0; i < matrixA.length; i++) { newMatrix.push(matrixA[i].slice(0).concat(matrixB[i].slice(0))); } return newMatrix; } var date = new Date(); var str = pad(date.getHours()) + pad(date.getMinutes()) + pad(date.getSeconds()); var numMatrix = nums[str[0]]; for (var i = 1; i < str.length; i++) { numMatrix = mergeMatrix(numMatrix, nums[str[i]]); if (i === 1 || i === 3) { numMatrix = mergeMatrix(numMatrix, [[[1,3]],[[1,3]],[[1,3]],[[1,3]],[[1,3]],[[1,3]]]); } } var table = document.getElementById('table'); [].slice.call(table.children).forEach(function(row,j){ [].slice.call(row.children).forEach(function(cell,i){ window.setTimeout(function(){cell.children[0].className = 'dial pos-' + numMatrix[j][i][0];},~~(Math.random() * 250)); window.setTimeout(function(){cell.children[1].className = 'dial pos-' + numMatrix[j][i][1];},~~(Math.random() * 250)); }); }); } window.setTimeout(showTime, 500); window.setInterval(showTime,1000);