ADD page "about" (possède également la FAQ)
[euphorik.git] / js / euphorik.js
index 88ef6e7..d7ef712 100755 (executable)
@@ -106,8 +106,7 @@ var messageType = {informatif: 0, question: 1, erreur: 2}
   */
 Util.prototype.jsonVersAction = function(json)
 {
-   // FIXME : ne plus encapsuler json dans de l'xml (problème avec yaws)
-   return {action: "<json>" + JSON.stringify(json) + "</json>" }
+   return {action : JSON.stringify(json) }
 }
 \r
 Util.prototype.md5 = function(chaine)\r
@@ -184,6 +183,29 @@ Util.prototype.replaceSelection = function(input, replaceString) {
    }\r
 }
 
+Util.prototype.rot13 = function(chaine)
+{
+   var ACode = 'A'.charCodeAt(0)
+   var aCode = 'a'.charCodeAt(0)
+   var MCode = 'M'.charCodeAt(0)
+   var mCode = 'm'.charCodeAt(0)
+   var ZCode = 'Z'.charCodeAt(0)
+   var zCode = 'z'.charCodeAt(0)
+
+   var f = function(ch, pos) {
+      if (pos == ch.length)
+         return ""
+      
+      var c = ch.charCodeAt(pos);
+      return String.fromCharCode(
+         c +
+         (c >= ACode && c <= MCode || c >= aCode && c <= mCode ? 13 :
+         (c > MCode && c <= ZCode || c > mCode && c <= zCode ? -13 : 0))
+      ) + f(ch, pos + 1)
+   }
+   return f(chaine, 0)
+}
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 function Pages()
@@ -459,10 +481,10 @@ Client.prototype.ajouterConversation = function(racine)
 {
    // vérification s'il elle n'existe pas déjà
    for (var i = 0; i < this.conversations.length; i++)
-      if (this.conversations[i].racine == racine)
+      if (this.conversations[i].root == racine)
          return false
          
-   this.conversations.push({racine : racine, page : 1})
+   this.conversations.push({root : racine, page : 1})
    return true
 }
 
@@ -514,7 +536,7 @@ Client.prototype.getJSONConversations = function()
 {
    var conversations = new Array()
    for (var i = 0; i < this.conversations.length; i++)
-      conversations.push({ "racine" : this.conversations[i].racine, "page" : this.conversations[i].page})
+      conversations.push({ "root" : this.conversations[i].root, "page" : this.conversations[i].page})
    return conversations
 }
 
@@ -525,6 +547,7 @@ Client.prototype.getJSONProfile = function()
       "cookie" : this.cookie,
       "login" : this.login,
       "password" : this.password,
+      "nick" : this.pseudo,
       "email" : this.email,
       "css" : this.css,
       "main_page" : this.pagePrincipale < 1 ? 1 : this.pagePrincipale,
@@ -564,11 +587,12 @@ Client.prototype.authentifie = function()
 
 Client.prototype.setStatut = function(statut)
 {  
+   //alert(statut)
    // conversation en "enum" si en "string"\r
    if (typeof(statut) == "string")\r
    {
       statut =
-         statut == "registered" ?
+         statut == "auth_registered" ?
             statutType.auth_registered :
          (statut == "auth_not_registered" ? statutType.auth_not_registered : statutType.deconnected)\r
    }   \r
@@ -688,7 +712,7 @@ Client.prototype.flush = function(async)
       return false
 
    thisClient = this
-   //this.util.jsonVersAction(this.getJSONProfile()).action.dump("Flush client")      
+   ;;; dumpObj(this.getJSONProfile())
    jQuery.ajax(
       {
          async: async,
@@ -734,6 +758,16 @@ Client.prototype.majMenu = function()
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
+function initialiserListeStyles(client)
+{
+   jQuery("#menuCss").change(
+      function()
+      {
+         client.setCss("css/" + jQuery("option:selected", this).attr("value") + "/euphorik.css")
+      }
+   )
+}
+
 jQuery.noConflict()
             
 // charge dynamiquement le script de debug
@@ -757,19 +791,13 @@ jQuery(document).ready(
       // connexion vers le serveur (utilise un cookie qui traine)\r
       client.connexionCookie()
       
-      // les styles css
-      for (var i = 1; i <= 3; i++)
-      {
-         jQuery("#css"+i).click(function(){
-            client.setCss("css/" + jQuery(this).attr("id").charAt(3) + "/euphorik.css")
-         })
-      }
+      initialiserListeStyles(client)
 
-      jQuery(document).unload(
+      // TODO : pourquoi jQuery(document).unload ne fonctionne pas ?
+      jQuery(window).unload(
          function()
          {
-            alert("ok")
-            client.flush()
+            client.flush(false)
          }
       )
       
@@ -787,10 +815,12 @@ jQuery(document).ready(
          )
       })
       jQuery("#menu .register").click(function(){ pages.afficherPage("register") })
+      jQuery("#menu .about").click(function(){ pages.afficherPage("about") })
 
       pages.ajouterPage(new PageMinichat(client, formateur, util))
       pages.ajouterPage(new PageProfile(client, formateur, util))
       pages.ajouterPage(new PageRegister(client, formateur, util))
+      pages.ajouterPage(new PageAbout(client, formateur, util))
       pages.afficherPage("minichat")
    }
 )
\ No newline at end of file