|
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.search.open", |
|
|
16 |
"IriSP.search.closed", |
|
|
17 |
"IriSP.search", |
|
|
18 |
"IriSP.search.cleared", |
|
|
19 |
"IriSP.search.matchFound", |
|
|
20 |
"IriSP.search.noMatchFound", |
|
|
21 |
"IriSP.search.triggeredSearch", |
|
830
|
22 |
"IriSP.TraceWidget.MouseEvents", |
|
826
|
23 |
"play", |
|
|
24 |
"pause", |
|
|
25 |
"volumechange", |
|
|
26 |
"timeupdate", |
|
|
27 |
"seeked", |
|
|
28 |
"play", |
|
|
29 |
"pause" |
|
|
30 |
]; |
|
|
31 |
IriSP._(_listeners).each(function(_listener) { |
|
830
|
32 |
_this._Popcorn.listen(_listener, function(_arg) { |
|
|
33 |
_this.eventHandler(_listener, _arg); |
|
826
|
34 |
}); |
|
|
35 |
}); |
|
|
36 |
|
|
|
37 |
} |
|
|
38 |
|
|
|
39 |
IriSP.TraceWidget.prototype = new IriSP.Widget(); |
|
|
40 |
|
|
|
41 |
IriSP.TraceWidget.prototype.draw = function() { |
|
830
|
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 |
}); |
|
826
|
98 |
} |
|
|
99 |
|
|
830
|
100 |
IriSP.TraceWidget.prototype.eventHandler = function(_listener, _arg) { |
|
|
101 |
var _traceName = 'Mdp_'; |
|
|
102 |
if (typeof _arg == "string" || typeof _arg == "number") { |
|
|
103 |
_arg = { "value" : _arg } |
|
826
|
104 |
} |
|
830
|
105 |
if (typeof _arg == "undefined") { |
|
|
106 |
_arg = {} |
|
|
107 |
} |
|
826
|
108 |
switch(_listener) { |
|
830
|
109 |
case 'IriSP.TraceWidget.MouseEvents': |
|
|
110 |
_traceName += _arg.widget + '_' + _arg.type; |
|
|
111 |
delete _arg.widget; |
|
|
112 |
delete _arg.type; |
|
826
|
113 |
break; |
|
830
|
114 |
case 'timeupdate': |
|
826
|
115 |
case 'play': |
|
|
116 |
case 'pause': |
|
830
|
117 |
_arg.time = this._Popcorn.currentTime() * 1000; |
|
826
|
118 |
case 'seeked': |
|
|
119 |
case 'volumechange': |
|
830
|
120 |
_traceName += 'Popcorn_' + _listener; |
|
826
|
121 |
break; |
|
|
122 |
default: |
|
|
123 |
_traceName += _listener.replace('IriSP.','').replace('.','_'); |
|
|
124 |
} |
|
|
125 |
this.lastEvent = _traceName; |
|
830
|
126 |
console.log("trace('" + _traceName + "', " + JSON.stringify(_arg) + ");"); |
|
826
|
127 |
} |