10 "IriSP.ArrowWidget.blockArrow", |
10 "IriSP.ArrowWidget.blockArrow", |
11 "IriSP.SliceWidget.position", |
11 "IriSP.SliceWidget.position", |
12 "IriSP.SliceWidget.show", |
12 "IriSP.SliceWidget.show", |
13 "IriSP.SliceWidget.hide", |
13 "IriSP.SliceWidget.hide", |
14 "IriSP.createAnnotationWidget.addedAnnotation", |
14 "IriSP.createAnnotationWidget.addedAnnotation", |
15 // "IriSP.PlayerWidget.AnnotateButton.clicked", |
|
16 // "IriSP.PlayerWidget.MouseOver", |
|
17 // "IriSP.PlayerWidget.MouseOut", |
|
18 "IriSP.search.open", |
15 "IriSP.search.open", |
19 "IriSP.search.closed", |
16 "IriSP.search.closed", |
20 "IriSP.search", |
17 "IriSP.search", |
21 "IriSP.search.cleared", |
18 "IriSP.search.cleared", |
22 // "IriSP.PolemicTweet.click", |
|
23 "IriSP.search.matchFound", |
19 "IriSP.search.matchFound", |
24 "IriSP.search.noMatchFound", |
20 "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", |
21 "IriSP.search.triggeredSearch", |
31 "IriSP.Widget.MouseEvents", |
22 "IriSP.TraceWidget.MouseEvents", |
32 "play", |
23 "play", |
33 "pause", |
24 "pause", |
34 "volumechange", |
25 "volumechange", |
35 "timeupdate", |
26 "timeupdate", |
36 "seeked", |
27 "seeked", |
37 "play", |
28 "play", |
38 "pause" |
29 "pause" |
39 ]; |
30 ]; |
40 IriSP._(_listeners).each(function(_listener) { |
31 IriSP._(_listeners).each(function(_listener) { |
41 _this._Popcorn.listen(_listener, function() { |
32 _this._Popcorn.listen(_listener, function(_arg) { |
42 _this.eventHandler(_listener, arguments); |
33 _this.eventHandler(_listener, _arg); |
43 }); |
34 }); |
44 }); |
35 }); |
45 |
36 |
46 } |
37 } |
47 |
38 |
48 IriSP.TraceWidget.prototype = new IriSP.Widget(); |
39 IriSP.TraceWidget.prototype = new IriSP.Widget(); |
49 |
40 |
50 IriSP.TraceWidget.prototype.draw = function() { |
41 IriSP.TraceWidget.prototype.draw = function() { |
|
42 this.mouseLocation = ''; |
|
43 var _this = this; |
|
44 IriSP.jQuery(".Ldt-Widget").bind("click mouseover mouseout dragstart dragstop", function(_e) { |
|
45 var _widget = this.id.match('LdtPlayer_widget_([^_]+)')[1], |
|
46 _class = _e.target.className; |
|
47 var _data = { |
|
48 "type": _e.type, |
|
49 "x": _e.clientX, |
|
50 "y": _e.clientY, |
|
51 "widget": _widget |
|
52 } |
|
53 if (typeof _class == "string" && _class.indexOf('Ldt-TraceMe') != -1) { |
|
54 var _name = _e.target.localName, |
|
55 _id = _e.target.id, |
|
56 _text = _e.target.textContent.trim(), |
|
57 _title = _e.target.title, |
|
58 _value = _e.target.value; |
|
59 _data.target = _name + (_id.length ? '#' + _id : '') + (_class.length ? '.' + _class.replace(/\s/g,'.').replace(/\.Ldt-(Widget|TraceMe)/g,'') : ''); |
|
60 if (typeof _title == "string" && _title.length && _title.length < 140) { |
|
61 _data.title = _title; |
|
62 } |
|
63 if (typeof _text == "string" && _text.length && _text.length < 140) { |
|
64 _data.text = _text; |
|
65 } |
|
66 if (typeof _value == "string" && _value.length) { |
|
67 _data.value = _value; |
|
68 } |
|
69 _this._Popcorn.trigger('IriSP.TraceWidget.MouseEvents', _data); |
|
70 } else { |
|
71 //console.log(_e.type+','+_this.mouseLocation+','+_widget); |
|
72 if (_e.type == "mouseover") { |
|
73 if (_this.mouseLocation != _widget) { |
|
74 _this._Popcorn.trigger('IriSP.TraceWidget.MouseEvents', _data); |
|
75 } else { |
|
76 if (typeof _this.moTimeout != "undefined") { |
|
77 clearTimeout(_this.moTimeout); |
|
78 delete _this.moTimeout; |
|
79 } |
|
80 } |
|
81 } |
|
82 if (_e.type == "click") { |
|
83 _this._Popcorn.trigger('IriSP.TraceWidget.MouseEvents', _data); |
|
84 } |
|
85 if (_e.type == "mouseout") { |
|
86 if (typeof _this.moTimeout != "undefined") { |
|
87 clearTimeout(_this.moTimeout); |
|
88 } |
|
89 _this.moTimeout = setTimeout(function() { |
|
90 if (_data.widget != _this.mouseLocation) { |
|
91 _this._Popcorn.trigger('IriSP.TraceWidget.MouseEvents', _data); |
|
92 } |
|
93 },100); |
|
94 } |
|
95 } |
|
96 _this.mouseLocation = _widget; |
|
97 }); |
51 } |
98 } |
52 |
99 |
53 IriSP.TraceWidget.prototype.eventHandler = function(_listener, _args) { |
100 IriSP.TraceWidget.prototype.eventHandler = function(_listener, _arg) { |
54 var _traceName = 'Mdp_', |
101 var _traceName = 'Mdp_'; |
55 _data = {}; |
102 if (typeof _arg == "string" || typeof _arg == "number") { |
56 |
103 _arg = { "value" : _arg } |
57 function packArgs() { |
|
58 for (var _i = 0; _i < _args.length; _i++) { |
|
59 _data[_i] = _args[_i]; |
|
60 } |
|
61 } |
104 } |
62 |
105 if (typeof _arg == "undefined") { |
|
106 _arg = {} |
|
107 } |
63 switch(_listener) { |
108 switch(_listener) { |
64 case 'IriSP.Widget.MouseEvents': |
109 case 'IriSP.TraceWidget.MouseEvents': |
65 var _type = _args[0].type, |
110 _traceName += _arg.widget + '_' + _arg.type; |
66 _name = _args[0].target_name, |
111 delete _arg.widget; |
67 _class = _args[0].target_class, |
112 delete _arg.type; |
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; |
113 break; |
|
114 case 'timeupdate': |
88 case 'play': |
115 case 'play': |
89 case 'pause': |
116 case 'pause': |
|
117 _arg.time = this._Popcorn.currentTime() * 1000; |
90 case 'seeked': |
118 case 'seeked': |
91 case 'timeupdate': |
|
92 case 'volumechange': |
119 case 'volumechange': |
93 _traceName += 'Popcorn' + _listener; |
120 _traceName += 'Popcorn_' + _listener; |
94 packArgs(); |
|
95 break; |
121 break; |
96 default: |
122 default: |
97 _traceName += _listener.replace('IriSP.','').replace('.','_'); |
123 _traceName += _listener.replace('IriSP.','').replace('.','_'); |
98 packArgs(); |
|
99 } |
124 } |
100 this.lastEvent = _traceName; |
125 this.lastEvent = _traceName; |
101 console.log("trace('" + _traceName + "', " + JSON.stringify(_data) + ");"); |
126 console.log("trace('" + _traceName + "', " + JSON.stringify(_arg) + ");"); |
102 } |
127 } |