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