src/js/widgets/polemicWidget.js
author hamidouk
Mon, 14 Nov 2011 17:19:26 +0100
branchrequire-js
changeset 238 6008172a0592
parent 231 accc7358d8b5
permissions -rw-r--r--
converted all the source files to use the require.js syntax.
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
238
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    21
define(["IriSP", "widgets", "util", "tooltipWidget"], function() {
169
427632a324d5 first import of the polemic tweet widget.
hamidouk
parents:
diff changeset
    22
238
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    23
  IriSP.PolemicWidget = function(Popcorn, config, Serializer) {
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    24
    IriSP.Widget.call(this, Popcorn, config, Serializer);
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    25
   
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    26
    this.userPol    = new Array();
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    27
    this.userNoPol  = new Array();
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    28
    this.userst      = new Array();
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    29
    this.numberOfTweet = 0;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    30
    this.Users;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    31
    this.TweetPolemic;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    32
    this.yMax        = this.height; 
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    33
    this.PaperSlider;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    34
    this.heightOfChart;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    35
    this.tweets  = new Array();
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    36
    this.svgElements = new Array();
176
c04283d7d1ef refactoring.
hamidouk
parents: 169
diff changeset
    37
    
238
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    38
    // Make and define the Raphael area
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    39
    this.paper = Raphael(document.getElementById(this._id), config.width, config.height);
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    40
    
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    41
  };
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    42
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    43
  IriSP.PolemicWidget.prototype = new IriSP.Widget();
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    44
    
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    45
  IriSP.PolemicWidget.prototype.draw = function() {
207
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    46
    
238
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    47
      // variable 
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    48
      // yMax
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    49
      
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    50
      var self = this;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    51
      var yCoef        = 2;             // coef for height of 1 tweet 
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    52
      var frameSize     = 5;             // frame size 
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    53
      var margin         = 1;            // marge between frame
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    54
      var lineSize      = this.width;        // timeline pixel width 
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    55
      var nbrframes     = lineSize/frameSize;     // frame numbers
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    56
      var numberOfTweet   = 0;            // number of tweet overide later 
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    57
      var duration      = +this._serializer.currentMedia().meta["dc:duration"];      // timescale width 
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    58
      var frameLength   = lineSize / frameSize;    // frame timescale  
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    59
      var timeline;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    60
      var colors  = new Array("","#1D973D","#C5A62D","#CE0A15","#036AAE","#585858");
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    61
      
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    62
      // array 
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    63
      //var tweets  = new Array();
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    64
      var element = new Array();
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    65
      var cluster = new Array();
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    66
      var frames  = new Array(frameLength);
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    67
      var slices  = new Array();
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    68
      
207
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
    69
      
238
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    70
      // Classes =======================================================================
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    71
      var Frames = function(){
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    72
        
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    73
        var Myclusters;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    74
        var x;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    75
        var y;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    76
        var width;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    77
        var height;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    78
      };
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    79
      Frames = function(json){
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    80
        // make my clusters
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    81
        // ou Frame vide 
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    82
      };
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    83
      Frames.prototype.draw = function(){
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    84
      };
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    85
      Frames.prototype.zoom = function(){
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    86
      };
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    87
      Frames.prototype.inside = function(){
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    88
      };
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    89
      var Clusters = function(){
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    90
        var Object;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    91
        var yDist;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    92
        var x;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    93
        var y;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    94
        var width;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    95
        var height;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    96
      };
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    97
      Clusters = function(json){
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    98
        // make my object
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
    99
      };
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   100
      var Tweet = function(){
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   101
      };
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   102
      // Classes =======================================================================
187
6f1def85018a removed useless printfs.
hamidouk
parents: 176
diff changeset
   103
238
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   104
      // Refactoring (parametere) ************************************************************
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   105
      // color translastion
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   106
      var qTweet_0  =0;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   107
      var qTweet_Q  =0;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   108
      var qTweet_REF=0;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   109
      var qTweet_OK =0;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   110
      var qTweet_KO =0;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   111
      function colorTranslation(value){
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   112
        if(value == "Q"){
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   113
          qTweet_Q+=1;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   114
          return 2;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   115
        }else if(value =="REF"){
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   116
          qTweet_REF+=1;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   117
          return 4;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   118
        }else if(value =="OK"){
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   119
          qTweet_OK+=1;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   120
          return 1;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   121
        }else if(value =="KO"){
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   122
          qTweet_KO+=1;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   123
          return 3;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   124
        }else if(value ==""){
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   125
          qTweet_0+=1;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   126
          return 5;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   127
        }
207
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   128
      }
238
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   129
      
169
427632a324d5 first import of the polemic tweet widget.
hamidouk
parents:
diff changeset
   130
238
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   131
        this._serializer.sync(function(data) { loaded_callback.call(self, data) });
207
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   132
        
238
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   133
        function loaded_callback (json) {
169
427632a324d5 first import of the polemic tweet widget.
hamidouk
parents:
diff changeset
   134
238
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   135
          // get current view (the first ???)
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   136
          view = json.views[0];
207
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   137
          
238
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   138
          // the tweets are by definition of the second annotation type FIXME ?
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   139
          tweet_annot_type = null;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   140
          if(typeof(view.annotation_types) !== "undefined" && view.annotation_types.length > 1) {
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   141
            tweet_annot_type = view.annotation_types[1];
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   142
          }
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   143
        
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   144
        for(var i = 0; i < json.annotations.length; i++) {
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   145
          var item = json.annotations[i];              
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   146
          var MyTime  = Math.floor(item.begin/duration*lineSize);
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   147
          var Myframe = Math.floor(MyTime/lineSize*frameLength);
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   148
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   149
          if (typeof(item.meta) !== "undefined" 
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   150
            && typeof(item.meta["id-ref"]) !== "undefined"
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   151
            && item.meta["id-ref"] === tweet_annot_type) {
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   152
              
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   153
            var MyTJson = JSON.parse(item.meta['dc:source']['content']);
207
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   154
            
238
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   155
              if (item.content['polemics'] != undefined 
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   156
              && item.content['polemics'][0] != null) {
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   157
              
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   158
              
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   159
                for(var j=0; j<item.content['polemics'].length; j++){
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   160
                    
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   161
                    this.tweets[numberOfTweet] = {
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   162
                          id:i,
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   163
                          qualification:colorTranslation(item.content['polemics'][j]),
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   164
                          yIndicator:MyTime,
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   165
                          yframe:Myframe,
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   166
                          title:item.content['title'],
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   167
                          timeframe:item.begin,
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   168
                          userId: MyTJson.id,
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   169
                          userScreenName: MyTJson.screen_name,
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   170
                          tsource:MyTJson
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   171
                          };
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   172
                    numberOfTweet+=1;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   173
                    
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   174
                }
207
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   175
            }
238
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   176
            else {
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   177
              this.tweets[numberOfTweet] = {
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   178
                    id:i,
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   179
                    qualification:colorTranslation(""),
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   180
                    yIndicator:MyTime,
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   181
                    yframe:Myframe,
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   182
                    title:item.content['title'],
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   183
                    timeframe:item.begin,
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   184
                    userId: MyTJson.id,
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   185
                    userScreenName: MyTJson.screen_name,
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   186
                    tsource:MyTJson
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   187
                    
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   188
              };
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   189
              numberOfTweet+=1;
207
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   190
            }
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   191
            
238
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   192
          } 
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   193
        };  
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   194
        
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   195
         DrawTweets.call (this); // FIXME: ugly.
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   196
         
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   197
        };      
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   198
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   199
      // tweet Drawing (in raphael) 
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   200
      function DrawTweets (){
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   201
      // GROUPES TWEET ============================================
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   202
      // Count nbr of cluster and tweet in a frame an save int in "frames"
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   203
        numberOfTweet = this.tweets.length;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   204
        for(var i=0; i<nbrframes; i++) {  
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   205
          for(var j=0; j<numberOfTweet; j++) {  
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   206
          
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   207
            if (i==this.tweets[j].yframe){
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   208
              
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   209
              var k = this.tweets[j].qualification;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   210
              
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   211
              // make array for frame cluster
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   212
              if(frames[i]==undefined){
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   213
                frames[i] = {id:i,
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   214
                       qualifVol:new Array(),
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   215
                       mytweetsID:new Array()
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   216
                      };
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   217
              }
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   218
              // add my tweet to frame
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   219
              frames[i].mytweetsID.push(this.tweets[j]);
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   220
              
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   221
              // count opinion by frame
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   222
              if( frames[i].qualifVol[k] == undefined){
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   223
                frames[i].qualifVol[k] = 1;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   224
              }else{
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   225
                frames[i].qualifVol[k] += 1;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   226
              }
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   227
              
207
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   228
            }
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   229
          }
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   230
        }
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   231
      
238
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   232
      // GROUPES TWEET ============================================    
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   233
      // max of tweet by Frame 
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   234
        var max = 0; 
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   235
        for(var i = 0; i < nbrframes; i++) {
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   236
          var moy  = 0;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   237
          for (var j = 0; j < 6; j++) {    
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   238
            if (frames[i] != undefined) {
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   239
              if (frames[i].qualifVol[j] != undefined) {
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   240
                moy += frames[i].qualifVol[j];
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   241
              }
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   242
            }
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   243
          }
207
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   244
          
238
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   245
          if (moy > max) {
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   246
            max = moy;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   247
          }
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   248
        }
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   249
      
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   250
        var tweetDrawed = new Array();
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   251
        var TweetHeight = 5;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   252
        
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   253
        // DRAW  TWEETS ============================================
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   254
        for(var i = 0; i < nbrframes; i++) {
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   255
          var addEheight = 5;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   256
          if (frames[i] != undefined){                
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   257
            // by type 
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   258
            
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   259
            for (var j = 6; j > -1; j--) {
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   260
              if (frames[i].qualifVol[j] != undefined) {
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   261
                // show tweet by type 
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   262
                for (var k = 0; k < frames[i].mytweetsID.length; k++) {
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   263
                
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   264
                  if (frames[i].mytweetsID[k].qualification == j) {                
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   265
                    var x = i * frameSize;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   266
                    var y = this.heightmax - addEheight;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   267
                    
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   268
                    if (this.yMax > y) {
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   269
                      this.yMax = y;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   270
                    }
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   271
                    
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   272
                    var e = this.paper.rect(x, y, frameSize - margin, TweetHeight /* height */).attr({stroke:"#00","stroke-width":0.1,  fill: colors[j]});  
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   273
                    this.svgElements.push(e);
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   274
                    
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   275
                    addEheight += TweetHeight;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   276
                    
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   277
                    e.time= frames[i].mytweetsID[k].timeframe;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   278
                    e.title= frames[i].mytweetsID[k].title;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   279
                    
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   280
                    e.mouseover(function(element) { return function (event) {
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   281
                          // event.clientX and event.clientY are to raphael what event.pageX and pageY are to jquery.                        
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   282
                          self.TooltipWidget.show.call(self.TooltipWidget, element.title, element.attr("fill"), event.clientX - 106, event.clientY - 160);
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   283
                          element.displayed = true;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   284
                          debugger;
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   285
                    }}(e)).mouseout(function(element) { return function () {                          
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   286
                            self.TooltipWidget.hide.call(self.TooltipWidget);
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   287
                    }}(e)).mousedown(function () {
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   288
                      self._Popcorn.currentTime(this.time/1000);
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   289
                    });
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   290
                    
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   291
                    IriSP.jQuery(e.node).attr('id', 't' + k + '');
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   292
                    IriSP.jQuery(e.node).attr('title', frames[i].mytweetsID[k].title);
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   293
                    IriSP.jQuery(e.node).attr('begin',  frames[i].mytweetsID[k].timeframe);                  
176
c04283d7d1ef refactoring.
hamidouk
parents: 169
diff changeset
   294
                  }
207
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   295
                }
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   296
              }
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   297
            }
2bc276f0c1ae converted tabs to spaces.
hamidouk
parents: 203
diff changeset
   298
          }
169
427632a324d5 first import of the polemic tweet widget.
hamidouk
parents:
diff changeset
   299
238
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   300
        }    
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   301
        // DRAW UI :: resize border and bgd      
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   302
        this.paperBackground = this.paper.rect(0, 0, this.width, this.heightmax).attr({fill:"#F8F8F8","stroke-width":0.1,opacity: 1});  
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   303
        // var PaperBorder   = this.paper.rect(0, this.yMax,this.width,1).attr({fill:"#fff",stroke: "none",opacity: 1});  
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   304
        
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   305
        this.paperSlider   = this.paper.rect(0, 0, 0, this.heightmax).attr({fill:"#D4D5D5", stroke: "none", opacity: 1});
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   306
        
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   307
        // the small white line displayed over the slider.
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   308
        this.sliderTip = this.paper.rect(0, 0, 1, this.heightmax).attr({fill:"#fc00ff", stroke: "none", opacity: 1});
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   309
        
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   310
        // decalage 
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   311
        // tweetSelection = this.paper.rect(-100,-100,5,5).attr({fill:"#fff",stroke: "none",opacity: 1});  
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   312
        
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   313
        
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   314
        this.paperSlider.toBack();
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   315
        this.paperBackground.toBack();
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   316
        this.sliderTip.toFront();
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   317
      }
196
9fb4dcb0b878 "fixed" a test and added a new array to contain references to the raphael nodes we create.
hamidouk
parents: 195
diff changeset
   318
      
238
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   319
      this._Popcorn.listen("timeupdate", IriSP.wrap(this, this.sliderUpdater));
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   320
  }
194
f5d86e5c4a56 some cleaning. Also added a progression indicator.
hamidouk
parents: 192
diff changeset
   321
238
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   322
  IriSP.PolemicWidget.prototype.sliderUpdater = function() {
169
427632a324d5 first import of the polemic tweet widget.
hamidouk
parents:
diff changeset
   323
238
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   324
      var time = +this._Popcorn.currentTime();
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   325
      var duration = +this._serializer.currentMedia().meta["dc:duration"];
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   326
      
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   327
      this.paperSlider.attr("width", time * (this.width / (duration / 1000)));
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   328
          
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   329
      this.sliderTip.attr("x", time * (this.width / (duration / 1000)));
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   330
  };
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   331
});
6008172a0592 converted all the source files to use the require.js syntax.
hamidouk
parents: 231
diff changeset
   332