From: Ummon Date: Mon, 23 Mar 2015 15:18:25 +0000 (+0100) Subject: Add a project and module file for IntelliJ. X-Git-Url: http://git.euphorik.ch/?p=euphorik.git;a=commitdiff_plain;h=cb02531d4a4b217997db3fdfe2661af18c576ddd Add a project and module file for IntelliJ. --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5b3f348 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.iws +*.beam +var/ \ No newline at end of file diff --git a/euphorik.iml b/euphorik.iml new file mode 100644 index 0000000..5e00088 --- /dev/null +++ b/euphorik.iml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/euphorik.ipr b/euphorik.ipr new file mode 100644 index 0000000..0847af7 --- /dev/null +++ b/euphorik.ipr @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/index.yaws b/index.yaws index a0e258b..7899936 100755 --- a/index.yaws +++ b/index.yaws @@ -1,112 +1,111 @@ - - - - out(A) -> - {header, {content_type, - case string:str((A#arg.headers)#headers.user_agent, "MSIE") of - 0 -> "text/html"; %"application/xhtml+xml"; % TODO : jquery.lightbox does not support application/xhtml+xml - _ -> "text/html" - end - }}. - - - - - euphorik.ch + + + + out(A) -> + {header, {content_type, + case string:str((A#arg.headers)#headers.user_agent, "MSIE") of + 0 -> "text/html"; %"application/xhtml+xml"; % TODO : jquery.lightbox does not support application/xhtml+xml + _ -> "text/html" + end + }}. + + + + + euphorik.ch - % set the stylesheet - out(A) -> - CSS = case euphorik_bd:css_from_user_cookie(yaws_api:find_cookie_val("cookie", A)) of - undefined -> "styles/1/euphorik.css"; - C -> C - end, - {ehtml, {link , - [ - {id, "mainCss" }, - {rel, "stylesheet"}, - {href, CSS}, - {type, "text/css"}, - {media, "screen"} - ], []} - }. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - % permet de prédéfinir la "class" du logo pour un ekMaster... - out(A) -> - Est_ek_master = euphorik_bd:is_ek_master_from_cookie(yaws_api:find_cookie_val("cookie", A)), - {ehtml, {'div', [{id, "logo"}] ++ if Est_ek_master -> [{class, "ekMaster"}]; true -> [] end}}. - - - - - -
-

- -

-
-
- -
- - + % set the stylesheet + out(A) -> + CSS = case euphorik_bd:css_from_user_cookie(yaws_api:find_cookie_val("cookie", A)) of + undefined -> "styles/1/euphorik.css"; + C -> C + end, + {ehtml, {link , + [ + {id, "mainCss" }, + {rel, "stylesheet"}, + {href, CSS}, + {type, "text/css"}, + {media, "screen"} + ], []} + }. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + % permet de prédéfinir la "class" du logo pour un ekMaster... + out(A) -> + Est_ek_master = euphorik_bd:is_ek_master_from_cookie(yaws_api:find_cookie_val("cookie", A)), + {ehtml, {'div', [{id, "logo"}] ++ if Est_ek_master -> [{class, "ekMaster"}]; true -> [] end}}. + + + + + +
+

+ +

+
+
+ +
+ + diff --git a/js/betterjs.js b/js/betterjs.js index 6c5b0e6..b4d0bb6 100644 --- a/js/betterjs.js +++ b/js/betterjs.js @@ -77,7 +77,7 @@ String.prototype.rtrim = function() { * (Not use for the moment) * See : http://www.coolpage.com/developer/javascript/Correct%20OOP%20for%20Javascript.html * - * Example : + * Example : * * function Mammal(name) { * this.name = name; diff --git a/js/client.js b/js/client.js index 0b77e65..1e87279 100644 --- a/js/client.js +++ b/js/client.js @@ -35,14 +35,14 @@ euphorik.Client = function(util, communication) { this.util = util; this.communication = communication; - + this.cookie = null; this.regexCookie = /cookie=([^;]*)/; - + this.resetPersonalData(); - + this.setStatus(euphorik.Client.statusType.disconnected); - + // If true then each data change is flushed to the server. // Active only for opera which doesn't support the unload event. this.autoflush = $.browser.opera; @@ -50,11 +50,11 @@ euphorik.Client = function(util, communication) { // The three status of a client. euphorik.Client.statusType = { - // authentified and registered : The user can post messages and can modify his profile + // Authentified and registered : The user can post messages and can modify his profile. auth_registered : 0, - // authentified but not registered : The user can only post messages + // Authentified but not registered : The user can only post messages. auth_not_registered : 1, - // disconnected (the initial state) : The user cannot post message + // Disconnected (the initial state) : The user cannot post message. disconnected : 2 }; @@ -74,11 +74,11 @@ euphorik.Client.prototype.resetPersonalData = function() { this.viewTimes = true; this.viewTooltips = true; this.cookie = undefined; - + this.mainConversationPage = 1; this.ekMaster = false; this.ostentatiousMaster = "light"; - + // The user opened conversations. // Each conversation object owns theses properties : // - root (integer) @@ -99,7 +99,7 @@ euphorik.Client.prototype.setCss = function(css) { this.css = css; $("link#mainCss").attr("href", this.css); - + if (this.autoflush) { this.flush(true); } @@ -133,8 +133,7 @@ euphorik.Client.prototype.previousPage = function(numConv) { * Définit la première page pour la conversation donnée. * @return true si la page a changé sinon false */ -euphorik.Client.prototype.goFirstPage = function(numConv) -{ +euphorik.Client.prototype.goFirstPage = function(numConv) { if (numConv < 0) { if (this.mainConversationPage === 1) { return false; @@ -156,7 +155,7 @@ euphorik.Client.prototype.goFirstPage = function(numConv) * @return true si la conversation a été créée sinon false (par exemple si la conv existe déjà) */ euphorik.Client.prototype.ajouterConversation = function(racine) { - // vérification s'il elle n'existe pas déjà + // vérification s'il elle n'existe pas déjà var existe = false; this.conversations.each(function(i, conv) { if (conv.root === racine) { @@ -166,12 +165,12 @@ euphorik.Client.prototype.ajouterConversation = function(racine) { if (existe) { return false; } - + this.conversations.push({root : racine, page : 1, isCollapsed : false}); if (this.autoflush) { this.flush(true); } - + return true; }; @@ -179,13 +178,13 @@ euphorik.Client.prototype.supprimerConversation = function(num) { if (num < 0 || num >= this.conversations.length) { return; } - - // décalage TODO : supprimer le dernier élément + + // décalage TODO : supprimer le dernier élément for (var i = num; i < this.conversations.length - 1; i++) { this.conversations[i] = this.conversations[i+1]; } this.conversations.pop(); - + if (this.autoflush) { this.flush(true); } @@ -243,11 +242,11 @@ euphorik.Client.prototype.setCookie = function() { if (!this.cookie) { return; } - + // doesn't work under IE.... /*document.cookie = "cookie=" + this.cookie + "; max-age=" + (60 * 60 * 24 * 365) */ - - document.cookie = + + document.cookie = "cookie="+this.cookie+"; expires=" + new Date(new Date().getTime() + 1000 * 60 * 60 * 24 * 365).toUTCString(); }; @@ -256,7 +255,7 @@ euphorik.Client.prototype.authentifie = function() { }; euphorik.Client.prototype.setStatus = function(statut) -{ +{ // conversation en "enum" si en "string" if (typeof(statut) === "string") { statut = @@ -264,20 +263,20 @@ euphorik.Client.prototype.setStatus = function(statut) euphorik.Client.statusType.auth_registered : (statut === "auth_not_registered" ? euphorik.Client.statusType.auth_not_registered : euphorik.Client.statusType.disconnected); } - + if (statut === this.statut) { return; } - + this.statut = statut; - + this.majMenu(); this.majLogo(); }; - -/** - * Try to authentify the client with the cookie information. - * Do nothing if there is no cookie. + +/** + * Try to authentify the client with the cookie information. + * Do nothing if there is no cookie. */ euphorik.Client.prototype.connectionCookie = function() { this.getCookie(); @@ -291,7 +290,7 @@ euphorik.Client.prototype.connexionLogin = function(login, password) { return this.connexion("authentification", {"login" : login, "password" : password }); }; -euphorik.Client.prototype.enregistrement = function(login, password) { +euphorik.Client.prototype.enregistrement = function(login, password) { if (this.authentifie()) { this.login = login; this.password = password; @@ -311,14 +310,14 @@ euphorik.Client.prototype.enregistrement = function(login, password) { */ euphorik.Client.prototype.getJSONEnregistrement = function(login, password) { var mess = {}; - + if (login && password) { mess.login = login; mess.password = password; } - + mess.profile = this.getJSONProfileInfos(); - + return mess; }; @@ -327,7 +326,7 @@ euphorik.Client.prototype.getJSONEnregistrement = function(login, password) { */ euphorik.Client.prototype.connexion = function(action, messageJson) { var thisClient = this; - + this.communication.requete( action, messageJson, @@ -354,13 +353,13 @@ euphorik.Client.prototype.chargerDonnees = function(data) { // la modification du statut qui suit met à jour le menu, le menu dépend (page admin) // de l'état ekMaster this.ekMaster = data.ek_master ? data.ek_master : false; - + this.setStatus(data.status); - + if (this.authentifie()) { this.cookie = data.cookie; this.setCookie(); - + this.id = data.id; this.login = data.login; this.nick = data.profile.nick; @@ -371,16 +370,16 @@ euphorik.Client.prototype.chargerDonnees = function(data) { this.viewTimes = data.profile.view_times; this.viewTooltips = data.profile.view_tooltips; this.ostentatiousMaster = data.profile.ostentatious_master; - + // la page de la conversation principale this.mainConversationPage = 1; - + // les conversations this.conversations = data.profile.conversations; this.conversations.map(function(conv) { return { root : conv.root, page : 1, isCollapsed : conv.minimized }; }); - + this.majBulle(); this.majCssSelectionee(); } @@ -393,19 +392,19 @@ euphorik.Client.prototype.chargerDonnees = function(data) { */ euphorik.Client.prototype.flush = function(async) { async = async || false; - + if (!this.authentifie()) { return false; } - + var thisClient = this; var ok = true; - + this.communication.requete( "set_profile", this.getJSONProfile(), function(data) { - thisClient.majBulle(); + thisClient.majBulle(); }, function(data) { thisClient.util.messageDialog(data.error_message); @@ -413,7 +412,7 @@ euphorik.Client.prototype.flush = function(async) { }, async ); - + return ok; }; @@ -421,8 +420,8 @@ euphorik.Client.prototype.majMenu = function() { var displayType = "block"; $("#menu .admin").css("display", this.ekMaster ? displayType : "none"); - - // met à jour le menu + + // met à jour le menu if (this.statut === euphorik.Client.statusType.auth_registered) { $("#menu .profile").css("display", displayType).text("profile"); $("#menu .logout").css("display", displayType); diff --git a/js/pageProfile.js b/js/pageProfile.js index 7bbe045..c5ea5df 100755 --- a/js/pageProfile.js +++ b/js/pageProfile.js @@ -18,7 +18,7 @@ euphorik.PageProfile = function(client, formater, util) { this.name = "profile"; - + this.client = client; this.formater = formater; this.util = util; @@ -31,32 +31,32 @@ euphorik.PageProfile.prototype.contenu = function() { euphorik.PageProfile.prototype.charger = function() { $("#page").html(this.getHTML()); - + // en fonction du statut if (this.client.authentifie()) { this.chargerProfile(); } else { this.chargerLogin(); } - + $("#page form#profile").submit(function(){ return false; }); }; -euphorik.PageProfile.prototype.chargerProfile = function() { +euphorik.PageProfile.prototype.chargerProfile = function() { var thisPage = this; - + $("form#profile input.login").val(this.client.login); $("form#profile input.nick").val(this.client.nick); $("form#profile input.email").val(this.client.email); $("form#profile input#viewTooltips").attr("checked", this.client.viewTooltips); $("form#profile input#viewTimes").attr("checked", this.client.viewTimes); - + $("form#profile select#chatOrder option").removeAttr("selected"); $("form#profile select#chatOrder option[value=" + this.client.chatOrder + "]").attr("selected", "selected"); - + $("form#profile select#affichagePseudo option").removeAttr("selected"); $("form#profile select#affichagePseudo option[value=" + this.client.nickFormat + "]").attr("selected", "selected"); - + if (this.client.ostentatiousMaster) { $("form#profile select#degreeOstentatoire option").removeAttr("selected"); $("form#profile select#degreeOstentatoire option[value=" + this.client.ostentatiousMaster + "]").attr("selected", "selected"); @@ -64,7 +64,7 @@ euphorik.PageProfile.prototype.chargerProfile = function() { $("form#profile button").click( function() { - thisPage.client.nick = thisPage.formate.formatNick($("form#profile input.nick").val()); + thisPage.client.nick = thisPage.formater.formatNick($("form#profile input.nick").val()); thisPage.client.email = $("form#profile input.email").val(); thisPage.client.chatOrder = $("form#profile select#chatOrder option:selected").attr("value"); thisPage.client.nickFormat = $("form#profile select#affichagePseudo option:selected").attr("value"); @@ -73,20 +73,20 @@ euphorik.PageProfile.prototype.chargerProfile = function() { } thisPage.client.viewTooltips = $("form#profile input#viewTooltips").attr("checked"); thisPage.client.viewTimes = $("form#profile input#viewTimes").attr("checked"); - + var password = $("form#profile input.password").val(); var passwordRe = $("form#profile input.passwordRe").val(); if (password !== "" || passwordRe !== "") { - if (password !== passwordRe) { + if (password !== passwordRe) { thisPage.util.messageDialog("Les mots de passes ne correspondent pas"); return; } thisPage.client.password = thisPage.util.md5(password); } - + if(!thisPage.client.flush()) { thisPage.util.messageDialog("Impossible de mettre à jour votre profile, causes inconnues", euphorik.Util.messageType.erreur); - } else { + } else { thisPage.util.messageDialog("Votre profile a été mis à jour"); thisPage.pages.displayPage("minichat"); } @@ -94,7 +94,7 @@ euphorik.PageProfile.prototype.chargerProfile = function() { ); }; -euphorik.PageProfile.prototype.chargerLogin = function() { +euphorik.PageProfile.prototype.chargerLogin = function() { var thisPage = this; $("#page form#profile button").click( @@ -118,7 +118,7 @@ euphorik.PageProfile.prototype.getHTML = function() { ' ' + ' password' + ' ' + - ' ' + + ' ' + (this.client.authentifie() ? '' + ' ' + ' password re' + diff --git a/modules/erl/euphorik_requests.erl b/modules/erl/euphorik_requests.erl index 42fb87f..8ee67a5 100755 --- a/modules/erl/euphorik_requests.erl +++ b/modules/erl/euphorik_requests.erl @@ -16,9 +16,9 @@ % You should have received a copy of the GNU General Public License % along with Euphorik. If not, see . % -% Ce module est fait pour répondre à des requêtes JSON via 'AJAX'. -% Il est définit comme 'appmods' pour l'url "request" dans Yaws. -% Par exemple http://www.euphorik.ch/request abouti sur la fonction out/1 de ce module. +% This module responds to JSON requests via 'AJAX'. +% It's defined as an Yaws 'appmods' with the url '/request'. +% For instance in debug mode 'http://localhost:8090/request' will call the out/1 function. % @author G.Burri @@ -28,14 +28,14 @@ -include("../include/euphorik_defines.hrl"). -% Point d'entrée pour les requêtes AJAX sur http://www.euphorik.ch/request. +% Entry point for all AJAX requests on '/request'. out(A) -> IP = case inet:peername(A#arg.clisock) of - {ok, {Adresse, _Port}} -> Adresse; - _ -> inconnue + {ok, {Address, _Port}} -> Address; + _ -> unknown end, - % passive -> active, permet de recevoir {tcp_closed, _} lorsque le socket se ferme - % keepalive -> true, evite que des firewalls coupe la connexion TCP sans prévenir + % active: to receive {tcp_closed, _} when the socket is closing. + % keepalive: avoid firewalls to cut the connection. inet:setopts(A#arg.clisock, [{active, true}, {keepalive, true}]), {value, {_, Contenu}} = lists:keysearch("action", 1, yaws_api:parse_post(A)), Ret = traiter_message(Contenu, IP),