X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;ds=inline;f=js%2Feuphorik.js;h=214c0f89d4b5ccf885c7e1cd7a635e75b7549e4c;hb=3c3e08ee08628398811d850f23d8494340ae8b2c;hp=afe0251e7da2334b843588c58c77a5bcf00a2d96;hpb=d1dff528ecf8ace680f8ba92d11b09e84fd6ff2f;p=euphorik.git
diff --git a/js/euphorik.js b/js/euphorik.js
index afe0251..214c0f8 100755
--- a/js/euphorik.js
+++ b/js/euphorik.js
@@ -16,181 +16,57 @@
// You should have received a copy of the GNU General Public License
// along with Euphorik. If not, see .
-/**
- * Contient la base javascript pour le site euphorik.ch.
- * Chaque page possède son propre fichier js nommé "page.js".
- * Auteur : GBurri
- * Date : 6.11.2007
- */
+/*jslint laxbreak:true */
// tout euphorik est contenu dans cet objet
-var euphorik = {}
-// ;; euphorik.include =
- //;; euphorik.include = function(f) { var s = document.createElement('script'); s.type = 'text/javascript'; s.src = "js/" + f + ".js"; document.getElementsByTagName('head')[0].appendChild(s); }
-
-
-// version jQuery : function(f) { jQuery.ajax({async : false, url : "js/" + f + ".js", dataType : "script"}) }
-// mais comme il n'est pas encore chargé...
-;; euphorik.include = function(f) {
-;; var req, url = 'js/' + f + '.js'
-;; if (window.XMLHttpRequest) {
-;; req = new XMLHttpRequest(); req.open("GET", url, false); req.send(null);
-;; } else if (window.ActiveXObject) {
-;; req = new ActiveXObject((navigator.userAgent.toLowerCase().indexOf('msie 5') != -1) ? "Microsoft.XMLHTTP" : "Msxml2.XMLHTTP");
-;; if (req) { req.open("GET", url, false); req.send(); }
-;; }
-;; if (req!==false) { if (req.status==200) { window.eval(req.responseText); } else if (req.status==404) { alert("erreur de chargement (404) de : " + url) } }
-;; };
-
-;; euphorik.include("jquery");
-;; euphorik.include("jquery.lightbox");
-;; euphorik.include("md5");
-;; euphorik.include("json2");
-;; euphorik.include("comet");
-
-;; euphorik.include("conf");
-;; euphorik.include("util");
-;; euphorik.include("formateur");
-;; euphorik.include("pages");
-;; euphorik.include("client");
-
-;; euphorik.include("pageMinichat/pageMinichat");
-;; euphorik.include("pageMinichat/conversation");
-;; euphorik.include("pageMinichat/conversations");
-;; euphorik.include("pageMinichat/message");
-;; euphorik.include("pageMinichat/commandes");
-;; euphorik.include("pageAdmin");
-;; euphorik.include("pageProfile");
-;; euphorik.include("pageRegister");
-;; euphorik.include("pageAbout");
-
-// tout un tas d'améliorations de JavaScript ;)
-/**
- * Pour chaque propriété de l'objet execute f(p, v) ou p est le nom de la propriété et v sa valeur.
- * Ne parcours pas les propriétés des prototypes.
- * FIXME : Normalement : Object.prototype.each = function(f) mais non supporté par jquery
- */
-//Object.prototype.each = function(f) {
-var objectEach = function(o, f) {
- for (var k in o) {
- if (o.hasOwnProperty(k)) {
- f(k, o[k]);
- }
- }
-};
-
-var objectMemberCount = function(o) {
- var nb = 0;
- for (var k in o) {
- if (o.hasOwnProperty(k)) {
- nb += 1;
- }
- }
- return nb;
-};
-
-Array.prototype.each = function(f) {
- for (var i = 0; i < this.length; i++) {
- f(i, this[i]);
- }
-};
-
-Array.prototype.map = function(f) {
- for (var i = 0; i < this.length; i++) {
- this[i] = f(this[i])
- }
-};
-
-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+$/, "");
-}
-
-
-/**
- * Voir : http://www.coolpage.com/developer/javascript/Correct%20OOP%20for%20Javascript.html
- *
- * Exemple :
- *
- * function Mammal(name) {
- * this.name = name;
- * }
- *
- * Cat.Inherits(Mammal);
- * function Cat(name) {
- * this.Super(Mammal, name);
- * }
- */
-/*Object.prototype.Super = function(parent) {
- if(arguments.length > 1) {
- parent.apply( this, Array.prototype.slice.call( arguments, 1 ) );
- } else {
- parent.call( this );
- }
-}
-Function.prototype.Inherits = function(parent) {
- this.prototype = new parent();
- this.prototype.constructor = this;
-}*/
-
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
+var euphorik = {};
// le main
$(document).ready(
- function()
- {
- var formateur = new euphorik.Formateur()
- var util = new euphorik.Util(formateur)
- var client = new euphorik.Client(util)
- var pages = new euphorik.Pages()
-
+ function() {
+ var fragment = new Fragment();
+ var formateur = new euphorik.Formateur();
+ var util = new euphorik.Util(formateur);
+ var communication = new euphorik.Communication(function(data) { util.messageDialogue(data.error_message); });
+ var client = new euphorik.Client(util, communication);
+ var pages = new euphorik.Pages(fragment);
// connexion vers le serveur (utilise un cookie qui traine)
- client.connexionCookie()
+ client.connexionCookie();
- $("#menuCss").change(function(){ client.setCss("styles/" + $("option:selected", this).attr("value") + "/euphorik.css")})
+ $("#menuCss").change(function() { client.setCss("styles/" + $("option:selected", this).attr("value") + "/euphorik.css"); });
// FIXME : ne fonctionne pas sous opera
// voir : http://dev.jquery.com/ticket/2892#preview
- $(window).unload(function(){client.flush()})
+ $(window).unload(function() { client.flush(); });
- $("#menu .minichat").click(function(){ pages.afficherPage("minichat") })
- $("#menu .admin").click(function(){ pages.afficherPage("admin") })
- $("#menu .profile").click(function(){ pages.afficherPage("profile") })
- $("#menu .logout").click(function(){
+ $("#menu .minichat").click(function() { pages.afficherPage("minichat"); });
+ $("#menu .admin").click(function() { pages.afficherPage("admin"); });
+ $("#menu .profile").click(function() { pages.afficherPage("profile"); });
+ $("#menu .logout").click(function() {
util.messageDialogue("Ãtes-vous sur de vouloir vous délogger ?", euphorik.Util.messageType.question,
- {"Oui" : function()
- {
+ {
+ "Oui" : function() {
client.deconnexion();
- pages.afficherPage("minichat", true)
+ pages.afficherPage("minichat", true);
},
- "Non" : function(){}
+ "Non" : function() {}
}
- )
- })
- $("#menu .register").click(function(){ pages.afficherPage("register") })
- $("#menu .about").click(function(){ pages.afficherPage("about") })
+ );
+ });
+ $("#menu .register").click(function(){ pages.afficherPage("register"); });
+ $("#menu .about").click(function(){ pages.afficherPage("about"); });
// TODO : simplifier et pouvoir créer des liens par exemple : Conditions d'utilisation
- $("#footer .conditions").click(function(){ pages.afficherPage("conditions_utilisation") })
-
- pages.ajouterPage(new euphorik.PageMinichat(client, formateur, util))
- pages.ajouterPage(new euphorik.PageAdmin(client, formateur, util))
- pages.ajouterPage(new euphorik.PageProfile(client, formateur, util))
- pages.ajouterPage(new euphorik.PageRegister(client, formateur, util))
- pages.ajouterPage(new euphorik.PageAbout(client, formateur, util))
- pages.ajouterPage("conditions_utilisation")
+ $("#footer .conditions").click(function(){ pages.afficherPage("conditions_utilisation"); });
+
+ pages.ajouterPage(new euphorik.PageMinichat(client, formateur, util, communication), true);
+ pages.ajouterPage(new euphorik.PageAdmin(client, formateur, util));
+ pages.ajouterPage(new euphorik.PageProfile(client, formateur, util));
+ pages.ajouterPage(new euphorik.PageRegister(client, formateur, util));
+ pages.ajouterPage(new euphorik.PageAbout(client, formateur, util));
+ pages.ajouterPage("conditions_utilisation");
- pages.afficherPage("minichat")
+ pages.afficherPage();
}
-)
+);