4a9261ac9ec20bb392653f1db27bacf5fa42c1a7
[euphorik.git] / js / euphorik.js
1 // coding: utf-8
2 // Copyright 2008 Grégory Burri
3 //
4 // This file is part of Euphorik.
5 //
6 // Euphorik is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // Euphorik is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with Euphorik. If not, see <http://www.gnu.org/licenses/>.
18
19 /*jslint laxbreak:true */
20
21 // tout euphorik est contenu dans cet objet
22 var euphorik = {};
23
24 // le main
25 $(document).ready(
26 function() {
27 var fragment = new Fragment();
28 var formateur = new euphorik.Formateur();
29 var util = new euphorik.Util(formateur);
30 var communication = new Communication();
31 var client = new euphorik.Client(util, communication);
32 var pages = new euphorik.Pages(fragment);
33
34 // connexion vers le serveur (utilise un cookie qui traine)
35 client.connexionCookie();
36
37 $("#menuCss").change(function() { client.setCss("styles/" + $("option:selected", this).attr("value") + "/euphorik.css"); });
38
39 // FIXME : ne fonctionne pas sous opera
40 // voir : http://dev.jquery.com/ticket/2892#preview
41 $(window).unload(function() { client.flush(); });
42
43 $("#menu .minichat").click(function() { pages.afficherPage("minichat"); });
44 $("#menu .admin").click(function() { pages.afficherPage("admin"); });
45 $("#menu .profile").click(function() { pages.afficherPage("profile"); });
46 $("#menu .logout").click(function() {
47 util.messageDialogue("Êtes-vous sur de vouloir vous délogger ?", euphorik.Util.messageType.question,
48 {
49 "Oui" : function() {
50 client.deconnexion();
51 pages.afficherPage("minichat", true);
52 },
53 "Non" : function() {}
54 }
55 );
56 });
57 $("#menu .register").click(function(){ pages.afficherPage("register"); });
58 $("#menu .about").click(function(){ pages.afficherPage("about"); });
59
60
61 // TODO : simplifier et pouvoir créer des liens par exemple : <span class="lien" href="conditions">Conditions d'utilisation</span>
62 $("#footer .conditions").click(function(){ pages.afficherPage("conditions_utilisation"); });
63
64 pages.ajouterPage(new euphorik.PageMinichat(client, formateur, util), true);
65 pages.ajouterPage(new euphorik.PageAdmin(client, formateur, util));
66 pages.ajouterPage(new euphorik.PageProfile(client, formateur, util));
67 pages.ajouterPage(new euphorik.PageRegister(client, formateur, util));
68 pages.ajouterPage(new euphorik.PageAbout(client, formateur, util));
69 pages.ajouterPage("conditions_utilisation");
70
71 pages.afficherPage();
72 }
73 );