| author | Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com> |
| Sun, 15 Feb 2015 00:43:16 +0100 | |
| changeset 1198 | ff4b567d51f2 |
| parent 955 | 5171f8825985 |
| child 1304 | 10974bff4dae |
| permissions | -rw-r--r-- |
| 598 | 1 |
IriSP.Widgets.Trace = function(player, config) { |
2 |
IriSP.Widgets.Widget.call(this, player, config); |
|
3 |
|
|
| 955 | 4 |
}; |
| 598 | 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 |
| 955 | 16 |
}; |
| 598 | 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 |
| 779 | 32 |
}, |
33 |
_annlisteners = { |
|
34 |
search: 0, |
|
35 |
"search-cleared": 0 |
|
| 598 | 36 |
}; |
| 694 | 37 |
IriSP._(_medialisteners).each(function(_ms, _listener) { |
38 |
var _f = function(_arg) { |
|
39 |
_this.eventHandler(_listener, _arg); |
|
| 955 | 40 |
}; |
| 694 | 41 |
if (_ms) { |
42 |
_f = IriSP._.throttle(_f, _ms); |
|
43 |
} |
|
44 |
_this.media.on(_listener, _f); |
|
| 598 | 45 |
}); |
| 779 | 46 |
var _annotations = this.source.getAnnotations(); |
47 |
IriSP._(_annlisteners).each(function(_ms, _listener) { |
|
48 |
var _f = function(_arg) { |
|
49 |
_this.eventHandler(_listener, _arg); |
|
| 955 | 50 |
}; |
| 779 | 51 |
if (_ms) { |
52 |
_f = IriSP._.throttle(_f, _ms); |
|
53 |
} |
|
54 |
_annotations.on(_listener, _f); |
|
55 |
}); |
|
| 598 | 56 |
|
|
656
635a86f25fe7
First tests for PT Protocol implementation
Raphael Velt <raph.velt@gmail.com>
parents:
652
diff
changeset
|
57 |
if (!this.tracer) { |
|
635a86f25fe7
First tests for PT Protocol implementation
Raphael Velt <raph.velt@gmail.com>
parents:
652
diff
changeset
|
58 |
|
|
635a86f25fe7
First tests for PT Protocol implementation
Raphael Velt <raph.velt@gmail.com>
parents:
652
diff
changeset
|
59 |
this.tracer = window.tracemanager.init_trace("test", { |
|
635a86f25fe7
First tests for PT Protocol implementation
Raphael Velt <raph.velt@gmail.com>
parents:
652
diff
changeset
|
60 |
url: this.url, |
|
635a86f25fe7
First tests for PT Protocol implementation
Raphael Velt <raph.velt@gmail.com>
parents:
652
diff
changeset
|
61 |
requestmode: this.requestmode, |
|
635a86f25fe7
First tests for PT Protocol implementation
Raphael Velt <raph.velt@gmail.com>
parents:
652
diff
changeset
|
62 |
syncmode: this.syncmode, |
|
635a86f25fe7
First tests for PT Protocol implementation
Raphael Velt <raph.velt@gmail.com>
parents:
652
diff
changeset
|
63 |
default_subject: this.default_subject |
|
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 |
|
|
635a86f25fe7
First tests for PT Protocol implementation
Raphael Velt <raph.velt@gmail.com>
parents:
652
diff
changeset
|
66 |
} |
|
635a86f25fe7
First tests for PT Protocol implementation
Raphael Velt <raph.velt@gmail.com>
parents:
652
diff
changeset
|
67 |
|
| 779 | 68 |
|
69 |
|
|
|
656
635a86f25fe7
First tests for PT Protocol implementation
Raphael Velt <raph.velt@gmail.com>
parents:
652
diff
changeset
|
70 |
this.tracer.trace("TraceWidgetInit", {}); |
|
1198
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
955
diff
changeset
|
71 |
_this.player.trigger("trace-ready"); |
| 598 | 72 |
this.mouseLocation = ''; |
|
1198
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
955
diff
changeset
|
73 |
IriSP.jQuery(".Ldt-Widget").on("mousedown mouseenter mouseleave", ".Ldt-TraceMe", function(_e) { |
| 694 | 74 |
var _target = IriSP.jQuery(this); |
| 623 | 75 |
|
| 755 | 76 |
var _widget = _target.attr("widget-type") || _target.parents(".Ldt-Widget").attr("widget-type"), |
| 623 | 77 |
_data = { |
78 |
"type": _e.type, |
|
79 |
"widget": _widget |
|
80 |
}, |
|
81 |
_targetEl = _target[0], |
|
82 |
_class = _targetEl.className, |
|
83 |
_name = _targetEl.localName, |
|
84 |
_id = _targetEl.id, |
|
| 755 | 85 |
_value = _target.val(), |
86 |
_traceInfo = _target.attr("trace-info"); |
|
87 |
_data.target = _name + (_id && _id.length ? '#' + IriSP.jqEscape(_id) : '') + (_class && _class.length ? ('.' + IriSP.jqEscape(_class).replace(/\s/g,'.')).replace(/\.Ldt-(Widget|TraceMe)/g,'') : ''); |
|
88 |
if (typeof _traceInfo == "string" && _traceInfo) { |
|
| 623 | 89 |
_data.traceInfo = _traceInfo; |
90 |
} |
|
91 |
if (typeof _value == "string" && _value.length) { |
|
92 |
_data.value = _value; |
|
93 |
} |
|
| 755 | 94 |
_this.eventHandler('UIEvent', _data); |
| 598 | 95 |
}); |
| 955 | 96 |
}; |
| 598 | 97 |
|
98 |
IriSP.Widgets.Trace.prototype.eventHandler = function(_listener, _arg) { |
|
99 |
var _traceName = 'Mdp_'; |
|
100 |
if (typeof _arg == "string" || typeof _arg == "number") { |
|
| 955 | 101 |
_arg = { "value" : _arg }; |
| 598 | 102 |
} |
103 |
if (typeof _arg == "undefined") { |
|
| 955 | 104 |
_arg = {}; |
| 598 | 105 |
} |
106 |
switch(_listener) { |
|
| 755 | 107 |
case 'UIEvent': |
| 598 | 108 |
_traceName += _arg.widget + '_' + _arg.type; |
109 |
delete _arg.widget; |
|
110 |
delete _arg.type; |
|
111 |
break; |
|
112 |
case 'play': |
|
113 |
case 'pause': |
|
| 694 | 114 |
_arg.milliseconds = this.media.getCurrentTime().milliseconds; |
115 |
case 'timeupdate': |
|
| 598 | 116 |
case 'seeked': |
117 |
case 'volumechange': |
|
| 694 | 118 |
_traceName += 'media_' + _listener; |
| 598 | 119 |
break; |
120 |
default: |
|
| 694 | 121 |
_traceName += _listener.replace('.','_'); |
| 598 | 122 |
} |
|
657
d563fda7b928
Traces now send Protocol Level and Cookie info
Raphael Velt <raph.velt@gmail.com>
parents:
656
diff
changeset
|
123 |
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
|
124 |
IriSP._(_arg).extend(this.extend); |
|
d563fda7b928
Traces now send Protocol Level and Cookie info
Raphael Velt <raph.velt@gmail.com>
parents:
656
diff
changeset
|
125 |
} |
| 598 | 126 |
this.tracer.trace(_traceName, _arg); |
| 694 | 127 |
if (this.js_console && typeof window.console !== "undefined" && typeof console.log !== "undefined") { |
| 598 | 128 |
console.log("tracer.trace('" + _traceName + "', " + JSON.stringify(_arg) + ");"); |
129 |
} |
|
|
1198
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
955
diff
changeset
|
130 |
}; |