-/**
- * La configuration.
- * Normalement 'const' à la place de 'var' mais non supporté par IE7.
- */
-var conf = {
- nickDefaut : "<nick>",
- nbMessageAffiche : 40, // (par page)
- pseudoDefaut : "<nick>",
- tempsAffichageMessageDialogue : 4000, // en ms
- tempsKick : 15, // en minute
- tempsBan : 60 * 24 * 3, // en minutes (3jours)
- smiles : {
- "smile" : [/:\)/g, /:-\)/g],
- "bigsmile" : [/:D/g, /:-D/g],
- "clin" : [/;\)/g, /;-\)/g],
- "cool" : [/8\)/g, /8-\)/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],
- "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]
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-String.prototype.trim = function()
-{
- return jQuery.trim(this) // anciennement : this.replace(/^\s+|\s+$/g, "");
-}
-
-String.prototype.ltrim = function()
-{
- return this.replace(/^\s+/, "");
-}
-
-String.prototype.rtrim = function()
-{
- return this.replace(/\s+$/, "");
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-/**
- * Cette classe regroupe des fonctions utilitaires (helpers).
- * @formateur est permet de formater les messages affichés à l'aide de messageDialogue (facultatif)
- */
-function Util(formateur)
-{
- $("#info .fermer").click(function(){
- $("#info").slideUp(50)
- })
-
- $("body").append('<div id="flecheBulle"></div>').append('<div id="messageBulle"><p></p></div>')
-
- this.formateur = formateur
- this.bulleActive = true
-}
-
-var messageType = {informatif: 0, question: 1, erreur: 2}
-
-/**
- * Affiche une boite de dialogue avec un message à l'intérieur.
- * @param message le message (string)
- * @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, formate)
-{
- var thisUtil = this
-
- if (type == undefined)
- type = messageType.informatif
-
- if (formate == undefined)
- formate = true
-
- if (this.timeoutMessageDialogue != undefined)
- clearTimeout(this.timeoutMessageDialogue)
-
- var fermer = function(){$("#info").slideUp(100)}
- fermer()
-
- $("#info .message").html(thisUtil.formateur == undefined || !formate ? message : thisUtil.formateur.traitementComplet(message))
- switch(type)
- {
- 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
- }
- $("#info .boutons").html("")
- for (var b in boutons)
- $("#info .boutons").append("<div>" + b + "</div>").find("div:last").click(boutons[b]).click(fermer)
-
- $("#info").slideDown(200)
- this.timeoutMessageDialogue = setTimeout(fermer, conf.tempsAffichageMessageDialogue)
-}
-
-/**
- * Affiche un info bulle lorsque le curseur survole l'élément donné.
- * FIXME : le width de element ne tient pas compte du padding !?
- */
-Util.prototype.infoBulle = function(message, element)
-{
- var thisUtil = this
-
- var cacherBulle = function()
- {
- $("#flecheBulle").hide()
- $("#messageBulle").hide()
- }
-
- element.hover(
- function(e)
- {
- if (!thisUtil.bulleActive)
- return
-
- var m = $("#messageBulle")
- var f = $("#flecheBulle")
-
- // remplie le paragraphe de la bulle avec le message
- $("p", m).html(message)
-
- // réinitialise la position, évite le cas ou la boite est collé à droite et remplie avec un texte la faisant dépassé
- // dans ce cas la hauteur n'est pas calculé correctement
- m.css("top", 0).css("left", 0)
-
- var positionFleche = {
- left : element.offset().left + element.width() / 2 - f.width() / 2,
- top : element.offset().top - f.height()
- }
- var positionMessage = {
- left : element.offset().left + element.width() / 2 - m.width() / 2,
- top : element.offset().top - f.height() - m.height()
- }
- var depassementDroit = (positionMessage.left + m.width()) - $("body").width()
- if (depassementDroit > 0)
- positionMessage.left -= depassementDroit
- else
- {
- if (positionMessage.left < 0)
- positionMessage.left = 0
- }
-
- m.css("top", positionMessage.top).css("left", positionMessage.left).show()
- f.css("top", positionFleche.top).css("left", positionFleche.left).show()
- },
- cacherBulle
- ).click(cacherBulle)
-}
-
-/**
- * Utilisé pour l'envoie de donnée avec la méthode ajax de jQuery.
- */
-Util.prototype.jsonVersAction = function(json)
-{
- return {action : JSON.stringify(json) }
-}
-
-Util.prototype.md5 = function(chaine)
-{
- return hex_md5(chaine)
-}
-
-// pompé de http://www.faqts.com/knowledge_base/view.phtml/aid/13562/fid/130
-Util.prototype.setSelectionRange = function(input, selectionStart, selectionEnd)
-{
- if (input.setSelectionRange)
- {
- input.focus()
- input.setSelectionRange(selectionStart, selectionEnd)
- }
- else if (input.createTextRange)
- {
- var range = input.createTextRange()
- range.collapse(true)
- range.moveEnd('character', selectionEnd)
- range.moveStart('character', selectionStart)
- range.select()
- }
-}
-
-Util.prototype.setCaretToEnd = function(input)
-{
- this.setSelectionRange(input, input.value.length, input.value.length)
-}
-Util.prototype.setCaretToBegin = function(input)
-{
- this.setSelectionRange(input, 0, 0)
-}
-Util.prototype.setCaretToPos = function(input, pos)
-{
- this.setSelectionRange(input, pos, pos)
-}
-Util.prototype.selectString = function(input, string)
-{
- var match = new RegExp(string, "i").exec(input.value)
- if (match)
- {
- this.setSelectionRange (input, match.index, match.index + match[0].length)
- }
-}
-Util.prototype.replaceSelection = function(input, replaceString) {
- if (input.setSelectionRange)
- {
- var selectionStart = input.selectionStart
- var selectionEnd = input.selectionEnd
- input.value = input.value.substring(0, selectionStart) + replaceString + input.value.substring(selectionEnd)
-
- if (selectionStart != selectionEnd) // has there been a selection
- this.setSelectionRange(input, selectionStart, selectionStart + replaceString.length)
- else // set caret
- this.setCaretToPos(input, selectionStart + replaceString.length)
- }
- else if (document.selection)
- {
- input.focus()
- var range = document.selection.createRange()
- if (range.parentElement() == input)
- {
- var isCollapsed = range.text == ''
- range.text = replaceString
- if (!isCollapsed)
- {
- range.moveStart('character', -replaceString.length);
- }