--- a/src/ldt/ldt/ldt_utils/templates/front/front_search_results.html Tue Jan 24 14:54:11 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/templates/front/front_search_results.html Tue Jan 24 14:55:05 2012 +0100
@@ -19,9 +19,6 @@
{% block body %}
{{block.super}}
<script type="text/javascript">
- var _width = 340,
- _height = 25,
- _colorRange = [ "#89e1ff", "#c800ff", "#85ff3b", "#ffff17", "#ff2f7e" ];
var _medias = [ {% for res in results.object_list %}
{
"iri_id" : '{{ res.content.iri_id }}',
@@ -36,72 +33,8 @@
"stats" : [{{ res.content.stat_annotation }}],
},{% endfor %}
];
- $(document).ready(function () {
- var _k = 0;
- $('.graph_annotation').each(function(_i) {
- var _values = _medias[_i].stats,
- _nb = _values.length,
- _max = _values.reduce(function(_a,_b) {
- return Math.max(_a,_b);
- }, 1),
- _x = function(_p) {
- return _p * _width / _nb;
- },
- _y = function(_p) {
- return _height * ( 1 - _p / _max );
- },
- _d = _values.map(function(_v,_k) {
- return ( _k == 0 ?
- "M" + _x(_k) + " " + _y(_v) :
- "C" + _x(_k-.5) + " " + _y(_values[_k - 1])
- + " " + + _x(_k-.5) + " " + _y(_v)
- + " " + + _x(_k) + " " + _y(_v)
- ) ;
- }).join("") + "L" + _width + " " + _height + "L0 " + _height;
- this.innerHTML = '';
- var _paper = new Raphael(this,_width,_height);
- _paper.path(_d).attr({
- "fill" : "#adadad",
- "stroke" : "none"
- });
- var _x = function(_p) {
- return _p * 340 / _medias[_i].duration;
- };
- for (var _j = 0; _j < _medias[_i].segments.length; _j++) {
- var _s = _medias[_i].segments[_j],
- _coul = _colorRange[_k % _colorRange.length],
- _rect = _paper.rect(_x(_s.begin),0,Math.max(1,_x(_s.duration)),25).attr({
- "fill" : _coul,
- "opacity" : .5,
- "stroke" : "none",
- });
- _rect.node.id = "re_" + _s.id;
- $("#li_" + _s.id + " .color_zone").css({
- "background" : _coul,
- "opacity" : .5,
- });
- _k ++;
- }
- });
- $("li.li_segment, .graph_annotation rect").mouseover(function() {
- var _id = this.id.substr(3);
- $("#re_" + _id + ", #li_" + _id + " .color_zone").css({
- "opacity" : ".9",
- });
- $("#re_" + _id).attr({
- "opacity" : ".9",
- });
- }).mouseout(function() {
- var _id = this.id.substr(3);
- $("#re_" + _id + ", #li_" + _id + " .color_zone").css({
- "opacity" : ".5",
- });
- $("#re_" + _id).attr({
- "opacity" : ".5",
- });
- });
- });
</script>
+<script src="{{LDT_MEDIA_PREFIX}}js/Ldt_front_search_results.js" type="text/javascript"></script>
{% if msg %}
{{ msg }}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ldt/ldt/static/ldt/js/Ldt_front_search_results.js Tue Jan 24 14:55:05 2012 +0100
@@ -0,0 +1,75 @@
+ var _width = 340,
+ _height = 25,
+ _colorRange = [ "#89e1ff", "#c800ff", "#85ff3b", "#ffff17", "#ff2f7e" ];
+ $(document).ready(function () {
+ var _k = 0;
+ $('.graph_annotation').each(function(_i) {
+ var _values = _medias[_i].stats,
+ _nb = _values.length,
+ _max = _values.reduce(function(_a,_b) {
+ return Math.max(_a,_b);
+ }, 1),
+ _x = function(_p) {
+ return _p * _width / _nb;
+ },
+ _y = function(_p) {
+ return _height * ( 1 - _p / _max );
+ },
+ _d = _values.map(function(_v,_k) {
+ return ( _k == 0 ?
+ "M" + _x(_k) + " " + _y(_v) :
+ "C" + _x(_k-.5) + " " + _y(_values[_k - 1])
+ + " " + + _x(_k-.5) + " " + _y(_v)
+ + " " + + _x(_k) + " " + _y(_v)
+ ) ;
+ }).join("") + "L" + _width + " " + _height + "L0 " + _height;
+ this.innerHTML = '';
+ var _paper = new Raphael(this,_width,_height);
+ _paper.path(_d).attr({
+ "fill" : "#adadad",
+ "stroke" : "none"
+ });
+ var _x = function(_p) {
+ return _p * 340 / _medias[_i].duration;
+ };
+ for (var _j = 0; _j < _medias[_i].segments.length; _j++) {
+ var _s = _medias[_i].segments[_j],
+ _coul = _colorRange[_k % _colorRange.length],
+ _rect = _paper.rect(_x(_s.begin),0,Math.max(1,_x(_s.duration)),25).attr({
+ "fill" : _coul,
+ "opacity" : .5,
+ "stroke" : "none",
+ });
+ _rect.node.id = "re_" + _s.id;
+ $("#li_" + _s.id + " .color_zone").css({
+ "background" : _coul,
+ "opacity" : .5,
+ });
+ _k ++;
+ }
+ });
+ $("li.li_segment, .graph_annotation rect").mouseover(function() {
+ var _id = this.id.substr(3);
+ $(".graph_annotation rect").css({
+ "opacity" : ".2",
+ });
+ $("#re_" + _id + ", #li_" + _id + " .color_zone").css({
+ "opacity" : ".9",
+ });
+ $("#re_" + _id).attr({
+ "opacity" : ".9",
+ });
+ $("#li_" + _id).addClass("selected");
+ }).mouseout(function() {
+ var _id = this.id.substr(3);
+ $("#li_" + _id).removeClass("selected");
+ $("#li_" + _id + " .color_zone").css({
+ "opacity" : ".5",
+ });
+ $(".graph_annotation rect").attr({
+ "opacity" : ".5",
+ }).css({
+ "opacity" : ".5",
+ });
+ });
+ });
\ No newline at end of file