From 5589945a2746d924df69a432b24d532135a5bc38 Mon Sep 17 00:00:00 2001 From: Micho Date: Sat, 18 May 2013 17:47:35 +0200 Subject: [PATCH] moving init function --- clients/anim/main.js | 47 ++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 23 deletions(-) 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;