| author | Raphael Velt <raph.velt@gmail.com> |
| Wed, 19 Dec 2012 16:52:21 +0100 | |
| changeset 755 | d50aeed9a54b |
| parent 694 | e9400c80e1e4 |
| child 779 | e13084ff318b |
| 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 |
if (typeof window.tracemanager === "undefined") { |
|
20 |
console.log("Tracemanager not found"); |
|
21 |
return; |
|
22 |
} |
|
23 |
var _this = this, |
|
| 694 | 24 |
_medialisteners = { |
| 598 | 25 |
"play" : 0, |
26 |
"pause" : 0, |
|
27 |
"volumechange" : 0, |
|
28 |
"seeked" : 0, |
|
29 |
"play" : 0, |
|
30 |
"pause" : 0, |
|
| 755 | 31 |
"timeupdate" : 10000 |
| 598 | 32 |
}; |
| 694 | 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); |
|
| 598 | 41 |
}); |
42 |
|
|
|
656
635a86f25fe7
First tests for PT Protocol implementation
Raphael Velt <raph.velt@gmail.com>
parents:
652
diff
changeset
|
43 |
if (!this.tracer) { |
|
635a86f25fe7
First tests for PT Protocol implementation
Raphael Velt <raph.velt@gmail.com>
parents:
652
diff
changeset
|
44 |
|
|
635a86f25fe7
First tests for PT Protocol implementation
Raphael Velt <raph.velt@gmail.com>
parents:
652
diff
changeset
|
45 |
this.tracer = window.tracemanager.init_trace("test", { |
|
635a86f25fe7
First tests for PT Protocol implementation
Raphael Velt <raph.velt@gmail.com>
parents:
652
diff
changeset
|
46 |
url: this.url, |
|
635a86f25fe7
First tests for PT Protocol implementation
Raphael Velt <raph.velt@gmail.com>
parents:
652
diff
changeset
|
47 |
requestmode: this.requestmode, |
|
635a86f25fe7
First tests for PT Protocol implementation
Raphael Velt <raph.velt@gmail.com>
parents:
652
diff
changeset
|
48 |
syncmode: this.syncmode, |
|
635a86f25fe7
First tests for PT Protocol implementation
Raphael Velt <raph.velt@gmail.com>
parents:
652
diff
changeset
|
49 |
default_subject: this.default_subject |
|
635a86f25fe7
First tests for PT Protocol implementation
Raphael Velt <raph.velt@gmail.com>
parents:
652
diff
changeset
|
50 |
}); |
|
635a86f25fe7
First tests for PT Protocol implementation
Raphael Velt <raph.velt@gmail.com>
parents:
652
diff
changeset
|
51 |
|
|
635a86f25fe7
First tests for PT Protocol implementation
Raphael Velt <raph.velt@gmail.com>
parents:
652
diff
changeset
|
52 |
} |
|
635a86f25fe7
First tests for PT Protocol implementation
Raphael Velt <raph.velt@gmail.com>
parents:
652
diff
changeset
|
53 |
|
|
635a86f25fe7
First tests for PT Protocol implementation
Raphael Velt <raph.velt@gmail.com>
parents:
652
diff
changeset
|
54 |
this.tracer.trace("TraceWidgetInit", {}); |
| 598 | 55 |
|
56 |
this.mouseLocation = ''; |
|
| 755 | 57 |
IriSP.jQuery(".Ldt-Widget").on("click mouseenter mouseleave", ".Ldt-TraceMe", function(_e) { |
| 694 | 58 |
var _target = IriSP.jQuery(this); |
| 623 | 59 |
|
| 755 | 60 |
var _widget = _target.attr("widget-type") || _target.parents(".Ldt-Widget").attr("widget-type"), |
| 623 | 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, |
|
| 755 | 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) { |
|
| 623 | 75 |
_data.traceInfo = _traceInfo; |
76 |
} |
|
77 |
if (typeof _value == "string" && _value.length) { |
|
78 |
_data.value = _value; |
|
79 |
} |
|
| 755 | 80 |
_this.eventHandler('UIEvent', _data); |
| 598 | 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) { |
|
| 755 | 93 |
case 'UIEvent': |
| 598 | 94 |
_traceName += _arg.widget + '_' + _arg.type; |
95 |
delete _arg.widget; |
|
96 |
delete _arg.type; |
|
97 |
break; |
|
98 |
case 'play': |
|
99 |
case 'pause': |
|
| 694 | 100 |
_arg.milliseconds = this.media.getCurrentTime().milliseconds; |
101 |
case 'timeupdate': |
|
| 598 | 102 |
case 'seeked': |
103 |
case 'volumechange': |
|
| 694 | 104 |
_traceName += 'media_' + _listener; |
| 598 | 105 |
break; |
106 |
default: |
|
| 694 | 107 |
_traceName += _listener.replace('.','_'); |
| 598 | 108 |
} |
|
657
d563fda7b928
Traces now send Protocol Level and Cookie info
Raphael Velt <raph.velt@gmail.com>
parents:
656
diff
changeset
|
109 |
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
|
110 |
IriSP._(_arg).extend(this.extend); |
|
d563fda7b928
Traces now send Protocol Level and Cookie info
Raphael Velt <raph.velt@gmail.com>
parents:
656
diff
changeset
|
111 |
} |
| 598 | 112 |
this.tracer.trace(_traceName, _arg); |
| 694 | 113 |
if (this.js_console && typeof window.console !== "undefined" && typeof console.log !== "undefined") { |
| 598 | 114 |
console.log("tracer.trace('" + _traceName + "', " + JSON.stringify(_arg) + ");"); |
115 |
} |
|
| 755 | 116 |
} |