|
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", |
|
928
|
14 |
tracer: null, |
|
|
15 |
extend: false |
|
882
|
16 |
} |
|
|
17 |
|
|
|
18 |
IriSP.Widgets.Trace.prototype.draw = function() { |
|
|
19 |
if (typeof window.tracemanager === "undefined") { |
|
|
20 |
console.log("Tracemanager not found"); |
|
|
21 |
return; |
|
|
22 |
} |
|
|
23 |
var _this = this, |
|
957
|
24 |
_medialisteners = { |
|
882
|
25 |
"play" : 0, |
|
|
26 |
"pause" : 0, |
|
|
27 |
"volumechange" : 0, |
|
|
28 |
"seeked" : 0, |
|
|
29 |
"play" : 0, |
|
|
30 |
"pause" : 0, |
|
986
|
31 |
"timeupdate" : 10000 |
|
882
|
32 |
}; |
|
957
|
33 |
IriSP._(_medialisteners).each(function(_ms, _listener) { |
|
|
34 |
var _f = function(_arg) { |
|
|
35 |
_this.eventHandler(_listener, _arg); |
|
|
36 |
} |
|
|
37 |
if (_ms) { |
|
|
38 |
_f = IriSP._.throttle(_f, _ms); |
|
|
39 |
} |
|
|
40 |
_this.media.on(_listener, _f); |
|
882
|
41 |
}); |
|
|
42 |
|
|
926
|
43 |
if (!this.tracer) { |
|
|
44 |
|
|
|
45 |
this.tracer = window.tracemanager.init_trace("test", { |
|
|
46 |
url: this.url, |
|
|
47 |
requestmode: this.requestmode, |
|
|
48 |
syncmode: this.syncmode, |
|
|
49 |
default_subject: this.default_subject |
|
|
50 |
}); |
|
|
51 |
|
|
|
52 |
} |
|
|
53 |
|
|
|
54 |
this.tracer.trace("TraceWidgetInit", {}); |
|
882
|
55 |
|
|
|
56 |
this.mouseLocation = ''; |
|
986
|
57 |
IriSP.jQuery(".Ldt-Widget").on("click mouseenter mouseleave", ".Ldt-TraceMe", function(_e) { |
|
956
|
58 |
var _target = IriSP.jQuery(this); |
|
906
|
59 |
|
|
986
|
60 |
var _widget = _target.attr("widget-type") || _target.parents(".Ldt-Widget").attr("widget-type"), |
|
906
|
61 |
_data = { |
|
|
62 |
"type": _e.type, |
|
|
63 |
"x": _e.clientX, |
|
|
64 |
"y": _e.clientY, |
|
|
65 |
"widget": _widget |
|
|
66 |
}, |
|
|
67 |
_targetEl = _target[0], |
|
|
68 |
_class = _targetEl.className, |
|
|
69 |
_name = _targetEl.localName, |
|
|
70 |
_id = _targetEl.id, |
|
986
|
71 |
_value = _target.val(), |
|
|
72 |
_traceInfo = _target.attr("trace-info"); |
|
|
73 |
_data.target = _name + (_id && _id.length ? '#' + IriSP.jqEscape(_id) : '') + (_class && _class.length ? ('.' + IriSP.jqEscape(_class).replace(/\s/g,'.')).replace(/\.Ldt-(Widget|TraceMe)/g,'') : ''); |
|
|
74 |
if (typeof _traceInfo == "string" && _traceInfo) { |
|
906
|
75 |
_data.traceInfo = _traceInfo; |
|
|
76 |
} |
|
|
77 |
if (typeof _value == "string" && _value.length) { |
|
|
78 |
_data.value = _value; |
|
|
79 |
} |
|
986
|
80 |
_this.eventHandler('UIEvent', _data); |
|
882
|
81 |
}); |
|
|
82 |
} |
|
|
83 |
|
|
|
84 |
IriSP.Widgets.Trace.prototype.eventHandler = function(_listener, _arg) { |
|
|
85 |
var _traceName = 'Mdp_'; |
|
|
86 |
if (typeof _arg == "string" || typeof _arg == "number") { |
|
|
87 |
_arg = { "value" : _arg } |
|
|
88 |
} |
|
|
89 |
if (typeof _arg == "undefined") { |
|
|
90 |
_arg = {} |
|
|
91 |
} |
|
|
92 |
switch(_listener) { |
|
986
|
93 |
case 'UIEvent': |
|
882
|
94 |
_traceName += _arg.widget + '_' + _arg.type; |
|
|
95 |
delete _arg.widget; |
|
|
96 |
delete _arg.type; |
|
|
97 |
break; |
|
|
98 |
case 'play': |
|
|
99 |
case 'pause': |
|
960
|
100 |
_arg.milliseconds = this.media.getCurrentTime().milliseconds; |
|
|
101 |
case 'timeupdate': |
|
882
|
102 |
case 'seeked': |
|
|
103 |
case 'volumechange': |
|
957
|
104 |
_traceName += 'media_' + _listener; |
|
882
|
105 |
break; |
|
|
106 |
default: |
|
957
|
107 |
_traceName += _listener.replace('.','_'); |
|
882
|
108 |
} |
|
928
|
109 |
if (typeof this.extend === "object" && this.extend) { |
|
|
110 |
IriSP._(_arg).extend(this.extend); |
|
|
111 |
} |
|
882
|
112 |
this.tracer.trace(_traceName, _arg); |
|
930
|
113 |
if (this.js_console && typeof window.console !== "undefined" && typeof console.log !== "undefined") { |
|
882
|
114 |
console.log("tracer.trace('" + _traceName + "', " + JSON.stringify(_arg) + ");"); |
|
|
115 |
} |
|
986
|
116 |
} |