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