//
// You should have received a copy of the GNU General Public License
// along with Euphorik. If not, see <http://www.gnu.org/licenses/>.
-
+
/*jslint laxbreak:true */
-euphorik.PageMinichat = function(client, formater, util, communication) {
+euphorik.PageMinichat = function(client, formatter, util, communication) {
this.name = "minichat";
-
+
this.client = client;
- this.formater = formater;
+ this.formatter = formatter;
this.util = util;
this.communication = communication;
- this.commandes = new euphorik.Commandes(this.client, this, this.util, this.formater);
-
+ this.commandes = new euphorik.Commandes(this.client, this, this.util, this.formatter);
+
// permet d'éviter d'envoyer plusieurs messages simultanément en pressant
// rapidement sur "enter" par exemple
this.envoieMessageEnCours = false;
' <button class="return"></button>' +
' </p>' +
'</form>';
-
- var trollXHTML = '<div id="trollCourant">Troll de la semaine : <span class="troll"></span></div>';
+
var conversationXHTML = '<table id="conversations"><tr></tr></table>';
-
+
if (this.client.chatOrder === "reverse") {
- return trollXHTML + formulaireXHTML + conversationXHTML;
+ return formulaireXHTML + conversationXHTML;
} else {
- return trollXHTML + conversationXHTML + formulaireXHTML;
+ return conversationXHTML + formulaireXHTML;
}
};
euphorik.PageMinichat.prototype.charger = function() {
thisPage = this;
-
+
$("#posterMessage input.nick").val(this.client.nick);
-
+
// cet appel ne doit pas être fait avant l'appel à 'charger'
- this.conversations = new euphorik.Conversations(this.client, this.formater, this.util, this.communication, this.fragment);
-
+ this.conversations = new euphorik.Conversations(this.client, this.formatter, this.util, this.communication, this.fragment);
+
this.chargerConversationsFragment();
-
- this.conversations.rafraichirMessages(true);
+
+ this.conversations.rafraichirMessages(true);
this.util.setCaretToEnd($("form#posterMessage input.message")[0]);
// les outils de bannissement (uniquement pour les ekMaster)
- if (this.client.ekMaster) {
+ if (this.client.ekMaster) {
// TODO : augmentation un peu space, à revoir
this.util.outilsBan = $(
'<span id="outilsBan">' +
' <img id="slap" src="img/slap.gif" alt="Avertissement" />' +
'</span>'
);
-
+
this.util.infoBulle("Slap", $("#slap", this.util.outilsBan));
this.util.infoBulle("Kick (" + euphorik.conf.tempsKick + "min)", $("#kick", this.util.outilsBan));
this.util.infoBulle("Ban (" + euphorik.conf.tempsBan / 24 / 60 + " jours)", $("#ban", this.util.outilsBan));
this.util.infoBulle("La raison", $("input", this.util.outilsBan));
}
-
+
// la barre d'outils liée à chaque message
- this.util.outilsMessage = $('<div id="outilsMess"><div class="extraire"></div><div class="extraireCompletement"></div></div>').prependTo("#page.minichat");
- this.util.infoBulle("Ouvrir la conversation liée au troll de la semaine", $("#trollCourant .troll"));
+ this.util.outilsMessage = $('<div id="outilsMess"><div class="extraire"></div><div class="extraireCompletement"></div></div>').prependTo("#page.minichat");
this.util.infoBulle("Cliquer sur les messages pour les enlevers de la liste",
$("form#posterMessage #repondA").hover(
function() {
if ($(e.target).is(".nb")) {
thisPage.conversations.enleverMessagesRepond();
}
- }
+ }
),
euphorik.Util.positionBulleType.droite
);
// <smiles>
$("body").append('<div id="smiles"></div>');
// affichage des smiles
- $("#smiles").append(this.formater.getSmilesHTML()).children().each(
+ $("#smiles").append(this.formatter.getSmilesHTML()).children().each(
function(i) {
var opacityBase = $(this).css("opacity");
$(this).click(
function() {
- thisPage.util.replaceSelection($("form#posterMessage input.message")[0], thisPage.formater.smiles[$(this).attr("class")][0].source.replace(/\\/g, ""));
+ thisPage.util.replaceSelection($("form#posterMessage input.message")[0], thisPage.formatter.smiles[$(this).attr("class")][0].source.replace(/\\/g, ""));
}
).hover(
function() { $(this).animate({opacity: 1}, 200); },
}
);
// </smiles>
-
+
// événements
- var nouveauMessage =
- function() {
+ var nouveauMessage =
+ function() {
// captcha anti bot
if ($("form#posterMessage input.captcha").val() !== "") {
return;
}
-
+
var message = $("form#posterMessage input.message").val();
-
+
// traitement des commandes..
- var retCommandes = thisPage.commandes.exec(message);
+ var retCommandes = thisPage.commandes.exec(message);
switch (retCommandes[0]) {
case euphorik.Commandes.statut.pas_une_commande :
thisPage.envoyerMessage(message);
case euphorik.Commandes.statut.ok :
$("form#posterMessage input.message").val("");
break;
- }
-
+ }
+
$("form#posterMessage input.message").focus();
};
-
+
$("form#posterMessage").keypress(
function(e) {
if (e.which === 13) { // return
}
}
);
-
+
$("form#posterMessage button.return").click(nouveauMessage);
-
+
// interdiction de submiter le formulaire
$("form#posterMessage").submit(function(){ return false; });
-
+
$("input.nick").click(
function() {
var input = $("input.nick")[0];
};
euphorik.PageMinichat.prototype.chargerConversationsFragment = function() {
- var thisPageMinichat = this;
-
+ var thisPageMinichat = this;
+
// attention : "conv" doit être un tableau d'entier
try {
var conv = this.fragment.getVal("conv");
;; console.log(e)
}
};
-
+
euphorik.PageMinichat.prototype.decharger = function() {
this.conversations.comet.stopAttenteCourante();
-
+
$("body #smiles").remove();
-
+
this.fragment.delVal("conv");
};
* Envoie un nouve message donné, le nick utilisé est celui se trouvant
* dans la zone de saisie (form#posterMessage input.nick).
*/
-euphorik.PageMinichat.prototype.envoyerMessage = function(message) {
- var thisPageMinichat = this;
+euphorik.PageMinichat.prototype.envoyerMessage = function(message) {
+ var thisPageMinichat = this;
var nick = $("form#posterMessage input.nick").val();
// (un nick vide est autorisé)
- nick = this.formater.filtrerInputPseudo(nick);
-
+ nick = this.formatter.formatNick(nick);
+
if (nick === euphorik.conf.defaultNick) {
- this.util.messageDialog("Le nick ne peut pas être " + euphorik.conf.defaultNick);
+ this.util.messageDialog("Choose a nickname");
return;
}
-
+
message = message.trim();
if (!message) {
- this.util.messageDialog("Le message est vide");
+ this.util.messageDialog("The message is empty");
return;
}
-
- this.client.nick = nick;
if (!this.client.authentifie()) {
if (!this.client.enregistrement()) {
- this.util.messageDialog("login impossible");
+ this.util.messageDialog("unable to login");
return;
}
}
-
+
// évite le double post
if (this.envoieMessageEnCours) {
this.util.messageDialog("Message en cours d'envoie...");
return;
}
this.envoieMessageEnCours = true;
-
+
+ this.client.nick = nick;
+
this.communication.requete(
"put_message",
- this.getJSONMessage(nick, message),
+ this.getJSONMessage(this.client.nick, message),
function() {
$("form#posterMessage input.message").val("");
- thisPageMinichat.conversations.enleverMessagesRepond();
+ thisPageMinichat.conversations.enleverMessagesRepond();
thisPageMinichat.envoieMessageEnCours = false;
},
function(data) {
objectEach(this.conversations.messagesRepond, function(id) {
repondA.push(parseInt(id, 10));
});
-
+
return {
"cookie" : this.client.cookie,
"nick" : nick,