front_idill/src/mosaic/js/mosaic.js
changeset 47 4e1ee94d70b1
parent 46 9d7a2aa112fb
child 52 277c94533395
equal deleted inserted replaced
46:9d7a2aa112fb 47:4e1ee94d70b1
   195 	this.lastNonNullSN = null;
   195 	this.lastNonNullSN = null;
   196 	//Largeur de la marge pour le centrage vertical de la mosaïque.
   196 	//Largeur de la marge pour le centrage vertical de la mosaïque.
   197 	this.MPTop_margin;
   197 	this.MPTop_margin;
   198 	this.top_margin;
   198 	this.top_margin;
   199 	
   199 	
   200 	//Gesture actuellement cherchée.
   200 	//Gestures actuellement cherchées dans les vidéos.
   201 	this.currentSearchGesture = '';
   201 	this.currentSearchGesture = [];
   202 	
   202 	
   203 	//Mosaïque locale.
   203 	//Mosaïque locale.
   204 	this.localMos;
   204 	this.localMos;
   205 	//Position des voisins lors d'un zoom.
   205 	//Position des voisins lors d'un zoom.
   206 	this.neighboursIds = [];
   206 	this.neighboursIds = [];
   272 		{
   272 		{
   273 			for(var i = 0 ; i < imgs ; i++)
   273 			for(var i = 0 ; i < imgs ; i++)
   274 			{
   274 			{
   275 				//On charge les images de petite taille pour ne pas surcharger la mosaïque lors de l'affichage global.
   275 				//On charge les images de petite taille pour ne pas surcharger la mosaïque lors de l'affichage global.
   276 				str += '<div id="snapshotDiv-' + i + '" class="snapshotDivs" style="opacity: 0;"><img id="snapshot-' + i + '" class="snapshots" src="snapshots-little/' + this.imgs[i] + '" /></div>';
   276 				str += '<div id="snapshotDiv-' + i + '" class="snapshotDivs" style="opacity: 0;"><img id="snapshot-' + i + '" class="snapshots" src="snapshots-little/' + this.imgs[i] + '" /></div>';
       
   277 				//Au départ aucune vidéo n'a de gesture de recherche.
       
   278 				this.currentSearchGesture[i] = '';
   277 			}
   279 			}
   278 		}
   280 		}
   279 		
   281 		
   280 		return str + '<div id="ghostPanel"></div>';
   282 		return str + '<div id="ghostPanel"></div>';
   281 	}
   283 	}
   396 				//_this.isSearchByCurvesOn = true;
   398 				//_this.isSearchByCurvesOn = true;
   397 				// _this.startSearch();
   399 				// _this.startSearch();
   398 				// console.log('CANVAS READY');
   400 				// console.log('CANVAS READY');
   399 				// /!\ //
   401 				// /!\ //
   400 				
   402 				
   401 				/*_this.currentSearchGesture = 'bend';
       
   402 				_this.currentMode = 'FILTER';
       
   403 				_this.searchFilter('bend');*/
       
   404 				
       
   405 				_this.previousZoomedSN = $('#snapshotDiv-' + _this.fillingIds[0]);
   403 				_this.previousZoomedSN = $('#snapshotDiv-' + _this.fillingIds[0]);
   406 			}
   404 			}
   407 		});
   405 		});
   408 	}
   406 	}
   409 	
   407 	
   468 						_this.isSearchByCurvesOn = true;
   466 						_this.isSearchByCurvesOn = true;
   469 						_this.startSearch();
   467 						_this.startSearch();
   470 						
   468 						
   471 						/*if(!_this.curvesGesturesFound)
   469 						/*if(!_this.curvesGesturesFound)
   472 						{
   470 						{
   473 							$('.notifications').remove();
   471 							this.removeNotifications();
   474 							_this.filterSearch();
   472 							_this.filterSearch();
   475 						}*/
   473 						}*/
   476 						
   474 						
   477 						_this.searchCanvas.onPointerIn(_this.mousePosX, _this.mousePosY - _this.MPTop_margin, null, null);
   475 						_this.searchCanvas.onPointerIn(_this.mousePosX, _this.mousePosY - _this.MPTop_margin, null, null);
   478 					}
   476 					}
   494 						_this.isSearchByCurvesOn = true;
   492 						_this.isSearchByCurvesOn = true;
   495 						_this.startSearch();
   493 						_this.startSearch();
   496 						
   494 						
   497 						/*if(!_this.curvesGesturesFound)
   495 						/*if(!_this.curvesGesturesFound)
   498 						{
   496 						{
   499 							$('.notifications').remove();
   497 							this.removeNotifications();
   500 							_this.searchSearch();
   498 							_this.searchSearch();
   501 						}*/
   499 						}*/
   502 						
   500 						
   503 						_this.searchCanvas.onPointerIn(_this.mousePosX, _this.mousePosY - _this.MPTop_margin, null, null);
   501 						_this.searchCanvas.onPointerIn(_this.mousePosX, _this.mousePosY - _this.MPTop_margin, null, null);
   504 					}
   502 					}
   537 						if(_this.currentMode == "SEARCH" && _this.playerIsReady)
   535 						if(_this.currentMode == "SEARCH" && _this.playerIsReady)
   538 						{
   536 						{
   539 							_this.player.widgets[0].searchByGesture(gesture_match);
   537 							_this.player.widgets[0].searchByGesture(gesture_match);
   540 							_this.isCurrentlyInASearchByGesture = _this.player.widgets[0].isCurrentlyInASearchByGesture;
   538 							_this.isCurrentlyInASearchByGesture = _this.player.widgets[0].isCurrentlyInASearchByGesture;
   541 							
   539 							
   542 							$('.notifications').remove();
   540 							if(_this.player && _this.player.widgets[0] && _this.timeToGoAt[_this.centerId] === 0 && _this.player.widgets[0].atLeastOneSearchMarker(_this.currentSearchGesture[_this.centerId]))
       
   541 							{
       
   542 								_this.player.widgets[0].goToFirstSearchedMarker(_this.currentSearchGesture[_this.centerId]);
       
   543 							}
       
   544 							
       
   545 							_this.removeNotifications();
       
   546 							_this.currentSearchGesture[_this.centerId] = gesture_match;
   543 							_this.searchGesture(gesture_match, 'valid');
   547 							_this.searchGesture(gesture_match, 'valid');
   544 							_this.curvesGesturesFound = false;
   548 							_this.curvesGesturesFound = false;
   545 						}
   549 						}
   546 						else if(_this.currentMode == "FILTER")
   550 						else if(_this.currentMode == "FILTER")
   547 						{
   551 						{
   548 							if(_this.isMosaicFiltered)
   552 							if(_this.isMosaicFiltered)
   549 							{
   553 							{
   550 								$('.notifications').remove();
   554 								_this.removeNotifications();
   551 								_this.filterSearchedType = gesture_match;
   555 								_this.filterSearchedType = gesture_match;
   552 								_this.filterGesture(gesture_match, 'valid');
   556 								_this.filterGesture(gesture_match, 'valid');
   553 								_this.searchFilter(gesture_match);
   557 								_this.searchFilter(gesture_match);
   554 								_this.curvesGesturesFound = false;
   558 								_this.curvesGesturesFound = false;
   555 							}
   559 							}
   585 				
   589 				
   586 				_this.mouseUpDownDelta = 0;
   590 				_this.mouseUpDownDelta = 0;
   587 				_this.isSearchByCurvesOn = false;
   591 				_this.isSearchByCurvesOn = false;
   588 				_this.leaveSearch();
   592 				_this.leaveSearch();
   589 				
   593 				
   590 				if(_this.currentMode == 'FILTER' && _this.filterSearchedType != '')//if(_this.currentSearchGesture != '')
   594 				if(_this.currentMode == 'FILTER' && _this.filterSearchedType != '')
   591 				{
   595 				{
   592 					$('.notifications').remove();
   596 					_this.removeNotifications();
   593 					_this.filterGesture(_this.currentSearchGesture, 'valid');
   597 					_this.filterGesture(_this.filterSearchedType, 'valid');
   594 				}
   598 				}
   595 				
       
   596 			});
   599 			});
   597 		});
   600 		});
   598 	}
   601 	}
   599 }
   602 }
   600 
   603 
   730 	//Si il y a plus d'un snapshot à afficher, on entre dans le mode INCOMING avec en paramètre le nombre à afficher.
   733 	//Si il y a plus d'un snapshot à afficher, on entre dans le mode INCOMING avec en paramètre le nombre à afficher.
   731 	if(n > 1 && n < this.config['imagesToShow'])
   734 	if(n > 1 && n < this.config['imagesToShow'])
   732 	{
   735 	{
   733 		this.currentMode = "INCOMING-" + n;
   736 		this.currentMode = "INCOMING-" + n;
   734 		this.unzoom();
   737 		this.unzoom();
   735 		this.currentSearchGesture = '';
   738 		
   736 		$('.notifications').remove();
   739 		for(var i = 0 ; i < this.config['imagesToShow'] ; i++)
       
   740 		{
       
   741 			this.currentSearchGesture[i] = '';
       
   742 		}
       
   743 		
       
   744 		this.removeNotifications();
   737 		this.isMosaicFiltered = false;
   745 		this.isMosaicFiltered = false;
   738 		this.isCurrentlyInASearchByGesture = false;
   746 		this.isCurrentlyInASearchByGesture = false;
   739 		$('#mainPointer').fadeTo(this.config['timePrezoom'], 0);
   747 		$('#mainPointer').fadeTo(this.config['timePrezoom'], 0);
   740 		$('#secondPointer').fadeTo(this.config['timePrezoom'], 0);
   748 		$('#secondPointer').fadeTo(this.config['timePrezoom'], 0);
   741 		$('#spinner').remove();
   749 		$('#spinner').remove();
   753 				this.currentMode = "INCOMING-20";
   761 				this.currentMode = "INCOMING-20";
   754 				this.unzoom();
   762 				this.unzoom();
   755 			}
   763 			}
   756 			
   764 			
   757 			this.currentMode = "MOSAIC";
   765 			this.currentMode = "MOSAIC";
   758 			$('.notifications').remove();
   766 			this.removeNotifications();
   759 			this.mosaicSelectionAndSearch();
   767 			this.mosaicSelectionAndSearch();
   760 			clearTimeout(this.nouserTimeout);
   768 			clearTimeout(this.nouserTimeout);
   761 			console.log('OK');
   769 			console.log('OK');
   762 		}
   770 		}
   763 		//On affiche les notifications.
   771 		//On affiche les notifications.
   867 	{
   875 	{
   868 		if(this.player && this.player.widgets && this.playerIsReady && !this.isSwipe)
   876 		if(this.player && this.player.widgets && this.playerIsReady && !this.isSwipe)
   869 		{
   877 		{
   870 			this.isSwipe = true;
   878 			this.isSwipe = true;
   871 			
   879 			
   872 			if(this.currentMode == 'SEARCH' && this.isMosaicFiltered && !this.player.widgets[0].isAMarkerAhead(this.currentSearchGesture))
   880 			if(this.currentMode == 'SEARCH' && this.isMosaicFiltered && !this.player.widgets[0].isAMarkerAhead(this.currentSearchGesture[this.centerId]))
   873 			{
   881 			{
   874 				this.playNextVideo();
   882 				this.playNextVideo();
   875 			}
   883 			}
   876 			
   884 			
   877 			//L'utilisateur a fait un swipe left.
   885 			//L'utilisateur a fait un swipe left.
   878 			if(event.indexOf("LEFT") != -1)
   886 			if(event.indexOf("LEFT") != -1)
   879 			{
   887 			{
   880 				this.player.widgets[0].switchToMarker(true, this.currentSearchGesture);
   888 				this.player.widgets[0].switchToMarker(true, this.currentSearchGesture[this.centerId]);
   881 				if(this.currentMode == 'VIDEO')
   889 				if(this.currentMode == 'VIDEO')
   882 				{
   890 				{
   883 					$('.notifications').remove();
   891 					this.removeNotifications();
   884 					this.videoSwipe('left');
   892 					this.videoSwipe('left');
   885 				}
   893 				}
   886 				else if(this.currentMode == 'SEARCH' && !this.currentSearchGesture)
   894 				else if(this.currentMode == 'SEARCH' && !this.currentSearchGesture[this.centerId])
   887 				{
   895 				{
   888 					$('.notifications').remove();
   896 					this.removeNotifications();
   889 					this.searchSearchAndSwipe('left');
   897 					this.searchSearchAndSwipe('left');
   890 				}
   898 				}
   891 				else if(this.currentMode == 'SEARCH' && this.currentSearchGesture)
   899 				else if(this.currentMode == 'SEARCH' && this.currentSearchGesture[this.centerId])
   892 				{
   900 				{
   893 					$('.notifications').remove();
   901 					this.removeNotifications();
   894 					this.searchGestureAndSwipe(this.currentSearchGesture, 'valid', 'left');
   902 					this.searchGestureAndSwipe(this.currentSearchGesture[this.centerId], 'valid', 'left');
   895 				}
   903 				}
   896 			}
   904 			}
   897 			//L'utilisateur a fait un swipe right.
   905 			//L'utilisateur a fait un swipe right.
   898 			else if(event.indexOf("RIGHT") != -1)
   906 			else if(event.indexOf("RIGHT") != -1)
   899 			{
   907 			{
   900 				this.player.widgets[0].switchToMarker(false, this.currentSearchGesture);
   908 				this.player.widgets[0].switchToMarker(false, this.currentSearchGesture[this.centerId]);
   901 				if(this.currentMode == 'VIDEO')
   909 				if(this.currentMode == 'VIDEO')
   902 				{
   910 				{
   903 					$('.notifications').remove();
   911 					this.removeNotifications();
   904 					this.videoSwipe('right');
   912 					this.videoSwipe('right');
   905 				}
   913 				}
   906 				else if(this.currentMode == 'SEARCH' && !this.currentSearchGesture)
   914 				else if(this.currentMode == 'SEARCH' && !this.currentSearchGesture[this.centerId])
   907 				{
   915 				{
   908 					$('.notifications').remove();
   916 					this.removeNotifications();
   909 					this.searchSearchAndSwipe('right');
   917 					this.searchSearchAndSwipe('right');
   910 				}
   918 				}
   911 				else if(this.currentMode == 'SEARCH' && this.currentSearchGesture)
   919 				else if(this.currentMode == 'SEARCH' && this.currentSearchGesture[this.centerId])
   912 				{
   920 				{
   913 					$('.notifications').remove();
   921 					this.removeNotifications();
   914 					this.searchGestureAndSwipe(this.currentSearchGesture, 'valid', 'right');
   922 					this.searchGestureAndSwipe(this.currentSearchGesture[this.centerId], 'valid', 'right');
   915 				}
   923 				}
   916 			}
   924 			}
   917 			
   925 			
   918 			//On le fait disparaitre au bout d'un certain temps.
   926 			//On le fait disparaitre au bout d'un certain temps.
   919 			this.notifySwipeTimeout = setTimeout(function()
   927 			this.notifySwipeTimeout = setTimeout(function()
   920 			{
   928 			{
   921 				_this.isSwipe = false;
   929 				_this.isSwipe = false;
   922 				
   930 				
   923 				// /!\ //
   931 				// /!\ //
   924 				$('.notifications').remove();
   932 				_this.removeNotifications();
   925 				
   933 				
   926 				if(_this.currentMode == 'SEARCH' && !_this.currentSearchGesture)
   934 				if(_this.currentMode == 'SEARCH' && !_this.currentSearchGesture[_this.centerId])
   927 				{
   935 				{
   928 					_this.searchSearch();
   936 					_this.searchSearch();
   929 				}
   937 				}
   930 				else if(_this.currentMode == 'SEARCH' && _this.currentSearchGesture)
   938 				else if(_this.currentMode == 'SEARCH' && _this.currentSearchGesture[_this.centerId])
   931 				{
   939 				{
   932 					_this.searchGesture(_this.currentSearchGesture, 'valid');
   940 					_this.searchGesture(_this.currentSearchGesture[_this.centerId], 'valid');
   933 				}
   941 				}
   934 				
   942 				
   935 			}, this.config['timeoutNotifySwipe']);
   943 			}, this.config['timeoutNotifySwipe']);
   936 		}
   944 		}
   937 	}
   945 	}
   938 	else if(event.indexOf("BEND") != -1 || event.indexOf('KNEE-UP') != -1 || event.indexOf('FALL') != -1 || event.indexOf('JUMP') != -1)
   946 	else if(event.indexOf("BEND") != -1 || event.indexOf('KNEE-UP') != -1 || event.indexOf('FALL') != -1 || event.indexOf('JUMP') != -1)
   939 	{
   947 	{
   940 		gestureReceived = event.toLowerCase();
   948 		gestureReceived = event.toLowerCase();
   941 		gestureReceived = gestureReceived.replace('wave', 'hello');
   949 		gestureReceived = gestureReceived.replace('wave', 'hello');
   942 		this.currentSearchGesture = gestureReceived;
   950 		this.currentSearchGesture[centerId] = gestureReceived;
   943 	}
   951 	}
   944 	else if(event.indexOf("HELLO") != -1 && this.canNotifyHelp && !this.areBothPointersHere)
   952 	else if(event.indexOf("HELLO") != -1 && this.canNotifyHelp && !this.areBothPointersHere)
   945 	{
   953 	{
   946 		if(this.currentMode == 'SEARCH')
   954 		if(this.currentMode == 'SEARCH')
   947 		{
   955 		{
   958 		if(this.currentMode == "SEARCH" && this.playerIsReady)
   966 		if(this.currentMode == "SEARCH" && this.playerIsReady)
   959 		{
   967 		{
   960 			this.player.widgets[0].searchByGesture(gestureReceived);
   968 			this.player.widgets[0].searchByGesture(gestureReceived);
   961 			this.isCurrentlyInASearchByGesture = this.player.widgets[0].isCurrentlyInASearchByGesture;
   969 			this.isCurrentlyInASearchByGesture = this.player.widgets[0].isCurrentlyInASearchByGesture;
   962 			
   970 			
   963 			$('.notifications').remove();
   971 			this.removeNotifications();
   964 			this.searchGesture(gestureReceived, 'valid');
   972 			this.searchGesture(gestureReceived, 'valid');
   965 		}
   973 		}
   966 		else if(this.currentMode == "FILTER")
   974 		else if(this.currentMode == "FILTER")
   967 		{
   975 		{
   968 			if(this.isMosaicFiltered)
   976 			if(this.isMosaicFiltered)
   969 			{
   977 			{
   970 				// console.log('FILTER !!!');
   978 				// console.log('FILTER !!!');
   971 				// this.notifySearch1Gesture(gestureReceived, 'valid');
   979 				// this.notifySearch1Gesture(gestureReceived, 'valid');
   972 				$('.notifications').remove();
   980 				this.removeNotifications();
   973 				this.filterGesture(gestureReceived, 'valid');
   981 				this.filterGesture(gestureReceived, 'valid');
   974 				this.searchFilter(gestureReceived);
   982 				this.searchFilter(gestureReceived);
   975 			}
   983 			}
   976 		}
   984 		}
   977 		
   985 		
  1117 					_this.canSwipe = true;
  1125 					_this.canSwipe = true;
  1118 				}
  1126 				}
  1119 				
  1127 				
  1120 				console.log('TIME TO GO AT : ' + _this.timeToGoAt[_this.centerId], _this.centerId, _this.imgs[_this.centerId]);
  1128 				console.log('TIME TO GO AT : ' + _this.timeToGoAt[_this.centerId], _this.centerId, _this.imgs[_this.centerId]);
  1121 				
  1129 				
  1122 				if(_this.isMosaicFiltered)
  1130 				// if(_this.isMosaicFiltered)
  1123 				{
  1131 				// {
  1124 					if(_this.currentSearchGesture == '')
  1132 					if(_this.currentSearchGesture[_this.centerId] == '')
  1125 					{
  1133 					{
  1126 						_this.removeFilter();
  1134 						_this.removeFilter();
  1127 					}
  1135 					}
  1128 					else
  1136 					else
  1129 					{
  1137 					{
  1130 						_this.currentMode = 'SEARCH';
  1138 						_this.currentMode = 'SEARCH';
  1131 						// console.log(_this.currentSearchGesture);
  1139 						// console.log(_this.currentSearchGesture);
  1132 						_this.player.widgets[0].searchByGesture(_this.currentSearchGesture);
  1140 						_this.player.widgets[0].searchByGesture(_this.currentSearchGesture[_this.centerId]);
  1133 						_this.isCurrentlyInASearchByGesture = _this.player.widgets[0].isCurrentlyInASearchByGesture;
  1141 						_this.isCurrentlyInASearchByGesture = _this.player.widgets[0].isCurrentlyInASearchByGesture;
  1134 						
  1142 						
  1135 						if(_this.timeToGoAt[_this.centerId] === 0 && _this.player.widgets[0].atLeastOneSearchMarker(_this.currentSearchGesture))
  1143 						if(_this.timeToGoAt[_this.centerId] === 0 && _this.player.widgets[0].atLeastOneSearchMarker(_this.currentSearchGesture[_this.centerId]))
  1136 						{
  1144 						{
  1137 							_this.player.widgets[0].goToFirstSearchedMarker(_this.currentSearchGesture);
  1145 							_this.player.widgets[0].goToFirstSearchedMarker(_this.currentSearchGesture[_this.centerId]);
  1138 						}
  1146 						}
  1139 						else
  1147 						else
  1140 						{
  1148 						{
  1141 							_this.player.popcorn.currentTime(_this.timeToGoAt[_this.centerId]);
  1149 							_this.player.popcorn.currentTime(_this.timeToGoAt[_this.centerId]);
  1142 						}
  1150 						}
  1143 					}
  1151 					}
  1144 				}
  1152 				// }
  1145 				// /!\ //
  1153 				// /!\ //
  1146 				else
  1154 				/*else
  1147 				{
  1155 				{
  1148 					if(_this.player.popcorn)
  1156 					if(_this.player.popcorn)
  1149 					{
  1157 					{
  1150 						_this.player.popcorn.currentTime(_this.timeToGoAt[_this.centerId]);
  1158 						_this.player.popcorn.currentTime(_this.timeToGoAt[_this.centerId]);
  1151 					}
  1159 					}
  1152 				}
  1160 				}*/
  1153 			});
  1161 			});
  1154 		}
  1162 		}
  1155 	});
  1163 	});
  1156 }
  1164 }
  1157 
  1165