--- a/front_js/pointers/pointers/js/pointers.js Mon Jul 09 14:24:42 2012 +0200
+++ b/front_js/pointers/pointers/js/pointers.js Fri Jul 13 14:57:43 2012 +0200
@@ -20,27 +20,41 @@
/*
* Classe définissant les pointers.
*/
-function pointers()
+function Pointers(config)
{
this.mainPointerLastX = 0;
this.mainPointerLastY = 0;
this.secondPointerLastX = 0;
this.secondPointerLastY = 0;
+
+ this.isMainPointerDisplayed = false;
+ this.isSecondPointerDisplayed = false;
+
+ this.pointerLeftTimeout = null;
+ this.pointerRightTimeout = null;
+
+ this.config = config;
+
+ this.client = new Client(this.config.host, this.config.port, this);
+
+ this.addPointers();
}
/*
* Affiche les pointeurs.
*/
-pointers.prototype.addPointers = function()
+Pointers.prototype.addPointers = function()
{
var mainPointer = '<div id="mainPointer" class="pointers"></div>';
var secondPointer = '<div id="secondPointer" class="pointers"></div>';
- $('body').append(mainPointer + secondPointer);
+ var textPanel = "<div id='textPanel'>Les mains sont trop loin ou trop près.</div>";
+ $('body').append(textPanel + mainPointer + secondPointer);
$('#secondPointer').css(
{
top: $(window).height() / 2 - $('#secondPointer').height() / 2,
- left: $(window).width() / 4 - $('#secondPointer').width() / 2
+ left: $(window).width() / 4 - $('#secondPointer').width() / 2,
+ opacity: 0
});
this.secondPointerLastX = $(window).width() / 4 - $('#secondPointer').width() / 2;
@@ -49,7 +63,8 @@
$('#mainPointer').css(
{
top: $(window).height() / 2 - $('#mainPointer').height() / 2,
- left: $(window).width() * 3 / 4 - $('#mainPointer').width() / 2
+ left: $(window).width() * 3 / 4 - $('#mainPointer').width() / 2,
+ opacity: 0
});
this.mainPointerLastX = $(window).width() * 3 / 4 - $('#mainPointer').width() / 2;
@@ -60,43 +75,43 @@
* Affiche/Masque le pointeur principal.
* Main est un booléen valant vrai s'il faut afficher le pointeur.
*/
-pointers.prototype.mainPointerDisplay = function(main)
+Pointers.prototype.mainPointerDisplay = function(main)
{
var _this = this;
//Si le booléen est à vrai, on affiche le pointeur.
if(main)
{
- $('#mainPointer').fadeTo(this.config['timeFilling'], '1');
+ $('#mainPointer').fadeTo(this.config.timeFilling, '1');
}
else
{
- $('#mainPointer').fadeTo(this.config['timeFilling'], '0');
+ $('#mainPointer').fadeTo(this.config.timeFilling, '0');
}
}
/*
* Affiche/Masque le pointeur secondaire.
* Main est un booléen valant vrai s'il faut afficher le pointeur.
*/
-pointers.prototype.secondPointerDisplay = function(second)
+Pointers.prototype.secondPointerDisplay = function(second)
{
var _this = this;
//Si le booléen est à vrai, on affiche le pointeur.
if(second)
{
- $('#secondPointer').fadeTo(this.config['timeFilling'], '1');
+ $('#secondPointer').fadeTo(this.config.timeFilling, '1');
}
else
{
- $('#secondPointer').fadeTo(this.config['timeFilling'], '0');
+ $('#secondPointer').fadeTo(this.config.timeFilling, '0');
}
}
/*
* Raffraîchit la position des pointeurs.
*/
-pointers.prototype.refreshMainPointer = function(x, y)
+Pointers.prototype.refreshMainPointer = function(x, y)
{
x *= 7;
y *= 7;
@@ -135,7 +150,7 @@
});
}
-pointers.prototype.refreshSecondPointer = function(x, y)
+Pointers.prototype.refreshSecondPointer = function(x, y)
{
if(!this.mouseInteractions)
{
@@ -175,4 +190,27 @@
top: pointerY,
left: pointerX
});
+}
+
+/*
+ * Met à jour l'affichage du texte.
+*/
+Pointers.prototype.textUpdate = function()
+{
+ if(this.isMainPointerDisplayed && this.isSecondPointerDisplayed)
+ {
+ $('#textPanel').html('Les deux pointeurs sont détectés.');
+ }
+ else if(this.isMainPointerDisplayed && !this.isSecondPointerDisplayed)
+ {
+ $('#textPanel').html('Le pointer droit est détecté.');
+ }
+ else if(!this.isMainPointerDisplayed && this.isSecondPointerDisplayed)
+ {
+ $('#textPanel').html('Le pointeur gauche est détecté.');
+ }
+ if(!this.isMainPointerDisplayed && !this.isSecondPointerDisplayed)
+ {
+ $('#textPanel').html('Les mains sont trop loin ou trop près.');
+ }
}
\ No newline at end of file