|
882
|
1 |
IriSP.Widgets.Trace = function(player, config) { |
|
|
2 |
IriSP.Widgets.Widget.call(this, player, config); |
|
|
3 |
|
|
|
4 |
} |
|
|
5 |
|
|
|
6 |
IriSP.Widgets.Trace.prototype = new IriSP.Widgets.Widget(); |
|
|
7 |
|
|
|
8 |
IriSP.Widgets.Trace.prototype.defaults = { |
|
|
9 |
js_console : false, |
|
|
10 |
url: "http://traces.advene.org:5000/", |
|
|
11 |
requestmode: 'GET', |
|
924
|
12 |
syncmode: "sync", |
|
926
|
13 |
default_subject: "IRI", |
|
|
14 |
tracer: null |
|
882
|
15 |
} |
|
|
16 |
|
|
|
17 |
IriSP.Widgets.Trace.prototype.draw = function() { |
|
|
18 |
this.lastEvent = ""; |
|
|
19 |
if (typeof window.tracemanager === "undefined") { |
|
|
20 |
console.log("Tracemanager not found"); |
|
|
21 |
return; |
|
|
22 |
} |
|
|
23 |
var _this = this, |
|
|
24 |
_listeners = { |
|
|
25 |
"IriSP.search.open" : 0, |
|
|
26 |
"IriSP.search.closed" : 0, |
|
|
27 |
"IriSP.search" : 0, |
|
|
28 |
"IriSP.search.cleared" : 0, |
|
|
29 |
"IriSP.search.matchFound" : 0, |
|
|
30 |
"IriSP.search.noMatchFound" : 0, |
|
|
31 |
"IriSP.search.triggeredSearch" : 0, |
|
|
32 |
"IriSP.TraceWidget.MouseEvents" : 0, |
|
|
33 |
"play" : 0, |
|
|
34 |
"pause" : 0, |
|
|
35 |
"volumechange" : 0, |
|
|
36 |
"seeked" : 0, |
|
|
37 |
"play" : 0, |
|
|
38 |
"pause" : 0, |
|
|
39 |
"timeupdate" : 2000 |
|
|
40 |
}; |
|
|
41 |
IriSP._(_listeners).each(function(_ms, _listener) { |
|
|
42 |
var _f = function(_arg) { |
|
|
43 |
_this.eventHandler(_listener, _arg); |
|
|
44 |
} |
|
|
45 |
if (_ms) { |
|
|
46 |
_f = IriSP._.throttle(_f, _ms); |
|
|
47 |
} |
|
|
48 |
_this.player.popcorn.listen(_listener, _f); |
|
|
49 |
}); |
|
|
50 |
|
|
926
|
51 |
if (!this.tracer) { |
|
|
52 |
|
|
|
53 |
this.tracer = window.tracemanager.init_trace("test", { |
|
|
54 |
url: this.url, |
|
|
55 |
requestmode: this.requestmode, |
|
|
56 |
syncmode: this.syncmode, |
|
|
57 |
default_subject: this.default_subject |
|
|
58 |
}); |
|
|
59 |
|
|
|
60 |
} |
|
|
61 |
|
|
|
62 |
this.tracer.trace("TraceWidgetInit", {}); |
|
882
|
63 |
|
|
|
64 |
this.mouseLocation = ''; |
|
906
|
65 |
IriSP.jQuery(".Ldt-Widget").bind("click mouseover mouseout", function(_e) { |
|
|
66 |
var _target = IriSP.jQuery(_e.target); |
|
|
67 |
|
|
|
68 |
while (!_target.hasClass("Ldt-TraceMe") && !_target.hasClass("Ldt-Widget") && _target.length) { |
|
|
69 |
_target = _target.parent(); |
|
882
|
70 |
} |
|
906
|
71 |
|
|
|
72 |
var _widget = IriSP.jQuery(this).attr("widget-type"), |
|
|
73 |
_data = { |
|
|
74 |
"type": _e.type, |
|
|
75 |
"x": _e.clientX, |
|
|
76 |
"y": _e.clientY, |
|
|
77 |
"widget": _widget |
|
|
78 |
}, |
|
|
79 |
_targetEl = _target[0], |
|
|
80 |
_class = _targetEl.className, |
|
|
81 |
_name = _targetEl.localName, |
|
|
82 |
_id = _targetEl.id, |
|
|
83 |
_value = _targetEl.value, |
|
|
84 |
_traceInfo = _target.attr("trace-info"), |
|
|
85 |
_lastTarget = _name + (_id && _id.length ? '#' + IriSP.jqEscape(_id) : '') + (_class && _class.length ? ('.' + IriSP.jqEscape(_class).replace(/\s/g,'.')).replace(/\.Ldt-(Widget|TraceMe)/g,'') : ''); |
|
|
86 |
_data.target = _lastTarget |
|
|
87 |
if (typeof _traceInfo == "string" && _traceInfo.length && _traceInfo.length < 140) { |
|
|
88 |
_data.traceInfo = _traceInfo; |
|
|
89 |
_lastTarget += ( ";" + _traceInfo ); |
|
|
90 |
} |
|
|
91 |
if (typeof _value == "string" && _value.length) { |
|
|
92 |
_data.value = _value; |
|
|
93 |
} |
|
|
94 |
switch(_e.type) { |
|
|
95 |
case "mouseover": |
|
|
96 |
if (_this.lastTarget != _lastTarget) { |
|
882
|
97 |
_this.player.popcorn.trigger('IriSP.TraceWidget.MouseEvents', _data); |
|
|
98 |
} else { |
|
|
99 |
if (typeof _this.moTimeout != "undefined") { |
|
|
100 |
clearTimeout(_this.moTimeout); |
|
906
|
101 |
_this.moTimeout = undefined; |
|
882
|
102 |
} |
|
|
103 |
} |
|
906
|
104 |
break; |
|
|
105 |
case "mouseout": |
|
882
|
106 |
if (typeof _this.moTimeout != "undefined") { |
|
|
107 |
clearTimeout(_this.moTimeout); |
|
|
108 |
} |
|
|
109 |
_this.moTimeout = setTimeout(function() { |
|
906
|
110 |
if (_lastTarget != _this.lastTarget) { |
|
882
|
111 |
_this.player.popcorn.trigger('IriSP.TraceWidget.MouseEvents', _data); |
|
|
112 |
} |
|
|
113 |
},100); |
|
906
|
114 |
break; |
|
|
115 |
default: |
|
|
116 |
_this.player.popcorn.trigger('IriSP.TraceWidget.MouseEvents', _data); |
|
882
|
117 |
} |
|
906
|
118 |
_this.lastTarget = _lastTarget; |
|
882
|
119 |
}); |
|
|
120 |
} |
|
|
121 |
|
|
|
122 |
IriSP.Widgets.Trace.prototype.eventHandler = function(_listener, _arg) { |
|
|
123 |
var _traceName = 'Mdp_'; |
|
|
124 |
if (typeof _arg == "string" || typeof _arg == "number") { |
|
|
125 |
_arg = { "value" : _arg } |
|
|
126 |
} |
|
|
127 |
if (typeof _arg == "undefined") { |
|
|
128 |
_arg = {} |
|
|
129 |
} |
|
|
130 |
switch(_listener) { |
|
|
131 |
case 'IriSP.TraceWidget.MouseEvents': |
|
|
132 |
_traceName += _arg.widget + '_' + _arg.type; |
|
|
133 |
delete _arg.widget; |
|
|
134 |
delete _arg.type; |
|
|
135 |
break; |
|
|
136 |
case 'timeupdate': |
|
|
137 |
case 'play': |
|
|
138 |
case 'pause': |
|
|
139 |
_arg.time = this.player.popcorn.currentTime() * 1000; |
|
|
140 |
case 'seeked': |
|
|
141 |
case 'volumechange': |
|
|
142 |
_traceName += 'Popcorn_' + _listener; |
|
|
143 |
break; |
|
|
144 |
default: |
|
|
145 |
_traceName += _listener.replace('IriSP.','').replace('.','_'); |
|
|
146 |
} |
|
|
147 |
this.lastEvent = _traceName; |
|
|
148 |
this.tracer.trace(_traceName, _arg); |
|
|
149 |
if (this.js_console) { |
|
|
150 |
console.log("tracer.trace('" + _traceName + "', " + JSON.stringify(_arg) + ");"); |
|
|
151 |
} |
|
|
152 |
} |