diff --git a/clients/anim/main.js b/clients/anim/main.js index 82ec2b7..db59c63 100644 --- a/clients/anim/main.js +++ b/clients/anim/main.js @@ -16,6 +16,30 @@ $(function () { start(); }) +function init() { + context = $('#canvas')[0].getContext('2d'); + clients = []; + data.matrix.forEach(function (times, index) { + clients[index] = {point:undefined, x:0, y:0, r:0, x0:0, y0:0, r0:0}; + random[index] = Math.random(); + }); + + var menu = $('#menu'); + for (var i = 2; i < 16; i++) { + (function () { + var time = i*6*60; + var d = Math.floor(i/4); + var h = (i % 4)*6; + var node = $('T'+d+' '+h+':00'); + node.click(function () { + currentTime = time; + start(); + }) + menu.append(node); + })(); + } +} + function start() { if (!interval) interval = setInterval(update, frameDuration); setTimeout(stop, 10000); @@ -41,29 +65,6 @@ function update() { renderCanvas(); } -function init() { - context = $('#canvas')[0].getContext('2d'); - clients = []; - data.matrix.forEach(function (times, index) { - clients[index] = {point:undefined, x:0, y:0, r:0, x0:0, y0:0, r0:0}; - }); - - var menu = $('#menu'); - for (var i = 2; i < 16; i++) { - (function () { - var time = i*6*60; - var d = Math.floor(i/4); - var h = (i % 4)*6; - var node = $('T'+d+' '+h+':00'); - node.click(function () { - currentTime = time; - start(); - }) - menu.append(node); - })(); - } -} - function renderTime() { var d = Math.floor(currentTime/1440); var h = Math.floor(currentTime/60) % 24;