- return [versionShort == null ? "url" : versionShort, estUneImage]
- }
-
-/**
- * Traite les pseudo et messages à être affiché dans le titre d'une image visualisé avec lightbox.
- */
-Formateur.prototype.traiterPourFenetreLightBox = function(M, urlCourante)
-{
- thisFormateur = this
- var traitementUrl = function(url)
- {
- return "[" + thisFormateur.getShort(url)[0] + (urlCourante == url ? ": image courante" : "") + "]"
- }
- \r
- return this.remplacerBalisesHTML(M).replace(this.regexUrl, traitementUrl)
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-var statutType = {enregistre: 0, identifie: 1, non_identifie: 2}
-\r
-function Client(util)\r
-{
- this.util = util
- \r
- this.cookie = null
- this.regexCookie = new RegExp("^cookie=([^;]*)")
- \r
- // Obsolète
- //this.captchaCrypt = null
-
- // données personnels\r
- this.resetDonneesPersonnelles()
-
- this.setStatut(statutType.non_identifie)
-
- // le dernier message d'erreur recut du serveur (par exemple une connexion foireuse : "login impossible")
- this.dernierMessageErreur = ""\r
-}
-\r
-Client.prototype.resetDonneesPersonnelles = function()\r
-{\r
- this.pseudo = conf.pseudoDefaut\r
- this.login = ""\r
- this.password = ""\r
- this.email = ""\r
- this.css = jQuery("link#cssPrincipale").attr("href")
-
- // les conversations, une conversation est un objet possédant les attributs suivants :
- // - racine (entier)
- // - page (entier)
- this.conversations = new Array()\r
-}
-
-Client.prototype.setCss = function(css)
-{
- if (this.css == css)
- return
-
- this.css = css
- jQuery("link#cssPrincipale").attr("href", this.css)
- this.majMenu()
-
- if (this.identifie())
- this.flush()
-}
-
-/**
- * Ajoute une conversation à la vue de l'utilisateur.
- * Le profile de l'utilisateur est directement sauvegardé sur le serveur.
- * @param racines la racine de la conversation
- */
-Client.prototype.ajouterConversation = function(racine)
-{
- this.conversations.push({racine : racine, page : 1})
- this.flush()
-}\r
-
-Client.prototype.getXMLlogin = function(login, password)
-{
- var XMLDocument = this.util.creerDocumentXMLAction()
- XMLDocument.documentElement.setAttribute("name", "login")
-
- var nodeLogin = XMLDocument.createElement("login")
- nodeLogin.appendChild(XMLDocument.createTextNode(login))
- XMLDocument.documentElement.appendChild(nodeLogin)
-
- var nodePassword = XMLDocument.createElement("password")
- nodePassword.appendChild(XMLDocument.createTextNode(password))
- XMLDocument.documentElement.appendChild(nodePassword)
-
- return XMLDocument
-}
-
-Client.prototype.getXMLloginCookie = function()
-{
- var XMLDocument = this.util.creerDocumentXMLAction()
- XMLDocument.documentElement.setAttribute("name", "login")
-
- var nodeCookie = XMLDocument.createElement("cookie")
- nodeCookie.appendChild(XMLDocument.createTextNode(this.cookie))
- XMLDocument.documentElement.appendChild(nodeCookie)
-
- return XMLDocument
-}
-\r
-/* Obsolète
-Client.prototype.getXMLloginCaptcha = function(captchaCrypt, captchaInput)
-{
- var XMLDocument = this.util.creerDocumentXMLAction()
- XMLDocument.documentElement.setAttribute("name", "loginCaptcha")
-
- var nodecaptchaCrypt = XMLDocument.createElement("captchaCrypt")
- nodecaptchaCrypt.appendChild(XMLDocument.createTextNode(captchaCrypt))
- XMLDocument.documentElement.appendChild(nodecaptchaCrypt)
-
- var nodecaptchaInput = XMLDocument.createElement("captchaInput")
- nodecaptchaInput.appendChild(XMLDocument.createTextNode(captchaInput))
- XMLDocument.documentElement.appendChild(nodecaptchaInput)
-
- return XMLDocument
-}*/
-\r
-/* Obsolète
-Client.prototype.getXMLgenerationCaptcha = function()
-{
- var XMLDocument = this.util.creerDocumentXMLAction()
- XMLDocument.documentElement.setAttribute("name", "generationCaptcha")
-
- return XMLDocument
-}*/
-
-Client.prototype.getXMLEnregistrement = function(login, password)
-{
- var XMLDocument = this.util.creerDocumentXMLAction()
- XMLDocument.documentElement.setAttribute("name", "register")
-
- var nodeLogin = XMLDocument.createElement("login")
- nodeLogin.appendChild(XMLDocument.createTextNode(login))
- XMLDocument.documentElement.appendChild(nodeLogin)
-
- var nodePassword = XMLDocument.createElement("password")
- nodePassword.appendChild(XMLDocument.createTextNode(password))
- XMLDocument.documentElement.appendChild(nodePassword)
-
- return XMLDocument
-}
-
-Client.prototype.getXMLProfile = function()
-{
- var XMLDocument = this.util.creerDocumentXMLAction()
- XMLDocument.documentElement.setAttribute("name", "profile")
-
- var nodeCookie = XMLDocument.createElement("cookie")
- nodeCookie.appendChild(XMLDocument.createTextNode(this.cookie))
- XMLDocument.documentElement.appendChild(nodeCookie)
-
- var nodeLogin = XMLDocument.createElement("login")
- nodeLogin.appendChild(XMLDocument.createTextNode(this.login))
- XMLDocument.documentElement.appendChild(nodeLogin)
-
- var nodePassword = XMLDocument.createElement("password")
- nodePassword.appendChild(XMLDocument.createTextNode(this.password))
- XMLDocument.documentElement.appendChild(nodePassword)
-
- var nodePseudo = XMLDocument.createElement("pseudo")
- nodePseudo.appendChild(XMLDocument.createTextNode(this.pseudo))
- XMLDocument.documentElement.appendChild(nodePseudo)
-
- var nodeEmail = XMLDocument.createElement("email")
- nodeEmail.appendChild(XMLDocument.createTextNode(this.email))
- XMLDocument.documentElement.appendChild(nodeEmail)
-
- var nodeCSS = XMLDocument.createElement("css")
- nodeCSS.appendChild(XMLDocument.createTextNode(this.css))
- XMLDocument.documentElement.appendChild(nodeCSS)
-
- // mémorise les conversations affichées
- if (this.conversations.length > 0)
- {
- var nodeConversations = XMLDocument.createElement("conversations")
- XMLDocument.documentElement.appendChild(nodeConversations)
- for (var i = 0; i < this.conversations.length; i++)
- {
- var nodeConv = XMLDocument.createElement("conversation")
- nodeConversations.appendChild(nodeConv)
-
- var nodeRacine = XMLDocument.createElement("racine")
- nodeRacine.appendChild(XMLDocument.createTextNode(this.conversations[i].racine))
- nodeConv.appendChild(nodeRacine)
-
- var nodePage = XMLDocument.createElement("page")
- nodePage.appendChild(XMLDocument.createTextNode(this.conversations[i].page))
- nodeConv.appendChild(nodePage)
- }
- }
-
- return XMLDocument
-}
-
-/**
- * Renvoie null si pas définit.
- */
-Client.prototype.getCookie = function()
-{
- var cookie = this.regexCookie.exec(document.cookie)
- if (cookie == null) this.cookie = null
- else this.cookie = cookie[1]
-}\r
-\r
-Client.prototype.delCookie = function()\r
-{\r
- document.cookie = "cookie=; max-age=0"\r
-}
-
-Client.prototype.setCookie = function(cookie)
-{
- if (this.cookie == null)
- return
-
- document.cookie =
- "cookie="+this.cookie+
- "; max-age=" + (60 * 60 * 24 * 365)
-}
-
-Client.prototype.identifie = function()
-{
- return this.statut == statutType.enregistre || this.statut == statutType.identifie
-}
-
-Client.prototype.setStatut = function(statut)
-{ \r
- if(typeof(statut) == "string")\r
- {
- statut =
- statut == "enregistre" ?
- statutType.enregistre : (statut == "identifie" ? statutType.identifie : statutType.non_identifie) \r
- } \r
- \r
- if (statut == this.statut) return \r
- \r
- this.statut = statut \r
- this.majMenu()
-}\r
-
-/**
- * Demande la génération d'un captcha au serveur et l'affiche.
- */\r
- /* Obsolète
-Client.prototype.afficherCaptcha = function(query)
-{
- var thisClient = this
-
- $.post("request", this.util.xmlVersAction(this.getXMLgenerationCaptcha()),
- function(data, textStatus)
- {
- var chemin = jQuery("chemin", data.documentElement).text()
- thisClient.captchaCrypt = jQuery("captchaCrypt", data.documentElement).text()
- jQuery(query).prepend(
- "<p id=\"captcha\" >Es-tu un bot ? <img class=\"captchaImg\" src=\"" + chemin + "\" />" +
- "<input name=\"captchaInput\" type=\"text\" size=\"5\" max_length=\"5\" ></p>"
- )
- }
- )
-}
-
-Client.prototype.cacherCaptcha = function()
-{
- jQuery("#captcha").remove()
-}*/
-\r
-/**\r
- * Effectue la connexion vers le serveur.\r
- * Cette fonction est bloquante tant que la connexion n'a pas été établie.\r
- * S'il existe un cookie en local on s'authentifie directement avec lui.\r
- * Si il n'est pas possible de s'authentifier alors on affiche un captcha anti-bot.\r
- */\r
-Client.prototype.connexionCookie = function()\r
-{\r
- this.getCookie()\r
- if (this.cookie == null) return false;
- return this.connexion(this.util.xmlVersAction(this.getXMLloginCookie()))\r
-}
-
-Client.prototype.connexionLogin = function(login, password)
-{
- return this.connexion(this.util.xmlVersAction(this.getXMLlogin(login, password)))
-}
-\r
-/* Obsolète\r
-Client.prototype.connexionCaptcha = function()
-{
- return this.connexion(this.util.xmlVersAction(this.getXMLloginCaptcha(this.captchaCrypt, jQuery("#captcha input").val())))
-}*/
-
-Client.prototype.enregistrement = function(login, password)
-{
- if (this.identifie())
- {
- this.login = login
- this.password = password
- if(this.flush())
- this.setStatut(statutType.enregistre)
- return true
- }
- else\r
- {\r
- if (login == undefined) login = ""\r
- if (password == undefined) password = ""
- return this.connexion(this.util.xmlVersAction(this.getXMLEnregistrement(login, password)))\r
- }
-}
-
-Client.prototype.connexion = function(action)
-{
- thisClient = this
- jQuery.ajax(
- {
- async: false,
- type: "POST",
- url: "request",
- dataType: "xml",
- data: action,
- success:
- function(data)
- {
- thisClient.chargerDonnees(data)
- }
- }
- )
- return this.identifie()
-}\r
-\r
-Client.prototype.deconnexion = function()\r
-{\r
- this.setStatut(statutType.non_identifie) // deconnexion\r
- this.resetDonneesPersonnelles()\r
- this.delCookie ()\r
-}
-
-Client.prototype.chargerDonnees = function(data)
-{
- this.setStatut(jQuery("statut", data.documentElement).text())
-
- if (this.identifie())
- {
- this.cookie = jQuery("cookie", data.documentElement).text()
- this.setCookie()
- \r
- this.login = jQuery("login", data.documentElement).text()
- this.pseudo = jQuery("pseudo", data.documentElement).text()\r
- this.email = jQuery("email", data.documentElement).text()\r
- this.css = jQuery("css", data.documentElement).text()
- // met à jour la css
- if (this.css != "")
- {
- jQuery("link#cssPrincipale").attr("href", this.css)
- this.majMenu()
- }
- }
- this.dernierMessageErreur = jQuery("information", data.documentElement).text()
-}
-
-/**
- * Met à jour les données personne sur serveur.
- */
-Client.prototype.flush = function()
-{
- thisClient = this
- //thisClient.util.log(this.util.xmlVersAction(this.getXMLProfile()).action)
- jQuery.ajax(
- {
- async: true,
- type: "POST",
- url: "request",
- dataType: "xml",
- data: this.util.xmlVersAction(this.getXMLProfile()),
- success:
- function(data)