client/annotviz/app/annotsvizview.html
changeset 121 df6b39f962bc
parent 117 c0034b35c44e
child 122 3b11017a76a4
equal deleted inserted replaced
120:89544c28a364 121:df6b39f962bc
    21     <script src="/js/libs-annotviz.js"></script>
    21     <script src="/js/libs-annotviz.js"></script>
    22     <script src="/js/annotviz.js"></script>
    22     <script src="/js/annotviz.js"></script>
    23     <script>
    23     <script>
    24 
    24 
    25         var PIXI = require('pixi');
    25         var PIXI = require('pixi');
    26         var annotCategories = [];
       
    27 
    26 
    28         function colorToHex(input) {
    27         function colorToHex(input) {
    29             if (input.substring(0, 1) === '#') {
    28             if (input.substring(0, 1) === '#') {
    30                 return input;
    29                 return input;
    31             }
    30             }
    34                 var r = m[1], g=[2], b=[3];
    33                 var r = m[1], g=[2], b=[3];
    35                 return "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
    34                 return "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
    36             }
    35             }
    37         }
    36         }
    38 
    37 
    39         function getAnnotCategories(ecode, serverUrl) {
       
    40 
       
    41             var url = serverUrl+"/p/api/v1/event/" + ecode;
       
    42 
       
    43             var jsonLoader = new PIXI.JsonLoader(url, true);
       
    44             jsonLoader.on('loaded', function(res) {
       
    45                 var data = res.target.json;
       
    46 
       
    47                 while(annotCategories.length > 0) {
       
    48                     annotCategories.pop();
       
    49                 }
       
    50 
       
    51                 data.sessions.forEach(function(session) {
       
    52                     var annotCat = {
       
    53                         ts: session.start_ts === null ? new Date(0) : Date.parse(session.start_ts),
       
    54                         colors: {}
       
    55                     }
       
    56                     var categoriesJson = session.categories_json;
       
    57                     annotCat.order = categoriesJson.order;
       
    58                     categoriesJson.categories.forEach(function(cat) {
       
    59                         annotCat.colors[cat.code] = colorToHex(cat.color);
       
    60                     });
       
    61                     annotCat.defaultColor = categoriesJson.defaultColor || "#536991";
       
    62                     annotCategories.push(annotCat);
       
    63                 });
       
    64                 console.log(annotCategories);
       
    65             });
       
    66 
       
    67             jsonLoader.load();
       
    68         }
       
    69 
       
    70 
       
    71 
       
    72 	    var pianorollChannel  = 'PIANOROLL';
    38 	    var pianorollChannel  = 'PIANOROLL';
    73 	    var annotationChannel = 'ANNOT';
    39 	    var annotationChannel = 'ANNOT';
    74 	    var eventCode = 'test_1';
    40 	    var eventCode = 'atelier2';
    75         getAnnotCategories(eventCode, "http://127.0.0.1:8080");
    41 	    var serverUrl = "http://172.16.0.20:8080";
    76 	    var wsUri;
    42 	    var wsUri;
       
    43 	    
    77 	    if (window.location.protocol === 'file:') {
    44 	    if (window.location.protocol === 'file:') {
    78 	        wsUri = 'ws://172.16.0.20:8090/broadcast';
    45 	        wsUri = 'ws://172.16.0.20:8090/broadcast';
    79 	    }
    46 	    }
    80 	    else {
    47 	    else {
    81 	        wsUri = 'ws://' + window.location.hostname + ':8090/broadcast';
    48 	        wsUri = 'ws://' + window.location.hostname + ':8090/broadcast';
    89 	    	logger: logger
    56 	    	logger: logger
    90 	    });
    57 	    });
    91 
    58 
    92 
    59 
    93         var annotsvizview = new annotviz.AnnotsVizView({
    60         var annotsvizview = new annotviz.AnnotsVizView({
       
    61         	urlCategories: serverUrl + "/p/api/v1/event/" + eventCode,
    94         	logger: logger,
    62         	logger: logger,
    95         	stageView: stageView,
    63         	stageView: stageView,
    96         	wsPianoroll: new annotviz.WsWrapper(wsUriPianoroll, logger),
    64         	wsPianoroll: new annotviz.WsWrapper(wsUriPianoroll, logger),
    97         	wsAnnot: new annotviz.WsWrapper(wsUriAnnotation, logger),
    65         	wsAnnot: new annotviz.WsWrapper(wsUriAnnotation, logger),
    98         	timeBegin: 1421919000000,
    66         	timeBegin: 1421919000000,