src/js/widgets/polemicWidget.js
author veltr
Fri, 06 Apr 2012 16:49:32 +0200
branchpopcorn-port
changeset 842 4ae2247a59f4
parent 830 18ca612e9ff0
child 874 38b65761a7d5
permissions -rw-r--r--
Changes for Cinecast
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
169
427632a324d5 first import of the polemic tweet widget.
hamidouk
parents:
diff changeset
     1
/* 
207
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
     2
 *   
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
     3
 *  Copyright 2010 Institut de recherche et d'innovation 
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
     4
 *  contributor(s) : Samuel Huron 
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
     5
 *   
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
     6
 *  contact@iri.centrepompidou.fr
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
     7
 *  http://www.iri.centrepompidou.fr 
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
     8
 *   
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
     9
 *  This software is a computer program whose purpose is to show and add annotations on a video .
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    10
 *  This software is governed by the CeCILL-C license under French law and
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    11
 *  abiding by the rules of distribution of free software. You can  use, 
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    12
 *  modify and/ or redistribute the software under the terms of the CeCILL-C
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    13
 *  license as circulated by CEA, CNRS and INRIA at the following URL
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    14
 *  "http://www.cecill.info". 
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    15
 *  
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    16
 *  The fact that you are presently reading this means that you have had
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    17
 *  knowledge of the CeCILL-C license and that you accept its terms.
169
427632a324d5 first import of the polemic tweet widget.
hamidouk
parents:
diff changeset
    18
*/
427632a324d5 first import of the polemic tweet widget.
hamidouk
parents:
diff changeset
    19
// CHART TIMELINE / VERSION PROTOTYPE  ::
427632a324d5 first import of the polemic tweet widget.
hamidouk
parents:
diff changeset
    20
528
a5894f09825a added docs.
hamidouk
parents: 490
diff changeset
    21
/** the polemic widget */
169
427632a324d5 first import of the polemic tweet widget.
hamidouk
parents:
diff changeset
    22
IriSP.PolemicWidget = function(Popcorn, config, Serializer) {
427632a324d5 first import of the polemic tweet widget.
hamidouk
parents:
diff changeset
    23
  IriSP.Widget.call(this, Popcorn, config, Serializer);
427632a324d5 first import of the polemic tweet widget.
hamidouk
parents:
diff changeset
    24
 
207
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    25
  this.userPol    = new Array();
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    26
  this.userNoPol  = new Array();
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    27
  this.userst      = new Array();
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    28
  this.numberOfTweet = 0;
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    29
  this.Users;
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    30
  this.TweetPolemic;
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    31
  this.yMax        = this.height; 
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    32
  this.PaperSlider;
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    33
  this.heightOfChart;
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    34
  this.tweets  = new Array();
395
5766e8238aaf search in twitter feed now works.
hamidouk
parents: 379
diff changeset
    35
  this.svgElements = {};
169
427632a324d5 first import of the polemic tweet widget.
hamidouk
parents:
diff changeset
    36
  
566
098929cd2d62 made the polemicwidget adjust its size automatically and fixed a couple edgecases.
hamidouk
parents: 565
diff changeset
    37
  this.oldSearchMatches = [];
169
427632a324d5 first import of the polemic tweet widget.
hamidouk
parents:
diff changeset
    38
};
427632a324d5 first import of the polemic tweet widget.
hamidouk
parents:
diff changeset
    39
427632a324d5 first import of the polemic tweet widget.
hamidouk
parents:
diff changeset
    40
IriSP.PolemicWidget.prototype = new IriSP.Widget();
207
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    41
  
169
427632a324d5 first import of the polemic tweet widget.
hamidouk
parents:
diff changeset
    42
IriSP.PolemicWidget.prototype.draw = function() {
207
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    43
  
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    44
    // variable 
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    45
    // yMax
176
c04283d7d1ef refactoring.
hamidouk
parents: 169
diff changeset
    46
    
c04283d7d1ef refactoring.
hamidouk
parents: 169
diff changeset
    47
    var self = this;
207
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    48
    var yCoef        = 2;             // coef for height of 1 tweet 
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    49
    var frameSize     = 5;             // frame size 
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    50
    var margin         = 1;            // marge between frame
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    51
    var lineSize      = this.width;        // timeline pixel width 
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    52
    var nbrframes     = lineSize/frameSize;     // frame numbers
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    53
    var numberOfTweet   = 0;            // number of tweet overide later 
842
4ae2247a59f4 Changes for Cinecast
veltr
parents: 830
diff changeset
    54
    var duration      = this.getDuration();      // timescale width 
207
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    55
    var frameLength   = lineSize / frameSize;    // frame timescale  
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    56
    var timeline;
830
18ca612e9ff0 Lots of changes
veltr
parents: 827
diff changeset
    57
    var colors  = new Array("","#1D973D","#036AAE","#CE0A15","#C5A62D","#585858");
207
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    58
    
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    59
    // array 
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    60
    //var tweets  = new Array();
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    61
    var element = new Array();
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    62
    var cluster = new Array();
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    63
    var frames  = new Array(frameLength);
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    64
    var slices  = new Array();
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    65
    
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    66
    
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    67
    // Classes =======================================================================
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    68
    var Frames = function(){
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    69
      
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    70
      var Myclusters;
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    71
      var x;
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    72
      var y;
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    73
      var width;
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    74
      var height;
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    75
    };
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    76
    Frames = function(json){
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    77
      // make my clusters
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    78
      // ou Frame vide 
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    79
    };
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    80
    Frames.prototype.draw = function(){
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    81
    };
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    82
    Frames.prototype.zoom = function(){
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    83
    };
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    84
    Frames.prototype.inside = function(){
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    85
    };
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    86
    var Clusters = function(){
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    87
      var Object;
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    88
      var yDist;
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    89
      var x;
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    90
      var y;
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    91
      var width;
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    92
      var height;
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    93
    };
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    94
    Clusters = function(json){
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    95
      // make my object
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    96
    };
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    97
    var Tweet = function(){
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    98
    };
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    99
    // Classes =======================================================================
187
6f1def85018a removed useless printfs.
hamidouk
parents: 176
diff changeset
   100
207
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   101
    // Refactoring (parametere) ************************************************************
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   102
    // color translastion
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   103
    var qTweet_0  =0;
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   104
    var qTweet_Q  =0;
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   105
    var qTweet_REF=0;
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   106
    var qTweet_OK =0;
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   107
    var qTweet_KO =0;
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   108
    function colorTranslation(value){
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   109
      if(value == "Q"){
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   110
        qTweet_Q+=1;
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   111
        return 2;
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   112
      }else if(value =="REF"){
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   113
        qTweet_REF+=1;
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   114
        return 4;
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   115
      }else if(value =="OK"){
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   116
        qTweet_OK+=1;
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   117
        return 1;
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   118
      }else if(value =="KO"){
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   119
        qTweet_KO+=1;
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   120
        return 3;
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   121
      }else if(value ==""){
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   122
        qTweet_0+=1;
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   123
        return 5;
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   124
      }
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   125
    }
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   126
    
169
427632a324d5 first import of the polemic tweet widget.
hamidouk
parents:
diff changeset
   127
624
177dfeacc7a6 made the polemicwidget not show itself if it has no data to display.
hamidouk
parents: 595
diff changeset
   128
      this._serializer.sync(function(data) { loaded_callback.call(self, data); return; });
176
c04283d7d1ef refactoring.
hamidouk
parents: 169
diff changeset
   129
      
c04283d7d1ef refactoring.
hamidouk
parents: 169
diff changeset
   130
      function loaded_callback (json) {
595
29d86e6c61a6 finished going through the widgets to add stricter line checking.
hamidouk
parents: 567
diff changeset
   131
      var view_type = this._serializer.getTweets();
29d86e6c61a6 finished going through the widgets to add stricter line checking.
hamidouk
parents: 567
diff changeset
   132
624
177dfeacc7a6 made the polemicwidget not show itself if it has no data to display.
hamidouk
parents: 595
diff changeset
   133
      
566
098929cd2d62 made the polemicwidget adjust its size automatically and fixed a couple edgecases.
hamidouk
parents: 565
diff changeset
   134
      if (typeof(view_type) === "undefined") {
624
177dfeacc7a6 made the polemicwidget not show itself if it has no data to display.
hamidouk
parents: 595
diff changeset
   135
        var view_type = this._serializer.getTweetIds()[0];
595
29d86e6c61a6 finished going through the widgets to add stricter line checking.
hamidouk
parents: 567
diff changeset
   136
        if (typeof(view_type) === "undefined") {
29d86e6c61a6 finished going through the widgets to add stricter line checking.
hamidouk
parents: 567
diff changeset
   137
          // default to guessing if nothing else works.
624
177dfeacc7a6 made the polemicwidget not show itself if it has no data to display.
hamidouk
parents: 595
diff changeset
   138
          var view = json.views[0];
595
29d86e6c61a6 finished going through the widgets to add stricter line checking.
hamidouk
parents: 567
diff changeset
   139
          
29d86e6c61a6 finished going through the widgets to add stricter line checking.
hamidouk
parents: 567
diff changeset
   140
          if(typeof(view.annotation_types) !== "undefined") {
631
70e6ec9d9f65 added a test for backward-compatibility.
hamidouk
parents: 624
diff changeset
   141
            /* we need to be backward compatible with the old files which used to
70e6ec9d9f65 added a test for backward-compatibility.
hamidouk
parents: 624
diff changeset
   142
               feature only two lines : Chapitrage and Tweets. We've added a
70e6ec9d9f65 added a test for backward-compatibility.
hamidouk
parents: 624
diff changeset
   143
               "Contributions" line so we need to discriminate against that */
70e6ec9d9f65 added a test for backward-compatibility.
hamidouk
parents: 624
diff changeset
   144
            if (view.annotation_types.length === 2 && typeof(this._serializer.getContributions()) === "undefined") {
624
177dfeacc7a6 made the polemicwidget not show itself if it has no data to display.
hamidouk
parents: 595
diff changeset
   145
              var view_type = view.annotation_types[1];
595
29d86e6c61a6 finished going through the widgets to add stricter line checking.
hamidouk
parents: 567
diff changeset
   146
            } else {
624
177dfeacc7a6 made the polemicwidget not show itself if it has no data to display.
hamidouk
parents: 595
diff changeset
   147
              console.log("PolemicWidget: invalid file - minimizing");
177dfeacc7a6 made the polemicwidget not show itself if it has no data to display.
hamidouk
parents: 595
diff changeset
   148
              return;
595
29d86e6c61a6 finished going through the widgets to add stricter line checking.
hamidouk
parents: 567
diff changeset
   149
            }
29d86e6c61a6 finished going through the widgets to add stricter line checking.
hamidouk
parents: 567
diff changeset
   150
          }      
29d86e6c61a6 finished going through the widgets to add stricter line checking.
hamidouk
parents: 567
diff changeset
   151
        }
566
098929cd2d62 made the polemicwidget adjust its size automatically and fixed a couple edgecases.
hamidouk
parents: 565
diff changeset
   152
      }
595
29d86e6c61a6 finished going through the widgets to add stricter line checking.
hamidouk
parents: 567
diff changeset
   153
      
624
177dfeacc7a6 made the polemicwidget not show itself if it has no data to display.
hamidouk
parents: 595
diff changeset
   154
      // Make and define the Raphael area
177dfeacc7a6 made the polemicwidget not show itself if it has no data to display.
hamidouk
parents: 595
diff changeset
   155
      this.paper = Raphael(document.getElementById(this._id), this._config.width, this._config.height);
177dfeacc7a6 made the polemicwidget not show itself if it has no data to display.
hamidouk
parents: 595
diff changeset
   156
      
177dfeacc7a6 made the polemicwidget not show itself if it has no data to display.
hamidouk
parents: 595
diff changeset
   157
      // event handlers
177dfeacc7a6 made the polemicwidget not show itself if it has no data to display.
hamidouk
parents: 595
diff changeset
   158
      this._Popcorn.listen("IriSP.search", IriSP.wrap(this, function(searchString) { this.searchHandler(searchString); }));
177dfeacc7a6 made the polemicwidget not show itself if it has no data to display.
hamidouk
parents: 595
diff changeset
   159
      this._Popcorn.listen("IriSP.search.closed", IriSP.wrap(this, this.searchFieldClosedHandler));
177dfeacc7a6 made the polemicwidget not show itself if it has no data to display.
hamidouk
parents: 595
diff changeset
   160
      this._Popcorn.listen("IriSP.search.cleared", IriSP.wrap(this, this.searchFieldClearedHandler));
177dfeacc7a6 made the polemicwidget not show itself if it has no data to display.
hamidouk
parents: 595
diff changeset
   161
      this.selector.mouseleave(IriSP.wrap(this, function() { self.TooltipWidget.hide.call(self.TooltipWidget); }));
177dfeacc7a6 made the polemicwidget not show itself if it has no data to display.
hamidouk
parents: 595
diff changeset
   162
      this._Popcorn.listen("timeupdate", IriSP.wrap(this, this.sliderUpdater));
648
431b3495f958 highlight a tweet if it corresponds to a hashtag link.
hamidouk
parents: 631
diff changeset
   163
      this._Popcorn.listen("IriSP.Mediafragment.showAnnotation", IriSP.wrap(this, this.showAnnotation));
624
177dfeacc7a6 made the polemicwidget not show itself if it has no data to display.
hamidouk
parents: 595
diff changeset
   164
      
176
c04283d7d1ef refactoring.
hamidouk
parents: 169
diff changeset
   165
      for(var i = 0; i < json.annotations.length; i++) {
265
e0d32948bf62 added a message sent when the user clicks on a tweet.
hamidouk
parents: 246
diff changeset
   166
        var item = json.annotations[i];        
207
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   167
        var MyTime  = Math.floor(item.begin/duration*lineSize);
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   168
        var Myframe = Math.floor(MyTime/lineSize*frameLength);
169
427632a324d5 first import of the polemic tweet widget.
hamidouk
parents:
diff changeset
   169
207
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   170
        if (typeof(item.meta) !== "undefined" 
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   171
          && typeof(item.meta["id-ref"]) !== "undefined"
566
098929cd2d62 made the polemicwidget adjust its size automatically and fixed a couple edgecases.
hamidouk
parents: 565
diff changeset
   172
          && item.meta["id-ref"] === view_type) {
207
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   173
            
820
7968346b9689 Added compatibility with cinecast format (with get_aliased)
veltr
parents: 648
diff changeset
   174
            var MyTJson = {},
7968346b9689 Added compatibility with cinecast format (with get_aliased)
veltr
parents: 648
diff changeset
   175
                _source = IriSP.get_aliased(item.meta, ['dc:source', 'source']);
7968346b9689 Added compatibility with cinecast format (with get_aliased)
veltr
parents: 648
diff changeset
   176
            if (_source !== null) {
7968346b9689 Added compatibility with cinecast format (with get_aliased)
veltr
parents: 648
diff changeset
   177
              var MyTJson = JSON.parse(_source['content']);
566
098929cd2d62 made the polemicwidget adjust its size automatically and fixed a couple edgecases.
hamidouk
parents: 565
diff changeset
   178
            }
098929cd2d62 made the polemicwidget adjust its size automatically and fixed a couple edgecases.
hamidouk
parents: 565
diff changeset
   179
            
207
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   180
            if (item.content['polemics'] != undefined 
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   181
            && item.content['polemics'][0] != null) {
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   182
            
265
e0d32948bf62 added a message sent when the user clicks on a tweet.
hamidouk
parents: 246
diff changeset
   183
              // a tweet can have many polemics at the same time.
207
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   184
              for(var j=0; j<item.content['polemics'].length; j++){
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   185
                  
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   186
                  this.tweets[numberOfTweet] = {
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   187
                        id:i,
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   188
                        qualification:colorTranslation(item.content['polemics'][j]),
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   189
                        yIndicator:MyTime,
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   190
                        yframe:Myframe,
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   191
                        title:item.content['title'],
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   192
                        timeframe:item.begin,
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   193
                        userId: MyTJson.id,
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   194
                        userScreenName: MyTJson.screen_name,
265
e0d32948bf62 added a message sent when the user clicks on a tweet.
hamidouk
parents: 246
diff changeset
   195
                        tsource:MyTJson,
e0d32948bf62 added a message sent when the user clicks on a tweet.
hamidouk
parents: 246
diff changeset
   196
                        cinecast_id: item.id
207
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   197
                        };
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   198
                  numberOfTweet+=1;
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   199
                  
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   200
              }
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   201
          }
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   202
          else {
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   203
            this.tweets[numberOfTweet] = {
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   204
                  id:i,
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   205
                  qualification:colorTranslation(""),
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   206
                  yIndicator:MyTime,
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   207
                  yframe:Myframe,
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   208
                  title:item.content['title'],
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   209
                  timeframe:item.begin,
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   210
                  userId: MyTJson.id,
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   211
                  userScreenName: MyTJson.screen_name,
265
e0d32948bf62 added a message sent when the user clicks on a tweet.
hamidouk
parents: 246
diff changeset
   212
                  tsource:MyTJson,
e0d32948bf62 added a message sent when the user clicks on a tweet.
hamidouk
parents: 246
diff changeset
   213
                  cinecast_id: item.id
207
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   214
            };
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   215
            numberOfTweet+=1;
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   216
          }
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   217
          
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   218
        } 
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   219
      };  
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   220
      
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   221
       DrawTweets.call (this); // FIXME: ugly.
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   222
       
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   223
      };      
169
427632a324d5 first import of the polemic tweet widget.
hamidouk
parents:
diff changeset
   224
207
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   225
    // tweet Drawing (in raphael) 
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   226
    function DrawTweets (){
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   227
    // GROUPES TWEET ============================================
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   228
    // Count nbr of cluster and tweet in a frame an save int in "frames"
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   229
      numberOfTweet = this.tweets.length;
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   230
      for(var i=0; i<nbrframes; i++) {  
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   231
        for(var j=0; j<numberOfTweet; j++) {  
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   232
        
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   233
          if (i==this.tweets[j].yframe){
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   234
            
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   235
            var k = this.tweets[j].qualification;
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   236
            
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   237
            // make array for frame cluster
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   238
            if(frames[i]==undefined){
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   239
              frames[i] = {id:i,
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   240
                     qualifVol:new Array(),
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   241
                     mytweetsID:new Array()
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   242
                    };
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   243
            }
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   244
            // add my tweet to frame
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   245
            frames[i].mytweetsID.push(this.tweets[j]);
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   246
            
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   247
            // count opinion by frame
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   248
            if( frames[i].qualifVol[k] == undefined){
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   249
              frames[i].qualifVol[k] = 1;
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   250
            }else{
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   251
              frames[i].qualifVol[k] += 1;
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   252
            }
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   253
            
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   254
          }
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   255
        }
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   256
      }
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   257
    
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   258
    // GROUPES TWEET ============================================    
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   259
    // max of tweet by Frame 
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   260
      var max = 0; 
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   261
      for(var i = 0; i < nbrframes; i++) {
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   262
        var moy  = 0;
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   263
        for (var j = 0; j < 6; j++) {    
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   264
          if (frames[i] != undefined) {
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   265
            if (frames[i].qualifVol[j] != undefined) {
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   266
              moy += frames[i].qualifVol[j];
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   267
            }
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   268
          }
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   269
        }
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   270
        
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   271
        if (moy > max) {
176
c04283d7d1ef refactoring.
hamidouk
parents: 169
diff changeset
   272
          max = moy;
c04283d7d1ef refactoring.
hamidouk
parents: 169
diff changeset
   273
        }
207
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   274
      }
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   275
    
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   276
      var tweetDrawed = new Array();
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   277
      var TweetHeight = 5;
566
098929cd2d62 made the polemicwidget adjust its size automatically and fixed a couple edgecases.
hamidouk
parents: 565
diff changeset
   278
      var newHeight = TweetHeight * max + 10;
098929cd2d62 made the polemicwidget adjust its size automatically and fixed a couple edgecases.
hamidouk
parents: 565
diff changeset
   279
207
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   280
      
566
098929cd2d62 made the polemicwidget adjust its size automatically and fixed a couple edgecases.
hamidouk
parents: 565
diff changeset
   281
      if (newHeight > this.height) {
098929cd2d62 made the polemicwidget adjust its size automatically and fixed a couple edgecases.
hamidouk
parents: 565
diff changeset
   282
        this.paper.setSize(this.width, newHeight);
098929cd2d62 made the polemicwidget adjust its size automatically and fixed a couple edgecases.
hamidouk
parents: 565
diff changeset
   283
        this.height = newHeight;
098929cd2d62 made the polemicwidget adjust its size automatically and fixed a couple edgecases.
hamidouk
parents: 565
diff changeset
   284
        console.log("resizeing");
098929cd2d62 made the polemicwidget adjust its size automatically and fixed a couple edgecases.
hamidouk
parents: 565
diff changeset
   285
      }
098929cd2d62 made the polemicwidget adjust its size automatically and fixed a couple edgecases.
hamidouk
parents: 565
diff changeset
   286
      
098929cd2d62 made the polemicwidget adjust its size automatically and fixed a couple edgecases.
hamidouk
parents: 565
diff changeset
   287
  
207
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   288
      // DRAW  TWEETS ============================================
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   289
      for(var i = 0; i < nbrframes; i++) {
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   290
        var addEheight = 5;
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   291
        if (frames[i] != undefined){                
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   292
          // by type 
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   293
          
194
f5d86e5c4a56 some cleaning. Also added a progression indicator.
hamidouk
parents: 192
diff changeset
   294
          for (var j = 6; j > -1; j--) {
207
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   295
            if (frames[i].qualifVol[j] != undefined) {
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   296
              // show tweet by type 
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   297
              for (var k = 0; k < frames[i].mytweetsID.length; k++) {
194
f5d86e5c4a56 some cleaning. Also added a progression indicator.
hamidouk
parents: 192
diff changeset
   298
              
207
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   299
                if (frames[i].mytweetsID[k].qualification == j) {                
194
f5d86e5c4a56 some cleaning. Also added a progression indicator.
hamidouk
parents: 192
diff changeset
   300
                  var x = i * frameSize;
566
098929cd2d62 made the polemicwidget adjust its size automatically and fixed a couple edgecases.
hamidouk
parents: 565
diff changeset
   301
                  var y = this.height - addEheight;
194
f5d86e5c4a56 some cleaning. Also added a progression indicator.
hamidouk
parents: 192
diff changeset
   302
                  
207
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   303
                  if (this.yMax > y) {
176
c04283d7d1ef refactoring.
hamidouk
parents: 169
diff changeset
   304
                    this.yMax = y;
c04283d7d1ef refactoring.
hamidouk
parents: 169
diff changeset
   305
                  }
c04283d7d1ef refactoring.
hamidouk
parents: 169
diff changeset
   306
                  
567
ada550479aaf fixed search highlighting bug.
hamidouk
parents: 566
diff changeset
   307
                  /* some tweets seem to be duplicated - so we make a check before
ada550479aaf fixed search highlighting bug.
hamidouk
parents: 566
diff changeset
   308
                     creating a new rect */
ada550479aaf fixed search highlighting bug.
hamidouk
parents: 566
diff changeset
   309
                  if (this.svgElements.hasOwnProperty(frames[i].mytweetsID[k].cinecast_id))
ada550479aaf fixed search highlighting bug.
hamidouk
parents: 566
diff changeset
   310
                    continue;
ada550479aaf fixed search highlighting bug.
hamidouk
parents: 566
diff changeset
   311
                  
265
e0d32948bf62 added a message sent when the user clicks on a tweet.
hamidouk
parents: 246
diff changeset
   312
                  var e = this.paper.rect(x, y, frameSize - margin, TweetHeight /* height */)
e0d32948bf62 added a message sent when the user clicks on a tweet.
hamidouk
parents: 246
diff changeset
   313
                                    .attr({stroke:"#00","stroke-width":0.1,  fill: colors[j]});  
196
9fb4dcb0b878 "fixed" a test and added a new array to contain references to the raphael nodes we create.
hamidouk
parents: 195
diff changeset
   314
                  
207
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   315
                  addEheight += TweetHeight;
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   316
                  
648
431b3495f958 highlight a tweet if it corresponds to a hashtag link.
hamidouk
parents: 631
diff changeset
   317
                  /* stick a lot of things into e because that's the easiest way
431b3495f958 highlight a tweet if it corresponds to a hashtag link.
hamidouk
parents: 631
diff changeset
   318
                     to do it */
395
5766e8238aaf search in twitter feed now works.
hamidouk
parents: 379
diff changeset
   319
                  e.color = colors[j];
265
e0d32948bf62 added a message sent when the user clicks on a tweet.
hamidouk
parents: 246
diff changeset
   320
                  e.time = frames[i].mytweetsID[k].timeframe;
e0d32948bf62 added a message sent when the user clicks on a tweet.
hamidouk
parents: 246
diff changeset
   321
                  e.title = frames[i].mytweetsID[k].title;
e0d32948bf62 added a message sent when the user clicks on a tweet.
hamidouk
parents: 246
diff changeset
   322
                  e.id = frames[i].mytweetsID[k].cinecast_id;
395
5766e8238aaf search in twitter feed now works.
hamidouk
parents: 379
diff changeset
   323
                  this.svgElements[e.id] = e;
477
1e51d638e7ea fixes in a rush.
hamidouk
parents: 443
diff changeset
   324
                  
830
18ca612e9ff0 Lots of changes
veltr
parents: 827
diff changeset
   325
                  IriSP.jQuery(e.node).mouseenter(function(element) { return function (_e) {                    
827
1dc2f85c3b89 BUGFIX: Tooltips are now positioned relative to their parent widget.
veltr
parents: 820
diff changeset
   326
                        self.TooltipWidget.show.call(self.TooltipWidget, element.title, element.attr("fill"), element.attrs.x + element.attrs.width / 2, element.attrs.y - 2);
477
1e51d638e7ea fixes in a rush.
hamidouk
parents: 443
diff changeset
   327
                        element.displayed = true;
830
18ca612e9ff0 Lots of changes
veltr
parents: 827
diff changeset
   328
                        self._Popcorn.trigger("IriSP.TraceWidget.MouseEvents", {
18ca612e9ff0 Lots of changes
veltr
parents: 827
diff changeset
   329
                            "widget" : "StackGraphWidget",
18ca612e9ff0 Lots of changes
veltr
parents: 827
diff changeset
   330
                            "type": "mousemove",
18ca612e9ff0 Lots of changes
veltr
parents: 827
diff changeset
   331
                            "x": _e.pageX,
18ca612e9ff0 Lots of changes
veltr
parents: 827
diff changeset
   332
                            "y": _e.pageY,
18ca612e9ff0 Lots of changes
veltr
parents: 827
diff changeset
   333
                            "annotation_id": element.id
18ca612e9ff0 Lots of changes
veltr
parents: 827
diff changeset
   334
                        });
490
2a7fca4f0cc4 fixed stupid bug which disabled seeking when clicking on a tweet.
hamidouk
parents: 485
diff changeset
   335
                  }}(e)).mousedown(function(element) { return function () {                    
2a7fca4f0cc4 fixed stupid bug which disabled seeking when clicking on a tweet.
hamidouk
parents: 485
diff changeset
   336
                    self._Popcorn.currentTime(element.time/1000);
2a7fca4f0cc4 fixed stupid bug which disabled seeking when clicking on a tweet.
hamidouk
parents: 485
diff changeset
   337
                    self._Popcorn.trigger("IriSP.PolemicTweet.click", element.id); 
2a7fca4f0cc4 fixed stupid bug which disabled seeking when clicking on a tweet.
hamidouk
parents: 485
diff changeset
   338
                    }
2a7fca4f0cc4 fixed stupid bug which disabled seeking when clicking on a tweet.
hamidouk
parents: 485
diff changeset
   339
                  }(e));                  
207
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   340
                  
194
f5d86e5c4a56 some cleaning. Also added a progression indicator.
hamidouk
parents: 192
diff changeset
   341
                  IriSP.jQuery(e.node).attr('id', 't' + k + '');
207
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   342
                  IriSP.jQuery(e.node).attr('title', frames[i].mytweetsID[k].title);
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   343
                  IriSP.jQuery(e.node).attr('begin',  frames[i].mytweetsID[k].timeframe);                  
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   344
                }
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   345
              }
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   346
            }
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   347
          }
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   348
        }
169
427632a324d5 first import of the polemic tweet widget.
hamidouk
parents:
diff changeset
   349
207
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   350
      }    
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   351
      // DRAW UI :: resize border and bgd      
566
098929cd2d62 made the polemicwidget adjust its size automatically and fixed a couple edgecases.
hamidouk
parents: 565
diff changeset
   352
      this.paperBackground = this.paper.rect(0, 0, this.width, this.height).attr({fill:"#F8F8F8","stroke-width":0.1,opacity: 1});  
357
6edf399cfa26 the polemicWidget now draws correctly borders around itself.
hamidouk
parents: 265
diff changeset
   353
6edf399cfa26 the polemicWidget now draws correctly borders around itself.
hamidouk
parents: 265
diff changeset
   354
      // outer borders
6edf399cfa26 the polemicWidget now draws correctly borders around itself.
hamidouk
parents: 265
diff changeset
   355
      this.outerBorders   = [];
6edf399cfa26 the polemicWidget now draws correctly borders around itself.
hamidouk
parents: 265
diff changeset
   356
      this.outerBorders.push(this.paper.rect(0, this.height - 1, this.width, 1).attr({fill:"#ababab",stroke: "none",opacity: 1}));  
6edf399cfa26 the polemicWidget now draws correctly borders around itself.
hamidouk
parents: 265
diff changeset
   357
      this.outerBorders.push(this.paper.rect(0, 0, this.width, 1).attr({fill:"#ababab",stroke: "none",opacity: 1}));  
6edf399cfa26 the polemicWidget now draws correctly borders around itself.
hamidouk
parents: 265
diff changeset
   358
6edf399cfa26 the polemicWidget now draws correctly borders around itself.
hamidouk
parents: 265
diff changeset
   359
      // inner borders
6edf399cfa26 the polemicWidget now draws correctly borders around itself.
hamidouk
parents: 265
diff changeset
   360
      this.innerBorders   = [];
6edf399cfa26 the polemicWidget now draws correctly borders around itself.
hamidouk
parents: 265
diff changeset
   361
      this.innerBorders.push(this.paper.rect(1, this.height - 2, this.width, 1).attr({fill:"#efefef",stroke: "none",opacity: 1}));  
6edf399cfa26 the polemicWidget now draws correctly borders around itself.
hamidouk
parents: 265
diff changeset
   362
      this.innerBorders.push(this.paper.rect(1, 1, this.width, 1).attr({fill:"#efefef",stroke: "none",opacity: 1}));  
6edf399cfa26 the polemicWidget now draws correctly borders around itself.
hamidouk
parents: 265
diff changeset
   363
      this.innerBorders.push(this.paper.rect(1, 1, 1, this.height - 2).attr({fill:"#d0d1d1",stroke: "none",opacity: 0.8}));  
6edf399cfa26 the polemicWidget now draws correctly borders around itself.
hamidouk
parents: 265
diff changeset
   364
      this.innerBorders.push(this.paper.rect(this.width - 2, 1, 1, this.height - 2).attr({fill:"#efefef",stroke: "none",opacity: 1}));  
6edf399cfa26 the polemicWidget now draws correctly borders around itself.
hamidouk
parents: 265
diff changeset
   365
6edf399cfa26 the polemicWidget now draws correctly borders around itself.
hamidouk
parents: 265
diff changeset
   366
6edf399cfa26 the polemicWidget now draws correctly borders around itself.
hamidouk
parents: 265
diff changeset
   367
566
098929cd2d62 made the polemicwidget adjust its size automatically and fixed a couple edgecases.
hamidouk
parents: 565
diff changeset
   368
      this.paperSlider   = this.paper.rect(0, 0, 0, this.height).attr({fill:"#D4D5D5", stroke: "none", opacity: 1});
197
a793a8a0c9d2 added a rectangle tip to show where we are in the video .
hamidouk
parents: 196
diff changeset
   369
      
a793a8a0c9d2 added a rectangle tip to show where we are in the video .
hamidouk
parents: 196
diff changeset
   370
      // the small white line displayed over the slider.
566
098929cd2d62 made the polemicwidget adjust its size automatically and fixed a couple edgecases.
hamidouk
parents: 565
diff changeset
   371
      this.sliderTip = this.paper.rect(0, 0, 1, this.height).attr({fill:"#fc00ff", stroke: "none", opacity: 1});
207
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   372
      // decalage 
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   373
      // tweetSelection = this.paper.rect(-100,-100,5,5).attr({fill:"#fff",stroke: "none",opacity: 1});  
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   374
      
196
9fb4dcb0b878 "fixed" a test and added a new array to contain references to the raphael nodes we create.
hamidouk
parents: 195
diff changeset
   375
      
207
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   376
      this.paperSlider.toBack();
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   377
      this.paperBackground.toBack();
197
a793a8a0c9d2 added a rectangle tip to show where we are in the video .
hamidouk
parents: 196
diff changeset
   378
      this.sliderTip.toFront();
207
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   379
    }
194
f5d86e5c4a56 some cleaning. Also added a progression indicator.
hamidouk
parents: 192
diff changeset
   380
    
624
177dfeacc7a6 made the polemicwidget not show itself if it has no data to display.
hamidouk
parents: 595
diff changeset
   381
194
f5d86e5c4a56 some cleaning. Also added a progression indicator.
hamidouk
parents: 192
diff changeset
   382
}
f5d86e5c4a56 some cleaning. Also added a progression indicator.
hamidouk
parents: 192
diff changeset
   383
528
a5894f09825a added docs.
hamidouk
parents: 490
diff changeset
   384
/** update the positionMarker as time passes */
194
f5d86e5c4a56 some cleaning. Also added a progression indicator.
hamidouk
parents: 192
diff changeset
   385
IriSP.PolemicWidget.prototype.sliderUpdater = function() {
169
427632a324d5 first import of the polemic tweet widget.
hamidouk
parents:
diff changeset
   386
194
f5d86e5c4a56 some cleaning. Also added a progression indicator.
hamidouk
parents: 192
diff changeset
   387
    var time = +this._Popcorn.currentTime();
842
4ae2247a59f4 Changes for Cinecast
veltr
parents: 830
diff changeset
   388
    var duration = this.getDuration();
194
f5d86e5c4a56 some cleaning. Also added a progression indicator.
hamidouk
parents: 192
diff changeset
   389
    
f5d86e5c4a56 some cleaning. Also added a progression indicator.
hamidouk
parents: 192
diff changeset
   390
    this.paperSlider.attr("width", time * (this.width / (duration / 1000)));
197
a793a8a0c9d2 added a rectangle tip to show where we are in the video .
hamidouk
parents: 196
diff changeset
   391
        
a793a8a0c9d2 added a rectangle tip to show where we are in the video .
hamidouk
parents: 196
diff changeset
   392
    this.sliderTip.attr("x", time * (this.width / (duration / 1000)));
194
f5d86e5c4a56 some cleaning. Also added a progression indicator.
hamidouk
parents: 192
diff changeset
   393
};
528
a5894f09825a added docs.
hamidouk
parents: 490
diff changeset
   394
a5894f09825a added docs.
hamidouk
parents: 490
diff changeset
   395
/** reacts to IriSP.search events */    
395
5766e8238aaf search in twitter feed now works.
hamidouk
parents: 379
diff changeset
   396
IriSP.PolemicWidget.prototype.searchHandler = function(searchString) {
5766e8238aaf search in twitter feed now works.
hamidouk
parents: 379
diff changeset
   397
  if (searchString == "")
5766e8238aaf search in twitter feed now works.
hamidouk
parents: 379
diff changeset
   398
    return;
5766e8238aaf search in twitter feed now works.
hamidouk
parents: 379
diff changeset
   399
5766e8238aaf search in twitter feed now works.
hamidouk
parents: 379
diff changeset
   400
  var matches = this._serializer.searchTweetsOccurences(searchString);
5766e8238aaf search in twitter feed now works.
hamidouk
parents: 379
diff changeset
   401
5766e8238aaf search in twitter feed now works.
hamidouk
parents: 379
diff changeset
   402
  if (IriSP.countProperties(matches) > 0) {
398
d1883378b822 renamed search signal.
hamidouk
parents: 395
diff changeset
   403
    this._Popcorn.trigger("IriSP.search.matchFound");
395
5766e8238aaf search in twitter feed now works.
hamidouk
parents: 379
diff changeset
   404
  } else {
398
d1883378b822 renamed search signal.
hamidouk
parents: 395
diff changeset
   405
    this._Popcorn.trigger("IriSP.search.noMatchFound");
395
5766e8238aaf search in twitter feed now works.
hamidouk
parents: 379
diff changeset
   406
  }
5766e8238aaf search in twitter feed now works.
hamidouk
parents: 379
diff changeset
   407
565
903435828e6c WIP - reducing the opacity of the rectanges which are not search results.
hamidouk
parents: 528
diff changeset
   408
  
903435828e6c WIP - reducing the opacity of the rectanges which are not search results.
hamidouk
parents: 528
diff changeset
   409
  // decrease the opacity of the other elements.
903435828e6c WIP - reducing the opacity of the rectanges which are not search results.
hamidouk
parents: 528
diff changeset
   410
  for (var id in this.svgElements) {
903435828e6c WIP - reducing the opacity of the rectanges which are not search results.
hamidouk
parents: 528
diff changeset
   411
    var e = this.svgElements[id];
567
ada550479aaf fixed search highlighting bug.
hamidouk
parents: 566
diff changeset
   412
    e.attr({fill: e.color, opacity: 0.4});   
565
903435828e6c WIP - reducing the opacity of the rectanges which are not search results.
hamidouk
parents: 528
diff changeset
   413
  }
903435828e6c WIP - reducing the opacity of the rectanges which are not search results.
hamidouk
parents: 528
diff changeset
   414
  
566
098929cd2d62 made the polemicwidget adjust its size automatically and fixed a couple edgecases.
hamidouk
parents: 565
diff changeset
   415
098929cd2d62 made the polemicwidget adjust its size automatically and fixed a couple edgecases.
hamidouk
parents: 565
diff changeset
   416
  for (var id in matches) {    
395
5766e8238aaf search in twitter feed now works.
hamidouk
parents: 379
diff changeset
   417
    if (this.svgElements.hasOwnProperty(id)) {
443
7612eced3867 removed unused variable.
hamidouk
parents: 398
diff changeset
   418
      var e = this.svgElements[id];
565
903435828e6c WIP - reducing the opacity of the rectanges which are not search results.
hamidouk
parents: 528
diff changeset
   419
      this.svgElements[id].attr({fill: "#fc00ff", opacity: 1});
395
5766e8238aaf search in twitter feed now works.
hamidouk
parents: 379
diff changeset
   420
    }
5766e8238aaf search in twitter feed now works.
hamidouk
parents: 379
diff changeset
   421
  }
5766e8238aaf search in twitter feed now works.
hamidouk
parents: 379
diff changeset
   422
5766e8238aaf search in twitter feed now works.
hamidouk
parents: 379
diff changeset
   423
  this.oldSearchMatches = matches;
5766e8238aaf search in twitter feed now works.
hamidouk
parents: 379
diff changeset
   424
};
5766e8238aaf search in twitter feed now works.
hamidouk
parents: 379
diff changeset
   425
528
a5894f09825a added docs.
hamidouk
parents: 490
diff changeset
   426
/** reacts to IriSP.search.cleared messages */
395
5766e8238aaf search in twitter feed now works.
hamidouk
parents: 379
diff changeset
   427
IriSP.PolemicWidget.prototype.searchFieldClearedHandler = function() {
565
903435828e6c WIP - reducing the opacity of the rectanges which are not search results.
hamidouk
parents: 528
diff changeset
   428
  for (var id in this.svgElements) {
903435828e6c WIP - reducing the opacity of the rectanges which are not search results.
hamidouk
parents: 528
diff changeset
   429
    var e = this.svgElements[id];
903435828e6c WIP - reducing the opacity of the rectanges which are not search results.
hamidouk
parents: 528
diff changeset
   430
    e.attr({fill: e.color, opacity: 1});
395
5766e8238aaf search in twitter feed now works.
hamidouk
parents: 379
diff changeset
   431
  }
5766e8238aaf search in twitter feed now works.
hamidouk
parents: 379
diff changeset
   432
};
5766e8238aaf search in twitter feed now works.
hamidouk
parents: 379
diff changeset
   433
528
a5894f09825a added docs.
hamidouk
parents: 490
diff changeset
   434
/** reacts to IriSP.search.closed messages by clearing the highlighted elements */
395
5766e8238aaf search in twitter feed now works.
hamidouk
parents: 379
diff changeset
   435
IriSP.PolemicWidget.prototype.searchFieldClosedHandler = function() {
565
903435828e6c WIP - reducing the opacity of the rectanges which are not search results.
hamidouk
parents: 528
diff changeset
   436
  for (var id in this.svgElements) {
903435828e6c WIP - reducing the opacity of the rectanges which are not search results.
hamidouk
parents: 528
diff changeset
   437
    var e = this.svgElements[id];
903435828e6c WIP - reducing the opacity of the rectanges which are not search results.
hamidouk
parents: 528
diff changeset
   438
    e.attr({fill: e.color, opacity: 1});
395
5766e8238aaf search in twitter feed now works.
hamidouk
parents: 379
diff changeset
   439
  }
5766e8238aaf search in twitter feed now works.
hamidouk
parents: 379
diff changeset
   440
 
5766e8238aaf search in twitter feed now works.
hamidouk
parents: 379
diff changeset
   441
};
5766e8238aaf search in twitter feed now works.
hamidouk
parents: 379
diff changeset
   442
   
648
431b3495f958 highlight a tweet if it corresponds to a hashtag link.
hamidouk
parents: 631
diff changeset
   443
IriSP.PolemicWidget.prototype.showAnnotation = function(id) {
431b3495f958 highlight a tweet if it corresponds to a hashtag link.
hamidouk
parents: 631
diff changeset
   444
  if (this.svgElements.hasOwnProperty(id)) {
431b3495f958 highlight a tweet if it corresponds to a hashtag link.
hamidouk
parents: 631
diff changeset
   445
    var e = this.svgElements[id];
431b3495f958 highlight a tweet if it corresponds to a hashtag link.
hamidouk
parents: 631
diff changeset
   446
    this.TooltipWidget.show(e.title, e.attr("fill"), e.x - 103, e.y - 160);
431b3495f958 highlight a tweet if it corresponds to a hashtag link.
hamidouk
parents: 631
diff changeset
   447
  }
431b3495f958 highlight a tweet if it corresponds to a hashtag link.
hamidouk
parents: 631
diff changeset
   448
};