front_idill/src/mosaic/js/search.js
author bastiena
Sun, 09 Sep 2012 15:11:32 +0200
changeset 89 b6a115568b52
parent 79 9eff85166868
child 97 be87091be54e
permissions -rw-r--r--
Front IDILL: credits for mouse interactions
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
     1
/*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
     2
* This file is part of the TraKERS\Front IDILL package.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
     3
*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
     4
* (c) IRI <http://www.iri.centrepompidou.fr/>
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
     5
*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
     6
* For the full copyright and license information, please view the LICENSE
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
     7
* file that was distributed with this source code.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
     8
*/
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
     9
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    10
/*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    11
 * Projet : TraKERS
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    12
 * Module : Front IDILL
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    13
 * Fichier : search.js
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    14
 * 
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    15
 * Auteur : alexandre.bastien@iri.centrepompidou.fr
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    16
 * 
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    17
 * Fonctionnalités : Définit les fonctions de recherche par courbe de haut niveau (instantiation et manipulation de la classe de recherche par courbe mais pas les courbes en elles-mêmes ni le détecteur).
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    18
 */
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    19
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    20
/*
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    21
 * Lance une recherche par courbes.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    22
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    23
 * mosaic > fonction onMouseMove.
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    24
 */
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    25
Mosaic.prototype.startSearch = function()
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    26
{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    27
    var _this = this;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    28
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    29
    var top, left, width, height, margin_top, inMosaic;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    30
    //Si on est dans le cas d'un filtrage de mosaïque.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    31
    if(this.currentMode == "FILTER")
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    32
    {
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
    33
        /*var mainPanel = $('#mainPanel');
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    34
        top = mainPanel.position().top;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    35
        left = mainPanel.position().left;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    36
        width = mainPanel.width();
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
    37
        height = mainPanel.height();*/
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
    38
        // margin_top = this.MPTop_margin;
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    39
        inMosaic = true;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    40
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    41
    //Sinon si c'est une recherche dans la vidéo.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    42
    else if(this.currentMode == "SEARCH")
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    43
    {
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
    44
        /*top = this.snTop;
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    45
        left = this.snLeft;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    46
        width = this.snWidth;
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
    47
        height = this.snHeight;*/
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
    48
        // margin_top = '0px';
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    49
        inMosaic = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    50
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    51
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    52
    //On crée le canvas et on récupère le dictionnaire des courbes.
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
    53
    // this.searchCanvas = new SearchCanvas(top, left, width, height, margin_top, this.timeSearchFade, inMosaic, this);
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
    54
    this.searchCanvas = new SearchCanvas(0, 0, $(window).width(), $(window).height(), 0, this.timeSearchFade, inMosaic, this);
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    55
    this.searchCanvas.create(this.dictionary);
45
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
    56
}
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
    57
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
    58
/*
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
    59
 * Lit le dictionnaire pour reconnaître les courbes de recherche.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    60
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    61
 * mosaic > fonction loadParameters.
45
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
    62
*/
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    63
Mosaic.prototype.getDictionary = function()
45
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
    64
{
58
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
    65
    var path = (this.config.mouseInteractions ? this.config.curveDictionaryMI : this.config.curveDictionaryKI);
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    66
    var dico = [];
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    67
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    68
    var _this = this;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    69
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    70
    $.getJSON(path, function(data)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    71
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    72
        //Chaque entrée comporte un objet de cette forme : (nom, tableau). Tableau est un array de strings, qui sont les codes décrivant la courbe. Chaque code est un alias de cette courbe.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    73
        for(var i = 0 ; i < data.gestures.length ; i++)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    74
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    75
            _this.dictionary[i] = data.gestures[i];
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    76
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    77
    });
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    78
}
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    79
46
9d7a2aa112fb Front IDILL:
bastiena
parents: 45
diff changeset
    80
/*
9d7a2aa112fb Front IDILL:
bastiena
parents: 45
diff changeset
    81
 * Charge le texte affichable en fonction de la langue.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    82
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    83
 * mosaic > fonction loadParameters.
46
9d7a2aa112fb Front IDILL:
bastiena
parents: 45
diff changeset
    84
*/
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    85
Mosaic.prototype.getLang = function(lang)
46
9d7a2aa112fb Front IDILL:
bastiena
parents: 45
diff changeset
    86
{
63
0947deb9ab6d Front IDILL:
bastiena
parents: 58
diff changeset
    87
	//Si la langue choisie n'est pas disponible, on met l'anglais par défaut.
0947deb9ab6d Front IDILL:
bastiena
parents: 58
diff changeset
    88
	if(this.config.langs.indexOf(this.config.lang) == -1)
0947deb9ab6d Front IDILL:
bastiena
parents: 58
diff changeset
    89
	{
0947deb9ab6d Front IDILL:
bastiena
parents: 58
diff changeset
    90
		this.config.lang = "en";
0947deb9ab6d Front IDILL:
bastiena
parents: 58
diff changeset
    91
	}
0947deb9ab6d Front IDILL:
bastiena
parents: 58
diff changeset
    92
	
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    93
    var path = 'lang/' + this.config.lang + '.json';
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    94
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    95
    var _this = this;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    96
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    97
    $.getJSON(path, function(data)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    98
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    99
        _this.gesturesText = data.gesturesText;
55
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   100
		_this.notificationStrings = data.notificationStrings;
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   101
		_this.helpText = data.helpText;
89
b6a115568b52 Front IDILL:
bastiena
parents: 79
diff changeset
   102
		_this.creditsMetadata = data.credits_lang;
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   103
    });
46
9d7a2aa112fb Front IDILL:
bastiena
parents: 45
diff changeset
   104
}
9d7a2aa112fb Front IDILL:
bastiena
parents: 45
diff changeset
   105
58
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   106
/*
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   107
 * Ecoute la position des pointeurs si les deux sont détectés afin de tracer des courbes de recherche.
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   108
*/
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   109
Mosaic.prototype.listenToPointers = function()
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   110
{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   111
    if(this.searchCanvas)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   112
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   113
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   114
    }
58
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   115
}
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   116
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   117
/*
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   118
 * Quitte une recherche par courbes.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   119
 * Est appelé dans les fichiers :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   120
 * mosaic > fonction onMouseUp.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   121
 * curvesDetector > fonction updateDists.
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   122
 */
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   123
Mosaic.prototype.leaveSearch = function()
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   124
{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   125
    if(this.searchCanvas)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   126
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   127
        this.searchCanvas.leaveSearch();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   128
		//Dans le cadre du mode d'interactions souris, on indique qu'on est en mouse down de facon à ne plus être en mouse move avant le prochain mouse up puis d'un mouse down.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   129
		this.isMouseDown = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   130
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   131
    this.searchCanvas = null;
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   132
}
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   133
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   134
/*
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   135
 * Effectuer un filtrage de la mosaïque par rapport à un type de marqueurs.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   136
 * Est appelé dans les fichiers :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   137
 * mosaic > fonctions onMouseUp et manageControlEvents.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   138
 * curvesDetector > fonction updateDists.
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   139
*/
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   140
Mosaic.prototype.searchFilter = function(type)
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   141
{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   142
    var _this = this;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   143
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   144
    //Si on est en mode filtrage.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   145
    if(this.currentMode == "FILTER")
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   146
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   147
        //On indique pour chaque snapshot la recherche de filtrage.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   148
        for(var i = 0 ; i < this.config['imagesToShow'] ; i++)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   149
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   150
            this.currentSearchGesture[i] = type;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   151
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   152
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   153
        this.filterSearchedType = type;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   154
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   155
        //Si on a des annotations.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   156
        if(this.annotations.length > 0)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   157
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   158
            //On indique qu'on est en train de filtrer.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   159
            this.isMosaicFiltering = true;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   160
            
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   161
            //Va servir à compter le nombre d'occurence des marqueurs dans chaque video.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   162
            var gestureNumberByVideo = new Object();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   163
            var maxAnnotationNumber = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   164
            
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   165
            //Pour chaque annotation.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   166
            for(var i = 0 ; i < this.annotations.length ; i++)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   167
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   168
                //On récupère l'annotation en cours.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   169
                var current = this.annotations[i];
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   170
                
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   171
                //Si l'annotation correspond à la gesture recherchée.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   172
                if(current.annotationType.contents.title == type)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   173
                {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   174
                    //Si une video n'a pas été traitée, on met son nombre d'occurences à 0.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   175
                    if(gestureNumberByVideo[current.source.url] == undefined || gestureNumberByVideo[current.source.url] == '')
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   176
                    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   177
                        gestureNumberByVideo[current.source.url] = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   178
                    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   179
                    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   180
                    //On incrémente le nombre d'occurences de la video.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   181
                    gestureNumberByVideo[current.source.url]++;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   182
                }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   183
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   184
            
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   185
            //Pour chaque snapshot, s'il son nombre d'occurences n'a pas été encore calculé (cas où il n'y a pas de résultats dans ces videos là, on met leur nombre d'occurences à 0.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   186
            for(var i = 0 ; i < this.config['imagesToShow'] ; i++)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   187
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   188
                if(gestureNumberByVideo[this.urls[i]] == undefined || gestureNumberByVideo[this.urls[i]] == '')
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   189
                {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   190
                    gestureNumberByVideo[this.urls[i]] = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   191
                }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   192
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   193
            
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   194
            //On récupère la vidéo qui score le nombre d'occurences de la gesture le plus haut.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   195
            for(i in gestureNumberByVideo)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   196
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   197
                if(maxAnnotationNumber < gestureNumberByVideo[i])
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   198
                {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   199
                    maxAnnotationNumber = gestureNumberByVideo[i];
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   200
                }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   201
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   202
            
77
205409da0f32 Front IDILL:
bastiena
parents: 63
diff changeset
   203
            var snMargin = parseInt($('.snapshotDivs').css('margin-left'));
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   204
            
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   205
            //On affiche l'opacité résultante pour chaque vidéo.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   206
            for(var i = 0 ; i < this.config['imagesToShow'] ; i++)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   207
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   208
                //Opacité conventionelle.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   209
                var opacity;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   210
                if(maxAnnotationNumber > 0)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   211
                {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   212
                    opacity = gestureNumberByVideo[this.urls[i]] / maxAnnotationNumber;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   213
                }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   214
                else
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   215
                {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   216
                    opacity = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   217
                }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   218
                
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   219
                //Ce qui est à zéro le restera (par conséquent le snapshot associé sera invisible).
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   220
                if(opacity > 0)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   221
                {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   222
                    //On réhausse l'opacité de 50%.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   223
                    opacity = this.scaleIntervals(0., 1., 0.5, 1., opacity);    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   224
                }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   225
                this.opacities[i] = opacity;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   226
                
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   227
                var filterIndex = i;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   228
                
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   229
                //On applique les opacités aux snapshots.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   230
                $('#snapshotDiv-' + filterIndex).fadeTo(this.config['timeFilterFade'], opacity, function()
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   231
                {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   232
                    //On indique lorsque c'est terminé que la mosaique a terminé de filtrer.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   233
                    if(_this.isMosaicFiltering)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   234
                    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   235
                        _this.isMosaicFiltering = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   236
                    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   237
                });
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   238
                
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   239
                //Si l'opacité est nulle.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   240
                if(opacity == 0)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   241
                {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   242
                    //Le snapshot filtré actuel.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   243
                    var filteredSnapshot = $('#snapshotDiv-' + filterIndex);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   244
                    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   245
                    //S'il existe.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   246
                    if(filteredSnapshot.length > 0)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   247
                    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   248
                        //On rajoute un hider de façon à ce qu'on ne puisse pas le sélectionner.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   249
                        var hider = '<div id="filterHider-' + filterIndex + '" class="filterHiders"></div>';
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   250
                        $('#mainPanel').append(hider);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   251
                        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   252
                        $('#filterHider-' + filterIndex).css(
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   253
                        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   254
                            width: +filteredSnapshot.width() + 4 * snMargin,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   255
                            height: +filteredSnapshot.height() + 4 * snMargin,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   256
                            top: filteredSnapshot.position().top - snMargin,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   257
                            left: filteredSnapshot.position().left - snMargin
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   258
                        });
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   259
                    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   260
                }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   261
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   262
            
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   263
            //On indique que la mosaique a été filtrée.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   264
            this.isMosaicFiltered = true;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   265
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   266
    }
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   267
}
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   268
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   269
/*
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   270
 * Passe une valeur de l'intervalle [A, B] à l'intervalle [C, D].
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   271
 * Est appelé dans les fichiers :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   272
 * pointers > fonction pointersTimelineSelection.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   273
 * search > fonction searchFilter.
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   274
*/
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   275
Mosaic.prototype.scaleIntervals = function(A, B, C, D, val)
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   276
{
58
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   277
    // return (D - C + A) * val + (C - A);
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   278
	if(A == B)
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   279
	{
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   280
		return (D - C) / 2;
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   281
	}
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   282
	else
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   283
	{
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   284
		return (D - C) * (val - A) / (B - A) + C;
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   285
	}
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   286
}
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   287
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   288
/*
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   289
 * Retourne l'index d'un snapshot en fonction de ses metadonnées.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   290
*/
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   291
/*Mosaic.prototype.getIdxFromMetadata = function(metadata)
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   292
{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   293
    var _this = this;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   294
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   295
    for(idx in this.urls)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   296
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   297
        if(this.urls[idx] == metadata)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   298
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   299
            for(id in this.ids)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   300
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   301
                if(this.ids[id] == idx)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   302
                {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   303
                    return id;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   304
                }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   305
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   306
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   307
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   308
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   309
    return -1;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   310
}*/
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   311
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   312
/*
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   313
 * Enlève une recherche par filtre.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   314
 * Est appelé : dans les fichiers :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   315
 * pointers > fonctions checkIfPointerIsOnSearchNotification et removeSearchNotificationIfOnIt.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   316
 * mosaic > fonction onMarkersReady.
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   317
*/
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   318
Mosaic.prototype.removeFilter = function()
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   319
{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   320
    //Si on est en filtrage, on passe en mosaic et on retire la recherche.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   321
    if(this.currentMode == "FILTER")
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   322
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   323
        this.currentMode = "MOSAIC";
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   324
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   325
        var _this = this;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   326
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   327
        this.isMosaicFiltered = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   328
		this.isMosaicFiltering = true;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   329
        this.filterSearchedType = '';
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   330
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   331
        for(var i = 0 ; i < this.config['imagesToShow'] ; i++)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   332
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   333
            this.currentSearchGesture[i] = '';
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   334
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   335
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   336
        this.removeNotifications();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   337
        $('.filterHiders').remove();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   338
        $('.snapshotDivs').fadeTo(_this.config['timeFilterFade'], 1, function()
47
4e1ee94d70b1 Front IDILL:
bastiena
parents: 46
diff changeset
   339
		{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   340
			_this.isMosaicFiltering = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   341
		});
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   342
    }
45
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
   343
}
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
   344
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
   345
/*
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
   346
 * Parcours le dictionnaire pour trouver la première gesture à avoir un code identique à celui en entrée.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   347
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   348
 * mosaic > fonction onMouseUp.
45
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
   349
*/
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   350
Mosaic.prototype.gestureWithSameCode = function(code)
45
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
   351
{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   352
    //Pour tout le dictionnaire.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   353
    for(var i = 0 ; i < this.dictionary.length ; i++)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   354
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   355
        //Pour touts les codes de chaque gesture du dictionnaire.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   356
        for(var j = 0 ; j < this.dictionary[i].codes.length ; j++)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   357
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   358
            //Si le code en entrée est une partie début d'un des codes.
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   359
            if(this.dictionary[i].codes[j] === code || this.dictionary[i].codes[j].indexOf(code) == 0)
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   360
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   361
                //On retourne le nom de la gesture.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   362
                return this.dictionary[i].name;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   363
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   364
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   365
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   366
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   367
    return '';
89
b6a115568b52 Front IDILL:
bastiena
parents: 79
diff changeset
   368
}
b6a115568b52 Front IDILL:
bastiena
parents: 79
diff changeset
   369
b6a115568b52 Front IDILL:
bastiena
parents: 79
diff changeset
   370
/*
b6a115568b52 Front IDILL:
bastiena
parents: 79
diff changeset
   371
 * Extrait les données des crédits.
b6a115568b52 Front IDILL:
bastiena
parents: 79
diff changeset
   372
*/
b6a115568b52 Front IDILL:
bastiena
parents: 79
diff changeset
   373
Mosaic.prototype.getCredits = function()
b6a115568b52 Front IDILL:
bastiena
parents: 79
diff changeset
   374
{
b6a115568b52 Front IDILL:
bastiena
parents: 79
diff changeset
   375
	var _this = this;
b6a115568b52 Front IDILL:
bastiena
parents: 79
diff changeset
   376
	
b6a115568b52 Front IDILL:
bastiena
parents: 79
diff changeset
   377
	$.getJSON(this.config.creditsPath, function(data)
b6a115568b52 Front IDILL:
bastiena
parents: 79
diff changeset
   378
    {
b6a115568b52 Front IDILL:
bastiena
parents: 79
diff changeset
   379
        //On récupère les données des crédits et on les place dans un tableau avant de le retourner.
b6a115568b52 Front IDILL:
bastiena
parents: 79
diff changeset
   380
        for(var i = 0 ; i < data.creditsData.length ; i++)
b6a115568b52 Front IDILL:
bastiena
parents: 79
diff changeset
   381
        {
b6a115568b52 Front IDILL:
bastiena
parents: 79
diff changeset
   382
            _this.tabCredits[i] = data.creditsData[i];
b6a115568b52 Front IDILL:
bastiena
parents: 79
diff changeset
   383
        }
b6a115568b52 Front IDILL:
bastiena
parents: 79
diff changeset
   384
    });
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   385
}