|
826
|
1 |
IriSP.TraceWidget = function(Popcorn, config, Serializer) { |
|
|
2 |
IriSP.Widget.call(this, Popcorn, config, Serializer); |
|
|
3 |
this.lastEvent = ""; |
|
|
4 |
var _this = this, |
|
|
5 |
_listeners = [ |
|
|
6 |
"IriSP.ArrowWidget.releaseArrow", |
|
|
7 |
"IriSP.SliceWidget.hide", |
|
|
8 |
"IriSP.AnnotationsWidget.show", |
|
|
9 |
"IriSP.AnnotationsWidget.hide", |
|
|
10 |
"IriSP.ArrowWidget.blockArrow", |
|
|
11 |
"IriSP.SliceWidget.position", |
|
|
12 |
"IriSP.SliceWidget.show", |
|
|
13 |
"IriSP.SliceWidget.hide", |
|
|
14 |
"IriSP.createAnnotationWidget.addedAnnotation", |
|
|
15 |
// "IriSP.PlayerWidget.AnnotateButton.clicked", |
|
|
16 |
// "IriSP.PlayerWidget.MouseOver", |
|
|
17 |
// "IriSP.PlayerWidget.MouseOut", |
|
|
18 |
"IriSP.search.open", |
|
|
19 |
"IriSP.search.closed", |
|
|
20 |
"IriSP.search", |
|
|
21 |
"IriSP.search.cleared", |
|
|
22 |
// "IriSP.PolemicTweet.click", |
|
|
23 |
"IriSP.search.matchFound", |
|
|
24 |
"IriSP.search.noMatchFound", |
|
|
25 |
// "IriSP.SegmentsWidget.click", |
|
|
26 |
"IriSP.SliceWidget.zoneChange", |
|
|
27 |
// "IriSP.SparklineWidget.clicked", |
|
|
28 |
// "IriSP.StackGraphWidget.mouseOver", |
|
|
29 |
// "IriSP.StackGraphWidget.clicked", |
|
|
30 |
"IriSP.search.triggeredSearch", |
|
|
31 |
"IriSP.Widget.MouseEvents", |
|
|
32 |
"play", |
|
|
33 |
"pause", |
|
|
34 |
"volumechange", |
|
|
35 |
"timeupdate", |
|
|
36 |
"seeked", |
|
|
37 |
"play", |
|
|
38 |
"pause" |
|
|
39 |
]; |
|
|
40 |
IriSP._(_listeners).each(function(_listener) { |
|
|
41 |
_this._Popcorn.listen(_listener, function() { |
|
|
42 |
_this.eventHandler(_listener, arguments); |
|
|
43 |
}); |
|
|
44 |
}); |
|
|
45 |
|
|
|
46 |
} |
|
|
47 |
|
|
|
48 |
IriSP.TraceWidget.prototype = new IriSP.Widget(); |
|
|
49 |
|
|
|
50 |
IriSP.TraceWidget.prototype.draw = function() { |
|
|
51 |
} |
|
|
52 |
|
|
|
53 |
IriSP.TraceWidget.prototype.eventHandler = function(_listener, _args) { |
|
|
54 |
var _traceName = 'Mdp_', |
|
|
55 |
_data = {}; |
|
|
56 |
|
|
|
57 |
function packArgs() { |
|
|
58 |
for (var _i = 0; _i < _args.length; _i++) { |
|
|
59 |
_data[_i] = _args[_i]; |
|
|
60 |
} |
|
|
61 |
} |
|
|
62 |
|
|
|
63 |
switch(_listener) { |
|
|
64 |
case 'IriSP.Widget.MouseEvents': |
|
|
65 |
var _type = _args[0].type, |
|
|
66 |
_name = _args[0].target_name, |
|
|
67 |
_class = _args[0].target_class, |
|
|
68 |
_id = _args[0].target_id, |
|
|
69 |
_widget = _args[0].widget.match(/[^_]+widget/i)[0]; |
|
|
70 |
_traceName += _widget + '_' + _type; |
|
|
71 |
_data.x = _args[0].x; |
|
|
72 |
_data.y = _args[0].y; |
|
|
73 |
_data.target = _name + (_id.length ? '#' + _id : '') + (_class.length ? '.' + _class.replace(/\s/g,'.') : ''); |
|
|
74 |
if (typeof _args[0].value == "string" && _args[0].value.length) { |
|
|
75 |
_data.value = _args[0].value; |
|
|
76 |
} |
|
|
77 |
if ((_name == "button" || /button/.test(_class)) && typeof _args[0].text == "string" && _args[0].text.length) { |
|
|
78 |
_data.text = _args[0].text; |
|
|
79 |
} |
|
|
80 |
if (typeof _args[0].title == "string" && _args[0].title.length) { |
|
|
81 |
_data.title = _args[0].title; |
|
|
82 |
} |
|
|
83 |
// Filtrer les événements mouseover quand on se déplace vers des éléments non pertinents |
|
|
84 |
if (!_id.length && !_class.length && ( _type == 'mouseover' || _type == 'mouseout' ) && this.lastEvent.search('Mdp_' + _widget) == 0) { |
|
|
85 |
return; |
|
|
86 |
} |
|
|
87 |
break; |
|
|
88 |
case 'play': |
|
|
89 |
case 'pause': |
|
|
90 |
case 'seeked': |
|
|
91 |
case 'timeupdate': |
|
|
92 |
case 'volumechange': |
|
|
93 |
_traceName += 'Popcorn' + _listener; |
|
|
94 |
packArgs(); |
|
|
95 |
break; |
|
|
96 |
default: |
|
|
97 |
_traceName += _listener.replace('IriSP.','').replace('.','_'); |
|
|
98 |
packArgs(); |
|
|
99 |
} |
|
|
100 |
this.lastEvent = _traceName; |
|
|
101 |
console.log("trace('" + _traceName + "', " + JSON.stringify(_data) + ");"); |
|
|
102 |
} |