client/annotviz/app/js/main.js
author rougeronj
Mon, 19 Jan 2015 09:52:52 +0100
changeset 92 a323578ea954
parent 91 09a9074ea7b0
child 96 f58715468f1e
child 99 9d968fbcaa2a
permissions -rw-r--r--
generalview take interval in pixel as argument (not time anymore)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
85
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
/**
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
 * scripts/main.js
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
 *
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
 * This is the starting point for your application.
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
 * Take a look at http://browserify.org/ for more info
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
 */
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
'use strict';
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
var PIXI = require('pixi');
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
// Config vars
89
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
    14
var horizontalView = false;
85
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
var logger = false;
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
var sceneWidth = 1920;
89
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
    17
var sceneHeight = 1080;
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
    18
var prSize1 = 435;
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
    19
var prSize2 = 435;
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
    20
var prSize3 = 300;
85
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
var sceneBgColor = 0xFFFFFF;
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
var lineColor = 0x444444;
89
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
    23
if (horizontalView){
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
    24
	var pixelsPerSecond1 = Math.floor(sceneWidth / 10); // nb of pixels per second
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
    25
} else{
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
    26
	var pixelsPerSecond1 = Math.floor(sceneHeight / 10); // nb of pixels per second
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
    27
}
85
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
var manualFramerate = pixelsPerSecond1 / 4;
89
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
    29
if (horizontalView){
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
    30
	var pixelsPerSecond2 = Math.floor(sceneWidth / 60); // nb of pixels per second
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
    31
} else {
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
    32
	var pixelsPerSecond2 = Math.floor(sceneHeight / 60); // nb of pixels per second
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
    33
}
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
    34
var pixelsPerSecond3 = Math.floor(sceneHeight / 60); // nb of pixels per second
85
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
var lineInterval = 5000; // means line every 5 seconds
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
var nbLines = -1;
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
var noteHeight = 110;
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
var noteColors = [0xB90000, 0x4BDD71, 0xAF931E, 0x1C28BA, 0x536991];
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
var colorsReg = {};
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
// Vars
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
var noteDict = [];
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
// Timecode method
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
var timePageLoaded = Date.now();
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
var offsetMusic = false;
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
    45
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
    46
//create an new instance of a pixi stage
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
    47
var stage = new PIXI.Stage(sceneBgColor);
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
//create a renderer instance.
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
var renderer = PIXI.autoDetectRenderer(sceneWidth, sceneHeight);
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
    51
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
    52
//add the renderer view element to the DOM
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
    53
document.getElementById('canvasContainer').appendChild(renderer.view);
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
var uberContainer = new PIXI.DisplayObjectContainer();
89
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
    56
if (horizontalView){
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
    57
	uberContainer.position.x = Math.floor(sceneWidth*9/10);
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
    58
	uberContainer.position.y = 0;
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
    59
} else {
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
    60
	uberContainer.position.x = 0;
92
a323578ea954 generalview take interval in pixel as argument (not time anymore)
rougeronj
parents: 91
diff changeset
    61
	uberContainer.position.y = Math.floor(sceneHeight*9/10);
89
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
    62
}
85
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
    63
stage.addChild(uberContainer);
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
89
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
    65
/* ---------------------------------------------------------------- */
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
    66
/* ------------------- Init Pianoroll containers ------------------ */
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
    67
/* ---------------------------------------------------------------- */
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
    68
85
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
    69
var PianoRoll = require('./pianoroll.js')
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
    70
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
    71
var containerList = [];
89
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
    72
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
    73
if (horizontalView){
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
    74
	containerList.push(new PianoRoll(uberContainer, 0, 0, prSize1, true, pixelsPerSecond1, sceneWidth, noteColors, colorsReg, lineColor, lineInterval, offsetMusic, prSize1 / 128, horizontalView));
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
    75
	containerList.push(new PianoRoll(uberContainer, 0, prSize1, prSize2, false, pixelsPerSecond2, sceneWidth, noteColors, colorsReg, lineColor, lineInterval, offsetMusic, prSize2 / 128, horizontalView));
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
    76
} else {
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
    77
//	containerList.push(new PianoRoll(uberContainer, sceneWidth - prSize1, 0, sceneHeight, true, pixelsPerSecond1, prSize1, noteColors, colorsReg, lineColor, lineInterval, offsetMusic, prSize1 / 128, horizontalView));
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
    78
//	containerList.push(new PianoRoll(uberContainer, sceneWidth - (prSize1 + prSize2), 0, sceneHeight, false, pixelsPerSecond2, prSize2, noteColors, colorsReg, lineColor, lineInterval, offsetMusic, prSize2 / 128, horizontalView));
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
    79
	containerList.push(new PianoRoll(uberContainer, sceneWidth - prSize1, 0, sceneHeight, false, pixelsPerSecond2, prSize2, noteColors, colorsReg, lineColor, lineInterval, offsetMusic, prSize2 / 128, horizontalView));
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
    80
}
85
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
    81
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
// Line between two containers
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
    83
var graphics = new PIXI.Graphics();
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
    84
graphics.beginFill(0xFFFF00);
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
    85
graphics.lineStyle(1, lineColor);
89
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
    86
if (horizontalView){
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
    87
	graphics.moveTo(0, prSize1);
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
    88
	graphics.lineTo(sceneWidth, prSize1);
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
    89
} else {
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
    90
	graphics.moveTo(sceneWidth - prSize1, 0);
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
    91
	graphics.lineTo(sceneWidth - prSize1, sceneHeight);
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
    92
	graphics.moveTo(sceneWidth - (prSize1 + prSize3), 0);
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
    93
	graphics.lineTo(sceneWidth - (prSize1 + prSize3), sceneHeight);
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
    94
}
85
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
    95
graphics.endFill();
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
    96
stage.addChild(graphics);
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
    97
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
    98
function addNotes(data){
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
    99
    if(!offsetMusic){
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   100
        // get difference between the current note timecode and my zero to set the difference between the canvas's zero and the music's zero
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   101
        // in order to place in real time
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   102
        var now = Date.now();
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   103
        var timeBetweenNowAndStart = now - timePageLoaded;
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   104
        offsetMusic = timeBetweenNowAndStart - data.content[1];
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   105
    }
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   106
    var note = data.content[3];
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   107
    var velocity = data.content[4];
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   108
    if(velocity===0){
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   109
        if(typeof noteDict[data.content[2]][note]!=='undefined'){
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   110
            // We close the note in container one
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   111
            var duration = data.content[1] - noteDict[data.content[2]][note].ts;
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   112
            for(var i=0;i<containerList.length;i++){
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   113
                //               addNote(note, startTime,                          duration, velocity,                                 canal)
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   114
                containerList[i].addNote(note, noteDict[data.content[2]][note].ts, duration, noteDict[data.content[2]][note].velocity, data.content[2]);
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   115
            }
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   116
            // delete entry
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   117
            delete noteDict[data.content[2]][note];
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   118
        }
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   119
    }
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   120
    else{
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   121
        if(typeof noteDict[data.content[2]]==='undefined'){
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   122
            noteDict[data.content[2]] = {};
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   123
        }
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   124
        noteDict[data.content[2]][note] = {ts: data.content[1], velocity:velocity};
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   125
    }
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   126
}
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   127
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   128
function addLine(){
87
9611905b58fe correct code generation + index.html + time display
ymh <ymh.work@gmail.com>
parents: 85
diff changeset
   129
    var ts = new Date();
85
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   130
    for(var i=0;i<containerList.length;i++){
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   131
        containerList[i].addLine(ts);
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   132
    }
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   133
}
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   134
89
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   135
/* ---------------------------------------------------------------- */
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   136
/* ------------------- Init AnnotsRoll containers ----------------- */
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   137
/* ---------------------------------------------------------------- */
85
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   138
89
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   139
var AnnotsRoll = require('./annotsRoll.js')
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   140
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   141
var AnnotationRoll = new AnnotsRoll(uberContainer, sceneWidth - (prSize2 + prSize3), 0, prSize3 + prSize2, sceneHeight, prSize3, pixelsPerSecond3, lineInterval);
85
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   142
91
09a9074ea7b0 Add general View fonction for main representation
rougeronj
parents: 89
diff changeset
   143
/* ---------------------------------------------------------------- */
09a9074ea7b0 Add general View fonction for main representation
rougeronj
parents: 89
diff changeset
   144
/* ------------------- Init generalView container ----------------- */
09a9074ea7b0 Add general View fonction for main representation
rougeronj
parents: 89
diff changeset
   145
/* ---------------------------------------------------------------- */
09a9074ea7b0 Add general View fonction for main representation
rougeronj
parents: 89
diff changeset
   146
09a9074ea7b0 Add general View fonction for main representation
rougeronj
parents: 89
diff changeset
   147
var GeneralView = require('./generalView.js')
09a9074ea7b0 Add general View fonction for main representation
rougeronj
parents: 89
diff changeset
   148
92
a323578ea954 generalview take interval in pixel as argument (not time anymore)
rougeronj
parents: 91
diff changeset
   149
var GeneralRoll = new GeneralView(uberContainer, 0, 0, sceneWidth - (prSize2 + prSize3), sceneHeight, Date.now(), Date.now() + 300000, 30);
91
09a9074ea7b0 Add general View fonction for main representation
rougeronj
parents: 89
diff changeset
   150
09a9074ea7b0 Add general View fonction for main representation
rougeronj
parents: 89
diff changeset
   151
89
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   152
function addAnnots(data){
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   153
    var title = data.content.category.label;
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   154
    var user = data.content.user;
91
09a9074ea7b0 Add general View fonction for main representation
rougeronj
parents: 89
diff changeset
   155
    //Test cat and color
89
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   156
    var colorAnnot = 0x65A954;
91
09a9074ea7b0 Add general View fonction for main representation
rougeronj
parents: 89
diff changeset
   157
    
89
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   158
    AnnotationRoll.addAnnot(title, user, colorAnnot);
91
09a9074ea7b0 Add general View fonction for main representation
rougeronj
parents: 89
diff changeset
   159
    GeneralRoll.addAnnot(title, Date.now());
89
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   160
}
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   161
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   162
/* ---------------------------------------------------------------- */
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   163
/* ----------------------- Socket management ---------------------- */
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   164
/* ---------------------------------------------------------------- */
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   165
85
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   166
var sock = null;
89
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   167
var sock2 = null;
85
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   168
var ellog = null;
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   169
function log(m) {
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   170
    if(logger){
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   171
        ellog.innerHTML += m + '\n';
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   172
        ellog.scrollTop = ellog.scrollHeight;
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   173
    }
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   174
}
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   175
window.onload = function(){
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   176
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   177
    if(logger){
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   178
        ellog = document.getElementById('log');
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   179
    }
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   180
    else{
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   181
        document.body.removeChild(document.getElementById('log'));
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   182
    }
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   183
89
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   184
    var wsuriInit;
85
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   185
    var wsuri;
89
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   186
    var wsuri2;
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   187
    
85
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   188
    if (window.location.protocol === 'file:') {
89
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   189
    	wsuriInit = 'ws://127.0.0.1:8090/broadcast';
85
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   190
    } else {
89
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   191
    	wsuriInit = 'ws://' + window.location.hostname + ':8090/broadcast';
85
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   192
    }
89
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   193
    wsuri = wsuriInit + '?channel=PIANOROLL&event_code='+eventCode;
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   194
    wsuri2 = wsuriInit + '?channel=ANNOT&event_code='+eventCode;
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   195
    
85
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   196
    if ('WebSocket' in window) {
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   197
        sock = new WebSocket(wsuri);
89
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   198
        sock2 = new WebSocket(wsuri2);
85
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   199
    } else if ('MozWebSocket' in window) {
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   200
        sock = new MozWebSocket(wsuri);
89
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   201
        sock2 = new WebSocket(wsuri2);
85
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   202
    } else {
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   203
        log('Browser does not support WebSocket!');
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   204
        window.location = 'http://autobahn.ws/unsupportedbrowser';
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   205
    }
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   206
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   207
    if (sock) {
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   208
        sock.onopen = function(){
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   209
            if(logger){
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   210
                log('Connected to ' + wsuri);
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   211
            }
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   212
        };
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   213
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   214
        sock.onclose = function(e) {
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   215
            if(logger){
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   216
                log('Connection closed (wasClean = ' + e.wasClean + ', code = ' + e.code + ', reason = \'' + e.reason + '\')');
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   217
            }
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   218
            sock = null;
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   219
        };
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   220
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   221
        sock.onmessage = function(e) {
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   222
            if(logger){
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   223
                log('Got message: ' + e.data);
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   224
            }
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   225
            addNotes(JSON.parse(e.data));
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   226
        };
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   227
    }
89
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   228
    
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   229
    if (sock2) {
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   230
        sock2.onopen = function(){
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   231
            if(logger){
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   232
                log('Connected to ' + wsuri);
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   233
            }
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   234
        };
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   235
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   236
        sock2.onclose = function(e) {
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   237
            if(logger){
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   238
                log('Connection closed (wasClean = ' + e.wasClean + ', code = ' + e.code + ', reason = \'' + e.reason + '\')');
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   239
            }
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   240
            sock2 = null;
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   241
        };
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   242
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   243
        sock2.onmessage = function(e) {
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   244
            if(logger){
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   245
                log('Got message: ' + e.data);
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   246
            }
91
09a9074ea7b0 Add general View fonction for main representation
rougeronj
parents: 89
diff changeset
   247
            console.log(e);
89
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   248
            addAnnots(JSON.parse(e.data));
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   249
        };
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   250
    }
85
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   251
};
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   252
89
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   253
function replaceContainers(){
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   254
    var diff = (Date.now() - timePageLoaded)/1000;// nb of seconds since page loaded
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   255
    
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   256
    for(var i=0;i<containerList.length;i++){
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   257
        containerList[i].moveTo(-diff);
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   258
        AnnotationRoll.moveTo(-diff);
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   259
    }
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   260
    
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   261
    renderer.render(stage);
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   262
}
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   263
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   264
/* ---------------------------------------------------------------- */
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   265
/* ---------------------------- Main ------------------------------ */
b4bd49f01837 add annotsRoll class and create it in main. Adapt main and pianoroll to allow horizontal or vertical view
rougeronj
parents: 87
diff changeset
   266
/* ---------------------------------------------------------------- */
85
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   267
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   268
// Init page and intervals
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   269
addLine();
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   270
var moveInterval = window.setInterval(replaceContainers, 1000/manualFramerate);
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   271
var verticalLinesInterval = window.setInterval(addLine, lineInterval);
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   272
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   273
// Little inteval to show time
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   274
var nbSec = 0;
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   275
var mySpan = document.getElementById('myspan');
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   276
function updateTime(){
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   277
    nbSec++;
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   278
    var hours = parseInt( nbSec / 3600 ) % 24;
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   279
    var minutes = parseInt( nbSec / 60 ) % 60;
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   280
    var seconds = nbSec % 60;
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   281
    var timeStr = (hours < 10 ? '0' + hours : hours) + ':' + (minutes < 10 ? '0' + minutes : minutes) + ':' + (seconds  < 10 ? '0' + seconds : seconds);
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   282
    mySpan.innerHTML = timeStr;
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   283
}
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   284
var secondInterval = window.setInterval(updateTime, 1000);
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   285
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   286
module.exports = {
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   287
    moveInterval: moveInterval,
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   288
    verticalLinesInterval: verticalLinesInterval,
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   289
    secondInterval: secondInterval
eff9460bd4f2 add new visualization + small corrections
ymh <ymh.work@gmail.com>
parents:
diff changeset
   290
};