| author | Raphael Velt <raph.velt@gmail.com> |
| Tue, 02 Oct 2012 14:40:14 +0200 | |
| changeset 694 | e9400c80e1e4 |
| parent 668 | eb7e39c732c6 |
| child 755 | d50aeed9a54b |
| permissions | -rw-r--r-- |
| 598 | 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', |
|
|
652
b3ccfdbd581b
Added a default subject in the Trace Widget
Raphael Velt <raph.velt@gmail.com>
parents:
623
diff
changeset
|
12 |
syncmode: "sync", |
|
656
635a86f25fe7
First tests for PT Protocol implementation
Raphael Velt <raph.velt@gmail.com>
parents:
652
diff
changeset
|
13 |
default_subject: "IRI", |
|
657
d563fda7b928
Traces now send Protocol Level and Cookie info
Raphael Velt <raph.velt@gmail.com>
parents:
656
diff
changeset
|
14 |
tracer: null, |
|
d563fda7b928
Traces now send Protocol Level and Cookie info
Raphael Velt <raph.velt@gmail.com>
parents:
656
diff
changeset
|
15 |
extend: false |
| 598 | 16 |
} |
17 |
||
18 |
IriSP.Widgets.Trace.prototype.draw = function() { |
|
19 |
this.lastEvent = ""; |
|
20 |
if (typeof window.tracemanager === "undefined") { |
|
21 |
console.log("Tracemanager not found"); |
|
22 |
return; |
|
23 |
} |
|
24 |
var _this = this, |
|
| 694 | 25 |
_mdplisteners = { |
26 |
"search.open" : 0, |
|
27 |
"search.closed" : 0, |
|
28 |
"search" : 0, |
|
29 |
"search.cleared" : 0, |
|
30 |
"search.matchFound" : 0, |
|
31 |
"search.noMatchFound" : 0, |
|
32 |
"search.triggeredSearch" : 0, |
|
33 |
"TraceWidget.MouseEvents" : 0 |
|
34 |
} |
|
35 |
_medialisteners = { |
|
| 598 | 36 |
"play" : 0, |
37 |
"pause" : 0, |
|
38 |
"volumechange" : 0, |
|
39 |
"seeked" : 0, |
|
40 |
"play" : 0, |
|
41 |
"pause" : 0, |
|
42 |
"timeupdate" : 2000 |
|
43 |
}; |
|
| 694 | 44 |
IriSP._(_mdplisteners).each(function(_ms, _listener) { |
| 598 | 45 |
var _f = function(_arg) { |
46 |
_this.eventHandler(_listener, _arg); |
|
47 |
} |
|
48 |
if (_ms) { |
|
49 |
_f = IriSP._.throttle(_f, _ms); |
|
50 |
} |
|
| 694 | 51 |
_this.onMdpEvent(_listener, _f); |
52 |
}); |
|
53 |
IriSP._(_medialisteners).each(function(_ms, _listener) { |
|
54 |
var _f = function(_arg) { |
|
55 |
_this.eventHandler(_listener, _arg); |
|
56 |
} |
|
57 |
if (_ms) { |
|
58 |
_f = IriSP._.throttle(_f, _ms); |
|
59 |
} |
|
60 |
_this.media.on(_listener, _f); |
|
| 598 | 61 |
}); |
62 |
|
|
|
656
635a86f25fe7
First tests for PT Protocol implementation
Raphael Velt <raph.velt@gmail.com>
parents:
652
diff
changeset
|
63 |
if (!this.tracer) { |
|
635a86f25fe7
First tests for PT Protocol implementation
Raphael Velt <raph.velt@gmail.com>
parents:
652
diff
changeset
|
64 |
|
|
635a86f25fe7
First tests for PT Protocol implementation
Raphael Velt <raph.velt@gmail.com>
parents:
652
diff
changeset
|
65 |
this.tracer = window.tracemanager.init_trace("test", { |
|
635a86f25fe7
First tests for PT Protocol implementation
Raphael Velt <raph.velt@gmail.com>
parents:
652
diff
changeset
|
66 |
url: this.url, |
|
635a86f25fe7
First tests for PT Protocol implementation
Raphael Velt <raph.velt@gmail.com>
parents:
652
diff
changeset
|
67 |
requestmode: this.requestmode, |
|
635a86f25fe7
First tests for PT Protocol implementation
Raphael Velt <raph.velt@gmail.com>
parents:
652
diff
changeset
|
68 |
syncmode: this.syncmode, |
|
635a86f25fe7
First tests for PT Protocol implementation
Raphael Velt <raph.velt@gmail.com>
parents:
652
diff
changeset
|
69 |
default_subject: this.default_subject |
|
635a86f25fe7
First tests for PT Protocol implementation
Raphael Velt <raph.velt@gmail.com>
parents:
652
diff
changeset
|
70 |
}); |
|
635a86f25fe7
First tests for PT Protocol implementation
Raphael Velt <raph.velt@gmail.com>
parents:
652
diff
changeset
|
71 |
|
|
635a86f25fe7
First tests for PT Protocol implementation
Raphael Velt <raph.velt@gmail.com>
parents:
652
diff
changeset
|
72 |
} |
|
635a86f25fe7
First tests for PT Protocol implementation
Raphael Velt <raph.velt@gmail.com>
parents:
652
diff
changeset
|
73 |
|
|
635a86f25fe7
First tests for PT Protocol implementation
Raphael Velt <raph.velt@gmail.com>
parents:
652
diff
changeset
|
74 |
this.tracer.trace("TraceWidgetInit", {}); |
| 598 | 75 |
|
76 |
this.mouseLocation = ''; |
|
| 694 | 77 |
IriSP.jQuery(".Ldt-Widget").on("click mouseover mouseout", ".Ldt-TraceMe", function(_e) { |
78 |
var _target = IriSP.jQuery(this); |
|
| 623 | 79 |
|
80 |
var _widget = IriSP.jQuery(this).attr("widget-type"), |
|
81 |
_data = { |
|
82 |
"type": _e.type, |
|
83 |
"x": _e.clientX, |
|
84 |
"y": _e.clientY, |
|
85 |
"widget": _widget |
|
86 |
}, |
|
87 |
_targetEl = _target[0], |
|
88 |
_class = _targetEl.className, |
|
89 |
_name = _targetEl.localName, |
|
90 |
_id = _targetEl.id, |
|
91 |
_value = _targetEl.value, |
|
92 |
_traceInfo = _target.attr("trace-info"), |
|
93 |
_lastTarget = _name + (_id && _id.length ? '#' + IriSP.jqEscape(_id) : '') + (_class && _class.length ? ('.' + IriSP.jqEscape(_class).replace(/\s/g,'.')).replace(/\.Ldt-(Widget|TraceMe)/g,'') : ''); |
|
94 |
_data.target = _lastTarget |
|
| 668 | 95 |
if (typeof _traceInfo == "string" && _traceInfo.length) { |
| 623 | 96 |
_data.traceInfo = _traceInfo; |
97 |
_lastTarget += ( ";" + _traceInfo ); |
|
98 |
} |
|
99 |
if (typeof _value == "string" && _value.length) { |
|
100 |
_data.value = _value; |
|
101 |
} |
|
102 |
switch(_e.type) { |
|
103 |
case "mouseover": |
|
104 |
if (_this.lastTarget != _lastTarget) { |
|
| 694 | 105 |
_this.player.trigger('TraceWidget.MouseEvents', _data); |
| 598 | 106 |
} else { |
107 |
if (typeof _this.moTimeout != "undefined") { |
|
108 |
clearTimeout(_this.moTimeout); |
|
| 623 | 109 |
_this.moTimeout = undefined; |
| 598 | 110 |
} |
111 |
} |
|
| 623 | 112 |
break; |
113 |
case "mouseout": |
|
| 598 | 114 |
if (typeof _this.moTimeout != "undefined") { |
115 |
clearTimeout(_this.moTimeout); |
|
116 |
} |
|
117 |
_this.moTimeout = setTimeout(function() { |
|
| 623 | 118 |
if (_lastTarget != _this.lastTarget) { |
| 694 | 119 |
_this.player.trigger('TraceWidget.MouseEvents', _data); |
| 598 | 120 |
} |
121 |
},100); |
|
| 623 | 122 |
break; |
123 |
default: |
|
| 694 | 124 |
_this.player.trigger('TraceWidget.MouseEvents', _data); |
| 598 | 125 |
} |
| 623 | 126 |
_this.lastTarget = _lastTarget; |
| 598 | 127 |
}); |
128 |
} |
|
129 |
||
130 |
IriSP.Widgets.Trace.prototype.eventHandler = function(_listener, _arg) { |
|
131 |
var _traceName = 'Mdp_'; |
|
132 |
if (typeof _arg == "string" || typeof _arg == "number") { |
|
133 |
_arg = { "value" : _arg } |
|
134 |
} |
|
135 |
if (typeof _arg == "undefined") { |
|
136 |
_arg = {} |
|
137 |
} |
|
138 |
switch(_listener) { |
|
139 |
case 'IriSP.TraceWidget.MouseEvents': |
|
140 |
_traceName += _arg.widget + '_' + _arg.type; |
|
141 |
delete _arg.widget; |
|
142 |
delete _arg.type; |
|
143 |
break; |
|
144 |
case 'play': |
|
145 |
case 'pause': |
|
| 694 | 146 |
_arg.milliseconds = this.media.getCurrentTime().milliseconds; |
147 |
case 'timeupdate': |
|
| 598 | 148 |
case 'seeked': |
149 |
case 'volumechange': |
|
| 694 | 150 |
_traceName += 'media_' + _listener; |
| 598 | 151 |
break; |
152 |
default: |
|
| 694 | 153 |
_traceName += _listener.replace('.','_'); |
| 598 | 154 |
} |
155 |
this.lastEvent = _traceName; |
|
|
657
d563fda7b928
Traces now send Protocol Level and Cookie info
Raphael Velt <raph.velt@gmail.com>
parents:
656
diff
changeset
|
156 |
if (typeof this.extend === "object" && this.extend) { |
|
d563fda7b928
Traces now send Protocol Level and Cookie info
Raphael Velt <raph.velt@gmail.com>
parents:
656
diff
changeset
|
157 |
IriSP._(_arg).extend(this.extend); |
|
d563fda7b928
Traces now send Protocol Level and Cookie info
Raphael Velt <raph.velt@gmail.com>
parents:
656
diff
changeset
|
158 |
} |
| 598 | 159 |
this.tracer.trace(_traceName, _arg); |
| 694 | 160 |
if (this.js_console && typeof window.console !== "undefined" && typeof console.log !== "undefined") { |
| 598 | 161 |
console.log("tracer.trace('" + _traceName + "', " + JSON.stringify(_arg) + ");"); |
162 |
} |
|
163 |
} |