X-Git-Url: http://git.euphorik.ch/index.cgi?a=blobdiff_plain;f=js%2Feuphorik.js;h=6685b1620bfd29adfeee736464aefc1e6960e370;hb=f6158580ec307685d5ac2075ff7a58f205335690;hp=99a461f812c144011524bc6006400f688265faaf;hpb=044398d0ce631201bb0f724450446b90a35d79ce;p=euphorik.git
diff --git a/js/euphorik.js b/js/euphorik.js
index 99a461f..6685b16 100755
--- a/js/euphorik.js
+++ b/js/euphorik.js
@@ -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.stringify(json) + "" }
+ return {action : JSON.stringify(json) }
}
Util.prototype.md5 = function(chaine)
@@ -184,6 +183,29 @@ Util.prototype.replaceSelection = function(input, replaceString) {
}
}
+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()
@@ -393,6 +415,7 @@ Client.prototype.resetDonneesPersonnelles = function()
this.password = ""
this.email = ""
this.css = jQuery("link#cssPrincipale").attr("href")
+ this.nickFormat = "nick"
this.pagePrincipale = 1
@@ -528,6 +551,7 @@ Client.prototype.getJSONProfile = function()
"nick" : this.pseudo,
"email" : this.email,
"css" : this.css,
+ "nick_format" : this.nickFormat,
"main_page" : this.pagePrincipale < 1 ? 1 : this.pagePrincipale,
"conversations" : this.getJSONConversations()
}
@@ -565,6 +589,7 @@ Client.prototype.authentifie = function()
Client.prototype.setStatut = function(statut)
{
+ //alert(statut)
// conversation en "enum" si en "string"
if (typeof(statut) == "string")
{
@@ -637,7 +662,8 @@ Client.prototype.connexion = function(messageJson)
}
Client.prototype.deconnexion = function()
-{
+{
+ this.flush()
this.setStatut(statutType.deconnected) // deconnexion
this.resetDonneesPersonnelles()
this.delCookie ()
@@ -658,6 +684,7 @@ Client.prototype.chargerDonnees = function(data)
this.pseudo = data["nick"]
this.email = data["email"]
this.css = data["css"]
+ this.nickFormat = data["nick_format"]
// la page de la conversation principale
this.pagePrincipale = data["main_page"] == undefined ? 1 : data["main_page"]
@@ -735,6 +762,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
@@ -744,12 +781,6 @@ jQuery.noConflict()
jQuery(document).ready(
function()
{
- /* FIXME : ce code pose problème sur konqueror, voir : http://www.kde-forum.org/thread.php?threadid=17993
- var p = new DOMParser();
- var doc = p.parseFromString("\n", "text/xml")
- var s = new XMLSerializer()
- alert(s.serializeToString(doc)) */
-
var util = new Util()
var client = new Client(util)
var pages = new Pages()
@@ -758,19 +789,12 @@ jQuery(document).ready(
// connexion vers le serveur (utilise un cookie qui traine)
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)
// TODO : pourquoi jQuery(document).unload ne fonctionne pas ?
jQuery(window).unload(
function()
{
- //alert("ok")
client.flush(false)
}
)
@@ -789,10 +813,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