MOD minimodif
[euphorik.git] / js / euphorik.js
index b93498f..400f215 100755 (executable)
@@ -614,10 +614,10 @@ Client.prototype.kick = function(userId, raison)
    *  {
    *     "reply" : <reply>
    *  }
-   * @page la page
+   * @page la page courante pour laquelle on écoute des événements\r
+   * @util le helper 'util'
    */
-function PageEvent(page, util)
-{
+function PageEvent(page, util) {
    this.page = page
    this.util = util
    
@@ -631,12 +631,10 @@ function PageEvent(page, util)
 /**
   * Arrête l'attente courante s'il y en a une.
   */
-PageEvent.prototype.stopAttenteCourante = function()
-{
+PageEvent.prototype.stopAttenteCourante = function() {
    this.stop = true
          
-   if (this.attenteCourante != null)
-   {
+   if (this.attenteCourante != null) {
       this.attenteCourante.abort()   
    }
 }
@@ -648,8 +646,7 @@ PageEvent.prototype.stopAttenteCourante = function()
   * les fonctions acceptent un paramètre correspondant au données reçues.
   * exemple : {"new_message" : function(data){ ... }}
   */
-PageEvent.prototype.waitEvent = function(funSend, funsReceive)
-{
+PageEvent.prototype.waitEvent = function(funSend, funsReceive) {
    this.stopAttenteCourante()
    
    this.stop = false
@@ -658,14 +655,14 @@ PageEvent.prototype.waitEvent = function(funSend, funsReceive)
       
    // on doit conserver l'ordre des valeurs de l'objet JSON (le serveur les veut dans l'ordre définit dans le protocole)
    // TODO : ya pas mieux ?
-   var dataToSend = 
-   {
+   var dataToSend = {
       "header" : { "action" : "wait_event", "version" : euphorik.conf.versionProtocole },
       "page" : this.page
    }
    var poulpe = funSend()
-   for (var v in poulpe)
-      dataToSend[v] = poulpe[v]
+   for (var v in poulpe) {
+      dataToSend[v] = poulpe[v]\r
+   }
    
    this.attenteCourante = jQuery.ajax({
       type: "POST",
@@ -675,31 +672,29 @@ PageEvent.prototype.waitEvent = function(funSend, funsReceive)
       timeout: 180000, // timeout de 3min. Gros HACK pas beau. FIXME problème décrit ici : http://groups.google.com/group/jquery-en/browse_thread/thread/8724e64af3333a76
       data: this.util.jsonVersAction(dataToSend),
       success:
-         function(data)
-         {                        
+         function(data) {                        
             funsReceive[data["reply"]](data)
             
             // rappel de la fonction dans 100 ms
             setTimeout(function(){ thisPageEvent.waitEvent2(funSend, funsReceive) }, 100)
          },
       error:
-         function(XMLHttpRequest, textStatus, errorThrown)
-         {
-            ;; console.log("Connexion perdue dans waitEvent")
+         function(XMLHttpRequest, textStatus, errorThrown) {
+            ;; console.log("Connexion perdue dans PageEvent.prototype.waitEvent()")
             setTimeout(function(){ thisPageEvent.waitEvent2(funSend, funsReceive) }, 1000)
          }
-   })
-}
+   });
+};
 
 /**
   * Si un stopAttenteCourante survient un peu n'importe quand il faut imédiatement arreter de boucler.
   */
-PageEvent.prototype.waitEvent2 = function(funSend, funsReceive)
-{
-   if (this.stop)
-      return
-   this.waitEvent(funSend, funsReceive)
-}
+PageEvent.prototype.waitEvent2 = function(funSend, funsReceive) {
+   if (this.stop) {
+      return;\r
+   }
+   this.waitEvent(funSend, funsReceive);
+};
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////