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