front_idill/src/mosaic/js/mosaic.js
author bastiena
Tue, 31 Jul 2012 16:26:00 +0200
changeset 58 a28488078053
parent 55 afd60399a7b5
child 77 205409da0f32
permissions -rw-r--r--
Front IDILL: search curves modified : search curves exit when event other than many curves detected.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
     1
/*
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
     2
* This file is part of the TraKERS\Front IDILL package.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
     3
*
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
     4
* (c) IRI <http://www.iri.centrepompidou.fr/>
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
     5
*
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
     6
* For the full copyright and license information, please view the LICENSE
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
     7
* file that was distributed with this source code.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
     8
*/
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
     9
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    10
/*
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    11
 * Projet : TraKERS
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    12
 * Module : Front IDILL
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    13
 * Fichier : mosaic.js
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    14
 * 
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    15
 * Auteur : alexandre.bastien@iri.centrepompidou.fr
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    16
 * 
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    17
 * Fonctionnalités : Définit la "classe" mosaïque et définit des fonctions d'intéractions.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    18
 */
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    19
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    20
/*
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    21
 * Classe définissant la mosaïque.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    22
 * Elle contient sa longueur, le nombre d'images total, une liste d'urls pour les vidéos, leurs snapshots principaux et leur position.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    23
 * Contient également les dimensions en px de la mosaïque.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    24
 * Est appelé dans :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    25
 * la page d'index, afin de créer la mosaique.
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    26
 */
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    27
function Mosaic(config, default_conf)
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    28
{
58
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
    29
    this.gestures = ["fall", "jump", "circle", "screw", "bend", "arc", "knee-up", "right-angle", "wave", "slow", "hello", "no-motion", "contact", "up-down", "grand-jete"];
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
    30
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    31
    //Chemin du fichier de configuration.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    32
    this.config_path = config;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    33
    //Configuration par défaut en cas de valeur erronnée.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    34
    this.default_config = default_conf;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    35
    this.config = new Object();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    36
    //Tableaux des urls des vidéos, des snapshots et de leur position dans la mosaïque.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    37
    this.videos = [];
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    38
    this.urls = [];
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    39
    this.sources = [];
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    40
    this.imgs = [];
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    41
    this.opacities = [];
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    42
    this.timeToGoAt = [];
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    43
    this.ids = [];
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    44
    this.fillingIds = [];
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    45
    this.currentRandomVideoIdx = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    46
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    47
    //Dictionnaire pour les courbes de recherche.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    48
    this.dictionary = [];
55
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    49
	
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    50
	//Strings des notifications.
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    51
	this.notificationStrings = {
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    52
	"select":"Select", 
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    53
	"confirm":"Confirm", 
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    54
	"timeline":"Timeline move", 
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    55
	"move":"Move", 
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    56
	"search":"Search", 
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    57
	"next":"Next", 
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    58
	"previous":"Previous", 
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    59
	"unzoom":"Unzoom", 
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    60
	"unknown":"Unknown gesture", 
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    61
	"fall":"Fall", 
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    62
	"jump":"Jump", 
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    63
	"spin":"Spin", 
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    64
	"screw":"Screw", 
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    65
	"bend":"Bend", 
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    66
	"arc":"Arc", 
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    67
	"knee_up":"Knee up", 
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    68
	"breakdance":"Breakdance", 
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    69
	"wave":"Wave", 
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    70
	"no_motion":"No motion", 
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    71
	"contact":"Contact"};
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    72
	
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    73
	this.helpText = {
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    74
	"search_title":"Search", 
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    75
	"search_2hands_text":"Curves to be drawn with both hands",  
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    76
	"search_mouse_text":"Curves to be mouse-drawn",  
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    77
	"search_body_text":"Gestures to be performed with your body", 
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    78
	"controls_title":"Controls", 
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    79
	"controls_1hand_text":"Gestures to be performed with your hand", 
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    80
	"controls_timeline":"Move in timeline", 
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    81
	"controls_mos_horizontal":"Unzoom", 
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    82
	"controls_mos_vertical":"Unzoom", 
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    83
	"controls_move_down":"Move", 
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    84
	"controls_move_left":"Move", 
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    85
	"controls_move_right":"Move", 
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    86
	"controls_move_up":"Move", 
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    87
	"controls_next":"Next", 
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    88
	"controls_previous":"Previous", 
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    89
	"controls_selection":"Selection"
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    90
	}
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    91
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    92
    //Dernières positions des pointeurs.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    93
    this.mainPointerLastX = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    94
    this.mainPointerLastY = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    95
    this.secondPointerLastX = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    96
    this.secondPointerLastY = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    97
    //Dernières positions avant le lancement de la fonction d'idle.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    98
    this.mainPointerIdleStartX = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    99
    this.mainPointerIdleStartY = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   100
    this.secondPointerIdleStartX = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   101
    this.secondPointerIdleStartY = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   102
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   103
    //Coordonnées de la souris dans le mode d'interaction souris.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   104
    this.mousePosX = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   105
    this.mousePosY = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   106
    //Coordonnées précédentes de la souris dans le mode d'interaction souris.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   107
    this.mousePosLastX = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   108
    this.mousePosLastY = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   109
    //Valeur du déplacement entre un mouse up et un mouse down.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   110
    this.mouseUpDownDelta = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   111
	//Coordonnées de la souris au dernier mouse down.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   112
	this.mouseDownPosX = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   113
	this.mouseDownPosY = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   114
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   115
    //Dimensions de la mosaïque en pixels.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   116
    this.width = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   117
    this.height = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   118
    //Dimensions d'un snapshot en pixels.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   119
    this.snapshotWidth = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   120
    this.snapshotHeight = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   121
    //Espacement entre les snapshots en pixels.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   122
    this.marginWidth = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   123
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   124
    //Booléens permettant ou non certaines intéractions selon le contexte.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   125
    this.zoomed = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   126
    this.fullscreen = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   127
    this.canMoveToNeighbour = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   128
    this.mainPointerExitBorder = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   129
    this.secondPointerExitBorder = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   130
    this.isMainPointerDisplayed = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   131
    this.isSecondPointerDisplayed = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   132
    this.helpDisplayed = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   133
    //Indique si l'utilisateur a manuellement pausé la vidéo.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   134
    this.userPaused = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   135
    //Indique si on est en train de se déplacer vers un voisin.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   136
    this.currentlyMoving = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   137
    //Indique si on est en train de dézoomer vers la mosaïque.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   138
    this.currentlyUnzooming = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   139
    //Indique si on peut s'approcher de kinect.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   140
    this.canStart = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   141
    //Indique si on est actuellement sur un snapshot.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   142
    this.isOnASnapshot = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   143
    //Indique si l'idle des pointeurs est disponible (deux mains détectées).
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   144
    this.pointersIdleAvailable = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   145
    //Indique si le timeout pour l'idle des pointeurs à besoin d'être lancé.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   146
    this.pointersIdleNeedLaunch = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   147
    //Indique si les deux mains sont là.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   148
    this.areBothPointersHere = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   149
    //Indique si le timeout pour la détection de deux pointeurs a été lancé.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   150
    this.areBothPointersTimeoutLaunched = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   151
    //Indique si la mosaïque a été filtrée.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   152
    this.isMosaicFiltered = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   153
    //Indique si on est actuellement dans une recherche par gesture.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   154
    this.isCurrentlyInASearchByGesture = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   155
    //Indique si un pointeur est déjà sur une notification de recherche par gesture.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   156
    this.alreadyOnNotification = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   157
    //Si on a fait un swipe.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   158
    this.isSwipe = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   159
    //On peut swiper.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   160
    this.canSwipe = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   161
    //On passe vers une autre video automatiquement à la fin d'une lecture.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   162
    this.autoMove = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   163
    //Si l'utilisateur a demandé à sélectionner la TL.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   164
    this.isTLRequested = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   165
    //Le pointeur gauche a sélectionné la TL.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   166
    this.isTLSelectedBySecondPointer = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   167
    //Le pointeur droit a sélectionné la TL.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   168
    this.isTLSelectedByMainPointer = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   169
    //On peut afficher l'aide.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   170
    this.canNotifyHelp = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   171
    //Indique si la mosaique est en train d'être filtrée.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   172
    this.isMosaicFiltering = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   173
    this.arrowLeftLoading = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   174
    this.arrowRightLoading = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   175
    this.arrowUpLoading = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   176
    this.arrowDownLoading = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   177
    //On est dans une recherche par courbes.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   178
    this.isSearchByCurvesOn = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   179
    this.canDrawNextCurve = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   180
    //Dans le mode d'interaction souris, indique si on se situe actuellement sur un snapshot entièrement prézoomé.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   181
    this.isOnAPrezoomSN = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   182
    //Indique si une courbe de recherche donne au moins un résultat.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   183
    this.curvesGesturesFound = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   184
    //Indique si on souhaite supprimer la recherche en cours.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   185
    this.gestureDelRequested = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   186
    //Code de gesture actuellement calculé par les détecteurs de courbes.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   187
    this.actualCode = '';
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   188
    //Indique si l'utilisateur est entré dans la zone de recherche.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   189
    this.isUserInSearchZone = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   190
	this.isMouseDown = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   191
	//Indique si on est en train de prézoomer.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   192
	this.isPrezooming = false;
55
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   193
	//Indique si l'icone d'aide a été agrandie.
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   194
	this.isHelpIconZoomed = false;
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   195
	//Indique si l'icone d'aide est dans une interaction de zoom/dezoom en cours.
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   196
	this.isHelpIconZooming = false;
58
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   197
	//Indique à l'utilisateur s'il doit retirer ses mains pour refaire une recherche par courbes.
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   198
	this.mustTakeOutHands = false;
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   199
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   200
    //Timeout (attente) pour le zoom après un préZoom.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   201
    this.zoomTimeout = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   202
    //Timeout (attente) pour le passage vers un voisin.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   203
    this.moveToNeighbourTimeout = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   204
    this.mainPointerExitBorderTimeout = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   205
    this.secondPointerExitBorderTimeout = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   206
    //Idle time pour les pointeurs afin d'informer le front qu'on souhaite faire une recherche.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   207
    this.pointersSearchIdleTimeout = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   208
    //Vérifie toutes les N ms que les deux pointeurs sont détectés.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   209
    this.areBothPointersHereTimeout = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   210
    //Délai de suppression d'une notification de recherche par gesture.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   211
    this.removeNotificationByGestureTimeout = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   212
    //Délai de suppression d'une notification de recherche par gesture infructueuse.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   213
    this.removeFailedNotificationByGestureTimeout = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   214
    //Délai avant la suppression de notification swipe.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   215
    this.notifySwipeTimeout = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   216
    //Délai pour la sélection de la TL.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   217
    this.selectTLTimeout = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   218
    //Délai pour slider sur la TL.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   219
    this.canSlideInTLTimeout = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   220
    //Délai pour afficher l'aide.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   221
    this.canNotifyHelpTimeout = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   222
    this.arrowLeftTimeout = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   223
    this.arrowRightTimeout = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   224
    this.arrowUpTimeout = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   225
    this.arrowDownTimeout = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   226
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   227
    this.arrowSpinnerTimeout = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   228
    this.nouserTimeout = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   229
    this.nextDrawCurveTimeout = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   230
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   231
    //Dernier message INCOMING (pour éviter d'effectuer n fois la même action.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   232
    this.lastIncomingMessage = '';
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   233
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   234
    //Type de marqueur recherché dans la mosaïque (en mode filter).
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   235
    this.filterSearchedType = "";
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   236
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   237
    //Mode actuel.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   238
    this.currentMode = "NO-USER";
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   239
    //Snapshot sur lequel on a zoomé.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   240
    this.previousZoomedSN = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   241
    //Snapshot sur lequel on a prezoomé.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   242
    this.previousPrezoomDiv = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   243
    //Son ID.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   244
    this.previousId = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   245
    //Dernier snapshot prézoomé non null.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   246
    this.lastNonNullSN = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   247
    //Largeur de la marge pour le centrage vertical de la mosaïque.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   248
    this.MPTop_margin = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   249
    this.top_margin = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   250
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   251
    //Gestures actuellement cherchées dans les vidéos.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   252
    this.currentSearchGesture = [];
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   253
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   254
    //Position des voisins lors d'un zoom.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   255
    this.neighboursIds = [];
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   256
    //ID du snapshot du milieu lors d'un zoom.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   257
    this.centerId = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   258
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   259
    //Voisins sélectionnés par les pointeurs.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   260
    this.mainPointerNeighbourSelectedId = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   261
    this.secondPointerNeighbourSelectedId = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   262
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   263
    //Snapshots a afficher.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   264
    this.snapshotsToShow = 1;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   265
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   266
    //Lecteur.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   267
    this.player = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   268
    //Si le lecteur est prêt.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   269
    this.playerIsReady = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   270
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   271
    //Annotations (pour les marqueurs los d'un filtrage).
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   272
    this.annotations = [];
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   273
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   274
    //Client websocket pour recevoir les notifications du Middleware.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   275
    this.client = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   276
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   277
    //Coordonnées et dimensions d'un snapshot zoomé.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   278
    this.snTop = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   279
    this.snLeft = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   280
    this.snWidth = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   281
    this.snHeight = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   282
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   283
    this.searchCanvas = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   284
    //Position actuelle de la vidéo zoomée.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   285
    this.notifyTopVideo = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   286
    this.notifyLeftVideo = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   287
    this.loadParameters(this.config_path);
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   288
}
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   289
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   290
/*
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   291
 * Méthode d'affichage de la mosaïque.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   292
 * Génère une matrice de imgs.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   293
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   294
 * mosaic > fonction loadMosaic, afin de créer les éléments visuels de la mosaique.
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   295
 */
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   296
Mosaic.prototype.createMosaic = function()
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   297
{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   298
	var _this = this;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   299
	
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   300
    //On ajoute le player au body pour le lancer la première fois qu'on zoom.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   301
	$('body').append('<div class="player" id="video"></div><div class="LdtPlayer" id="LdtPlayer"></div>');
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   302
	
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   303
	//On recharge la fenêtre si sa taille a changé.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   304
	$(window).resize(function()
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   305
	{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   306
		_.debounce(window.location.reload(), _this.config.timeReloadAfterResize);
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   307
	});
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   308
	
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   309
    var initPanel = '<div id="initPanel"></div>';
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   310
    var mp = $('#mainPanel');
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   311
    mp.append(initPanel);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   312
    $('#initPanel').css(
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   313
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   314
        background: 'transparent',
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   315
        width: mp.width(),
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   316
        height: mp.height(),
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   317
        top: mp.position().top,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   318
        left: mp.position().left,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   319
        'margin-top': this.MPTop_margin
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   320
    });
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   321
    
55
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   322
    var len = this.config.imagesByLine, imgs = this.config.imagesToShow, imgsTotal = this.config.imagesTotal;
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   323
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   324
    //S'il s'agit d'un rectangle.
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   325
    if(imgs % len == 0)
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   326
    {
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   327
        this.lastIncomingMessage = 'INCOMING-0';
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   328
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   329
        var str = '';
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   330
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   331
        if(this.imgs.length >= imgs)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   332
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   333
            for(var i = 0 ; i < imgs ; i++)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   334
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   335
                //On charge les images de petite taille pour ne pas surcharger la mosaïque lors de l'affichage global.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   336
                str += '<div id="snapshotDiv-' + i + '" class="snapshotDivs" style="opacity: 0;"><img id="snapshot-' + i + '" class="snapshots" src="snapshots-little/' + this.imgs[i] + '" /></div>';
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   337
                //Au départ aucune vidéo n'a de gesture de recherche.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   338
                this.currentSearchGesture[i] = '';
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   339
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   340
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   341
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   342
        return str + '<div id="ghostPanel"></div>';
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   343
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   344
    else
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   345
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   346
        alert("Le nombre d'images a afficher doit être divisible par la longueur de la mosaïque !");
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   347
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   348
}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   349
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   350
/*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   351
 * Fonction appelée lors d'un mouse down en mode d'interaction souris.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   352
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   353
 * mosaic > fonction loadMosaic, attachée à l'événement jQuery mousedown.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   354
*/
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   355
Mosaic.prototype.onMouseDown = function(e)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   356
{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   357
	this.isMouseDown = true;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   358
	
55
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   359
	//Si on se trouve sur l'icone d'aide et qu'elle est zoomée.
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   360
	if(this.isHelpIconZoomed)
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   361
	{
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   362
		//On affiche différentes aides en fonction de si on se trouve dans une vidéo ou non.
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   363
		if(this.currentMode == 'SEARCH' || this.currentMode == 'VIDEO' || this.currentMode == 'TIMELINE')
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   364
		{
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   365
			this.notifyHelp(false);
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   366
		}
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   367
		else if(this.currentMode == 'FILTER' || this.currentMode == 'MOSAIC')
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   368
		{
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   369
			this.notifyHelp(true);
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   370
		}
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   371
	}
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   372
	
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   373
	//On met à jour les coordonnées de la souris au dernier mouse down.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   374
	this.mouseDownPosX = e.pageX;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   375
	this.mouseDownPosY = e.pageY;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   376
	
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   377
	//Si on est sur une notification de gesture de recherche.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   378
	this.removeSearchNotificationIfOnIt(e.pageX, e.pageY);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   379
	this.isUserInSearchZone = true;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   380
	
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   381
	//Si on est en mode de tracé de courbes, on indique qu'on a commencé à tracer au canvas.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   382
	if(this.isSearchByCurvesOn)
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   383
	{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   384
		this.searchCanvas.onPointerIn(this.mousePosX, this.mousePosY, null, null);
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   385
	}
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   386
}
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   387
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   388
/*
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   389
 * Fonction appelée lors d'un mouse move en mode d'interaction souris.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   390
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   391
 * mosaic > fonction loadMosaic, attachée à l'événement jQuery mousemove.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   392
*/
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   393
Mosaic.prototype.onMouseMove = function(e)
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   394
{
55
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   395
	//On vérifie si la souris n'est pas sur l'icone d'aide.
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   396
	if(this.isOnHelpIcon(this.mousePosX, this.mousePosY))
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   397
	{
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   398
		//On agrandit l'icone d'aide.
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   399
		this.showBigHelp();
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   400
	}
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   401
	else
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   402
	{
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   403
		//On la rétrecit sinon.
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   404
		this.showSmallHelp();
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   405
	}
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   406
	
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   407
	//Si on n'a pas appuyé sur la souris avant, on part.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   408
	if(!this.isMouseDown)
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   409
	{
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   410
		return;
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   411
	}
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   412
	
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   413
	var _this = this;
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   414
	
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   415
	//Si on est en mode de tracé de courbes, on met à jour la courbe.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   416
	if(this.isSearchByCurvesOn)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   417
	{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   418
		this.searchCanvas.onPointerMove(this.mousePosX, this.mousePosY - this.MPTop_margin, null, null);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   419
	}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   420
	
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   421
	//On met à jour l'ancienne position de la souris si elle est nulle.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   422
	if(!this.mousePosLastX && this.mousePosLastX != 0)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   423
	{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   424
		this.mousePosLastX = this.mousePosX;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   425
	}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   426
	if(!this.mousePosLastY && this.mousePosLastY != 0)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   427
	{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   428
		this.mousePosLastY = this.mousePosY;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   429
	}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   430
	
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   431
	//Le delta s'accroît si la souris bouge.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   432
	this.mouseUpDownDelta += Math.floor(Math.sqrt((this.mousePosLastX - e.pageX) * (this.mousePosLastX - e.pageX) + (this.mousePosLastY - e.pageY) * (this.mousePosLastY - e.pageY)));
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   433
	
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   434
	//On met à jour l'ancienne position de la souris.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   435
	if(this.mousePosLastX != this.mousePosX)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   436
	{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   437
		this.mousePosLastX = this.mousePosX;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   438
	}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   439
	if(this.mousePosLastY != this.mousePosY)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   440
	{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   441
		this.mousePosLastY = this.mousePosY;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   442
	}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   443
	
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   444
	//Si la souris a parcouru une trop grande distance, on entre en recherche.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   445
	if(this.mouseUpDownDelta > this.config.mouseUpDownDeltaTreshold)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   446
	{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   447
		//Si on est en mosaique, on entre en filtrage.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   448
		if(this.currentMode == "MOSAIC")
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   449
		{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   450
			this.preUnzoom();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   451
			this.currentMode = "FILTER";
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   452
			this.isMosaicFiltered = true;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   453
		}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   454
		//Si on est en mode de filtrage, mais qu'on n'est pas en tracé de courbes.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   455
		else if(this.currentMode == "FILTER" && !this.isSearchByCurvesOn && this.isUserInSearchZone)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   456
		{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   457
			//On lance une nouvelle recherche pas courbes.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   458
			this.preUnzoom();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   459
		}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   460
		//Si on est dans une vidéo, on entre en recherche.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   461
		else if(this.currentMode == "VIDEO" || this.currentMode == "TIMELINE")
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   462
		{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   463
			this.currentMode = "SEARCH";
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   464
		}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   465
		//Si on est en mode recherche dans une vidéo, mais qu'on n'est pas en tracé de courbes.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   466
		/*else if(this.currentMode == "SEARCH" && !this.isSearchByCurvesOn)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   467
		{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   468
			//On lance une nouvelle recherche pas courbes.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   469
		}*/
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   470
		
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   471
		if(this.currentMode != "NO-USER" && this.currentMode.indexOf("INCOMING") == -1 && !this.isSearchByCurvesOn)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   472
		{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   473
			this.isSearchByCurvesOn = true;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   474
			this.startSearch();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   475
			this.searchCanvas.onPointerIn(this.mousePosX, this.mousePosY - this.MPTop_margin, null, null);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   476
		}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   477
		
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   478
		//S'il n'est pas possible d'afficher l'aide.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   479
		if(!this.canNotifyHelp)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   480
		{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   481
			//On rend son affichage possible après un certain délai.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   482
			this.canNotifyHelpTimeout = setTimeout(function()
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   483
			{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   484
				_this.canNotifyHelp = true;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   485
			}, this.config.timeoutCanNotifyHelp);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   486
		}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   487
	}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   488
}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   489
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   490
/*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   491
 * Fonction appelée lors d'un mouse up en mode d'interaction souris.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   492
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   493
 * mosaic > fonction loadMosaic, attachée à l'événement jQuery mousemove.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   494
*/
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   495
Mosaic.prototype.onMouseUp = function()
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   496
{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   497
	this.isMouseDown = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   498
	
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   499
	//Si on était en train de tracer une courbe.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   500
	if(this.isSearchByCurvesOn)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   501
	{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   502
		//On quitte la zone de recherche.
58
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   503
		/*this.isUserInSearchZone = false;
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   504
		
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   505
		//On regarde si ce qu'on a tracé correspond à une courbe en particulier.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   506
		var gesture_match = this.gestureWithSameCode(this.actualCode);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   507
		this.actualCode = '';
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   508
		
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   509
		//Si oui.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   510
		if(gesture_match.length > 0)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   511
		{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   512
			//Si on est en mode recherche dans une vidéo et que le player est prêt.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   513
			if(this.currentMode == "SEARCH" && this.playerIsReady)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   514
			{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   515
				//On effectue une recherche dans cette vidéo.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   516
				this.player.widgets[0].searchByGesture(gesture_match);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   517
				this.isCurrentlyInASearchByGesture = this.player.widgets[0].isCurrentlyInASearchByGesture;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   518
				
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   519
				//On va au premier marqueur trouvé.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   520
				if(this.player && this.player.widgets[0] && this.timeToGoAt[this.centerId] === 0 && this.player.widgets[0].atLeastOneSearchMarker(this.currentSearchGesture[this.centerId]))
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   521
				{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   522
					this.player.widgets[0].goToFirstSearchedMarker(this.currentSearchGesture[this.centerId]);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   523
				}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   524
				
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   525
				//On affiche la notification de gesture de recherche.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   526
				this.removeNotifications();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   527
				this.currentSearchGesture[this.centerId] = gesture_match;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   528
				this.searchGesture(gesture_match, 'valid');
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   529
				this.curvesGesturesFound = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   530
			}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   531
			//Si on est en mode de filtrage de mosaique.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   532
			else if(this.currentMode == "FILTER")
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   533
			{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   534
				if(this.isMosaicFiltered)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   535
				{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   536
					//On notifie la recherche par filtrage.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   537
					this.removeNotifications();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   538
					this.filterSearchedType = gesture_match;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   539
					this.filterGesture(gesture_match, 'valid');
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   540
					//On filtre la mosaique.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   541
					this.searchFilter(gesture_match);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   542
					this.curvesGesturesFound = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   543
				}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   544
			}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   545
		}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   546
		//Si aucune gesture ne matche dans le dictionnaire.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   547
		else
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   548
		{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   549
			//Si on était en mode filtrage de la mosaïque et qu'aucune gesture de filtrage n'avait été détectée avant ca, on revient en mode mosaïque.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   550
			if(this.currentMode == "FILTER" && this.filterSearchedType == "")
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   551
			{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   552
				this.currentMode = "MOSAIC";
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   553
				this.isMosaicFiltered = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   554
			}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   555
			//Sinon si on était en mode recherche dans une video et qu'aucune gesture n'avait été détectée avant ca, on revient en mode video.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   556
			if(this.currentMode == "SEARCH" && this.currentSearchGesture[this.centerId] == "")
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   557
			{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   558
				this.currentMode = "VIDEO";
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   559
			}
58
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   560
		}*/
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   561
		//On dit au module de recherche qu'on arrête de tracer des courbes.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   562
		this.searchCanvas.onPointerOut();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   563
	}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   564
	
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   565
	this.mousePosLastX = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   566
	this.mousePosLastY = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   567
	
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   568
	//Si la distance parcourue par la souris entre le mouse down et le mouse up est inférieure ou égale au seuil.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   569
	if(this.mouseUpDownDelta <= this.config.mouseUpDownDeltaTreshold)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   570
	{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   571
		//Si on est sur un snapshot prézoomé.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   572
		if(this.isOnAPrezoomSN && this.previousZoomedSN != '' && (this.currentMode == 'MOSAIC' || this.currentMode == 'FILTER') && !this.isPrezooming)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   573
		{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   574
			this.zoom();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   575
		}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   576
	}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   577
	
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   578
	//On réinitialise le delta, on quitte la recherche par courbes.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   579
	this.mouseUpDownDelta = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   580
	this.isSearchByCurvesOn = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   581
	this.leaveSearch();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   582
	
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   583
	//Si on est en mode de filtrage et qu'on a une gesture de filtrage trouvée.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   584
	if(this.currentMode == 'FILTER' && this.filterSearchedType != '')
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   585
	{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   586
		//On notifie.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   587
		this.removeNotifications();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   588
		this.filterGesture(this.filterSearchedType, 'valid');
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   589
	}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   590
}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   591
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   592
/*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   593
 * Fonction appelée lors d'un clic en mode d'interaction souris.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   594
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   595
 * mosaic > fonction loadMosaic.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   596
*/
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   597
Mosaic.prototype.onClick = function(x, y)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   598
{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   599
	//Si la position de la souris entre le mouse down et le mouse up change de plus de 10px, on part.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   600
	if(!this.mouseDownPosX || !this.mouseDownPosY || Math.sqrt((this.mouseDownPosX - x) * (this.mouseDownPosX - x) + (this.mouseDownPosY - y) * (this.mouseDownPosY - y)) > 10)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   601
	{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   602
		return;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   603
	}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   604
	
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   605
	//Si on est dans un mode autre qu'un mode zoomé et qu'on n'affiche pas l'aide, on part.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   606
	if(this.currentMode != "VIDEO" && this.currentMode != "SEARCH" && this.currentMode != "TIMELINE" && !this.helpDisplayed)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   607
	{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   608
		return;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   609
	}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   610
	
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   611
	//Si on clique en dehors de la video centrale, alors on dézoome.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   612
	var TL = $('.Ldt-Timeline');
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   613
	var TLwidth = TL.width(), TLheight = TL.height();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   614
	var Ptop = $('.LdtPlayer').position().top, Pleft = $('.LdtPlayer').position().left;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   615
	var Pheight = $('.LdtPlayer').height();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   616
	var MPx = this.mousePosX, MPy = this.mousePosY;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   617
	
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   618
	//On regarde si on a cliqué sur un snapshot.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   619
	var SN = this.pointerPositionToSN(MPx - this.notifyLeftVideo, MPy - this.notifyTopVideo, true);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   620
	var SNId;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   621
	if(SN)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   622
	{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   623
		SNId = parseInt(SN.attr('id').replace('snapshotDiv-', ''));
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   624
	}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   625
	
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   626
	//Si on n'a pas demandé à supprimé la notification de gesture.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   627
	if(!this.gestureDelRequested && !this.helpDisplayed)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   628
	{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   629
		//Si non, ou s'il ne fait pas partie des voisins.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   630
		if(!SNId || !_.include(this.neighboursIds, SNId))
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   631
		{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   632
			//Si le clic a lieu en dehors du player et que l'aide n'est pas affichée, on dezoom.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   633
			if(MPx < Pleft || MPx > (+Pleft + TLwidth) || MPy < Ptop || MPy > (+Ptop + Pheight - TLheight))
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   634
			{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   635
				this.unzoom();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   636
			}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   637
		}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   638
		//Si on se trouve sur un voisin, on bouge.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   639
		else if(SNId && _.include(this.neighboursIds, SNId) && this.canMoveToNeighbour)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   640
		{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   641
			this.moveToNeighbour($('#snapshotDiv-' + SNId));
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   642
		}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   643
	}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   644
	//Si on l'a demandé, on enlève la demande de suppression.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   645
	else
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   646
	{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   647
		this.gestureDelRequested = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   648
	}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   649
	
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   650
	//Si l'aide est affichée, un clic la ferme.
55
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   651
	if(this.helpDisplayed && !this.isHelpIconZoomed && !this.isHelpIconZooming)
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   652
	{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   653
		this.removeHelp();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   654
	}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   655
}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   656
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   657
/*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   658
 * Permet de raffraichir la mosaïque.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   659
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   660
 * mosaic > fonction loadFromJson, afin de charger la mosaique une fois que les fichiers de métadonnées ont été lus.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   661
 */
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   662
Mosaic.prototype.loadMosaic = function()
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   663
{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   664
    // console.log('LOAD');
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   665
    var createMosaic = this.createMosaic();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   666
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   667
    if(createMosaic == '')
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   668
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   669
        return;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   670
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   671
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   672
    var _this = this;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   673
    
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   674
    //On affecte les chemins vers les images à la mosaïque.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   675
    this.previousZoomedSN;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   676
    //On met à jour la mosaïque.
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   677
    $('#mainPanel').html(createMosaic);
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   678
    //On récupère la taille des bordures.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   679
    this.marginWidth = $('.snapshotDivs').css('margin-bottom');
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   680
    this.marginWidth = parseFloat(this.marginWidth)*2;
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   681
    //On calcule la taille des divs contenant les snapshots.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   682
    this.width = $('#mainPanel').innerWidth();
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   683
    //On ne calculera pas tout de suite la hauteur de la mosaique étant donnée qu'elle est calculée par la suite dynamiquement.
55
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   684
    this.snapshotWidth = this.width / this.config.imagesByLine - this.marginWidth;
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   685
    this.snapshotHeight = this.snapshotWidth*9/16;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   686
    $('.snapshotDivs').css('width', this.snapshotWidth).css('height', this.snapshotHeight).css('margin', this.marginWidth/2);
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   687
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   688
    this.height = $('#mainPanel').innerHeight();
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   689
    //On centre verticalement la mosaïque.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   690
    this.MPTop_margin = ($(document).height() - $('#mainPanel').height())/2;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   691
    $('#mainPanel').css('margin-top', this.MPTop_margin).css('margin-bottom', this.MPTop_margin);
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   692
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   693
    //On fait coincider le background du body avec celui de la mosaïque.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   694
    $('body').css('background-position', '0px ' + this.MPTop_margin + 'px');
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   695
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   696
    this.addPointers();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   697
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   698
    //Si dans le metadata player _ n'est pas déclaré, on le déclare.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   699
    if(typeof _ !== "undefined" && typeof IriSP._ === "undefined")
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   700
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   701
        IriSP._ = _;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   702
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   703
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   704
    if(typeof $ !== "undefined" && typeof IriSP.jQuery === "undefined")
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   705
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   706
        IriSP.jQuery = $;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   707
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   708
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   709
    //On charge les marqueurs.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   710
    var sourceManager = new IriSP.Model.Directory(),
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   711
    globalAnnotations = new IriSP.Model.List(sourceManager),
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   712
    nbFichiers = _this.urls.length,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   713
    fichiersCharges = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   714
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   715
    //Récupère les annotations.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   716
    for (var i = 0; i < nbFichiers; i++)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   717
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   718
        _this.sources[i] = sourceManager.remoteSource({url: _this.urls[i], serializer: IriSP.serializers.ldt});
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   719
        _this.sources[i].onLoad(function()
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   720
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   721
            var source = this;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   722
            globalAnnotations.addElements(source.getAnnotations());
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   723
            fichiersCharges++;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   724
            if (fichiersCharges == nbFichiers)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   725
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   726
                //Instructions à exécuter quand tout est chargé.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   727
                _this.annotations = globalAnnotations;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   728
                // console.log(_this.annotations.length + ' annotations loaded from ' + nbFichiers + ' files.');
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   729
                
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   730
                //Si on gère les interactions à la souris.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   731
                if(_this.config.mouseInteractions)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   732
                {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   733
                    //On met à jour la position estimée de la souris.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   734
                    $(window).mousemove(function(e)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   735
                    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   736
                        // _this.refreshPointers(e.pageX, e.pageY, _this, true);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   737
                        _this.refreshPointers(e.pageX, e.pageY, true);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   738
                        _this.mousePosX = e.pageX;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   739
                        _this.mousePosY = e.pageY;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   740
                    });
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   741
                }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   742
                
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   743
                //Si on a activé la préphase mais qu'on est en mode Kinect.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   744
                if(_this.config.noUserModeEnabled && !_this.config.mouseInteractions)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   745
                {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   746
                    //On active la préphase.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   747
                    _this.init();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   748
                    _this.showNImages(0);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   749
                    _this.currentMode = "NO-USER";
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   750
                }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   751
                else
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   752
                {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   753
                    //Sinon on affiche directement la mosaique.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   754
                    _this.showNImages(20);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   755
                    _this.currentMode = "MOSAIC";
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   756
                }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   757
                
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   758
                //Le premier snapshot sur lequel on zoom en préphase.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   759
                _this.previousZoomedSN = $('#snapshotDiv-' + _this.fillingIds[0]);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   760
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   761
        });
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   762
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   763
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   764
    //Si on est en mode d'intéraction souris.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   765
    if(this.config.mouseInteractions)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   766
    {
55
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   767
		//On affiche l'icone d'aide.
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   768
		this.helpIcon();
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   769
		
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   770
        //Si on fait un mouse down sur le body, on vérifie enregistre le déplacement de la souris jusqu'au prochain mouse up.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   771
        $(window).mousedown(function (e)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   772
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   773
			_this.onMouseDown(e);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   774
			return false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   775
        });
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   776
		
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   777
		//On écoute le déplacement de la souris.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   778
		$(window).mousemove(function(e)
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   779
		{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   780
			_this.onMouseMove(e);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   781
			return false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   782
		});
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   783
		
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   784
		//Si on fait un mouse up après ce mouse down.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   785
		$(window).mouseup(function()
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   786
		{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   787
			_this.onMouseUp();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   788
			return false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   789
		});
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   790
		
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   791
		//Si on fait un clic.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   792
		$(window).click(function(e)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   793
		{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   794
			_this.onClick(e.pageX, e.pageY);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   795
			_this.removeSearchNotificationIfOnIt(e.pageX, e.pageY);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   796
			return false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   797
		});
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   798
		
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   799
		$(window).on('mousewheel', function(event, delta, deltaX, deltaY)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   800
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   801
			//Si on est dans un mode autre qu'on mode zoomé ou que l'aide est affichée, on part.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   802
			if(_this.currentMode != "VIDEO" && _this.currentMode != "SEARCH" && _this.currentMode != "TIMELINE" || _this.helpDisplayed)
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   803
			{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   804
				return;
45
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
   805
			}
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
   806
			
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   807
            //Quand on "tire" la molette vers soi, on dezoom.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   808
            if (delta < 0)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   809
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   810
                _this.unzoom();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   811
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   812
        });
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   813
    }
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   814
}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   815
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   816
/*
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   817
 * Charge les paramètres du Front. Local (true/false) est le mode de chargement des données.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   818
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   819
 * mosaic > fonction Mosaic, est appelée dans le constructeur de manière à charger les paramètres de configuration avant la création de la mosaique.
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   820
*/
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   821
Mosaic.prototype.loadParameters = function(file_path)
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   822
{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   823
    var _this = this;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   824
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   825
    //Variables censées être des ints.
58
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   826
    var supposedToBeInt = ['imagesByLine', 'imagesToShow', 'totalImages', 'timeReloadAfterResize', 'timePrezoom', 'timePreUnzoom', 'zoomTime', 'timeUnzoom', 'timeNeighbourGlowing', 'timeNeighbourUnglowing', 'timeMovingToNeighbour', 'timeSearchFade', 'timeNotifyFade', 'timeFilterFade', 'timeANFade', 'timeFilling', 'zoomedMargin', 'timeoutZoom', 'timeoutUnzoom', 'timeoutMoveToNeighbour', 'timeoutPointersIdle', 'timeoutAreBothPointersHere', 'timeoutRemoveNotificationByGesture', 'timeoutNotifySwipe', 'timeoutSelectTL', 'timeoutSlideTL', 'timeoutCanNotifyHelp', 'timeoutRemoveSpinner', 'timeoutNouser', 'timeoutNextDrawCurve', 'mouseUpDownDeltaTreshold', 'kinectUpDownDeltaTreshold', 'helpBorderSize'];
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   827
    //Variables censées êtres des floats.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   828
    var supposedToBeFloat = ['zoomPercentage', 'prezoomPercentage'];
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   829
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   830
    //On lit le fichier de configuration.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   831
    $.getJSON(file_path, function(data)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   832
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   833
        //Pour chaque ligne du fichier.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   834
        for(key in data)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   835
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   836
            var val = data[key];
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   837
            
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   838
            //Si la valeur est prise pour un int.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   839
            if(_.include(supposedToBeInt, key))
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   840
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   841
                //On la parse et s'il y a une erreur, on l'indique dans la console avant d'affecter la valeur par défaut.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   842
                //Sinon on lui affecte la valeur lue.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   843
                var intVal = parseInt(val);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   844
                if(isNaN(intVal))
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   845
                {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   846
                    _this.config[key] = _this.default_config[key];
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   847
                    console.log("param[" + key + "] : Valeur " + val + " incorrecte (non Int). Valeur par défaut " + _this.default_config[key] + " chargée à la place.");
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   848
                }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   849
                else
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   850
                {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   851
                    _this.config[key] = intVal;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   852
                }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   853
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   854
            //Si la valeur est prise pour un float.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   855
            else if(_.include(supposedToBeFloat, key))
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   856
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   857
                //On la parse et s'il y a une erreur, on l'indique dans la console avant d'affecter la valeur par défaut.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   858
                //Sinon on lui affecte la valeur lue.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   859
                var floatVal = parseFloat(val);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   860
                if(isNaN(floatVal))
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   861
                {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   862
                    _this.config[key] = _this.default_config[key];
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   863
                    console.log("param[" + key + "] : Valeur " + val + " incorrecte (non Float). Valeur par défaut " + _this.default_config[key] + " chargée à la place.");
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   864
                }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   865
                else
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   866
                {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   867
                    _this.config[key] = floatVal;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   868
                }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   869
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   870
            else
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   871
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   872
				//S'il s'agit de la langue, on met par défaut si la valeur est nulle.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   873
				if(key == 'lang' && val == '')
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   874
				{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   875
					_this.config[key] = _this.default_config[key];
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   876
				}
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   877
                //Sinon si c'est une string, on l'affecte.
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   878
				else
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   879
				{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   880
					_this.config[key] = val;
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   881
				}
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   882
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   883
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   884
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   885
        //On remplit le tableau d'ids.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   886
        for(var i = 0 ; i < _this.config.totalImages ; i++)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   887
            _this.ids.push(i);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   888
        //On les mélange.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   889
        _this.ids = _.shuffle(_this.ids);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   890
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   891
        //On remplit le tableau d'ids destiné à afficher les snapshots au fur et à mesure.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   892
        for(var i = 0 ; i < _this.config.imagesToShow ; i++)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   893
            _this.fillingIds.push(i);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   894
        //On les mélange.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   895
        _this.fillingIds = _.shuffle(_this.fillingIds);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   896
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   897
        //Si la config spécifie le chargement comme étant local/en ligne, on charge le fichier des vidéos approprié.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   898
        if(_this.config.local)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   899
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   900
            _this.loadFromJson(_this.config.videoConfigFileLocal);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   901
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   902
        else
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   903
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   904
            _this.loadFromJson(_this.config.videoConfigFileOnline);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   905
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   906
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   907
        //On initialise le client dans le cas d'intéractions Kinect.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   908
        if(!_this.config.mouseInteractions)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   909
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   910
            _this.client = new Client(_this.config.host, _this.config.port, _this);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   911
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   912
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   913
        //On prend le dictionnaire stockant les codes des courbes de recherche.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   914
        _this.getDictionary();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   915
        //On charge le fichier des langues.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   916
        _this.getLang();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   917
    });
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   918
}
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   919
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   920
/*
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   921
 * Phase principale (utilisateur non détecté). Une vidéo se lance aléatoirement.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   922
 * L'interface est identique à celle du zoom, mais sans interaction possible avec les voisins, ni les controles timeline.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   923
 * Lors de la fin d'une lecture, on dézoome vers la mosaïque, puis on rezoome vers un autre snapshot (aléatoire).
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   924
 * Est appelé dans les fichiers :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   925
 * mosaic > fonction loadMosaic.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   926
 * zoomInteractions > fonction unzoom.
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   927
*/
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   928
Mosaic.prototype.init = function()
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   929
{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   930
    var _this = this;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   931
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   932
    //Si l'index de lecture des vidéos en mode sans utilisateur excède le nombre maximal de vidéos, il est remis à 0 pour tourner en boucle.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   933
    if(this.currentRandomVideoIdx > this.config.imagesToShow)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   934
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   935
        this.currentRandomVideoIdx = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   936
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   937
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   938
    //Le snapshot sur lequel on doit zoomé a pour id le tableau de lecture aléatoire à l'index de lecture.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   939
    this.previousZoomedSN = $('#snapshotDiv-' + this.fillingIds[this.currentRandomVideoIdx]);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   940
    this.previousId = $('img', this.previousZoomedSN).attr('id');
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   941
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   942
    //On fait apparaître le snapshot avant de zoomer dessus.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   943
    this.previousZoomedSN.fadeTo(this.config.timePrezoom, 1, function()
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   944
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   945
        _this.zoom();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   946
        _this.currentRandomVideoIdx++;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   947
    });
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   948
}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   949
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   950
/*
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   951
 * Remplissage de la mosaïque en fonction du nombre d'images à afficher.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   952
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   953
 * mosaic > fonctions loadMosaic et manageControlEvents.
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   954
*/
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   955
Mosaic.prototype.showNImages = function(n)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   956
{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   957
    //Si on bouge vers un voisin, on n'utilise pas cette fonction.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   958
    if(this.currentlyMoving)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   959
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   960
        return;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   961
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   962
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   963
    //Si il y a plus d'un snapshot à afficher, on entre dans le mode INCOMING avec en paramètre le nombre à afficher.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   964
    if(n > 1 && n < this.config.imagesToShow)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   965
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   966
        //On met en mode incoming avec le nombre de snapshots à afficher.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   967
        this.currentMode = "INCOMING-" + n;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   968
        //On dézoom.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   969
        this.unzoom();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   970
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   971
        //On initialise les gestures de recherche.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   972
        for(var i = 0 ; i < this.config.imagesToShow ; i++)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   973
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   974
            this.currentSearchGesture[i] = '';
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   975
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   976
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   977
        //On enlève les notifications.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   978
        this.removeNotifications();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   979
        //On annule les recherches.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   980
        this.isMosaicFiltered = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   981
        this.isCurrentlyInASearchByGesture = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   982
        //On masque les pointeurs.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   983
        $('#mainPointer').fadeTo(this.config.timePrezoom, 0);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   984
        $('#secondPointer').fadeTo(this.config.timePrezoom, 0);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   985
        //On enlève le spinner.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   986
        $('#spinner').remove();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   987
        //On déselectionne tous les voisins.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   988
        this.deselectAllNeighbours();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   989
        //On enlève tous les prézooms en cours.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   990
        $('.prezoomContainers').remove();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   991
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   992
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   993
    //Si on doit afficher la mosaique complète.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   994
    if(n >= this.config.imagesToShow)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   995
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   996
        //Si on est en mode sans utilisateur ou bien en mode d'utilisateur approchant.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   997
        if(this.currentMode == "NO-USER" || this.currentMode.indexOf("INCOMING-") > -1)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   998
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   999
            //Si on est en intéractions Kinect.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1000
            if(!this.config.mouseInteractions)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1001
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1002
                //On met le mode à jour.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1003
                this.currentMode = "INCOMING-20";
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1004
                //On dézoom.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1005
                this.unzoom();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1006
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1007
            
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1008
            //On passe en mode mosaique.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1009
            this.currentMode = "MOSAIC";
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1010
            //On enlève les notifications, et on met les notifications de sélection et de recherche.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1011
            this.removeNotifications();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1012
            this.mosaicSelectionAndSearch();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1013
            //On retarde le mécanisme de redémarrage.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1014
            clearTimeout(this.nouserTimeout);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1015
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1016
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1017
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1018
    //Pour les snapshots à afficher.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1019
    for(var i = 0 ; i < n ; i++)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1020
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1021
        //Si les snapshots ne sont pas affichés.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1022
        if($('#snapshotDiv-' + this.fillingIds[i]).css('opacity') < 1)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1023
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1024
            //On les fait apparaître.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1025
            $('#snapshotDiv-' + this.fillingIds[i]).fadeTo(this.config.timeFilling, '1');
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1026
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1027
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1028
    //Pour ceux à masquer.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1029
    for(var i = n ; i < this.config.imagesToShow ; i++)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1030
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1031
        //Si les snapshots ne sont pas masqués et qu'il ne s'agit pas du dernier snapshot en lecture aléatoire (mode NO-USER).
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1032
        if($('#snapshotDiv-' + this.fillingIds[i]).css('opacity') > 0 && this.fillingIds[i] != this.currentRandomVideoIdx)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1033
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1034
            //On les masque.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1035
            $('#snapshotDiv-' + this.fillingIds[i]).fadeTo(this.config.timeFilling, '0');
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1036
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1037
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1038
}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1039
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1040
/*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1041
 * Gère les événements de contrôle dans la mosaïque.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1042
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1043
 * client > fonction processMsg.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1044
*/
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1045
Mosaic.prototype.manageControlEvents = function(event)
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1046
{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1047
    var _this = this;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1048
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1049
    if(typeof event === 'undefined')
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1050
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1051
        return;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1052
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1053
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1054
    var gestureReceived = '';
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1055
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1056
    //Si l'utilisateur arrive et qu'on a la préphase activée.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1057
    if(event.indexOf("INCOMING-") != -1 && this.config.noUserModeEnabled)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1058
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1059
        //Si on peut démarrer.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1060
        if(this.canStart)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1061
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1062
            //Si on veut afficher plus de snapshots que disponibles, on affiche le maximum.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1063
            if(this.snapshotsToShow > this.config.imagesToShow)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1064
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1065
                this.snapshotsToShow = this.config.imagesToShow;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1066
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1067
            else
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1068
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1069
                //On récupère le nombre de snapshots à afficher.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1070
                var params = event.split('-');
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1071
                this.snapshotsToShow = params[1];
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1072
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1073
            
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1074
            //Si la position de l'utilisateur a changé.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1075
            if(event != this.lastIncomingMessage)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1076
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1077
                //On la met à jour et on affiche la mosaique en conséquence.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1078
                this.lastIncomingMessage = event;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1079
                this.showNImages(this.snapshotsToShow);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1080
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1081
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1082
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1083
        //On retarde le mécanisme de redémarrage.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1084
        clearTimeout(this.nouserTimeout);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1085
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1086
        //Après un délai d'absence de l'utilisateur on redémarre.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1087
        this.nouserTimeout = setTimeout(function()
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1088
        {
58
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
  1089
            // window.location.reload();
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1090
        }, this.config.timeoutNouser);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1091
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1092
    //S'il n'y a qu'un snapshot à afficher et qu'on est en préphase, on redémarre.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1093
    else if((event == "NO-USER" || event == "INCOMING-0" || event == "INCOMING-1") && this.config.noUserModeEnabled)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1094
    {
58
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
  1095
        // window.location.reload();
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1096
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1097
    //Si on a fait un swipe.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1098
    else if(event.indexOf("SWIPE") != -1)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1099
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1100
        //Si le player est près et qu'on n'est pas en train de faire un swipe.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1101
        if(this.player && this.player.widgets && this.playerIsReady && !this.isSwipe)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1102
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1103
            //On est en train de faire un swipe.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1104
            this.isSwipe = true;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1105
            
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1106
            //Si on est en mode de recherche, que la mosaique est filtrée et qu'on est arrivé au dernier marqueur.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1107
            if(this.currentMode == 'SEARCH' && this.isMosaicFiltered && !this.player.widgets[0].isAMarkerAhead(this.currentSearchGesture[this.centerId]))
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1108
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1109
                //On passe à la prochaine vidéo qui contient des résultats.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1110
                this.playNextVideo();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1111
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1112
            
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1113
			//On spécifie s'il s'agit d'un swipe left ou right.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1114
			var swipeType = ((event.indexOf("LEFT") != -1) ? 'left' : 'right');
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1115
			var isSwipeLeft = ((event.indexOf("LEFT") != -1) ? true : false);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1116
			
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1117
			//On passe au marqueur suivant/précédent en fonction du type de swipe.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1118
			this.player.widgets[0].switchToMarker(isSwipeLeft, this.currentSearchGesture[this.centerId]);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1119
			//Si on est en mode vidéo.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1120
			if(this.currentMode == 'VIDEO')
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1121
			{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1122
				//On affiche la notification.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1123
				this.removeNotifications();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1124
				this.videoSwipe(swipeType);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1125
			}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1126
			//Si on est en mode recherche dans une vidéo et qu'on n'a pas de gesture de recherche.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1127
			else if(this.currentMode == 'SEARCH' && this.currentSearchGesture[this.centerId] == '')
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1128
			{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1129
				//On affiche la notification.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1130
				this.removeNotifications();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1131
				this.searchSearchAndSwipe(swipeType);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1132
			}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1133
			//Si on est en mode recherche dans une vidéo et qu'on a une gesture de recherche.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1134
			else if(this.currentMode == 'SEARCH' && this.currentSearchGesture[this.centerId] != '')
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1135
			{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1136
				//On affiche la notification.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1137
				this.removeNotifications();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1138
				this.searchGestureAndSwipe(this.currentSearchGesture[this.centerId], 'valid', swipeType);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1139
			}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1140
            
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1141
            //On le fait disparaitre au bout d'un certain temps.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1142
            this.notifySwipeTimeout = setTimeout(function()
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1143
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1144
                _this.isSwipe = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1145
                _this.removeNotifications();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1146
                
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1147
                //Si on est en mode de recherche dans une vidéo et qu'aucune gesture n'est recherchée.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1148
                if(_this.currentMode == 'SEARCH' && _this.currentSearchGesture[_this.centerId] == '')
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1149
                {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1150
                    _this.searchSearch();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1151
                }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1152
                //Si on est en mode de recherche dans une vidéo et qu'on a une recherche par gesture.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1153
                else if(_this.currentMode == 'SEARCH' && _this.currentSearchGesture[_this.centerId] != '')
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1154
                {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1155
                    _this.searchGesture(_this.currentSearchGesture[_this.centerId], 'valid');
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1156
                }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1157
                
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1158
            }, this.config.timeoutNotifySwipe);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1159
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1160
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1161
    //Si on reçoit l'instruction correspondant à une des quatre gestures de recherche corporelle.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1162
    else if(event.indexOf("BEND") != -1 || event.indexOf('KNEE-UP') != -1 || event.indexOf('FALL') != -1 || event.indexOf('JUMP') != -1)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1163
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1164
        //On la met en minuscule.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1165
        gestureReceived = event.toLowerCase();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1166
        //On met à jour la gesture recherchée.
58
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
  1167
        this.currentSearchGesture[this.centerId] = gestureReceived;
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1168
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1169
    //Si on a effectué un hello, qu'on peut notifier l'aide et que les deux mains ne sont pas dans la zone de recherche.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1170
    else if(event.indexOf("HELLO") != -1 && this.canNotifyHelp && !this.areBothPointersHere)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1171
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1172
        //On affiche différentes aides en fonction de si on se trouve dans une vidéo ou non.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1173
        if(this.currentMode == 'SEARCH')
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1174
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1175
            this.notifyHelp(false);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1176
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1177
        else if(this.currentMode == 'FILTER')
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1178
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1179
            this.notifyHelp(true);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1180
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1181
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1182
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1183
    //Si on a reçu une gesture.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1184
    if(gestureReceived != '')
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1185
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1186
        //Si on est en mode recherche et que le player est prêt.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1187
        if(this.currentMode == "SEARCH" && this.playerIsReady)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1188
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1189
            //On recherche dans la vidéo.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1190
            this.player.widgets[0].searchByGesture(gestureReceived);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1191
            this.isCurrentlyInASearchByGesture = this.player.widgets[0].isCurrentlyInASearchByGesture;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1192
            //On notifie.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1193
            this.removeNotifications();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1194
            this.searchGesture(gestureReceived, 'valid');
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1195
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1196
        //Si on est dans un filtrage.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1197
        else if(this.currentMode == "FILTER")
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1198
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1199
            if(this.isMosaicFiltered)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1200
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1201
                //On notifie et on filtre.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1202
                this.removeNotifications();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1203
                this.filterGesture(gestureReceived, 'valid');
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1204
                this.searchFilter(gestureReceived);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1205
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1206
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1207
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1208
        //Si l'aide est affichée, on l'enlève.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1209
        if(this.helpDisplayed)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1210
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1211
            this.removeHelp();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1212
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1213
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1214
}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1215
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1216
/*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1217
 * Fonction qui s'exécute lorsque le player a chargé.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1218
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1219
 * mosaic > fonction loadPlayer.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1220
*/
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1221
Mosaic.prototype.onPlayerLoad = function()
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1222
{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1223
	var _this = this;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1224
	
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1225
	if(this.currentMode == 'NO-USER')
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1226
	{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1227
		//On peut s'approcher de la kinect.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1228
		this.canStart = true;
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1229
	}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1230
	
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1231
	//Lorsque le player est en pause (par exemple lorsque le curseur arrive à la fin de la timeline).
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1232
	if(this.player.popcorn)
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1233
	{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1234
		this.player.popcorn.listen('pause', function()
47
4e1ee94d70b1 Front IDILL:
bastiena
parents: 46
diff changeset
  1235
		{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1236
			//Si la pause est naturelle (fin de la timeline, dézoom, déplacement vers un voisin).
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1237
			if(!_this.userPaused)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1238
			{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1239
				//Si c'est en mode sans utilisateur.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1240
				if(_this.currentMode == 'NO-USER')
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1241
				{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1242
					//On dézoome.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1243
					_this.unzoom();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1244
				}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1245
				//Sinon, si ce n'est pas causé par un déplacement ou un dézoom.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1246
				else if(!_this.currentlyMoving && !_this.currentlyUnzooming)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1247
				{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1248
					//Si on est en mode timeline et qu'on est en pause, c'est probablement que l'user a placé le curseur à la fin.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1249
					if(_this.currentMode != 'TIMELINE')
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1250
					{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1251
						_this.playNextVideo();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1252
					}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1253
				}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1254
			}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1255
		});
47
4e1ee94d70b1 Front IDILL:
bastiena
parents: 46
diff changeset
  1256
		
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1257
		//Si les marqueurs ont été chargés.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1258
		this.player.popcorn.on("markersready", function()
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1259
		{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1260
			_this.onMarkersReady();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1261
		});
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1262
	}
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1263
}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1264
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1265
/*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1266
 * Fonction qui s'exécute lorsque les marqueurs d'une video on été placés.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1267
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1268
 * mosaic > fonction onPlayerLoad.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1269
*/
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1270
Mosaic.prototype.onMarkersReady = function()
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1271
{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1272
	var _this = this;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1273
	
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1274
	//Le player est prêt.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1275
	this.playerIsReady = true;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1276
	
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1277
	if(this.player.widgets[0])
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1278
	{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1279
		//On spécifie à la timeline dans quel mode d'intéraction on est.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1280
		this.player.widgets[0].setMouseInteractions(this.config.mouseInteractions);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1281
		//Idem pour la langue.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1282
		if(this.gesturesText.length > 0)
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1283
		{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1284
			this.player.widgets[0].setLang(this.gesturesText);
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1285
		}
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1286
	}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1287
	
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1288
	//Si on est en mode video ou recherche ou timeline.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1289
	if(this.currentMode == 'VIDEO' || this.currentMode == 'SEARCH' || this.currentMode == 'TIMELINE')
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1290
	{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1291
		//On peut faire des swipes.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1292
		this.canSwipe = true;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1293
	}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1294
	
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1295
	//Si aucune recherche par gesture n'est effectuée.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1296
	if(this.currentSearchGesture[this.centerId] == '')
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1297
	{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1298
		//On enlève le filtre.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1299
		this.removeFilter();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1300
	}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1301
	//Sinon.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1302
	else
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1303
	{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1304
		//On entre en mode recherche dans une vidéo.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1305
		this.currentMode = 'SEARCH';
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1306
		//On recherche la gesture.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1307
		this.player.widgets[0].searchByGesture(this.currentSearchGesture[this.centerId]);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1308
		this.isCurrentlyInASearchByGesture = this.player.widgets[0].isCurrentlyInASearchByGesture;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1309
		
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1310
		//On va au premier marqueur trouvé.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1311
		if(this.timeToGoAt[this.centerId] === 0 && this.player.widgets[0].atLeastOneSearchMarker(this.currentSearchGesture[this.centerId]))
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1312
		{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1313
			this.player.widgets[0].goToFirstSearchedMarker(this.currentSearchGesture[this.centerId]);
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1314
		}
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1315
		//Si aucun marqueur n'est trouvé.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1316
		else
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1317
		{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1318
			//On va juste là où on était la dernière fois qu'on a joué la vidéo.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1319
			this.player.popcorn.currentTime(this.timeToGoAt[this.centerId]);
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1320
		}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1321
	}
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1322
}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1323
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1324
/*
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1325
 * Chargement du player basé sur le metadataplayer.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1326
 * Est appelé dans les fichiers :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1327
 * neighbours > fonction moveToNeighbour.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1328
 * zoomInteractions > zoom.
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1329
*/
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1330
Mosaic.prototype.loadPlayer = function(newZoomTop, newZoomLeft, newSnWidth, newSnHeight, zoomTop, zoomLeft, timeToGo)
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1331
{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1332
    var _this = this;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1333
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1334
    //On configure les options de lancement.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1335
    IriSP.libFiles.defaultDir = "../lib/";
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1336
    IriSP.widgetsDir = "./player/metadataplayer/"
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1337
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1338
    var videoToPlay = this.videos[this.centerId];
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1339
    var currentMetadata = this.urls[this.centerId];
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1340
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1341
    var _metadata = {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1342
        url: currentMetadata,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1343
        format: 'ldt'
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1344
    };
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1345
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1346
    var _config = {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1347
        gui: {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1348
            zoomTop: zoomTop - this.marginWidth*2,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1349
            zoomLeft: zoomLeft,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1350
            width: newSnWidth,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1351
            height: newSnHeight,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1352
            container: 'LdtPlayer',
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1353
            default_options: {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1354
                metadata: _metadata
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1355
            },
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1356
            css:'./player/metadataplayer/LdtPlayer-core.css',
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1357
            widgets: [
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1358
                {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1359
                    type: "Timeline"
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1360
                }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1361
            ]
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1362
        },
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1363
        player:{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1364
            type: 'html5', // player type
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1365
            video: videoToPlay,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1366
            live: true,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1367
            height: newSnHeight,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1368
            width: newSnWidth,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1369
            autostart: true
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1370
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1371
    };
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1372
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1373
    //On positionne le player.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1374
    $('.LdtPlayer').css(
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1375
    {
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1376
        position: 'absolute',
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1377
        'background-color': '#000000',
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1378
        top: newZoomTop,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1379
        left: newZoomLeft
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1380
    });
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1381
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1382
    //On démarre le player.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1383
    this.player = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1384
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1385
    this.player = new IriSP.Metadataplayer(_config, _metadata);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1386
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1387
    this.player.onLoad(function()
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1388
    {
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1389
        _this.onPlayerLoad();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1390
    });
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1391
}
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1392
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1393
/*
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1394
 * Charge les vidéos, les snapshots et les annotations depuis un fichier json.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1395
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1396
 * mosaic > fonction loadParameters.
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1397
*/
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1398
Mosaic.prototype.loadFromJson = function(path)
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1399
{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1400
    var _this = this;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1401
    var i = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1402
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1403
    //On ouvre le fichier contenant les vidéos et les adresses des métadonnées.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1404
    $.getJSON(path, function(data)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1405
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1406
        $.each(data, function(key, val)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1407
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1408
            $.each(val, function(key_video, val_video)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1409
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1410
                //On extrait les métadonnées.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1411
                $.getJSON(val_video.metadata, function(meta)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1412
                {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1413
                    //Si on est en chargement local.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1414
                    if(_this.config.local)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1415
                    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1416
                        //On cherche les vidéos dans les métadonnées.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1417
                        _this.affectVideoById(val_video.metadata, meta.medias[0].url.replace('rtmp://media.iri.centrepompidou.fr/ddc_player/', './player/videos/').replace('mp4:', '').replace('video/', '').replace('ldtplatform/', '').replace('.m4v', '.mp4'));
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1418
                    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1419
                    //Si on est en chargement en ligne.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1420
                    else
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1421
                    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1422
                        //On met l'adresse des videos en ligne.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1423
                        _this.affectVideoById(val_video.metadata, meta.medias[0].url.replace('rtmp://', 'http://').replace('/ddc_player/', '/').replace('mp4:', '').replace('.m4v', '.mp4'));
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1424
                    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1425
                });
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1426
                
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1427
                //On affecte les images et métadonnées.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1428
                _this.imgs[_this.ids[i]] = val_video.snapshot;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1429
                _this.urls[_this.ids[i]] = val_video.metadata;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1430
                //Au départ, on commence à 0 ms dans les vidéos.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1431
                _this.timeToGoAt[_this.ids[i]] = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1432
                i++;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1433
            });
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1434
        });
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1435
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1436
        //On charge la mosaique.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1437
        _this.loadMosaic();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1438
    });
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1439
}
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1440
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1441
/*
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1442
 * Affecte une vidéo au tableau des vidéos selon son id.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1443
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1444
 * mosaic > fonction loadFromJson.
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1445
*/
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1446
Mosaic.prototype.affectVideoById = function(metadata_id, video)
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1447
{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1448
    for (i = 0 ; i < this.urls.length ; i++)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1449
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1450
        if(this.urls[i] == metadata_id)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1451
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1452
            this.videos[i] = video;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1453
            break;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1454
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1455
    }
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1456
}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1457
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1458
/*
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1459
 * Affiche la date actuelle pour l'affichage de messages dans la console.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1460
 * Est appelé dans chaque console.log() où on veut afficher la date à laquelle l'instruction est exécutée.
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1461
*/
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
  1462
Mosaic.prototype.date = function()
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1463
{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1464
   var date, h, min, s;
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1465
   date = new Date();
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1466
   h = date.getHours();
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1467
   min = date.getMinutes();
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1468
   s = date.getSeconds();
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1469
   if (h < 10)
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1470
      h = "0" + h;
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1471
   if (min < 10)
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1472
      min = "0" + min;
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1473
   if (s < 10)
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1474
      s = "0" + s;
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1475
   return (h + ":" + min + ":" + s);
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1476
};