X-Git-Url: http://git.euphorik.ch/index.cgi?a=blobdiff_plain;ds=inline;f=js%2Feuphorik.js;h=b36fbbbe2d85108cbcad7866d67d8ff8c753214e;hb=81b3e94e62dd60087d71efc42004f8222d9e1e7a;hp=6685b1620bfd29adfeee736464aefc1e6960e370;hpb=5f49b7e6af9be3e2415136013370af4ac99d59da;p=euphorik.git
diff --git a/js/euphorik.js b/js/euphorik.js
index 6685b16..b36fbbb 100755
--- a/js/euphorik.js
+++ b/js/euphorik.js
@@ -21,19 +21,27 @@ var conf = {
"bigsmile" : [/:D/g, /:-D/g],
"clin" : [/;\)/g, /;-\)/g],
"cool" : [/8\)/g, /8-\)/g],
- "eheheh" : [/:P/g, /:-P/g],
- "oh" : [/:o/g, /:O/g],
+ "eheheh" : [/:P/g, /:-P/g],
+ "lol" : [/\[-lol\]/g],
+ "spliff" : [/\[-spliff\]/g],
+ "oh" : [/:o/g, /:O/g],
+ "heink" : [/\[-heink\]/g],
+ "hum" : [/\[-hum\]/g],
+ "boh" : [/\[-boh\]/g],
+ "sniff" : [/:\(/g, /:-\(/g],
+ "triste" : [/\[-triste\]/g],
"pascontent" : [/>\(/g, />\(/g],
- "sniff" : [/:\(/g, /:-\(/g],
- "argn" : [/\[:argn\]/g],
- "bunny" : [/\[:lapin\]/g],
- "chat" : [/\[:chat\]/g],
- "renne" : [/\[:renne\]/g],
- "lol" : [/\[:lol\]/g],
- "spliff" : [/\[:spliff\]/g],
- "star" : [/\[:star\]/g],
- "triste" : [/\[:triste\]/g],
- "kirby" : [/\[:kirby\]/g]
+ "argn" : [/\[-argn\]/g],
+ "redface" : [/\[-redface\]/g],
+ "bunny" : [/\[-lapin\]/g],
+ "chat" : [/\[-chat\]/g],
+ "renne" : [/\[-renne\]/g],
+ "star" : [/\[-star\]/g],
+ "kirby" : [/\[-kirby\]/g],
+ "slurp" : [/\[-slurp\]/g],
+ "agreed" : [/\[-agreed\]/g],
+ "dodo" : [/\[-dodo\]/g],
+ "bn" : [/\[-bn\]/g]
}
}
@@ -61,8 +69,8 @@ String.prototype.rtrim = function()
*/
function Util()
{
- jQuery("#info .fermer").click(function(){
- jQuery("#info").slideUp(50)
+ $("#info .fermer").click(function(){
+ $("#info").slideUp(50)
})
}
@@ -81,21 +89,21 @@ Util.prototype.messageDialogue = function(message, type, boutons)
if (this.timeoutMessageDialogue != undefined)
clearTimeout(this.timeoutMessageDialogue)
- var fermer = function(){jQuery("#info").slideUp(100)}
+ var fermer = function(){$("#info").slideUp(100)}
fermer()
- jQuery("#info .message").html(message)
+ $("#info .message").html(message)
switch(type)
{
- case messageType.informatif : jQuery("#info #icone").attr("class", "information"); break
- case messageType.question : jQuery("#info #icone").attr("class", "interrogation"); break
- case messageType.erreur : jQuery("#info #icone").attr("class", "exclamation"); break
+ case messageType.informatif : $("#info #icone").attr("class", "information"); break
+ case messageType.question : $("#info #icone").attr("class", "interrogation"); break
+ case messageType.erreur : $("#info #icone").attr("class", "exclamation"); break
}
- jQuery("#info .boutons").html("")
+ $("#info .boutons").html("")
for (var b in boutons)
- jQuery("#info .boutons").append("
" + b + "
").find("div:last").click(boutons[b]).click(fermer)
+ $("#info .boutons").append("" + b + "
").find("div:last").click(boutons[b]).click(fermer)
- jQuery("#info").slideDown(200)
+ $("#info").slideDown(200)
this.timeoutMessageDialogue = setTimeout(fermer, conf.tempsAffichageMessageDialogue)
}
@@ -230,11 +238,11 @@ Pages.prototype.afficherPage = function(nomPage, forcerChargement)
if (this.pageCourante != null && this.pageCourante.decharger)
this.pageCourante.decharger()
- jQuery("#menu div").removeClass("courante")
- jQuery("#menu div." + nomPage).addClass("courante")
+ $("#menu div").removeClass("courante")
+ $("#menu div." + nomPage).addClass("courante")
this.pageCourante = page
- jQuery("#page").html(this.pageCourante.contenu()).removeClass().addClass(this.pageCourante.nom)
+ $("#page").html(this.pageCourante.contenu()).removeClass().addClass(this.pageCourante.nom)
if (this.pageCourante.charger)
this.pageCourante.charger()
@@ -297,7 +305,8 @@ Formateur.prototype.traiterLiensConv = function(M)
}
/**
- * FIXME : Cette méthode est attrocement lourde ! A optimiser.
+ * FIXME : Cette méthode est attrocement lourde ! A optimiser.
+ * moyenne su échantillon : 234ms
*/
Formateur.prototype.traiterSmiles = function(M)
{
@@ -328,7 +337,7 @@ Formateur.prototype.traiterURL = function(M, pseudo)
if (!thisFormateur.regexTestProtocoleExiste.test(url))
url = "http://" + url
var extension = thisFormateur.getShort(url)
- return "[" + extension[0] + "]"
+ return "[" + extension[0] + "]"
}
return M.replace(this.regexUrl, traitementUrl)
}
@@ -414,10 +423,11 @@ Client.prototype.resetDonneesPersonnelles = function()
this.login = ""
this.password = ""
this.email = ""
- this.css = jQuery("link#cssPrincipale").attr("href")
+ this.css = $("link#cssPrincipale").attr("href")
this.nickFormat = "nick"
this.pagePrincipale = 1
+ this.ekMaster = false
// les conversations, une conversation est un objet possédant les attributs suivants :
// - racine (entier)
@@ -431,7 +441,7 @@ Client.prototype.setCss = function(css)
return
this.css = css
- jQuery("link#cssPrincipale").attr("href", this.css)
+ $("link#cssPrincipale").attr("href", this.css)
this.majMenu()
}
@@ -663,10 +673,10 @@ Client.prototype.connexion = function(messageJson)
Client.prototype.deconnexion = function()
{
- this.flush()
+ this.flush()
+ this.delCookie()
this.setStatut(statutType.deconnected) // deconnexion
this.resetDonneesPersonnelles()
- this.delCookie ()
}
Client.prototype.chargerDonnees = function(data)
@@ -692,12 +702,13 @@ Client.prototype.chargerDonnees = function(data)
// met à jour la css
if (this.css != "")
{
- jQuery("link#cssPrincipale").attr("href", this.css)
+ $("link#cssPrincipale").attr("href", this.css)
this.majMenu()
}
// les conversations
thisClient.conversations = data["conversations"]
+ thisClient.ekMaster = data["ek_master"]
}
this.dernierMessageErreur = data["error_message"]
}
@@ -737,48 +748,109 @@ 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
+ $("#menu .admin").css("display", this.ekMaster ? "none" : "inline")
+
// met à jour le menu
if (this.statut == statutType.auth_registered)
{
- jQuery("#menu .profile").css("display", displayType).text("profile")
- jQuery("#menu .logout").css("display", displayType)
- jQuery("#menu .register").css("display", "none")
+ $("#menu .profile").css("display", displayType).text("profile")
+ $("#menu .logout").css("display", displayType)
+ $("#menu .register").css("display", "none")
}
else if (this.statut == statutType.auth_not_registered)
{
- jQuery("#menu .profile").css("display", "none")
- jQuery("#menu .logout").css("display", displayType)
- jQuery("#menu .register").css("display", displayType)
+ $("#menu .profile").css("display", "none")
+ $("#menu .logout").css("display", displayType)
+ $("#menu .register").css("display", displayType)
}
else
{
- jQuery("#menu .profile").css("display", displayType).text("login")
- jQuery("#menu .logout").css("display", "none")
- jQuery("#menu .register").css("display", displayType)
+ $("#menu .profile").css("display", displayType).text("login")
+ $("#menu .logout").css("display", "none")
+ $("#menu .register").css("display", displayType)
}
}
+
+Client.prototype.slap = function(userId, raison)
+{
+ var thisClient = this
+
+ jQuery.ajax({
+ type: "POST",
+ url: "request",
+ dataType: "json",
+ data: this.util.jsonVersAction(
+ {
+ "action" : "slap",
+ "cookie" : thisClient.cookie,
+ "user_id" : userId,
+ "reason" : raison
+ }),
+ success:
+ function(data)
+ {
+ if (data["reply"] == "error")
+ thisClient.util.messageDialogue(data["error_message"])
+ }
+ })
+}
+
+
+Client.prototype.ban = function(userId, raison, minutes)
+{
+ var thisClient = this
+
+ // par défaut un ban correspond à 3 jours
+ if (typeof(minutes) == "undefined")
+ minutes = 60 * 24 * 3
+
+ jQuery.ajax({
+ type: "POST",
+ url: "request",
+ dataType: "json",
+ data: this.util.jsonVersAction(
+ {
+ "action" : "ban",
+ "cookie" : thisClient.cookie,
+ "duration" : minutes,
+ "user_id" : userId,
+ "reason" : raison
+ }),
+ success:
+ function(data)
+ {
+ if (data["reply"] == "error")
+ thisClient.util.messageDialogue(data["error_message"])
+ }
+ })
+}
+
+Client.prototype.kick = function(userId, raison)
+{
+ this.ban(userId, raison, 15)
+}
+
///////////////////////////////////////////////////////////////////////////////////////////////////
function initialiserListeStyles(client)
{
- jQuery("#menuCss").change(
+ $("#menuCss").change(
function()
{
- client.setCss("css/" + jQuery("option:selected", this).attr("value") + "/euphorik.css")
+ client.setCss("css/" + $("option:selected", this).attr("value") + "/euphorik.css")
}
)
}
-
-jQuery.noConflict()
// charge dynamiquement le script de debug
;;; jQuery.ajax({async : false, url : "js/debug.js", dataType : "script"})
// le main
-jQuery(document).ready(
+$(document).ready(
function()
{
var util = new Util()
@@ -791,17 +863,13 @@ jQuery(document).ready(
initialiserListeStyles(client)
- // TODO : pourquoi jQuery(document).unload ne fonctionne pas ?
- jQuery(window).unload(
- function()
- {
- client.flush(false)
- }
- )
+ // TODO : pourquoi $(document).unload ne fonctionne pas ?
+ $(window).unload(function(){client.flush(false)})
- jQuery("#menu .minichat").click(function(){ pages.afficherPage("minichat") })
- jQuery("#menu .profile").click(function(){ pages.afficherPage("profile") })
- jQuery("#menu .logout").click(function(){
+ $("#menu .minichat").click(function(){ pages.afficherPage("minichat") })
+ $("#menu .admin").click(function(){ pages.afficherPage("admin") })
+ $("#menu .profile").click(function(){ pages.afficherPage("profile") })
+ $("#menu .logout").click(function(){
util.messageDialogue("Ãtes-vous sur de vouloir vous délogger ?", messageType.question,
{"Oui" : function()
{
@@ -812,10 +880,11 @@ jQuery(document).ready(
}
)
})
- jQuery("#menu .register").click(function(){ pages.afficherPage("register") })
- jQuery("#menu .about").click(function(){ pages.afficherPage("about") })
+ $("#menu .register").click(function(){ pages.afficherPage("register") })
+ $("#menu .about").click(function(){ pages.afficherPage("about") })
pages.ajouterPage(new PageMinichat(client, formateur, util))
+ pages.ajouterPage(new PageAdmin(client, formateur, util))
pages.ajouterPage(new PageProfile(client, formateur, util))
pages.ajouterPage(new PageRegister(client, formateur, util))
pages.ajouterPage(new PageAbout(client, formateur, util))