author | rougeronj |
Thu, 22 Jan 2015 11:16:20 +0100 | |
changeset 117 | c0034b35c44e |
parent 113 | 7531e4180915 |
child 119 | e6605fecb175 |
child 121 | df6b39f962bc |
permissions | -rw-r--r-- |
103 | 1 |
<!DOCTYPE html> |
2 |
<html lang="en"> |
|
3 |
<head> |
|
4 |
<meta charset="utf-8"> |
|
5 |
<meta name="viewport" content="width=device-width,initial-scale=1"> |
|
6 |
<meta name="description" content=""> |
|
7 |
<meta name="author" content="I.R.I"> |
|
8 |
<link rel="shortcut icon" href="/img/favicon.ico"> |
|
9 |
||
10 |
<title>AnnotsVizView</title> |
|
11 |
||
12 |
<!-- Custom styles for this template --> |
|
13 |
<link href="/css/annotviz.css" rel="stylesheet"> |
|
14 |
</head> |
|
15 |
||
16 |
<body> |
|
17 |
<h1>Piano Roll vertical</h1> |
|
18 |
<noscript>You must enable JavaScript</noscript> |
|
19 |
<div id="canvasContainer"></div> |
|
20 |
<!--pre id="log"></pre--> |
|
21 |
<script src="/js/libs-annotviz.js"></script> |
|
22 |
<script src="/js/annotviz.js"></script> |
|
23 |
<script> |
|
108 | 24 |
|
25 |
var PIXI = require('pixi'); |
|
26 |
var annotCategories = []; |
|
27 |
||
28 |
function colorToHex(input) { |
|
29 |
if (input.substring(0, 1) === '#') { |
|
30 |
return input; |
|
31 |
} |
|
32 |
else { |
|
33 |
var m = input.match(/^rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i); |
|
34 |
var r = m[1], g=[2], b=[3]; |
|
35 |
return "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1); |
|
36 |
} |
|
37 |
} |
|
38 |
||
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 |
||
103 | 72 |
var pianorollChannel = 'PIANOROLL'; |
73 |
var annotationChannel = 'ANNOT'; |
|
117
c0034b35c44e
merge + gulp + correction of superposition category-text
rougeronj
parents:
113
diff
changeset
|
74 |
var eventCode = 'test_1'; |
108 | 75 |
getAnnotCategories(eventCode, "http://127.0.0.1:8080"); |
103 | 76 |
var wsUri; |
105
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
77 |
if (window.location.protocol === 'file:') { |
104 | 78 |
wsUri = 'ws://172.16.0.20:8090/broadcast'; |
105
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
79 |
} |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
80 |
else { |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
81 |
wsUri = 'ws://' + window.location.hostname + ':8090/broadcast'; |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
82 |
} |
103 | 83 |
wsUriPianoroll = wsUri + '?channel=' + pianorollChannel + '&event_code=' + eventCode; |
84 |
wsUriAnnotation = wsUri + '?channel=' + annotationChannel + '&event_code=' + eventCode; |
|
108 | 85 |
|
103 | 86 |
var logger = new annotviz.ConsoleLogger(true); |
108 | 87 |
|
103 | 88 |
var stageView = new annotviz.StageView({ |
89 |
logger: logger |
|
90 |
}); |
|
91 |
||
108 | 92 |
|
103 | 93 |
var annotsvizview = new annotviz.AnnotsVizView({ |
94 |
logger: logger, |
|
95 |
stageView: stageView, |
|
96 |
wsPianoroll: new annotviz.WsWrapper(wsUriPianoroll, logger), |
|
97 |
wsAnnot: new annotviz.WsWrapper(wsUriAnnotation, logger), |
|
113 | 98 |
timeBegin: 1421919000000, |
99 |
timeEnd: 1421951400000 |
|
103 | 100 |
}); |
108 | 101 |
|
103 | 102 |
|
103 |
function stop() { |
|
104 |
stageView.stop(); |
|
105 |
} |
|
106 |
function start() { |
|
107 |
stageView.start(); |
|
108 |
} |
|
109 |
||
110 |
window.onload = function() { |
|
111 |
stageView.init(); |
|
112 |
start(); |
|
113 |
} |
|
114 |
</script> |
|
115 |
</body> |
|
116 |
</html> |