From 9d95f5af441fda194444405983e4d110c2514680 Mon Sep 17 00:00:00 2001 From: Greg Burri Date: Sun, 11 May 2008 07:31:23 +0000 Subject: [PATCH] MOD remplacement des jQuery par des $( (puisqu'il n'y a plus de conflits avec prototype) --- js/euphorik.js | 70 +++++++++++------------ js/pageMinichat.js | 140 ++++++++++++++++++++++----------------------- js/pageProfile.js | 30 +++++----- js/pageRegister.js | 12 ++-- 4 files changed, 126 insertions(+), 126 deletions(-) diff --git a/js/euphorik.js b/js/euphorik.js index 8892035..2b885ab 100755 --- a/js/euphorik.js +++ b/js/euphorik.js @@ -69,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) }) } @@ -89,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) } @@ -238,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() @@ -423,7 +423,7 @@ 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 @@ -441,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() } @@ -702,7 +702,7 @@ 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 @@ -753,21 +753,21 @@ Client.prototype.majMenu = function() // 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) } } @@ -808,10 +808,10 @@ Client.prototype.kick = function(userId) 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") } ) } @@ -820,7 +820,7 @@ function initialiserListeStyles(client) ;;; jQuery.ajax({async : false, url : "js/debug.js", dataType : "script"}) // le main -jQuery(document).ready( +$(document).ready( function() { var util = new Util() @@ -833,12 +833,12 @@ 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 .profile").click(function(){ pages.afficherPage("profile") }) + $("#menu .logout").click(function(){ util.messageDialogue("Êtes-vous sur de vouloir vous délogger ?", messageType.question, {"Oui" : function() { @@ -849,8 +849,8 @@ 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 PageProfile(client, formateur, util)) diff --git a/js/pageMinichat.js b/js/pageMinichat.js index aeda772..792caf9 100755 --- a/js/pageMinichat.js +++ b/js/pageMinichat.js @@ -31,47 +31,47 @@ PageMinichat.prototype.charger = function() { thisPage = this - jQuery("form input.pseudo").val(this.client.pseudo) + $("form input.pseudo").val(this.client.pseudo) // cet appel ne doit pas être fait avant l'appel à 'charger' this.messages = new Messages(this.client, this.formateur, this.util) this.messages.rafraichirMessages(true) - this.util.setCaretToEnd(jQuery("form input.message")[0]) + this.util.setCaretToEnd($("form input.message")[0]) // les outils de bannissement (uniquement pour les ekMaster) if (this.client.ekMaster) { - jQuery("body").append( + $("body").append( "
\"Ban\"Ban\"Avertissement\"
" ) - jQuery("#outilsBan").hover( + $("#outilsBan").hover( function(){}, function() { - jQuery("#outilsBan").hide() + $("#outilsBan").hide() } ) } // - jQuery("body").append("
") + $("body").append("
") // affichage des smiles - jQuery("#smiles").append(this.formateur.getSmilesHTML()).children().each( + $("#smiles").append(this.formateur.getSmilesHTML()).children().each( function(i) { - var opacityBase = jQuery(this).css("opacity") - jQuery(this).click( + var opacityBase = $(this).css("opacity") + $(this).click( function(event) { - thisPage.util.replaceSelection(jQuery("form input.message")[0], thisPage.formateur.smiles[jQuery(this).attr("class")][0].source.replace(/\\/g, "")) + thisPage.util.replaceSelection($("form input.message")[0], thisPage.formateur.smiles[$(this).attr("class")][0].source.replace(/\\/g, "")) } ) .hover( function() { - jQuery(this).animate( + $(this).animate( { opacity: 1 }, 200 @@ -79,7 +79,7 @@ PageMinichat.prototype.charger = function() }, function() { - jQuery(this).animate( + $(this).animate( { opacity: opacityBase }, 200 @@ -88,19 +88,19 @@ PageMinichat.prototype.charger = function() ) } ) - jQuery("form button.smiles").hover( + $("form button.smiles").hover( function(e) { - var offset = jQuery(e.target).offset() - jQuery("#smiles").css("top", offset.top).css("left", offset.left).show() + var offset = $(e.target).offset() + $("#smiles").css("top", offset.top).css("left", offset.left).show() }, function(e){} ) - jQuery("#smiles").hover( + $("#smiles").hover( function(){}, function(e) { - jQuery("#smiles").hide() + $("#smiles").hide() } ) //
@@ -110,17 +110,17 @@ PageMinichat.prototype.charger = function() function() { // captcha anti bot - if (jQuery("form input.captcha").val() != "") return + if ($("form input.captcha").val() != "") return thisPage.envoyerMessage( - jQuery("form input.pseudo").val(), - jQuery("form input.message").val() + $("form input.pseudo").val(), + $("form input.message").val() ) - jQuery("form input.message")[0].focus() + $("form input.message")[0].focus() } - jQuery("form").keypress( + $("form").keypress( function(e) { if (e.which == 13) // return @@ -128,15 +128,15 @@ PageMinichat.prototype.charger = function() } ) - jQuery("form button.return").click(nouveauMessage) + $("form button.return").click(nouveauMessage) // interdiction de submiter le formulaire - jQuery("form").submit(function(){ return false}) + $("form").submit(function(){ return false}) - jQuery("input.pseudo").click( + $("input.pseudo").click( function() { - var input = jQuery("input.pseudo")[0] + var input = $("input.pseudo")[0] if (input.value == conf.pseudoDefaut) input.value = "" } @@ -148,8 +148,8 @@ PageMinichat.prototype.decharger = function() //alert(this.attenteCourante) this.messages.stopAttenteCourante() - jQuery("body #smiles").remove() - jQuery("body #outilsBan").remove() + $("body #smiles").remove() + $("body #outilsBan").remove() } PageMinichat.prototype.getJSONMessage = function(pseudo, message, repondA) @@ -213,12 +213,12 @@ PageMinichat.prototype.envoyerMessage = function(pseudo, message) if(data["reply"] == "ok") { - jQuery("form input.message").val("") + $("form input.message").val("") // met à jour la classe des messages auquel repond celui ci (c'est un peu de la triche) for (var i = 0; i < repondA.length; i++) { - jQuery("#conversations div#" + repondA[i]).addClass("repondu") + $("#conversations div#" + repondA[i]).addClass("repondu") /* Ca sert à rien, TODO : tester/virer for (var c = 0; c < thisPageMinichat.messages.conversations.length; c++) for (var m = 0; m < thisPageMinichat.messages.conversations[c].messages.length; m++) @@ -354,7 +354,7 @@ function Conversation(num, util, formateur, client) this.nbMessageMax = conf.nbMessageAffiche // Le nombre de message affiché par page - jQuery("#conversations").append( + $("#conversations").append( '
\
' + (num == 0 ? '' : '
x
c
') + @@ -364,11 +364,11 @@ function Conversation(num, util, formateur, client) ) // enlève la mise en évidence pour la conversation - jQuery("#conversations #" + this.getId()).hover( + $("#conversations #" + this.getId()).hover( function(){}, function(event) { - jQuery("#conversations .message").removeClass("cache") + $("#conversations .message").removeClass("cache") thisConversation.messageOver = null } ) @@ -381,9 +381,9 @@ function Conversation(num, util, formateur, client) */ Conversation.prototype.setPage = function(pageCourante, dernierePage) { - jQuery("#conversations #" + this.getId() + " .numPage").text(pageCourante) - jQuery("#conversations #" + this.getId() + " .next").css("display", pageCourante == 1 ? "none" : "inline") - jQuery("#conversations #" + this.getId() + " .prev").css("display", dernierePage ? "none" : "inline") + $("#conversations #" + this.getId() + " .numPage").text(pageCourante) + $("#conversations #" + this.getId() + " .next").css("display", pageCourante == 1 ? "none" : "inline") + $("#conversations #" + this.getId() + " .prev").css("display", dernierePage ? "none" : "inline") } /** @@ -393,7 +393,7 @@ Conversation.prototype.eventLien = function(fun) { var thisConversation = this - jQuery("#conversations #" + this.getId() + " .titre .lien").click( + $("#conversations #" + this.getId() + " .titre .lien").click( function() { fun(thisConversation.num) @@ -408,7 +408,7 @@ Conversation.prototype.eventFermer = function(fun) { var thisConversation = this - jQuery("#conversations #" + this.getId() + " .titre .fermer").click( + $("#conversations #" + this.getId() + " .titre .fermer").click( function() { fun(thisConversation.num) @@ -425,13 +425,13 @@ Conversation.prototype.setFunPage = function(funNext, funPrev, funReset) { var thisConversation = this - jQuery("#conversations #" + this.getId() + " .next").click( + $("#conversations #" + this.getId() + " .next").click( function() { funNext(thisConversation.num) } ) - jQuery("#conversations #" + this.getId() + " .prev").click( + $("#conversations #" + this.getId() + " .prev").click( function() { funPrev(thisConversation.num) } ) - jQuery("#conversations #" + this.getId() + " .numPage").click( + $("#conversations #" + this.getId() + " .numPage").click( function() { funReset(thisConversation.num) } ) } @@ -459,7 +459,7 @@ Conversation.prototype.viderMessages = function() { this.messages = new Array() this.idDernierMessageAffiche = 0 - jQuery("#conversations #" + this.getId() + " .message").remove() + $("#conversations #" + this.getId() + " .message").remove() } /** @@ -474,7 +474,7 @@ Conversation.prototype.flush = function(funClickOuvrirConv) // est-ce que le prochain message est pair ? (permet d'alterner le style des messages) var messagePair = (this.idDernierMessageAffiche == 0 ? true : - (jQuery("#conversations #" + this.getId() + " div:first").attr("class").search("messagePair") == -1) + ($("#conversations #" + this.getId() + " div:first").attr("class").search("messagePair") == -1) ) // construction de l'XHTML des messages @@ -513,23 +513,23 @@ Conversation.prototype.flush = function(funClickOuvrirConv) messagePair = !messagePair } - jQuery("#conversations #" + this.getId()).prepend(XHTML) + $("#conversations #" + this.getId()).prepend(XHTML) // enlève les messages exedentaires - var nbMessagesAffiche = jQuery("#conversations #" + this.getId() + " .message").size() + var nbMessagesAffiche = $("#conversations #" + this.getId() + " .message").size() if (nbMessagesAffiche > this.nbMessageMax) - jQuery("#conversations #" + this.getId() + " .message").slice(this.nbMessageMax, nbMessagesAffiche).empty() + $("#conversations #" + this.getId() + " .message").slice(this.nbMessageMax, nbMessagesAffiche).empty() // ajoute les événements liés à chaque nouveau message - jQuery("#conversations #" + this.getId() + " .message").filter(function(){return parseInt(jQuery(this).attr("id"), 36) > thisConversation.idDernierMessageAffiche}).each( + $("#conversations #" + this.getId() + " .message").filter(function(){return parseInt($(this).attr("id"), 36) > thisConversation.idDernierMessageAffiche}).each( function() { - jQuery(".lienConv", this).click( + $(".lienConv", this).click( function(event) { // FIXME : ya pas mieux ? - var racine = jQuery(event.target).text() + var racine = $(event.target).text() funClickOuvrirConv(parseInt(racine.substring(1, racine.length - 1), 36)) return false } @@ -539,22 +539,22 @@ Conversation.prototype.flush = function(funClickOuvrirConv) // les outils de bannissement (uniquement pour les ekMaster) if (thisConversation.client.ekMaster) - jQuery(".pseudo", this).hover( + $(".pseudo", this).hover( function(e) { - var userId = parseInt(jQuery(this).attr("id").substr(4)) - var element = jQuery(e.target) + var userId = parseInt($(this).attr("id").substr(4)) + var element = $(e.target) var h = element.height() var offset = element.offset() - var outils = jQuery("#outilsBan").css("top", offset.top - 2).css("left", offset.left - 2).height(h < 16 ? 16 : h).width(element.width() + 16 * 3 + 4).show() - jQuery("img", outils).unbind() - jQuery("#kick", outils).click( + var outils = $("#outilsBan").css("top", offset.top - 2).css("left", offset.left - 2).height(h < 16 ? 16 : h).width(element.width() + 16 * 3 + 4).show() + $("img", outils).unbind() + $("#kick", outils).click( function(e) { thisConversation.client.kick(userId) } ) - jQuery("#ban", outils).click( + $("#ban", outils).click( function(e) { thisConversation.client.ban(userId) @@ -564,27 +564,27 @@ Conversation.prototype.flush = function(funClickOuvrirConv) function(){} ) - jQuery(this).click( + $(this).click( function(event) { - if (jQuery(event.target).is("a")) return + if ($(event.target).is("a")) return // l'id du message - var idMess = jQuery(this).attr("id") + var idMess = $(this).attr("id") // extraction d'une conversation - if (jQuery(event.target).is(".extraire")) + if ($(event.target).is(".extraire")) { funClickOuvrirConv(parseInt(idMess, 36)) return } - var valCourant = jQuery("input.message").val() + var valCourant = $("input.message").val() if (valCourant == undefined) valCourant = "" - var tag = jQuery(".pseudo", this).text() + "{" + idMess + "}" + ">" + var tag = $(".pseudo", this).text() + "{" + idMess + "}" + ">" if (valCourant.indexOf(tag, 0) == -1) - jQuery("input.message").val(tag + " " + valCourant) - thisConversation.util.setCaretToEnd(jQuery("form input.message")[0]) + $("input.message").val(tag + " " + valCourant) + thisConversation.util.setCaretToEnd($("form input.message")[0]) } ) // Q : pourquoi pas un .hover ? @@ -614,7 +614,7 @@ Conversation.prototype.flush = function(funClickOuvrirConv) Conversation.prototype.afficherConversation = function(element) { // cherche le message selectionné - var id = parseInt(jQuery(element).attr("id"), 36) + var id = parseInt($(element).attr("id"), 36) var message = this.messagesParId[id] if (message == undefined) return @@ -622,10 +622,10 @@ Conversation.prototype.afficherConversation = function(element) mess = message.getConversation(this) // FIXME : cet appel est très lent - jQuery("#conversations #" + this.getId() + " .message").each( + $("#conversations #" + this.getId() + " .message").each( function() { - var jq = jQuery(this) + var jq = $(this) if (!mess.hasOwnProperty(parseInt(jq.attr("id"), 36))) jq.addClass("cache") else @@ -639,7 +639,7 @@ Conversation.prototype.afficherConversation = function(element) */ Conversation.prototype.supprimer = function() { - jQuery("#conversations #" + this.getId()).remove() + $("#conversations #" + this.getId()).remove() } /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -758,7 +758,7 @@ Messages.prototype.ajouterMessage = function(element, numConversation) function(num) // insertion du lien vers la conversation { thisPage.util.replaceSelection( - jQuery("form input.message")[0], + $("form input.message")[0], "{" + thisMessages.client.conversations[num-1].root.toString(36) + "}" ) } @@ -826,7 +826,7 @@ Messages.prototype.supprimerConversation = function(num) */ Messages.prototype.ajusterLargeurConversations = function() { - jQuery("#conversations .conversation").css("width", 100 / this.conversations.length + "%") + $("#conversations .conversation").css("width", 100 / this.conversations.length + "%") } /** diff --git a/js/pageProfile.js b/js/pageProfile.js index f3ef3a8..0641e7c 100755 --- a/js/pageProfile.js +++ b/js/pageProfile.js @@ -17,7 +17,7 @@ PageProfile.prototype.contenu = function() PageProfile.prototype.charger = function() { - jQuery("#page").html(this.getHTML()) + $("#page").html(this.getHTML()) // en fonction du statut if (this.client.authentifie()) @@ -25,30 +25,30 @@ PageProfile.prototype.charger = function() else this.chargerLogin() - jQuery("#page form#profile").submit(function(){return false}) + $("#page form#profile").submit(function(){return false}) } PageProfile.prototype.chargerProfile = function() { var thisPage = this - jQuery("form#profile input.login").val(this.client.login) - jQuery("form#profile input.pseudo").val(this.client.pseudo) - jQuery("form#profile input.email").val(this.client.email) + $("form#profile input.login").val(this.client.login) + $("form#profile input.pseudo").val(this.client.pseudo) + $("form#profile input.email").val(this.client.email) - jQuery("form#profile select#affichagePseudo option").removeAttr("selected") - jQuery("form#profile select#affichagePseudo option[value=" + this.client.nickFormat + "]").attr("selected", "selected") + $("form#profile select#affichagePseudo option").removeAttr("selected") + $("form#profile select#affichagePseudo option[value=" + this.client.nickFormat + "]").attr("selected", "selected") - jQuery("form#profile button").click( + $("form#profile button").click( function() { - thisPage.client.pseudo = thisPage.formateur.filtrerInputPseudo(jQuery("form#profile input.pseudo").val()) - thisPage.client.email = jQuery("form#profile input.email").val() - thisPage.client.nickFormat = jQuery("form#profile select#affichagePseudo option:selected").attr("value") + thisPage.client.pseudo = thisPage.formateur.filtrerInputPseudo($("form#profile input.pseudo").val()) + thisPage.client.email = $("form#profile input.email").val() + thisPage.client.nickFormat = $("form#profile select#affichagePseudo option:selected").attr("value") - var password = jQuery("form#profile input.password").val() - var passwordRe = jQuery("form#profile input.passwordRe").val() + var password = $("form#profile input.password").val() + var passwordRe = $("form#profile input.passwordRe").val() if (password != "" || passwordRe != "") { if (password != passwordRe) @@ -74,10 +74,10 @@ PageProfile.prototype.chargerLogin = function() { var thisPage = this - jQuery("#page form#profile button").click( + $("#page form#profile button").click( function() { - if(!thisPage.client.connexionLogin(jQuery("form#profile input.login").val(), thisPage.util.md5(jQuery("form#profile input.password").val()))) + if(!thisPage.client.connexionLogin($("form#profile input.login").val(), thisPage.util.md5($("form#profile input.password").val()))) thisPage.util.messageDialogue("Couple login/pass introuvable") else { diff --git a/js/pageRegister.js b/js/pageRegister.js index 30d1790..797806e 100755 --- a/js/pageRegister.js +++ b/js/pageRegister.js @@ -36,18 +36,18 @@ PageRegister.prototype.contenu = function() PageRegister.prototype.charger = function() { - jQuery("#page form#register").submit(function(){return false}) + $("#page form#register").submit(function(){return false}) var thisPage = this - jQuery("#page form#register button").click( + $("#page form#register button").click( function() { - if (jQuery("#page form#register input.captcha").val() != "") return + if ($("#page form#register input.captcha").val() != "") return - var login = jQuery("#page form#register input.login").val().trim() - var password = jQuery("#page form#register input.password").val() - var passwordRe = jQuery("#page form#register input.passwordRe").val() + var login = $("#page form#register input.login").val().trim() + var password = $("#page form#register input.password").val() + var passwordRe = $("#page form#register input.passwordRe").val() if (login == "") thisPage.util.messageDialogue("Le login ne doit pas être vide") -- 2.43.0