X-Git-Url: http://git.euphorik.ch/index.cgi?a=blobdiff_plain;ds=inline;f=js%2Feuphorik.js;h=a3b0acf28da31646d5e3d260ecc1abc43c776bd6;hb=83ceb1d7e564a63603bd48bbbf785c02823f2d0d;hp=4210713c8a0d1787cccf43cdc90c2e4b7d615f75;hpb=934ab32cd6fac44f6b3ebedef69ce1ccd0b8701b;p=euphorik.git
diff --git a/js/euphorik.js b/js/euphorik.js
index 4210713..a3b0acf 100755
--- a/js/euphorik.js
+++ b/js/euphorik.js
@@ -1,4 +1,20 @@
// coding: utf-8
+// Copyright 2008 Grégory Burri
+//
+// This file is part of Euphorik.
+//
+// Euphorik is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Euphorik is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Euphorik. If not, see .
/**
* Contient la base javascript pour le site euphorik.ch.
@@ -65,13 +81,16 @@ String.prototype.rtrim = function()
///////////////////////////////////////////////////////////////////////////////////////////////////
/**
- * Cette classe regroupe des fonctions utilitaires (helpers).
+ * Cette classe regroupe des fonctions utilitaires (helpers).
+ * @formateur est permet de formater les messages affichés à l'aide de messageDialogue (facultatif)
*/
-function Util()
+function Util(formateur)
{
$("#info .fermer").click(function(){
$("#info").slideUp(50)
})
+
+ this.formateur = formateur
}
var messageType = {informatif: 0, question: 1, erreur: 2}
@@ -82,11 +101,17 @@ var messageType = {informatif: 0, question: 1, erreur: 2}
* @param type voir 'messageType'. par défaut messageType.informatif
* @param les boutons sous la forme d'un objet ou les clefs sont les labels des boutons
* et les valeurs les fonctions executées lorsqu'un bouton est activé.
+ * @param formate faut-il formaté le message ? true par défaut
*/
-Util.prototype.messageDialogue = function(message, type, boutons)
+Util.prototype.messageDialogue = function(message, type, boutons, formate)
{
+ var thisUtil = this
+
if (type == undefined)
type = messageType.informatif
+
+ if (formate == undefined)
+ formate = true
if (this.timeoutMessageDialogue != undefined)
clearTimeout(this.timeoutMessageDialogue)
@@ -94,7 +119,7 @@ Util.prototype.messageDialogue = function(message, type, boutons)
var fermer = function(){$("#info").slideUp(100)}
fermer()
- $("#info .message").html(message)
+ $("#info .message").html(thisUtil.formateur == undefined || !formate ? message : thisUtil.formateur.traitementComplet(message))
switch(type)
{
case messageType.informatif : $("#info #icone").attr("class", "information"); break
@@ -238,8 +263,8 @@ Pages.prototype.afficherPage = function(nomPage, forcerChargement)
if (this.pageCourante != null && this.pageCourante.decharger)
this.pageCourante.decharger()
- $("#menu div").removeClass("courante")
- $("#menu div." + nomPage).addClass("courante")
+ $("#menu li").removeClass("courante")
+ $("#menu li." + nomPage).addClass("courante")
this.pageCourante = page
$("#page").html(this.pageCourante.contenu()).removeClass().addClass(this.pageCourante.nom)
@@ -250,6 +275,11 @@ Pages.prototype.afficherPage = function(nomPage, forcerChargement)
///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Classe permettant de formater du texte par exemple pour la substitution des liens dans les
+ * message par "[url]".
+ * TODO : améliorer l'efficacité des méthods notamment lié au smiles.
+ */
function Formateur()
{
this.smiles = conf.smiles
@@ -289,7 +319,7 @@ Formateur.prototype.getSmilesHTML = function()
*/
Formateur.prototype.traitementComplet = function(M, pseudo)
{
- return this.traiterLiensConv(this.traiterSmiles(this.traiterURL(this.remplacerBalisesHTML(M), pseudo)))
+ return this.traiterLiensConv(this.traiterSmiles(this.traiterURL(this.traiterWikiSyntaxe(this.remplacerBalisesHTML(M)), pseudo)))
}
/**
@@ -326,7 +356,7 @@ Formateur.prototype.traiterSmiles = function(M)
Formateur.prototype.remplacerBalisesHTML = function(M)
{
- return M.replace(//g, ">")
+ return M.replace(//g, ">").replace(/"/g, """)
}
Formateur.prototype.traiterURL = function(M, pseudo)
@@ -343,6 +373,27 @@ Formateur.prototype.traiterURL = function(M, pseudo)
}
return M.replace(this.regexUrl, traitementUrl)
}
+
+/**
+ * Formatage en utilisant un sous-ensemble des règles de mediwiki.
+ * par exemple ''italic'' devient italic
+ */
+Formateur.prototype.traiterWikiSyntaxe = function(M)
+{
+ return M.replace(
+ /'''(.*?)'''/g,
+ function(texte, capture)
+ {
+ return "" + capture + ""
+ }
+ ).replace(
+ /''(.*?)''/g,
+ function(texte, capture)
+ {
+ return "" + capture + ""
+ }
+ )
+}
/**
* Renvoie une version courte de l'url.
@@ -756,9 +807,10 @@ Client.prototype.flush = function(async)
Client.prototype.majMenu = function()
{
// TODO : à virer : ne plus changer de style de display ... spa beau .. ou trouver une autre méthode
- var displayType = this.css == "css/3/euphorik.css" ? "block" : "inline" //this.client
+ // var displayType = this.css == "css/3/euphorik.css" ? "block" : "inline" //this.client
+ displayType = "block"
- $("#menu .admin").css("display", this.ekMaster ? "inline" : "none")
+ $("#menu .admin").css("display", this.ekMaster ? displayType : "none")
// met à jour le menu
if (this.statut == statutType.auth_registered)
@@ -904,7 +956,7 @@ PageEvent.prototype.waitEvent = function(funSend, funReceive)
error:
function(XMLHttpRequest, textStatus, errorThrown)
{
- setTimeout(function(){ thisPageEvent.rafraichirMessages(funSend, funReceive) }, 1000);
+ setTimeout(function(){ thisPageEvent.waitEvent(funSend, funReceive) }, 1000);
}
})
@@ -929,10 +981,10 @@ function initialiserListeStyles(client)
$(document).ready(
function()
{
- var util = new Util()
+ var formateur = new Formateur()
+ var util = new Util(formateur)
var client = new Client(util)
- var pages = new Pages()
- var formateur = new Formateur()
+ var pages = new Pages()
// connexion vers le serveur (utilise un cookie qui traine)
client.connexionCookie()
@@ -967,4 +1019,4 @@ $(document).ready(
pages.ajouterPage(new PageAbout(client, formateur, util))
pages.afficherPage("minichat")
}
-)
\ No newline at end of file
+)