author | ymh <ymh.work@gmail.com> |
Thu, 22 Jan 2015 12:12:33 +0100 | |
changeset 119 | e6605fecb175 |
parent 117 | c0034b35c44e |
child 122 | 3b11017a76a4 |
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 getAnnotCategories(ecode, serverUrl) { |
|
29 |
||
30 |
var url = serverUrl+"/p/api/v1/event/" + ecode; |
|
31 |
||
32 |
var jsonLoader = new PIXI.JsonLoader(url, true); |
|
33 |
jsonLoader.on('loaded', function(res) { |
|
34 |
var data = res.target.json; |
|
35 |
||
36 |
while(annotCategories.length > 0) { |
|
37 |
annotCategories.pop(); |
|
38 |
} |
|
39 |
||
40 |
data.sessions.forEach(function(session) { |
|
41 |
var annotCat = { |
|
42 |
ts: session.start_ts === null ? new Date(0) : Date.parse(session.start_ts), |
|
43 |
colors: {} |
|
44 |
} |
|
45 |
var categoriesJson = session.categories_json; |
|
46 |
annotCat.order = categoriesJson.order; |
|
47 |
categoriesJson.categories.forEach(function(cat) { |
|
119 | 48 |
annotCat.colors[cat.code] = annotviz.colorToHex(cat.color); |
108 | 49 |
}); |
50 |
annotCat.defaultColor = categoriesJson.defaultColor || "#536991"; |
|
51 |
annotCategories.push(annotCat); |
|
52 |
}); |
|
53 |
console.log(annotCategories); |
|
54 |
}); |
|
55 |
||
56 |
jsonLoader.load(); |
|
57 |
} |
|
58 |
||
59 |
||
60 |
||
103 | 61 |
var pianorollChannel = 'PIANOROLL'; |
62 |
var annotationChannel = 'ANNOT'; |
|
117
c0034b35c44e
merge + gulp + correction of superposition category-text
rougeronj
parents:
113
diff
changeset
|
63 |
var eventCode = 'test_1'; |
108 | 64 |
getAnnotCategories(eventCode, "http://127.0.0.1:8080"); |
103 | 65 |
var wsUri; |
105
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
66 |
if (window.location.protocol === 'file:') { |
104 | 67 |
wsUri = 'ws://172.16.0.20:8090/broadcast'; |
105
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
68 |
} |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
69 |
else { |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
70 |
wsUri = 'ws://' + window.location.hostname + ':8090/broadcast'; |
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
71 |
} |
103 | 72 |
wsUriPianoroll = wsUri + '?channel=' + pianorollChannel + '&event_code=' + eventCode; |
73 |
wsUriAnnotation = wsUri + '?channel=' + annotationChannel + '&event_code=' + eventCode; |
|
108 | 74 |
|
103 | 75 |
var logger = new annotviz.ConsoleLogger(true); |
108 | 76 |
|
103 | 77 |
var stageView = new annotviz.StageView({ |
78 |
logger: logger |
|
79 |
}); |
|
80 |
||
108 | 81 |
|
103 | 82 |
var annotsvizview = new annotviz.AnnotsVizView({ |
83 |
logger: logger, |
|
84 |
stageView: stageView, |
|
85 |
wsPianoroll: new annotviz.WsWrapper(wsUriPianoroll, logger), |
|
86 |
wsAnnot: new annotviz.WsWrapper(wsUriAnnotation, logger), |
|
113 | 87 |
timeBegin: 1421919000000, |
88 |
timeEnd: 1421951400000 |
|
103 | 89 |
}); |
108 | 90 |
|
103 | 91 |
|
92 |
function stop() { |
|
93 |
stageView.stop(); |
|
94 |
} |
|
95 |
function start() { |
|
96 |
stageView.start(); |
|
97 |
} |
|
98 |
||
99 |
window.onload = function() { |
|
100 |
stageView.init(); |
|
101 |
start(); |
|
102 |
} |
|
103 |
</script> |
|
104 |
</body> |
|
105 |
</html> |