projects
/
euphorik.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
(no commit message)
[euphorik.git]
/
js
/
euphorik.js
diff --git
a/js/euphorik.js
b/js/euphorik.js
index
8aaf875
..
a19d33e
100755
(executable)
--- a/
js/euphorik.js
+++ b/
js/euphorik.js
@@
-13,7
+13,7
@@
* Normalement 'const' à la place de 'var' mais non supporté par IE7.
*/
\r
var conf = {
\r
* Normalement 'const' à la place de 'var' mais non supporté par IE7.
*/
\r
var conf = {
\r
- nbMessageAffiche :
1
0, // (par page)
+ nbMessageAffiche :
4
0, // (par page)
pseudoDefaut : "<nick>",
\r
tempsAffichageMessageDialogue : 4000, // en ms
\r
smiles : {
\r
pseudoDefaut : "<nick>",
\r
tempsAffichageMessageDialogue : 4000, // en ms
\r
smiles : {
\r
@@
-74,6
+74,8
@@
function Util()
})
}
})
}
+var messageType = {informatif: 0, question: 1, erreur: 2}
+
/**
* Affiche une boite de dialogue avec un message à l'intérieur.
* @param message le message (string)
\r
/**
* Affiche une boite de dialogue avec un message à l'intérieur.
* @param message le message (string)
\r
@@
-105,9
+107,7
@@
Util.prototype.messageDialogue = function(message, type, boutons)
$("#info").slideDown(200)
this.timeoutMessageDialogue = setTimeout(fermer, conf.tempsAffichageMessageDialogue)
$("#info").slideDown(200)
this.timeoutMessageDialogue = setTimeout(fermer, conf.tempsAffichageMessageDialogue)
-}
-
-var messageType = {informatif: 0, question: 1, erreur: 2}
\r
+}
\r
/**
* Utilisé pour l'envoie de donnée avec la méthode ajax de jQuery.
/**
* Utilisé pour l'envoie de donnée avec la méthode ajax de jQuery.
@@
-277,11
+277,16
@@
Formateur.prototype.getSmilesHTML = function()
var XHTML = ""
\r
for (var sNom in this.smiles)
\r
{
\r
var XHTML = ""
\r
for (var sNom in this.smiles)
\r
{
\r
- XHTML += "<img class=\"" + sNom + "\" src=\"img/smileys/" + sNom + ".gif\" />"
\r
+ XHTML += "<img class=\"" + sNom + "\" src=\"img/smileys/" + sNom + ".gif\"
alt =\"" + sNom + "\"
/>"
\r
}
\r
return XHTML
\r
}
\r
}
\r
return XHTML
\r
}
\r
+/**
+ * Formatage complet d'un texte.
+ * @M le message
+ * @pseudo facultatif, permet de contruire le label des images sous la forme : "<Pseudo> : <Message>"
+ */
Formateur.prototype.traitementComplet = function(M, pseudo)
{
return this.traiterLiensConv(this.traiterSmiles(this.traiterURL(this.remplacerBalisesHTML(M), pseudo)))
Formateur.prototype.traitementComplet = function(M, pseudo)
{
return this.traiterLiensConv(this.traiterSmiles(this.traiterURL(this.remplacerBalisesHTML(M), pseudo)))
@@
-306,7
+311,7
@@
Formateur.prototype.traiterLiensConv = function(M)
\r
/**
\r
* FIXME : Cette méthode est attrocement lourde ! A optimiser.
\r
/**
\r
* FIXME : Cette méthode est attrocement lourde ! A optimiser.
- * moyenne su échantillon : 234ms
\r
+ * moyenne su
r
échantillon : 234ms
\r
*/
Formateur.prototype.traiterSmiles = function(M)
{
*/
Formateur.prototype.traiterSmiles = function(M)
{
@@
-314,7
+319,7
@@
Formateur.prototype.traiterSmiles = function(M)
{
ss = this.smiles[sNom]
for (var i = 0; i < ss.length; i++)
{
ss = this.smiles[sNom]
for (var i = 0; i < ss.length; i++)
- M = M.replace(ss[i], "<img src=\"img/smileys/" + sNom + ".gif\" />")
+ M = M.replace(ss[i], "<img src=\"img/smileys/" + sNom + ".gif\"
alt =\"" + sNom + "\"
/>")
}
return M
}
}
return M
}
@@
-327,9
+332,6
@@
Formateur.prototype.remplacerBalisesHTML = function(M)
Formateur.prototype.traiterURL = function(M, pseudo)
{
thisFormateur = this
Formateur.prototype.traiterURL = function(M, pseudo)
{
thisFormateur = this
-
- if (pseudo == undefined)
- pseudo = ""
var traitementUrl = function(url)
{
\r
var traitementUrl = function(url)
{
\r
@@
-337,7
+339,7
@@
Formateur.prototype.traiterURL = function(M, pseudo)
if (!thisFormateur.regexTestProtocoleExiste.test(url))
\r
url = "http://" + url
var extension = thisFormateur.getShort(url)
if (!thisFormateur.regexTestProtocoleExiste.test(url))
\r
url = "http://" + url
var extension = thisFormateur.getShort(url)
- return "<a " + (extension[1] ? "title=\"" +
thisFormateur.traiterPourFenetreLightBox(pseudo, url) + ": "
+ thisFormateur.traiterPourFenetreLightBox(M, url) + "\"" + " rel=\"lightbox\"" : "") + " href=\"" + url + "\" >[" + extension[0] + "]</a>"
+ return "<a " + (extension[1] ? "title=\"" +
(pseudo == undefined ? "" : thisFormateur.traiterPourFenetreLightBox(pseudo, url) + ": ")
+ thisFormateur.traiterPourFenetreLightBox(M, url) + "\"" + " rel=\"lightbox\"" : "") + " href=\"" + url + "\" >[" + extension[0] + "]</a>"
}
return M.replace(this.regexUrl, traitementUrl)
}
}
return M.replace(this.regexUrl, traitementUrl)
}
@@
-382,7
+384,7
@@
Formateur.prototype.traiterPourFenetreLightBox = function(M, urlCourante)
thisFormateur = this
var traitementUrl = function(url)
{
thisFormateur = this
var traitementUrl = function(url)
{
- return "[" + thisFormateur.getShort(url)[0] + (urlCourante == url ? "
: image courante
" : "") + "]"
+ return "[" + thisFormateur.getShort(url)[0] + (urlCourante == url ? "
*
" : "") + "]"
}
\r
return this.remplacerBalisesHTML(M).replace(this.regexUrl, traitementUrl)
}
\r
return this.remplacerBalisesHTML(M).replace(this.regexUrl, traitementUrl)
@@
-411,20
+413,19
@@
function Client(util)
// données personnels
\r
this.resetDonneesPersonnelles()
// données personnels
\r
this.resetDonneesPersonnelles()
- this.setStatut(statutType.deconnected)
-
- // le dernier message d'erreur recut du serveur (par exemple une connexion foireuse : "login impossible")
- this.dernierMessageErreur = ""
\r
+ this.setStatut(statutType.deconnected)
\r
}
\r
Client.prototype.resetDonneesPersonnelles = function()
\r
}
\r
Client.prototype.resetDonneesPersonnelles = function()
\r
-{
\r
+{
+ this.id = 0
\r
this.pseudo = conf.pseudoDefaut
\r
this.login = ""
\r
this.password = ""
\r
this.email = ""
\r
this.css = $("link#cssPrincipale").attr("href")
this.nickFormat = "nick"
this.pseudo = conf.pseudoDefaut
\r
this.login = ""
\r
this.password = ""
\r
this.email = ""
\r
this.css = $("link#cssPrincipale").attr("href")
this.nickFormat = "nick"
+ this.cookie = undefined
this.pagePrincipale = 1
this.ekMaster = false
this.pagePrincipale = 1
this.ekMaster = false
@@
-608,7
+609,7
@@
Client.prototype.setStatut = function(statut)
(statut == "auth_not_registered" ? statutType.auth_not_registered : statutType.deconnected)
\r
}
\r
\r
(statut == "auth_not_registered" ? statutType.auth_not_registered : statutType.deconnected)
\r
}
\r
\r
- if (statut == this.statut) return
\r
+ if (statut == this.statut) return
\r
\r
this.statut = statut
\r
this.majMenu()
\r
this.statut = statut
\r
this.majMenu()
@@
-639,8
+640,11
@@
Client.prototype.enregistrement = function(login, password)
this.login = login
this.password = password
if(this.flush())
this.login = login
this.password = password
if(this.flush())
+ {
this.setStatut(statutType.auth_registered)
this.setStatut(statutType.auth_registered)
- return true
+ return true
+ }
+ return false
}
else
\r
{
}
else
\r
{
@@
-663,7
+667,10
@@
Client.prototype.connexion = function(messageJson)
function(data)
{
;;; dumpObj(data)
function(data)
{
;;; dumpObj(data)
- thisClient.chargerDonnees(data)
+ if (data["reply"] == "error")
+ thisClient.util.messageDialogue(data["error_message"])
+ else
+ thisClient.chargerDonnees(data)
}
}
)
}
}
)
@@
-672,10
+679,10
@@
Client.prototype.connexion = function(messageJson)
\r
Client.prototype.deconnexion = function()
\r
{
\r
Client.prototype.deconnexion = function()
\r
{
- this.flush()
- this.delCookie()
\r
- this.setStatut(statutType.deconnected) // deconnexion
\r
+ this.flush(true)
+ this.delCookie()
this.resetDonneesPersonnelles()
\r
this.resetDonneesPersonnelles()
\r
+ this.setStatut(statutType.deconnected) // deconnexion
\r
}
Client.prototype.chargerDonnees = function(data)
}
Client.prototype.chargerDonnees = function(data)
@@
-690,7
+697,8
@@
Client.prototype.chargerDonnees = function(data)
{
this.cookie = data["cookie"]
this.setCookie()
{
this.cookie = data["cookie"]
this.setCookie()
-
\r
+
+ this.id = data["id"]
\r
this.login = data["login"]
this.pseudo = data["nick"]
\r
this.email = data["email"]
\r
this.login = data["login"]
this.pseudo = data["nick"]
\r
this.email = data["email"]
\r
@@
-703,7
+711,6
@@
Client.prototype.chargerDonnees = function(data)
// les conversations
this.conversations = data["conversations"]
}
// les conversations
this.conversations = data["conversations"]
}
- this.dernierMessageErreur = data["error_message"]
}
/**
}
/**
@@
-714,12
+721,14
@@
Client.prototype.chargerDonnees = function(data)
Client.prototype.flush = function(async)
{
if (async == undefined)
Client.prototype.flush = function(async)
{
if (async == undefined)
- async =
tru
e
+ async =
fals
e
if (!this.authentifie())
return false
if (!this.authentifie())
return false
- thisClient = this
+ var thisClient = this
+ var ok = true
+
;;; dumpObj(this.getJSONProfile())
jQuery.ajax(
{
;;; dumpObj(this.getJSONProfile())
jQuery.ajax(
{
@@
-731,20
+740,26
@@
Client.prototype.flush = function(async)
success:
function(data)
{
success:
function(data)
{
- //thisClient.util.log(thisClient.util.serializer.serializeToString(data))
+ ;;; dumpObj(data)
+ if (data["reply"] == "error")
+ {
+ thisClient.util.messageDialogue(data["error_message"])
+ ok = false
+ }
}
}
)
}
}
)
- // TODO : retourner false si un problème est survenu lors de l'update du profile
- return
true
+
+ return
ok
}
Client.prototype.majMenu = function()
{
// TODO : à virer : ne plus changer de style de display ... spa beau .. ou trouver une autre méthode
}
Client.prototype.majMenu = function()
{
// TODO : à virer : ne plus changer de style de display ... spa beau .. ou trouver une autre méthode
- var displayType = this.css == "css/3/euphorik.css" ? "block" : "inline" //this.client
+ // var displayType = this.css == "css/3/euphorik.css" ? "block" : "inline" //this.client
+ displayType = "block"
- $("#menu .admin").css("display", this.ekMaster ?
"inline"
: "none")
+ $("#menu .admin").css("display", this.ekMaster ?
displayType
: "none")
// met à jour le menu
if (this.statut == statutType.auth_registered)
// met à jour le menu
if (this.statut == statutType.auth_registered)
@@
-890,7
+905,7
@@
PageEvent.prototype.waitEvent = function(funSend, funReceive)
error:
function(XMLHttpRequest, textStatus, errorThrown)
{
error:
function(XMLHttpRequest, textStatus, errorThrown)
{
- setTimeout(function(){ thisPageEvent.
rafraichirMessages
(funSend, funReceive) }, 1000);
+ setTimeout(function(){ thisPageEvent.
waitEvent
(funSend, funReceive) }, 1000);
}
})
}
})
@@
-925,8
+940,9
@@
$(document).ready(
initialiserListeStyles(client)
initialiserListeStyles(client)
- // TODO : pourquoi $(document).unload ne fonctionne pas ?
- $(window).unload(function(){client.flush(false)})
+ // FIXME : ne fonctionne pas sous opera
+ // voir : http://dev.jquery.com/ticket/2892#preview
+ $(window).unload(function(){client.flush()})
$("#menu .minichat").click(function(){ pages.afficherPage("minichat") })
$("#menu .admin").click(function(){ pages.afficherPage("admin") })
$("#menu .minichat").click(function(){ pages.afficherPage("minichat") })
$("#menu .admin").click(function(){ pages.afficherPage("admin") })