-// coding: utf-8\r
-// Copyright 2008 Grégory Burri\r
-//\r
-// This file is part of Euphorik.\r
-//\r
-// Euphorik is free software: you can redistribute it and/or modify\r
-// it under the terms of the GNU General Public License as published by\r
-// the Free Software Foundation, either version 3 of the License, or\r
-// (at your option) any later version.\r
-//\r
-// Euphorik is distributed in the hope that it will be useful,\r
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-// GNU General Public License for more details.\r
-//\r
-// You should have received a copy of the GNU General Public License\r
+// 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,
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// 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 <http://www.gnu.org/licenses/>.
function PageMinichat(client, formateur, util)
this.formateur = formateur
this.util = util
+ // permet d'éviter d'envoyer plusieurs messages simultanément en pressant
+ // rapidement sur "enter" par exemple
+ this.envoieMessageEnCours = false
+
this.regexMessageTagMatch = /\{.*?\}>/g
this.regexMessageTagReplace = /^(.*?\{.*?\}>)*/
}
<form method="post" action="" id ="posterMessage">\
<p>\
<input class="captcha" name="captcha" type="text" size="8" maxlength="8"></input>\
- <input class="pseudo" name="pseudo" type="text" maxlength="50" value="<nick>"></input>\
+ <input class="pseudo" name="pseudo" type="text" maxlength="50" value="' + encodeURI(conf.nickDefaut) + '"></input>\
<input class="message" name="message" type="text" maxlength="500" value=""></input>\
<button class="smiles"></button>\
<button class="return"></button>\
this.messages = new Messages(this.client, this.formateur, this.util)
this.messages.rafraichirMessages(true)
- \r
+
this.util.setCaretToEnd($("form input.message")[0])
// les outils de bannissement (uniquement pour les ekMaster)
}
PageMinichat.prototype.envoyerMessage = function(pseudo, message)
-{
+{
var thisPageMinichat = this
-\r
+
// (un pseudo vide est autorisé)
pseudo = this.formateur.filtrerInputPseudo(pseudo)
for(var i = 0; i < tags.length; i++)
repondA.push(parseInt(/\{(.*?)\}>/.exec(tags[i])[1], 36))
message = message.replace(this.regexMessageTagReplace, "")
- }\r
- \r
- message = message.trim()\r
- if (message == "")\r
+ }
+
+ if (pseudo == conf.nickDefaut)
{
- this.util.messageDialogue("Le message est vide")\r
- return\r
- }\r
-\r
- if (!this.client.authentifie())\r
- if (!this.client.enregistrement())\r
- {\r
- this.util.messageDialogue("login impossible")\r
- return\r
+ this.util.messageDialogue("Le pseudo ne peut pas être " + conf.nickDefaut)
+ return
+ }
+
+ message = message.trim()
+ if (message == "")
+ {
+ this.util.messageDialogue("Le message est vide")
+ return
+ }
+
+ if (!this.client.authentifie())
+ if (!this.client.enregistrement())
+ {
+ this.util.messageDialogue("login impossible")
+ return
}
- this.client.pseudo = pseudo\r
-
- ;; dumpObj(this.getJSONMessage(pseudo, message, repondA))\r
- jQuery.ajax(\r
- {\r
- url : "request", \r
- type: "POST",\r
- data : this.util.jsonVersAction(this.getJSONMessage(pseudo, message, repondA)),\r
+ this.client.pseudo = pseudo
+
+ // évite le double post
+ if (this.envoieMessageEnCours)
+ {
+ this.util.messageDialogue("Message en cours d'envoie...")
+ return
+ }
+ this.envoieMessageEnCours = true
+
+ ;; dumpObj(this.getJSONMessage(pseudo, message, repondA))
+ jQuery.ajax(
+ {
+ url : "request",
+ type: "POST",
+ data : this.util.jsonVersAction(this.getJSONMessage(pseudo, message, repondA)),
dataType : "json",
beforeSend : function(xmlHttpRequest)
{
+ // TODO : ça marche ça ??
xmlHttpRequest.setRequestHeader("X-Requested-With", "")
- },\r
- success : function(data, textStatus)\r
+ },
+ success : function(data, textStatus)
{
;; dumpObj(data)
if(data["reply"] == "ok")
- { \r
+ {
$("form input.message").val("")
// met à jour la classe des messages auquel repond celui ci (c'est un peu de la triche) TODO : ya mieux ?
for (var i = 0; i < repondA.length; i++)
+ {
+ for (var j = 0; j < thisPageMinichat.messages.conversations.length; j++)
+ {
+ var mess = thisPageMinichat.messages.conversations[j].messagesParId[repondA[i]]
+ if (mess != undefined)
+ mess.clientARepondu = true
+ }
$("#conversations div#mess" + repondA[i].toString(36)).addClass("repondu")
+ }
}
else if (data["reply"] == "error")
{
thisPageMinichat.util.messageDialogue(data["error_message"])
- } \r
- }\r
- }\r
+ }
+ thisPageMinichat.envoieMessageEnCours = false
+ },
+ error : function()
+ {
+ thisPageMinichat.envoieMessageEnCours = false
+ }
+ }
)
}
var DOM = $(XHTML)
DOM.each(
function()
- {
+ {
$(".lienConv", this).click(
function(event)
{
funClickOuvrirConv(parseInt(racine.substring(1, racine.length - 1), 36))
return false
}
+ )
+
+ thisConversation.util.infoBulle("Extraction de la conversation", $(".extraire", this))
+
+ // l'id du message
+ var idMess36 = $(this).attr("id").substr(4)
+ var idMess = parseInt(idMess36, 36)
+
+ $(this).click(
+ function(event)
+ {
+ if ($(event.target).is("a") || $(event.target).parents("#outilsBan").length > 0) return
+
+ // extraction d'une conversation
+ if ($(event.target).is(".extraire"))
+ {
+ funClickOuvrirConv(idMess)
+ return
+ }
+
+ var valCourant = $("input.message").val()
+ if (valCourant == undefined) valCourant = ""
+ var tag = $(".pseudo span.ident", this).text() + "{" + idMess36 + "}" + ">"
+ if (valCourant.indexOf(tag, 0) == -1)
+ $("input.message").val(tag + " " + valCourant)
+ thisConversation.util.setCaretToEnd($("form input.message")[0])
+ }
+ )
+
+ // mise en évidence de la conversation
+ $(".entete", this).hover(
+ function()
+ {
+ thisConversation.decolorerEntetes()
+ thisConversation.afficherConversation(idMess)
+ },
+ // quand on sort de l'entête du message la mise en évidence est enlevée
+ function()
+ {
+ thisConversation.enleverMiseEnEvidence()
+ thisConversation.decolorerEntetes()
+ thisConversation.colorerEntetes()
+ }
)
if (thisConversation.client.viewTimes)
{
$("#outilsBan", this).hide()
}
- )
-
- thisConversation.util.infoBulle("Extraction de la conversation", $(".extraire", this))
-
- // l'id du message
- var idMess36 = $(this).attr("id").substr(4)
- var idMess = parseInt(idMess36, 36)
-
- $(this).click(
- function(event)
- {
- if ($(event.target).is("a") || $(event.target).parents("#outilsBan").length > 0) return
-
- // extraction d'une conversation
- if ($(event.target).is(".extraire"))
- {
- funClickOuvrirConv(idMess)
- return
- }
-
- var valCourant = $("input.message").val()
- if (valCourant == undefined) valCourant = ""
- var tag = $(".pseudo span.ident", this).text() + "{" + idMess36 + "}" + ">"
- if (valCourant.indexOf(tag, 0) == -1)
- $("input.message").val(tag + " " + valCourant)
- thisConversation.util.setCaretToEnd($("form input.message")[0])
- }
- )\r
- \r
- // mise en évidence de la conversation
- $(".entete", this).hover(\r
- function()\r
- {
- thisConversation.decolorerEntetes()\r
- thisConversation.afficherConversation(idMess)\r
- },
- // quand on sort de l'entête du message la mise en évidence est enlevée
- function()
- {
- thisConversation.enleverMiseEnEvidence()
- thisConversation.decolorerEntetes()
- thisConversation.colorerEntetes()
- }
- )
+ )\r
}
)
DOM.prependTo("#conversations #" + this.getId())
element["nick"],
element["login"],
element["content"]
- ) \r
+ )
message.appartientAuClient = element["owner"]
message.clientARepondu = element["answered"]
* Ajuste la largeur des conversations en fonction de leur nombre. modifie l'attribut CSS 'width'.
*/
Messages.prototype.ajusterLargeurConversations = function()
-{\r
- var largeurPourcent = (100 / this.conversations.length) \r
- // le "- 0.01" evite que IE se chie dessus lamentablement et affiche les conversations les unes au dessus des autres\r
- if($.browser["msie"])\r
+{
+ var largeurPourcent = (100 / this.conversations.length)
+ // le "- 0.01" evite que IE se chie dessus lamentablement et affiche les conversations les unes au dessus des autres
+ if($.browser["msie"])
largeurPourcent -= 0.05
$("#conversations .conversation").css("width", largeurPourcent + "%")
}