src/js/widgets/polemicViewer.js
author hamidouk
Mon, 05 Dec 2011 15:53:49 +0100
branchcap-demo
changeset 410 de8fdd68930f
parent 400 58ade3113a02
child 413 49be79683472
permissions -rw-r--r--
display the text as well as the description in the tooltip.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
400
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
     1
/* 
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
     2
 *   
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
     3
 *  Copyright 2010 Institut de recherche et d'innovation 
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
     4
 *  contributor(s) : Samuel Huron 
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
     5
 *   
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
     6
 *  contact@iri.centrepompidou.fr
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
     7
 *  http://www.iri.centrepompidou.fr 
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
     8
 *   
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
     9
 *  This software is a computer program whose purpose is to show and add annotations on a video .
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    10
 *  This software is governed by the CeCILL-C license under French law and
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    11
 *  abiding by the rules of distribution of free software. You can  use, 
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    12
 *  modify and/ or redistribute the software under the terms of the CeCILL-C
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    13
 *  license as circulated by CEA, CNRS and INRIA at the following URL
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    14
 *  "http://www.cecill.info". 
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    15
 *  
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    16
 *  The fact that you are presently reading this means that you have had
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    17
 *  knowledge of the CeCILL-C license and that you accept its terms.
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    18
*/
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    19
// CHART TIMELINE / VERSION PROTOTYPE  ::
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    20
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    21
IriSP.PolemicViewer = function(Popcorn, config, Serializer) {
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    22
  IriSP.Widget.call(this, Popcorn, config, Serializer);
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    23
 
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    24
  this.userPol    = new Array();
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    25
  this.userNoPol  = new Array();
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    26
  this.userst      = new Array();
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    27
  this.numberOfTweet = 0;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    28
  this.Users;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    29
  this.TweetPolemic;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    30
  this.yMax        = this.height; 
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    31
  this.PaperSlider;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    32
  this.heightOfChart;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    33
  this.tweets  = new Array();
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    34
  this.svgElements = {};
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    35
  
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    36
  // Make and define the Raphael area
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    37
  this.paper = Raphael(document.getElementById(this._id), config.width, config.height);
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    38
  
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    39
  this.oldSearchMatches = [];
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    40
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    41
  // event handlers
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    42
  this._Popcorn.listen("IriSP.search", IriSP.wrap(this, function(searchString) { this.searchHandler(searchString); }));
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    43
  this._Popcorn.listen("IriSP.search.closed", IriSP.wrap(this, this.searchFieldClosedHandler));
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    44
  this._Popcorn.listen("IriSP.search.cleared", IriSP.wrap(this, this.searchFieldClearedHandler));
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    45
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    46
};
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    47
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    48
IriSP.PolemicViewer.prototype = new IriSP.Widget();
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    49
  
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    50
IriSP.PolemicViewer.prototype.draw = function() {
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    51
  
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    52
    // variable 
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    53
    // yMax
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    54
    
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    55
    var self = this;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    56
    var yCoef        = 2;             // coef for height of 1 tweet 
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    57
    var frameSize     = 5;             // frame size 
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    58
    var margin         = 1;            // marge between frame
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    59
    var lineSize      = this.width;        // timeline pixel width 
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    60
    var nbrframes     = lineSize/frameSize;     // frame numbers
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    61
    var numberOfTweet   = 0;            // number of tweet overide later 
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    62
    var duration      = +this._serializer.currentMedia().meta["dc:duration"];      // timescale width 
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    63
    var frameLength   = lineSize / frameSize;    // frame timescale  
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    64
    var timeline;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    65
    var colors  = new Array("","#1D973D","#C5A62D","#CE0A15","#036AAE","#585858");
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    66
    
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    67
    // array 
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    68
    //var tweets  = new Array();
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    69
    var element = new Array();
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    70
    var cluster = new Array();
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    71
    var frames  = new Array(frameLength);
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    72
    var slices  = new Array();
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    73
    
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    74
    
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    75
    // Classes =======================================================================
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    76
    var Frames = function(){
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    77
      
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    78
      var Myclusters;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    79
      var x;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    80
      var y;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    81
      var width;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    82
      var height;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    83
    };
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    84
    Frames = function(json){
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    85
      // make my clusters
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    86
      // ou Frame vide 
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    87
    };
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    88
    Frames.prototype.draw = function(){
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    89
    };
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    90
    Frames.prototype.zoom = function(){
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    91
    };
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    92
    Frames.prototype.inside = function(){
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    93
    };
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    94
    var Clusters = function(){
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    95
      var Object;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    96
      var yDist;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    97
      var x;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    98
      var y;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
    99
      var width;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   100
      var height;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   101
    };
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   102
    Clusters = function(json){
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   103
      // make my object
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   104
    };
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   105
    var Tweet = function(){
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   106
    };
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   107
    // Classes =======================================================================
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   108
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   109
    // Refactoring (parametere) ************************************************************
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   110
    // color translastion
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   111
    var qTweet_0  =0;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   112
    var qTweet_Q  =0;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   113
    var qTweet_REF=0;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   114
    var qTweet_OK =0;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   115
    var qTweet_KO =0;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   116
    function colorTranslation(value){
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   117
      if(value.indexOf("??") !== -1){
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   118
        qTweet_Q+=1;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   119
        return 2;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   120
      }else if(value.indexOf("==") !== -1){
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   121
        qTweet_REF+=1;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   122
        return 4;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   123
      }else if(value.indexOf("++") !== -1){
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   124
        qTweet_OK+=1;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   125
        return 1;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   126
      }else if(value.indexOf("--") !== -1){
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   127
        qTweet_KO+=1;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   128
        return 3;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   129
      }else {
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   130
        qTweet_0+=1;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   131
        return 5;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   132
      }
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   133
    }
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   134
    
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   135
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   136
      this._serializer.sync(function(data) { loaded_callback.call(self, data) });
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   137
      
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   138
      function loaded_callback (json) {
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   139
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   140
        // get current view (the first ???)
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   141
        view = json.views[0];
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   142
        
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   143
        // the tweets are by definition of the second annotation type FIXME ?
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   144
        tweet_annot_type = null;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   145
        if(typeof(view.annotation_types) !== "undefined" && view.annotation_types.length > 1) {
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   146
          tweet_annot_type = view.annotation_types[1];
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   147
        }
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   148
      
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   149
      for(var i = 0; i < json.annotations.length; i++) {
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   150
        var item = json.annotations[i];        
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   151
        var MyTime  = Math.floor(item.begin/duration*lineSize);
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   152
        var Myframe = Math.floor(MyTime/lineSize*frameLength);
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   153
        /*
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   154
        if (typeof(item.meta) !== "undefined" 
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   155
          && typeof(item.meta["id-ref"]) !== "undefined"
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   156
          && item.meta["id-ref"] === tweet_annot_type) {
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   157
            
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   158
          var MyTJson = JSON.parse(item.meta['dc:source']['content']);
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   159
          
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   160
            if (item.content['polemics'] != undefined 
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   161
            && item.content['polemics'][0] != null) {
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   162
            
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   163
              // a tweet can have many polemics at the same time.
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   164
              for(var j=0; j<item.content['polemics'].length; j++){
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   165
                  
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   166
                  this.tweets[numberOfTweet] = {
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   167
                        id:i,
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   168
                        qualification:colorTranslation(item.content['polemics'][j]),
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   169
                        yIndicator:MyTime,
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   170
                        yframe:Myframe,
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   171
                        title:item.content['title'],
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   172
                        timeframe:item.begin,
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   173
                        userId: MyTJson.id,
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   174
                        userScreenName: MyTJson.screen_name,
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   175
                        tsource:MyTJson,
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   176
                        cinecast_id: item.id
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   177
                        };
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   178
                  numberOfTweet+=1;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   179
                  
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   180
              }
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   181
          }
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   182
          else {
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   183
          */
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   184
            this.tweets[numberOfTweet] = {
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   185
                  id:i,
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   186
                  qualification:colorTranslation(item.content['description']),
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   187
                  description:item.content['description'],
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   188
                  yIndicator:MyTime,
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   189
                  yframe:Myframe,
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   190
                  title:item.content['title'],
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   191
                  timeframe:item.begin,
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   192
                  userId: "nobody",
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   193
                  userScreenName: "nobody",
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   194
                  tsource: "iri ldt platform",
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   195
                  cinecast_id: item.id
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   196
            };
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   197
            numberOfTweet+=1;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   198
          
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   199
          /* } 
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   200
          
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   201
        } */
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   202
      };  
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   203
      
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   204
       DrawTweets.call (this); // FIXME: ugly.
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   205
       
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   206
      };      
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   207
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   208
    // tweet Drawing (in raphael) 
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   209
    function DrawTweets (){
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   210
    // GROUPES TWEET ============================================
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   211
    // Count nbr of cluster and tweet in a frame an save int in "frames"
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   212
      numberOfTweet = this.tweets.length;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   213
      for(var i=0; i<nbrframes; i++) {  
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   214
        for(var j=0; j<numberOfTweet; j++) {  
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   215
        
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   216
          if (i==this.tweets[j].yframe){
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   217
            
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   218
            var k = this.tweets[j].qualification;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   219
            
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   220
            // make array for frame cluster
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   221
            if(frames[i]==undefined){
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   222
              frames[i] = {id:i,
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   223
                     qualifVol:new Array(),
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   224
                     mytweetsID:new Array()
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   225
                    };
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   226
            }
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   227
            // add my tweet to frame
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   228
            frames[i].mytweetsID.push(this.tweets[j]);
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   229
            
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   230
            // count opinion by frame
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   231
            if( frames[i].qualifVol[k] == undefined){
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   232
              frames[i].qualifVol[k] = 1;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   233
            }else{
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   234
              frames[i].qualifVol[k] += 1;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   235
            }
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   236
            
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   237
          }
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   238
        }
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   239
      }
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   240
    
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   241
    // GROUPES TWEET ============================================    
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   242
    // max of tweet by Frame 
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   243
      var max = 0; 
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   244
      for(var i = 0; i < nbrframes; i++) {
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   245
        var moy  = 0;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   246
        for (var j = 0; j < 6; j++) {    
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   247
          if (frames[i] != undefined) {
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   248
            if (frames[i].qualifVol[j] != undefined) {
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   249
              moy += frames[i].qualifVol[j];
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   250
            }
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   251
          }
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   252
        }
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   253
        
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   254
        if (moy > max) {
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   255
          max = moy;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   256
        }
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   257
      }
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   258
    
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   259
      var tweetDrawed = new Array();
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   260
      var TweetHeight = 5;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   261
      
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   262
      // DRAW  TWEETS ============================================
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   263
      for(var i = 0; i < nbrframes; i++) {
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   264
        var addEheight = 5;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   265
        if (frames[i] != undefined){                
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   266
          // by type 
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   267
          
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   268
          for (var j = 6; j > -1; j--) {
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   269
            if (frames[i].qualifVol[j] != undefined) {
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   270
              // show tweet by type 
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   271
              for (var k = 0; k < frames[i].mytweetsID.length; k++) {
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   272
              
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   273
                if (frames[i].mytweetsID[k].qualification == j) {                
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   274
                  var x = i * frameSize;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   275
                  var y = this.heightmax - addEheight;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   276
                  
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   277
                  if (this.yMax > y) {
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   278
                    this.yMax = y;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   279
                  }
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   280
                  
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   281
                  var e = this.paper.rect(x, y, frameSize - margin, TweetHeight /* height */)
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   282
                                    .attr({stroke:"#00","stroke-width":0.1,  fill: colors[j]});  
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   283
                  
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   284
                  addEheight += TweetHeight;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   285
                  
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   286
                  e.color = colors[j];
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   287
                  e.time = frames[i].mytweetsID[k].timeframe;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   288
                  e.title = frames[i].mytweetsID[k].title;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   289
                  e.description = frames[i].mytweetsID[k].description;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   290
                  e.id = frames[i].mytweetsID[k].cinecast_id;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   291
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   292
                  this.svgElements[e.id] = e;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   293
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   294
                  e.mouseover(function(element) { return function (event) {
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   295
                        // event.clientX and event.clientY are to raphael what event.pageX and pageY are to jquery.                        
410
de8fdd68930f display the text as well as the description in the tooltip.
hamidouk
parents: 400
diff changeset
   296
                        self.TooltipWidget.show.call(self.TooltipWidget, e.title + " - " + element.description, element.attr("fill"), event.clientX - 106, event.clientY - 160);
400
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   297
                        element.displayed = true;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   298
                  }}(e)).mouseout(function(element) { return function () {                          
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   299
                          self.TooltipWidget.hide.call(self.TooltipWidget);
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   300
                  }}(e)).mousedown(function () {
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   301
                    self._Popcorn.currentTime(this.time/1000);
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   302
                    self._Popcorn.trigger("IriSP.PolemicTweet.click", this.id); 
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   303
                  });
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   304
                  
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   305
                  IriSP.jQuery(e.node).attr('id', 't' + k + '');
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   306
                  IriSP.jQuery(e.node).attr('title', frames[i].mytweetsID[k].title);
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   307
                  IriSP.jQuery(e.node).attr('begin',  frames[i].mytweetsID[k].timeframe);                  
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   308
                }
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   309
              }
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   310
            }
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   311
          }
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   312
        }
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   313
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   314
      }    
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   315
      // DRAW UI :: resize border and bgd      
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   316
      this.paperBackground = this.paper.rect(0, 0, this.width, this.heightmax).attr({fill:"#F8F8F8","stroke-width":0.1,opacity: 1});  
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   317
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   318
      // outer borders
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   319
      this.outerBorders   = [];
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   320
      this.outerBorders.push(this.paper.rect(0, this.height - 1, this.width, 1).attr({fill:"#ababab",stroke: "none",opacity: 1}));  
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   321
      this.outerBorders.push(this.paper.rect(0, 0, this.width, 1).attr({fill:"#ababab",stroke: "none",opacity: 1}));  
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   322
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   323
      // inner borders
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   324
      this.innerBorders   = [];
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   325
      this.innerBorders.push(this.paper.rect(1, this.height - 2, this.width, 1).attr({fill:"#efefef",stroke: "none",opacity: 1}));  
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   326
      this.innerBorders.push(this.paper.rect(1, 1, this.width, 1).attr({fill:"#efefef",stroke: "none",opacity: 1}));  
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   327
      this.innerBorders.push(this.paper.rect(1, 1, 1, this.height - 2).attr({fill:"#d0d1d1",stroke: "none",opacity: 0.8}));  
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   328
      this.innerBorders.push(this.paper.rect(this.width - 2, 1, 1, this.height - 2).attr({fill:"#efefef",stroke: "none",opacity: 1}));  
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   329
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   330
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   331
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   332
      this.paperSlider   = this.paper.rect(0, 0, 0, this.heightmax).attr({fill:"#D4D5D5", stroke: "none", opacity: 1});
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   333
      
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   334
      // the small white line displayed over the slider.
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   335
      this.sliderTip = this.paper.rect(0, 0, 1, this.heightmax).attr({fill:"#fc00ff", stroke: "none", opacity: 1});
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   336
      // decalage 
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   337
      // tweetSelection = this.paper.rect(-100,-100,5,5).attr({fill:"#fff",stroke: "none",opacity: 1});  
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   338
      
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   339
      
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   340
      this.paperSlider.toBack();
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   341
      this.paperBackground.toBack();
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   342
      this.sliderTip.toFront();
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   343
    }
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   344
    
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   345
    this._Popcorn.listen("timeupdate", IriSP.wrap(this, this.sliderUpdater));
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   346
}
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   347
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   348
IriSP.PolemicViewer.prototype.sliderUpdater = function() {
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   349
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   350
    var time = +this._Popcorn.currentTime();
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   351
    var duration = +this._serializer.currentMedia().meta["dc:duration"];
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   352
    
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   353
    this.paperSlider.attr("width", time * (this.width / (duration / 1000)));
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   354
        
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   355
    this.sliderTip.attr("x", time * (this.width / (duration / 1000)));
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   356
};
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   357
    
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   358
IriSP.PolemicViewer.prototype.searchHandler = function(searchString) {
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   359
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   360
  if (searchString == "")
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   361
    return;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   362
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   363
  var matches = this._serializer.searchTweetsOccurences(searchString);
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   364
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   365
  if (IriSP.countProperties(matches) > 0) {
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   366
    this._Popcorn.trigger("IriSP.search.matchFound");
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   367
  } else {
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   368
    this._Popcorn.trigger("IriSP.search.noMatchFound");
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   369
  }
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   370
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   371
  for (var id in matches) {
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   372
    var factor = 0.5 + matches[id] * 0.2;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   373
    if (this.svgElements.hasOwnProperty(id)) {
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   374
      this.svgElements[id].attr({fill: "#fc00ff"});
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   375
    }
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   376
  }
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   377
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   378
  // clean up the blocks that were in the previous search
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   379
  // but who aren't in the current one.
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   380
  for (var id in this.oldSearchMatches) {
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   381
    if (!matches.hasOwnProperty(id)) {
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   382
      var e = this.svgElements[id];
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   383
      e.attr({fill: e.color});
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   384
    }
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   385
  }
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   386
  
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   387
  this.oldSearchMatches = matches;
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   388
};
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   389
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   390
IriSP.PolemicViewer.prototype.searchFieldClearedHandler = function() {
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   391
  // clean up the blocks that were in the previous search
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   392
  // but who aren't in the current one.
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   393
  for (var id in this.oldSearchMatches) {
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   394
      var e = this.svgElements[id];
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   395
      e.attr({fill: e.color});
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   396
  }
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   397
 
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   398
};
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   399
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   400
IriSP.PolemicViewer.prototype.searchFieldClosedHandler = function() {
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   401
  // clean up the blocks that were in the previous search
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   402
  // but who aren't in the current one.
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   403
  for (var id in this.oldSearchMatches) {
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   404
      var e = this.svgElements[id];
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   405
      e.attr({fill: e.color});
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   406
  }
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   407
 
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   408
};
58ade3113a02 added a custom widget for the cap demo.
hamidouk
parents:
diff changeset
   409