777a036c5d6d425e9f4c5455c985c27f304857e1
[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 client = new euphorik.Client(util);
31 var pages = new euphorik.Pages(fragment);
32
33 // connexion vers le serveur (utilise un cookie qui traine)
34 client.connexionCookie();
35
36 $("#menuCss").change(function() { client.setCss("styles/" + $("option:selected", this).attr("value") + "/euphorik.css"); });
37
38 // FIXME : ne fonctionne pas sous opera
39 // voir : http://dev.jquery.com/ticket/2892#preview
40 $(window).unload(function() { client.flush(); });
41
42 $("#menu .minichat").click(function() { pages.afficherPage("minichat"); });
43 $("#menu .admin").click(function() { pages.afficherPage("admin"); });
44 $("#menu .profile").click(function() { pages.afficherPage("profile"); });
45 $("#menu .logout").click(function() {
46 util.messageDialogue("Êtes-vous sur de vouloir vous délogger ?", euphorik.Util.messageType.question,
47 {
48 "Oui" : function() {
49 client.deconnexion();
50 pages.afficherPage("minichat", true);
51 },
52 "Non" : function() {}
53 }
54 );
55 });
56 $("#menu .register").click(function(){ pages.afficherPage("register"); });
57 $("#menu .about").click(function(){ pages.afficherPage("about"); });
58
59
60 // TODO : simplifier et pouvoir créer des liens par exemple : <span class="lien" href="conditions">Conditions d'utilisation</span>
61 $("#footer .conditions").click(function(){ pages.afficherPage("conditions_utilisation"); });
62
63 pages.ajouterPage(new euphorik.PageMinichat(client, formateur, util), true);
64 pages.ajouterPage(new euphorik.PageAdmin(client, formateur, util));
65 pages.ajouterPage(new euphorik.PageProfile(client, formateur, util));
66 pages.ajouterPage(new euphorik.PageRegister(client, formateur, util));
67 pages.ajouterPage(new euphorik.PageAbout(client, formateur, util));
68 pages.ajouterPage("conditions_utilisation");
69
70 pages.afficherPage();
71 }
72 );