From: Greg Burri Date: Tue, 4 Dec 2007 19:44:28 +0000 (+0000) Subject: Premier commit X-Git-Tag: 1.0.0^2~214 X-Git-Url: https://git.euphorik.ch/?a=commitdiff_plain;h=6feaef2a51f7226c41d69f9e86f605718b78aa02;p=euphorik.git Premier commit --- 6feaef2a51f7226c41d69f9e86f605718b78aa02 diff --git a/conception/TODO.txt b/conception/TODO.txt new file mode 100755 index 0000000..c946ac2 --- /dev/null +++ b/conception/TODO.txt @@ -0,0 +1,132 @@ +-- TODO -- +[ok] * Réaliser la structure suivante : + * Table minichat : {id, auteur_id, date, pseudo, contenu, reponses_minichat_id} reponses_minichat_id peut être null + * Table reponse_minichat : {id, minichat_id} la clef est (id, minichat_id) + * Table user : {id, cookie, pseudo, date_creation, date_derniere_connexion, css} +[ok] Implémenter le protocol dans 'fonctionnement_minichat.txt' +[ok] Trier la requête et limiter à N le nombre de messages affichés +[ok] réaliser un controller sous la forme d'une application pour receptionner tout ce qui vient des formulaires +[ok] Ajouter un lien minichat.iduser -> user.id +[ok] Ajouter un id pour les messages qui est un entier auto incrémenté +[ok] Afficher un captcha le md5 de la valeur est l'envoyer avec +[ok] Formater les dates +[ok] Trouver et remplacer les url http://www.youpla.com par [url] +[ok] Traitement des smiles (remplacer :) par "" +[ok] Afficher les smiles disponibles, on peut clicker dessus pour en ajouter un dans le text +[ok] Mettre en évidence les posts auquels l'utilisateur courant à répondu ainsi que ses propres posts + * Vérifier le captcha + * Mettre un cookie +[ok] Mémoriser le pseudo et le remettre à chaque fois (si cookie) +[ok] Afficher un et pour renseigner l'utilisateur sur les différents zones de texte. Lorsque l'utilisateur click sur une zone le message disparait. (javascript). +[ok] Pouvoir répondre à un ou plusieurs messages en cliquant dessus (javascript) + * L'utilisateur peut clicker sur un message, cela appond le nom et l'id du message à son message, exe : "kiki:G3E> " "G3E" et l'id du message en base 36, si l'id est omis alors le dernier message dont le pseudo est kiki est pris en compte + * le(s) pseudo(s) de l'auteur du message auquel on répond préfixe notre message + * Lorsque l'on passe le curseur sur un message on voit la conversation avec une mise en évidence des réponses (les messages ne faisant pas partie de la conversation sont grisés ou masqués) +[ok] Maintenir le focus sur la ligne de saisie après l'envoie d'un message +[ok] Ajouter plusieurs messages d'un coup pour eviter des lenteurs au chargement +[pas besoin] Catcher les exceptions de parsage de l'xml dans euphorik_request +[ok] * Ne pas virer les balises html mais remplacer les <> par < > +[ok mais limité] Avoir accès aux archives (par page, par exemple) +[ok] Profiling pour améliorer les performances (surtout du coté client) +[ok] Interdir les {} dans les pseudo +[plus besoin] Finir le deamon +[plus besoin] tester si le captcha_crypt existe (en regardant les fichiers images temporaires) +[ok] Virer les balises html des messages et pseudo lors du stockage du message (et trimer). +[ok] afficher les pseudo des messages auquels un message répond (modification du protocole, il faut ajouter une liste de pseudo pour chaque message) +[ok] Possibilité de logout +[ok] Filtrer les { et } dans les pseudo sur la page profile +[ok] différentier [url] [gif] [png] et le reste des url. utiliser lightbox pour les images +[ok] Déplacer le formatage des messages du coté du client -> permet de demander à lightbox de reparser lors de l'ajout d'une image +[ok] Demander une confirmation lors d'un logout (are you sure jane ?) (vie la système de messagebox) +[ok] Possibilité d'enregistrement avec une page dédiée au profil. + * Pour se logger il suffit de donner un tuple login + password (le pseudo courant de chat est une données supplémentaire). + * La css choisie est une donnée personnelle. + * Les personnes enregistrées on un pseudo d'une couleur différente. + * (Ajout de smiles personnels)? +[ok] Ajouter des messages d'erreur ("login impossible", "captcha incorrect") +[ok] Ajouter des messages systèmes +[ok] Gérer le flood : si un utilisateur envoie plus de 2 messages par seconde pendant 5 secondes alors il ne peut plus poster pendant 5 secondes + * S'il récidive alors il est suspendu pendant 5^2 puis 5^3 + * Utiliser les messages systèmes pour annonce le flood +[ok] Pouvoir modifier la css (dark/light) + * Créer le style lite + * Créer le style old (avec le style de l'ancien site) +[ok] Ne pas afficher la css dans le profile + +* Ne pas effacer le message (dans le ) si l'on recoit un "pas ok" lors de l'envoie +* Ralentir volontairement le connexion lors d'un mauvais login +* Shift-enter pour ajouter une ligne dans la ligne de saisie (retour à la ligne) + * Crée un
XHTML +* réduire les pseudo trop long en mettant un ".." à la fin et permettre de le voir en entier lorsque le curseur le survol. +* Problème d'utf-8 avec opera +* Tester avec des caractères exotiques (jap, coréen, etc..) +* Rendre compatible IE 7 +* Pouvoir switcher entre un affichage "pseudo" ou "pseudo (login)" +* Faire une page faq et raconter n'importe quoi (entre autre la limitation avec firefox) "pourquoi ce site à des couleurs qui ne veulent rien dire ?" +* Créer un favicon (joli) +* Système de commande / + * /nick : changer de pseudo + * /me : "* " +* Ajouter de nouveaux smiles : + * "slurp" ("ca fait envie") : http://forum-images.hardware.fr/images/perso/huit.gif + * "agreed" : http://forum-images.hardware.fr/icones/smilies/jap.gif + * "dodo" (tete avec un bonnet de nuit et des ZZZZ) + * "hum?" : http://forum-images.hardware.fr/icones/smilies/heink.gif + * "pas reveillé" avec une tasse de café et des cernes : http://forum-images.hardware.fr/images/perso/elmoricq.gif + * "interrogation" genre http://forum-images.hardware.fr/icones/confused.gif + * http://forum-images.hardware.fr/images/perso/dao.gif ou http://forum-images.hardware.fr/icones/redface.gif + * http://forum-images.hardware.fr/icones/ohwell.gif +* Cleaner le code et eventuellement profiler un peu (le refresh est lent sous opera) +* Gestion de l'historique au niveau du navigateur (pouvoir revenir aux pages précédentes) +* Intégrer les totoz : http://www.totoz.eu/ (avec une limite de 3 par messages par exemple) + * avoir une option pour les cacher ou les voir + * modifier la syntaxe des smiles actuels (pour pas qu'ils entre en conflit avec totoz) +* Mettre un icone (genre sablier) lorsque le chat se charge (lors changement d'un changement de page par exemple) +* traitementComplet() de euphorik.js est très très lent à executer +* gestin des timezone (fuseaux horaire) +* Créer un style "super old school" (couleur 8 bit, pas de smiles/images, font fixe) +* Un statut "EK" avec plein de privilège à la con. (avoir une petite étoile à coté de son nick ou le nick d'une certaine couleur) + +-- Bugs -- +1 : Critique +2 : Urgent +3 : Peu grave +[ok] Au bout d'un moment opera n'écoute plus rien... et donc n'affiche plus les nouveaux messages.. +[ok] La méthod traiterSmiles est très lourde ! (4 secondes pour 80 appels (une page normale)) +[ok] Utiliser Alpha truc à la place d'opacity sous explorer +[ok] les heures sont formatées par le serveur avec un espace devant : " 12.30:10", zarb +[ok] un undefined est mis lorsque l'on répond à qqun qui n'a pas de pseudo (traiter ces pseudo par le formateur) +[ok] On ne peut pas réponde aux messages du système + +[3] Après un register le pseudo est effacé +[3] "Return" ne marche pas sous safari +[1] Apparement les process liés aux connexions ne sont jamais terminé même quand l'utilisateur coupe la connexion à cause de minichat:attends_nouveau_messages() +[2] cliquer sur les smiles ne marche pas sous IE +[2] le return ne marche pas sous IE +[3] la page est completement rechargé après avoir submité le profile dans opera +[3] après le login un '?' s'ajoute à l'adresse (opera, firefox) + +-- Idées -- +* Pouvoir cacher les dates +* Pouvoir choisir une couleur pour son pseudo +* Gestion de l'historique (calendrier) +* Créer un gamebot pour lancer des jeux. Par exemple un jeu d'énigmes +* Pourvoir ajouter du texte (correctif en général) à son dernier message par une commande, par exemple : /+ blabla +* smiles personnalisé, on peut en ajouter dans la préférence utilisateur. + * tout le monde peut voir les smiles des autres et les utiliser : [nom_user:smile] +* Possibilité de formater le texte ; bold, italic, etc.. +* Utiliser XMLRPC ou SOAP pour la communication client -> serveur +* Image annimé à la http://www.google.co.kr/ cf http://www.google.co.kr//ig/f/AaEyQnOaAr4/intl/ALL_kr/svc_sprite_all.gif +* Browser les messages par jour. Avec un joli calendar et tout et tout +* Bot de traduction +* RSS +* Voir les personnes connectées +* Statut : Modo avec ce qui va avec : kick ban sodo gravier etc... +* Plusieurs cannaux + + +-- Concurrents -- +http://www.phpfreechat.net/demo.fr.html +http://moules.org/board +http://hadoken.free.fr/board/index#b +http://bouchot.org/tribune#missive diff --git a/conception/fonctionnement_minichat.txt b/conception/fonctionnement_minichat.txt new file mode 100755 index 0000000..2ae4681 --- /dev/null +++ b/conception/fonctionnement_minichat.txt @@ -0,0 +1,203 @@ +Euphorik - minichat +------------------- + +A. Introduction +--------------- + +Le minichat utilise AJAX. Tous les messages sont au format XML +Eventuellement utiliser comet comme décrit ici + : http://www.zeitoun.net/index.php?2007/06/22/46-how-to-implement-comet-with-php + + +Structure : +----------- + +Les objets globaux : + - Messages (liste des messages actuellement affichés, permet de recupérer les nouveaux messages) + - Connexion (Information sur la connexion, information sur le user actuel) + + +B. Principe +----------- +Termes : serveur, client, utilisateur + + 1 Chargement de la page html. + 2 Le client écoute les derniers messages au serveur (asynchrone). + 3 Le client est initialement déconnecté, il regarde si un cookie existe sur la machine cliente : + a Si oui : il tente un login avec le cookie, si ok alors le client est connecté sinon il reste dans l'état déconnecté. + b Si non : il demande au serveur la génération d'un captcha et l'affiche. + 4 L'utilisateur peut alors envoyer un message. Il doit saisir le captcha s'il l'état et déconnecté. + a Si le captcha a été saisie le client envoie une requête de login + 5 Le message est posté + + +Principe concernant le rafraichissement: + * Le client envoie une demande au serveur avec l'id du dernier message (via XMLHttpRequest ou un méthode de JQuery) + * Le serveur maintient la connexion bloqué si le client est à jour. + * Dès que le serveur n'est plus à jours, il envoie les messages manquants. + +Problème : + * Comment faire de l'attente passive sur le serveur en écoutant l'arrivée d'un nouveau message au niveau de la bd + -> en utilisant le "event handling" de mnesia : http://www.erlang.org//doc/apps/mnesia/part_frame.html + chapitre 5.7 et 5.7.2 + + +C. Protocole +------------ +c : client +s : server + +C.1. Demande de génération d'un nouveau captcha : +----------------------------------------------- + +c -> s + + + +s -> c + + img/tmp/b1b1b4e72e6f3d00e477cf37cced5851.jpg + b1b1b4e72e6f3d00e477cf37cced5851 + + +C.2. Login : +------------ +le message du client est posté par la méthode POST et se nomme 'action'. + +c -> s +(nouveau user) (obsolète) + + b1b1b4e72e6f3d00e477cf37cced5851 + LKJDLA + + +ou +(ne sert pour l'instant qu'a mettre à jour user.date_derniere_connexion) +(si le login est faut, une temporisation est effectuée) + + LKJDLAKSJBFLKASN + + +ou + + Paul + IJKJDHHSAD9081238 + + + + Paul + IJKJDHHSAD9081238 + + +ou (login et password peuvent être omis) + + Paul + IJKJDHHSAD9081238 + + +s -> c +( et pas obligatoire) + + enregistre|identifie|erreur + LKJDLAKSJBFLKASN + 7ZS + Paul + paul49 + paul@pierre.com + css/lite.css + blabla + + + +C.3. Logout : +------------- +c -> s + + LKJDLAKSJBFLKASN + + +C.4. Profile : +-------------- +modification du profile, seul 'cookie' est obligatoire + +c -> s + + LKJDLAKSJBFLKASN + paul49 + IJKJDHHSAD9081238 + Paul + paul@pierre.com + css/dark.css + + +s -> c + + ok|pas ok + balbla> + + + +C.5. Refresh messages : +----------------------- + +Si dernierMessageId est absent alors le client ne possède pas de message. +Page peut être omis, il a alors la valeur 1 (première page) +dernierMessageId est en base 36 (l'histoire de rigoler un peu) + +c -> s + + LKJDLAKSJBFLKASN + 6ZR + 10 + 1 + + +s -> c + + 4 + + Hier 17:26:54 + + + + + Paul + paul_22 + Salut + + + + + + + + + +ou + + + raison + + +C.6. Envoie message : +--------------------- + +Un client envoie un message, le message peut répondre à un certain nombre d'autres messages. + n'est pas obligatoire. +c -> s + + LKJDLAKSJBFLKASN + Paul + Bonjour + + + + + + + +s -> c + + ok|pas ok + + diff --git a/conception/fond.xcf b/conception/fond.xcf new file mode 100755 index 0000000..96e905f Binary files /dev/null and b/conception/fond.xcf differ diff --git a/conception/icones/exclamation.xcf b/conception/icones/exclamation.xcf new file mode 100755 index 0000000..96381e0 Binary files /dev/null and b/conception/icones/exclamation.xcf differ diff --git a/conception/icones/fermer.xcf b/conception/icones/fermer.xcf new file mode 100755 index 0000000..9dc1f7b Binary files /dev/null and b/conception/icones/fermer.xcf differ diff --git a/conception/icones/information.xcf b/conception/icones/information.xcf new file mode 100755 index 0000000..a44fedb Binary files /dev/null and b/conception/icones/information.xcf differ diff --git a/conception/icones/interrogation.xcf b/conception/icones/interrogation.xcf new file mode 100755 index 0000000..8b7cfd8 Binary files /dev/null and b/conception/icones/interrogation.xcf differ diff --git a/conception/logo_1.xcf b/conception/logo_1.xcf new file mode 100755 index 0000000..f4993a8 Binary files /dev/null and b/conception/logo_1.xcf differ diff --git a/conception/logo_2.xcf b/conception/logo_2.xcf new file mode 100755 index 0000000..dc069c9 Binary files /dev/null and b/conception/logo_2.xcf differ diff --git a/conception/old.xcf b/conception/old.xcf new file mode 100755 index 0000000..ac44d56 Binary files /dev/null and b/conception/old.xcf differ diff --git a/conception/old_piedpage.xcf b/conception/old_piedpage.xcf new file mode 100755 index 0000000..9975be0 Binary files /dev/null and b/conception/old_piedpage.xcf differ diff --git a/conception/return.xcf b/conception/return.xcf new file mode 100755 index 0000000..086db3a Binary files /dev/null and b/conception/return.xcf differ diff --git a/css/1/euphorik.css b/css/1/euphorik.css new file mode 100755 index 0000000..a110f8b --- /dev/null +++ b/css/1/euphorik.css @@ -0,0 +1,181 @@ +@import url(../common.css); +@import url(pageMinichat.css); +@import url(pageProfileRegister.css); + +* { + padding: 0; + margin: 0; +} + +body { + font-family: sans-serif; + font-size: 10pt; + color: #EEEEEE; + text-align: center; /* uniquement pour IE */ + background-color: #DFDFDF; + background-image: url(../../img/css1/fond.png) +} + +#container { + position: relative; + width: 700px; + height: auto; + margin-left: auto; + margin-right: auto; + margin-top: 40px; +} + +#menu { + position: absolute; + z-index: 10; + top: 2px; + left: 300px; + font-size: 8pt; + background-color: #000000; + text-align: left; +} + +#menu div { + cursor: pointer; + display: inline; + padding: 2px; + margin-left: 2px; + background-color: #4f5519; +} + + +#menu div.courante { + background-color: #818c27; +} +#menu div:hover, +#menuCss div:hover { + background-color: #818c27 +} + +#menuCss { + position: absolute; + z-index: 10; + left: 600px; + top: -5px; +} + +#menuCss div { + cursor: pointer; + display: inline; + font-size: 6pt; + margin-left: 4px; + margin-right: 4px; +} + +#page { + position: relative; + padding: 25px 0px 15px 0px; + font-size: 8pt; + background-color: #000000; +} + +#logo { + z-index: 10; + background-image: url(../../img/css1/logo_2.png); + width: 253px; + height: 37px; + position: absolute; + top: -20px; + left: -10px; +} + +#footer { + text-align: right; +} +#footer a img{ + border-style: none; +} + +div#info { + width:100%; + position: fixed; + left: 0px; + top: 0px; + background-color: #000000; + border-bottom: 1px solid #aeaeae; + z-index: 20; +} + +div#info .fermer { + float:right; + cursor: pointer; + height:16px; + width: 16px; + background-image: url(../../img/fermer.gif) +} + +div#info #icone { + float:left; + height:16px; + width: 16px; +} +div#info #icone.interrogation { + background-image: url(../../img/interrogation.gif) +} +div#info #icone.information { + background-image: url(../../img/information.gif) +} +div#info #icone.exclamation { + background-image: url(../../img/exclamation.gif) +} + +div#info .boutons { + padding: 1px; +} + +div#info .boutons div { + cursor: pointer; + background-color: #770000; + display: inline; + padding: 0px 5px 0px 5px; + margin: 0px 5px 0px 5px; +} +div#info .boutons div:hover { + background-color: #bc0000; +} + +.captcha { + display:none +} + +/* Obsolète +#captcha { + margin-bottom: 5px; +} +#captcha input { + margin-left: 5px; +} +#captcha .captchaImg { + background-color: #FFFFFF; + vertical-align: bottom; +}*/ + +form input, +form button { + background-color: #164200; + border: #2d8800 1px solid; + color: #EEEEEE; + font-size: 9pt; +} + +a { + text-decoration: none; +} +a:link { + color: #7664ff; +} +a:visited { + color: #7664ff; +} +a:hover { + color: #ffad0f; +} +a:active { + color: #ffad0f; +} + diff --git a/css/1/pageMinichat.css b/css/1/pageMinichat.css new file mode 100755 index 0000000..d031b7f --- /dev/null +++ b/css/1/pageMinichat.css @@ -0,0 +1,159 @@ + +#page.minichat img { + margin: 0px; + vertical-align: bottom; +} + +#page.minichat #smiles { + border-width: 1px 0px 1px 0px; + border-color: #253f18; + border-style: solid; + margin-bottom: 10px; + padding: 1px; + height: 100%; + background-color: #0c2003; +} + +#page.minichat #smiles img { + cursor: pointer; + opacity: 0.5; +} + +#page.minichat .titreSmiles:hover { + background-color: #2d8800; +} + +#page.minichat form { + text-align: left; + margin-bottom: 15px; + padding-left: 10px; +} + +#page.minichat form .pseudo { + margin-right: 5px; +} + +#page.minichat form .message { + margin-right: 5px; +} + +#page.minichat form .return { + height: 15px; + width: 32px; + background-image: url(../../img/css1/return.png); + background-repeat: no-repeat; + background-position: 5px 2px; + vertical-align: top; +} + +#page.minichat #messages div.message { + border-left-width: 5px; + border-left-style: solid; + border-color: transparent; + text-align: left; + padding-right: 8px; + padding-left: 4px; + cursor: pointer; +} + +#page.minichat #messages div.messageImpair { + background-color: #05002c; +} + +#page.minichat #messages div.messagePair { + background-color: #080047; +} + +/* Il n'y a plus de mise en evidence +#page.minichat #messages div.miseEnEvidenceReponse { + background-color: #bd7a11; +} +#page.minichat #messages div.miseEnEvidenceCourant { + background-color: #bd1129; +} +#page.minichat #messages div.miseEnEvidenceConversation { + background-color: #b711bd; +}*/ + +#page.minichat #messages div.cache { + opacity: 0.3; + + /* Hack IE 7 */ + filter: alpha(opacity = 30); + zoom: 1 +} + +#page.minichat #messages div.reponse { + border-color: #bd7a11 +} +#page.minichat #messages div.repondu { + border-color: #b711bd +} +#page.minichat #messages div.proprietaire { + border-color: #bd1129 +} +#page.minichat #messages div.systeme { + background-color: #555555 +} + +#page.minichat div.message a { + font-weight: bold; +} + +#page.minichat .date { + display: inline; + color: #fd913b; + margin-right: 3px; + margin-left: 3px; +} + +#page.minichat div.message .pseudo, +#page.minichat form .pseudo { + display: inline; + margin-left: 4px; + margin-right: 2px; + font-weight: bold; + color: #76ff33; +} + +#page.minichat div.systeme .pseudo { + color: #CCCCCC +} + +/* Ca marche pas :( +#page.minichat div.message .pseudo { + min-width: 50px; + height:100px; +}*/ + +#page.minichat #messages .repondA { + display: inline; + margin-left: 4px; + color: #bd7a11 +} + +#page.minichat #messages .contenu { + display: inline; +} + +#page.minichat #pages { + margin-top: 10px; +} + +#page.minichat #pages span { + padding-right : 5px; + padding-left: 5px; + color: #7664ff; + cursor:pointer; +} + +#page.minichat #pages span.pageCourante { + font-weight: bold; + font-size: 150%; +} + +#page.minichat #pages span:hover { + font-size: 150%; + color: #ffad0f; +} + diff --git a/css/1/pageProfileRegister.css b/css/1/pageProfileRegister.css new file mode 100755 index 0000000..48f5bc9 --- /dev/null +++ b/css/1/pageProfileRegister.css @@ -0,0 +1,7 @@ +/* Réunit les page Profile et Register car ils ont beaucoup en commun */ + +#page.register, +#page.profile { + text-align: left; + padding: 30px 10px 10px 10px; +} diff --git a/css/2/euphorik.css b/css/2/euphorik.css new file mode 100755 index 0000000..a0d3743 --- /dev/null +++ b/css/2/euphorik.css @@ -0,0 +1,180 @@ +@import url(../common.css); +@import url(pageMinichat.css); +@import url(pageProfileRegister.css); + +* { + padding: 0; + margin: 0; +} + +body { + font-family: sans-serif; + font-size: 10pt; + color: #4b4b4b; + text-align: center; /* uniquement pour IE */ + background-color: #e5e1ff; + background-image: url(../../img/css2/fond.png); + background-repeat: repeat-x; +} + +#container { + position: relative; + width: 700px; + height: auto; + margin-left: auto; + margin-right: auto; + margin-top: 20px; +} + +#menu { + position: absolute; + z-index: 10; + font-size: 8pt; + left: 350px; + text-align: left; +} + +#menu div { + cursor: pointer; + display: inline; + padding: 2px; + margin-left: 2px; + background-color: #00eaa0; +} + +#menu div.courante { + background-color: #00ea48; +} +#menu div:hover, +#menuCss div:hover +{ + background-color: #00ea48 +} + +#menuCss { + position: absolute; + left: 600px; + top: -5px; + z-index: 10; +} + +#menuCss div { + cursor: pointer; + display: inline; + font-size: 8pt; + margin-left: 4px; + margin-right: 4px; +} + +#page { + position: relative; + padding: 20px 0px 15px 0px; + font-size: 8pt; + background-color: #eff4f8; +} + +#logo { + z-index: 10; + background-image: url(../../img/css2/logo.png); + width: 253px; + height: 37px; + position: absolute; + top: 5px; + left: 5px; +} + +#footer { + text-align: right; +} +#footer a img{ + border-style: none; +} + +div#info { + width:100%; + position: fixed; + left: 0px; + top: 0px; + background-color: #FFFFFF; + border-bottom: 1px solid #aeaeae; + z-index: 20; +} + +div#info .fermer { + float:right; + cursor: pointer; + height:16px; + width: 16px; + background-image: url(../../img/fermer.gif) +} + +div#info #icone { + float:left; + height:16px; + width: 16px; +} +div#info #icone.interrogation { + background-image: url(../../img/interrogation.gif) +} +div#info #icone.information { + background-image: url(../../img/information.gif) +} +div#info #icone.exclamation { + background-image: url(../../img/exclamation.gif) +} + +div#info .boutons { + padding: 1px; +} + +div#info .boutons div { + cursor: pointer; + background-color: #ff7070; + display: inline; + padding: 0px 5px 0px 5px; + margin: 0px 5px 0px 5px; +} +div#info .boutons div:hover { + background-color: #ffaeae; +} + +.captcha { + display:none +} + +/* Obsolète +#captcha { + margin-bottom: 5px; +} +#captcha input { + margin-left: 5px; +} +#captcha .captchaImg { + background-color: #FFFFFF; + vertical-align: bottom; +}*/ + +form input, +form button { + background-color: #FFFFFF; + border: #00eaa0 1px solid; + color: #4b4b4b; + font-size: 9pt; +} + +a { + text-decoration: none; +} +a:link { + color: #4332c1; +} +a:visited { + color: #4332c1; +} +a:hover { + color: #ffad0f; +} +a:active { + color: #ffad0f; +} + diff --git a/css/2/pageMinichat.css b/css/2/pageMinichat.css new file mode 100755 index 0000000..2bbfbeb --- /dev/null +++ b/css/2/pageMinichat.css @@ -0,0 +1,164 @@ + +#page.minichat img { + margin: 0px; + vertical-align: bottom; +} + +#page.minichat #smiles { + border-width: 1px 1px 1px 1px; + border-color: #ccdfed; + border-style: solid; + position: relative; + left: 280px; + width: 300px; + margin-bottom: 10px; + padding: 1px; + height: 100%; + background-color: #FFFFFF; +} + +#page.minichat #smiles img { + cursor: pointer; + opacity: 0.5; + margin-right:1px; +} + +#page.minichat .titreSmiles:hover { + background-color: #2d8800; +} + +#page.minichat form { + text-align: left; + margin-bottom: 15px; + padding-left: 10px; +} + +#page.minichat form .pseudo { + margin-right: 5px; +} + +#page.minichat form .message { + margin-right: 5px; +} + +#page.minichat form .return { + height: 15px; + width: 32px; + background-color: #BBBBBB; + background-image: url(../../img/css1/return.png); + background-repeat: no-repeat; + background-position: 5px 2px; + vertical-align: top; +} + +#page.minichat #messages div.message { + border-left-width: 5px; + border-left-style: solid; + border-color: transparent; + text-align: left; + padding-right: 8px; + padding-left: 4px; + cursor: pointer; +} + +#page.minichat #messages div.messageImpair { + background-color: #e4e1ff; +} + +#page.minichat #messages div.messagePair { + background-color: #eceaf7; +} + +/* Il n'y a plus de mise en evidence +#page.minichat #messages div.miseEnEvidenceReponse { + background-color: #bd7a11; +} +#page.minichat #messages div.miseEnEvidenceCourant { + background-color: #bd1129; +} +#page.minichat #messages div.miseEnEvidenceConversation { + background-color: #b711bd; +}*/ + +#page.minichat #messages div.cache { + opacity: 0.3; + + /* Hack IE 7 */ + filter: alpha(opacity = 30); + zoom: 1 +} + +#page.minichat #messages div.reponse { + border-color: #d2ad73 +} +#page.minichat #messages div.repondu { + border-color: #d066d4 +} +#page.minichat #messages div.proprietaire { + border-color: #d74a5e +} +#page.minichat #messages div.systeme { + background-color: #b1b1b1 +} + +#page.minichat div.message a { + font-weight: bold; +} + +#page.minichat .date { + display: inline; + color: #cf6f21; + margin-right: 3px; + margin-left: 3px; +} + +#page.minichat div.message .pseudo, +#page.minichat form .pseudo { + display: inline; + margin-left: 4px; + margin-right: 2px; + font-weight: bold; + color: #2b5715; +} + +#page.minichat div.systeme .pseudo { + color: #CCCCCC +} + +/* Ca marche pas :( +#page.minichat div.message .pseudo { + min-width: 50px; + height:100px; +}*/ + +#page.minichat #messages .repondA { + display: inline; + margin-left: 4px; + color: #95600d +} + +#page.minichat #messages .contenu { + display: inline; +} + +#page.minichat #pages { + margin-top: 10px; +} + +#page.minichat #pages span { + padding-right : 5px; + padding-left: 5px; + color: #7169ae; + cursor:pointer; +} + +#page.minichat #pages span.pageCourante { + font-weight: bold; + font-size: 150%; +} + +#page.minichat #pages span:hover { + font-size: 150%; + color: #ada9cf; +} + diff --git a/css/2/pageProfileRegister.css b/css/2/pageProfileRegister.css new file mode 100755 index 0000000..8d04e0d --- /dev/null +++ b/css/2/pageProfileRegister.css @@ -0,0 +1,7 @@ +/* Réunit les page Profile et Register car ils ont beaucoup en commun */ + +#page.register, +#page.profile { + text-align: left; + padding: 50px 10px 10px 10px; +} diff --git a/css/3/euphorik.css b/css/3/euphorik.css new file mode 100755 index 0000000..618a9b8 --- /dev/null +++ b/css/3/euphorik.css @@ -0,0 +1,171 @@ +@import url(../common.css); +@import url(pageMinichat.css); +@import url(pageProfileRegister.css); + +* { + padding: 0; + margin: 0; +} + +body { + font-family: sans-serif; + font-size: 10pt; + color: #000000; + text-align: center; /* uniquement pour IE */ + background-color: #837fb7; +} + +#container { + position: relative; + background-image: url(../../img/css3/logo.png); + background-repeat: repeat-x; + background-color: #b1b0d4; + width: 626px; + height: auto; + margin-left: auto; + margin-right: auto; +} + +#menu { + z-index: 10; + left: 503px; + top: 5px; + position: absolute; + font-size: 7pt; + text-align: left; +} + +#menu div { + cursor: pointer; +} +#menu div.courante { + background-color: #e6e770 +} +#menu div:hover, +#menuCss div:hover { + background-color: #e6e770 +} + +#menuCss { + text-align: right; + z-index: 10; + position: absolute; + left: 570px; + top: 5px; +} + +#menuCss div { + cursor: pointer; + font-size: 6pt; +} + +#page { + position: relative; + padding: 130px 0px 3px 0px; + font-size: 8pt; +} + +#logo { display: none; } + +#footer { + padding-top: 5px; + text-align: center; + width: 625px; + height: 27px; + background-image: url(../../img/css3/piedpage.png); + background-repeat: no-repeat; +} +#footer a img{ + border-style: none; +} + +#info { + width:100%; + position: fixed; + left: 0px; + top: 0px; + background-color: #d5d3ef; + border-bottom: 1px solid #837fb7; + z-index: 20; +} + +#info .fermer { + float:right; + cursor: pointer; + height:16px; + width: 16px; + background-image: url(../../img/fermer.gif) +} + +#info #icone { + float:left; + height:16px; + width: 16px; +} +#info #icone.interrogation { + background-image: url(../../img/interrogation.gif) +} +#info #icone.information { + background-image: url(../../img/information.gif) +} +#info #icone.exclamation { + background-image: url(../../img/exclamation.gif) +} + +#info .boutons { + padding: 1px; + margin-bottom: 2px; +} + +#info .boutons div { + cursor: pointer; + background-color: #b1b0d4; + display: inline; + padding: 0px 5px 0px 5px; + margin: 0px 5px 0px 5px; + border: 1px solid #837fb7; +} +#info .boutons div:hover { + background-color: #d5d3ef; +} + +.captcha { + display:none +} + +/* Obsolète +#captcha { + margin-bottom: 5px; +} +#captcha input { + margin-left: 5px; +} +#captcha .captchaImg { + background-color: #FFFFFF; + vertical-align: bottom; +}*/ + +form input, +form button { + background-color: #d5d3ef; + border: #837fb7 1px solid; + color: #000000; + font-size: 9pt; +} + +a { + text-decoration: underline; +} +a:link { + color: #1f15e8; +} +a:visited { + color: #1f15e8; +} +a:hover { + color: #645fd4; +} +a:active { + color: #645fd4; +} + diff --git a/css/3/pageMinichat.css b/css/3/pageMinichat.css new file mode 100755 index 0000000..d8f8706 --- /dev/null +++ b/css/3/pageMinichat.css @@ -0,0 +1,155 @@ + +#page.minichat img { + vertical-align: bottom; + margin-right: 1px; + margin-left: 1px; +} + +#page.minichat #smiles { + position: absolute; + top: 90px; + left: 104px; + margin-bottom: 10px; + padding: 1px; +} + +#page.minichat #smiles img { + margin-left: 9px; + cursor: pointer; + opacity: 0.5; +} + +#page.minichat form { + text-align: left; + margin-bottom: 15px; + padding-left: 10px; +} + +#page.minichat form .pseudo { + margin-right: 5px; +} + +#page.minichat form .message { + margin-right: 5px; +} + +#page.minichat form .return { + height: 15px; + width: 32px; + background-image: url(../../img/css1/return.png); + background-repeat: no-repeat; + background-position: 5px 2px; + vertical-align: top; +} + +#page.minichat #messages div.message { + border-left-width: 5px; + border-left-style: solid; + border-color: transparent; + text-align: left; + padding-right: 8px; + padding-left: 4px; + cursor: pointer; +} + +#page.minichat #messages div.messageImpair { + background-color: #9f9cd2; +} + +#page.minichat #messages div.messagePair { + background-color: #b2afd5; +} + +/* Il n'y a plus de mise en evidence +#page.minichat #messages div.miseEnEvidenceReponse { + background-color: #bd7a11; +} +#page.minichat #messages div.miseEnEvidenceCourant { + background-color: #bd1129; +} +#page.minichat #messages div.miseEnEvidenceConversation { + background-color: #b711bd; +}*/ + +#page.minichat #messages div.cache { + opacity: 0.3; + + /* Hack IE 7 */ + filter: alpha(opacity = 30); + zoom: 1 +} + +#page.minichat #messages div.reponse { + border-color: #bd7a11 +} +#page.minichat #messages div.repondu { + border-color: #b711bd +} +#page.minichat #messages div.proprietaire { + border-color: #bd1129 +} +#page.minichat #messages div.systeme { + background-color: #888888 +} + +#page.minichat div.message a { + font-weight: bold; +} + +#page.minichat .date { + display: inline; + color: #8a4106; + margin-right: 3px; + margin-left: 3px; +} + +#page.minichat div.message .pseudo, +#page.minichat form .pseudo { + display: inline; + margin-left: 4px; + margin-right: 2px; + font-weight: bold; + color: #8f4108; +} + +#page.minichat div.systeme .pseudo { + color: #CCCCCC +} + +/* Ca marche pas :( +#page.minichat div.message .pseudo { + min-width: 50px; + height:100px; +}*/ + +#page.minichat #messages .repondA { + display: inline; + margin-left: 4px; + color: #704605 +} + +#page.minichat #messages .contenu { + display: inline; +} + +#page.minichat #pages { + margin-top: 5px; +} + +#page.minichat #pages span { + padding-right : 5px; + padding-left: 5px; + color: #1f15e8; + cursor:pointer; +} + +#page.minichat #pages span.pageCourante { + font-weight: bold; + font-size: 150%; +} + +#page.minichat #pages span:hover { + font-size: 150%; + color: #645fd4; +} + diff --git a/css/3/pageProfileRegister.css b/css/3/pageProfileRegister.css new file mode 100755 index 0000000..50be113 --- /dev/null +++ b/css/3/pageProfileRegister.css @@ -0,0 +1,8 @@ +/* Réunit les page Profile et Register car ils ont beaucoup en commun */ + +#page.register, +#page.profile { + text-align: left; + padding-left: 10px; + padding-bottom: 10px; +} diff --git a/css/common.css b/css/common.css new file mode 100755 index 0000000..1157650 --- /dev/null +++ b/css/common.css @@ -0,0 +1,9 @@ +#underDevelopment { + position: fixed; + top: 0px; + z-index: 15; + padding: 2px 10px 2px 10px; + background-color: #FF6666; + color: #FFFFFF; + opacity: 0.8; +} \ No newline at end of file diff --git a/img/css1/fond.png b/img/css1/fond.png new file mode 100755 index 0000000..99a1511 Binary files /dev/null and b/img/css1/fond.png differ diff --git a/img/css1/logo_1.png b/img/css1/logo_1.png new file mode 100755 index 0000000..06318b0 Binary files /dev/null and b/img/css1/logo_1.png differ diff --git a/img/css1/logo_2.png b/img/css1/logo_2.png new file mode 100755 index 0000000..0a7da96 Binary files /dev/null and b/img/css1/logo_2.png differ diff --git a/img/css1/return.png b/img/css1/return.png new file mode 100755 index 0000000..d4aa70b Binary files /dev/null and b/img/css1/return.png differ diff --git a/img/css2/fond.png b/img/css2/fond.png new file mode 100755 index 0000000..43fb952 Binary files /dev/null and b/img/css2/fond.png differ diff --git a/img/css2/logo.png b/img/css2/logo.png new file mode 100755 index 0000000..aaeaef0 Binary files /dev/null and b/img/css2/logo.png differ diff --git a/img/css3/logo.gif b/img/css3/logo.gif new file mode 100755 index 0000000..92f49bd Binary files /dev/null and b/img/css3/logo.gif differ diff --git a/img/css3/logo.png b/img/css3/logo.png new file mode 100755 index 0000000..dc6bd85 Binary files /dev/null and b/img/css3/logo.png differ diff --git a/img/css3/piedpage.png b/img/css3/piedpage.png new file mode 100755 index 0000000..095fdb7 Binary files /dev/null and b/img/css3/piedpage.png differ diff --git a/img/exclamation.gif b/img/exclamation.gif new file mode 100755 index 0000000..46bb733 Binary files /dev/null and b/img/exclamation.gif differ diff --git a/img/fermer.gif b/img/fermer.gif new file mode 100755 index 0000000..3d78493 Binary files /dev/null and b/img/fermer.gif differ diff --git a/img/information.gif b/img/information.gif new file mode 100755 index 0000000..c75a5d6 Binary files /dev/null and b/img/information.gif differ diff --git a/img/interrogation.gif b/img/interrogation.gif new file mode 100755 index 0000000..47fd4b0 Binary files /dev/null and b/img/interrogation.gif differ diff --git a/img/powered-by-yaws.gif b/img/powered-by-yaws.gif new file mode 100755 index 0000000..8c874d8 Binary files /dev/null and b/img/powered-by-yaws.gif differ diff --git a/img/smileys/alien.gif b/img/smileys/alien.gif new file mode 100755 index 0000000..b75a32b Binary files /dev/null and b/img/smileys/alien.gif differ diff --git a/img/smileys/argn.gif b/img/smileys/argn.gif new file mode 100755 index 0000000..63d39a8 Binary files /dev/null and b/img/smileys/argn.gif differ diff --git a/img/smileys/autres/icon_angry.gif b/img/smileys/autres/icon_angry.gif new file mode 100755 index 0000000..15f9ccb Binary files /dev/null and b/img/smileys/autres/icon_angry.gif differ diff --git a/img/smileys/autres/icon_chinese.gif b/img/smileys/autres/icon_chinese.gif new file mode 100755 index 0000000..b162cfb Binary files /dev/null and b/img/smileys/autres/icon_chinese.gif differ diff --git a/img/smileys/autres/icon_confused.gif b/img/smileys/autres/icon_confused.gif new file mode 100755 index 0000000..b20fcb3 Binary files /dev/null and b/img/smileys/autres/icon_confused.gif differ diff --git a/img/smileys/autres/icon_cool.gif b/img/smileys/autres/icon_cool.gif new file mode 100755 index 0000000..bf0fd09 Binary files /dev/null and b/img/smileys/autres/icon_cool.gif differ diff --git a/img/smileys/autres/icon_largesmile.gif b/img/smileys/autres/icon_largesmile.gif new file mode 100755 index 0000000..19c523f Binary files /dev/null and b/img/smileys/autres/icon_largesmile.gif differ diff --git a/img/smileys/autres/icon_lol.gif b/img/smileys/autres/icon_lol.gif new file mode 100755 index 0000000..ebbec8b Binary files /dev/null and b/img/smileys/autres/icon_lol.gif differ diff --git a/img/smileys/autres/icon_mrgreen.gif b/img/smileys/autres/icon_mrgreen.gif new file mode 100755 index 0000000..29280bb Binary files /dev/null and b/img/smileys/autres/icon_mrgreen.gif differ diff --git a/img/smileys/autres/icon_neutral.gif b/img/smileys/autres/icon_neutral.gif new file mode 100755 index 0000000..6341536 Binary files /dev/null and b/img/smileys/autres/icon_neutral.gif differ diff --git a/img/smileys/autres/icon_redface.gif b/img/smileys/autres/icon_redface.gif new file mode 100755 index 0000000..6670542 Binary files /dev/null and b/img/smileys/autres/icon_redface.gif differ diff --git a/img/smileys/autres/icon_rolleyes.gif b/img/smileys/autres/icon_rolleyes.gif new file mode 100755 index 0000000..b2aab79 Binary files /dev/null and b/img/smileys/autres/icon_rolleyes.gif differ diff --git a/img/smileys/autres/icon_sad.gif b/img/smileys/autres/icon_sad.gif new file mode 100755 index 0000000..31cdd5f Binary files /dev/null and b/img/smileys/autres/icon_sad.gif differ diff --git a/img/smileys/autres/icon_smile.gif b/img/smileys/autres/icon_smile.gif new file mode 100755 index 0000000..71cd97a Binary files /dev/null and b/img/smileys/autres/icon_smile.gif differ diff --git a/img/smileys/autres/icon_surprised.gif b/img/smileys/autres/icon_surprised.gif new file mode 100755 index 0000000..3fdfc9d Binary files /dev/null and b/img/smileys/autres/icon_surprised.gif differ diff --git a/img/smileys/autres/icon_tongue.gif b/img/smileys/autres/icon_tongue.gif new file mode 100755 index 0000000..5e25f32 Binary files /dev/null and b/img/smileys/autres/icon_tongue.gif differ diff --git a/img/smileys/autres/icon_whistle.gif b/img/smileys/autres/icon_whistle.gif new file mode 100755 index 0000000..9c20056 Binary files /dev/null and b/img/smileys/autres/icon_whistle.gif differ diff --git a/img/smileys/autres/icon_wink.gif b/img/smileys/autres/icon_wink.gif new file mode 100755 index 0000000..c9e1a66 Binary files /dev/null and b/img/smileys/autres/icon_wink.gif differ diff --git a/img/smileys/bigsmile.gif b/img/smileys/bigsmile.gif new file mode 100755 index 0000000..b54cd0f Binary files /dev/null and b/img/smileys/bigsmile.gif differ diff --git a/img/smileys/bunny.gif b/img/smileys/bunny.gif new file mode 100755 index 0000000..5faa5d5 Binary files /dev/null and b/img/smileys/bunny.gif differ diff --git a/img/smileys/chat.gif b/img/smileys/chat.gif new file mode 100755 index 0000000..33cb58f Binary files /dev/null and b/img/smileys/chat.gif differ diff --git a/img/smileys/clin.gif b/img/smileys/clin.gif new file mode 100755 index 0000000..13d446d Binary files /dev/null and b/img/smileys/clin.gif differ diff --git a/img/smileys/cool.gif b/img/smileys/cool.gif new file mode 100755 index 0000000..c3aff9d Binary files /dev/null and b/img/smileys/cool.gif differ diff --git a/img/smileys/eheheh.gif b/img/smileys/eheheh.gif new file mode 100755 index 0000000..4fc3e19 Binary files /dev/null and b/img/smileys/eheheh.gif differ diff --git a/img/smileys/kirby.gif b/img/smileys/kirby.gif new file mode 100755 index 0000000..19784c5 Binary files /dev/null and b/img/smileys/kirby.gif differ diff --git a/img/smileys/lol.gif b/img/smileys/lol.gif new file mode 100755 index 0000000..b5e7153 Binary files /dev/null and b/img/smileys/lol.gif differ diff --git a/img/smileys/oh.gif b/img/smileys/oh.gif new file mode 100755 index 0000000..18d3abb Binary files /dev/null and b/img/smileys/oh.gif differ diff --git a/img/smileys/pascontent.gif b/img/smileys/pascontent.gif new file mode 100755 index 0000000..7297a64 Binary files /dev/null and b/img/smileys/pascontent.gif differ diff --git a/img/smileys/renne.gif b/img/smileys/renne.gif new file mode 100755 index 0000000..71c6316 Binary files /dev/null and b/img/smileys/renne.gif differ diff --git a/img/smileys/slurp.gif b/img/smileys/slurp.gif new file mode 100755 index 0000000..cced52c Binary files /dev/null and b/img/smileys/slurp.gif differ diff --git a/img/smileys/smile.gif b/img/smileys/smile.gif new file mode 100755 index 0000000..3fb63ae Binary files /dev/null and b/img/smileys/smile.gif differ diff --git a/img/smileys/sniff.gif b/img/smileys/sniff.gif new file mode 100755 index 0000000..da1895d Binary files /dev/null and b/img/smileys/sniff.gif differ diff --git a/img/smileys/spliff.gif b/img/smileys/spliff.gif new file mode 100755 index 0000000..a7338cb Binary files /dev/null and b/img/smileys/spliff.gif differ diff --git a/img/smileys/star.gif b/img/smileys/star.gif new file mode 100755 index 0000000..5259b73 Binary files /dev/null and b/img/smileys/star.gif differ diff --git a/img/smileys/triste.gif b/img/smileys/triste.gif new file mode 100755 index 0000000..0d8abc8 Binary files /dev/null and b/img/smileys/triste.gif differ diff --git a/index.html b/index.html new file mode 100755 index 0000000..2740552 --- /dev/null +++ b/index.html @@ -0,0 +1,34 @@ + + + + + euphorik.ch + + + + + + + + + + + + + +
! Under heavy development !
+
+ + + + +
+ +
+ + \ No newline at end of file diff --git a/js/euphorik.js b/js/euphorik.js new file mode 100755 index 0000000..433c0bc --- /dev/null +++ b/js/euphorik.js @@ -0,0 +1,807 @@ +// coding: utf-8 + +/** + * Auteur : GBurri + * Date : 6.11.2007 + */ + +/** + * La configuration. + * Normalement 'const' à la place de 'var' mais non supporté par IE7. + */ +var conf = { + nbMessageAffiche : 80, // (par page) + pseudoDefaut : "", + tempsAffichageMessageDialogue : 4000, // en ms + smiles : { + "smile" : [/:\)/g, /:-\)/g], + "bigsmile" : [/:D/g, /:-D/g], + "clin" : [/;\)/g, /;-\)/g], + "cool" : [/8\)/g, /8-\)/g], + "eheheh" : [/:P/g, /:-P/g], + "oh" : [/:o/g, /:O/g], + "pascontent" : [/>\(/g, />\(/g], + "sniff" : [/:\(/g, /:-\(/g], + "argn" : [/\[:argn\]/g], + "bunny" : [/\[:lapin\]/g], + "chat" : [/\[:chat\]/g], + "renne" : [/\[:renne\]/g], + "lol" : [/\[:lol\]/g], + "spliff" : [/\[:spliff\]/g], + "star" : [/\[:star\]/g], + "triste" : [/\[:triste\]/g], + "kirby" : [/\[:kirby\]/g] + } +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// + +String.prototype.trim = function() +{ + return this.replace(/^\s+|\s+$/g,""); +} +String.prototype.ltrim = function() +{ + return this.replace(/^\s+/,""); +} +String.prototype.rtrim = function() +{ + return this.replace(/\s+$/,""); +} + +String.prototype.dump = function() +{ + if (typeof dump != "undefined") + { + dump("\n--- EUPHORIK.CH ---\n") + dump(this) + dump("\n------\n") + } +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// + +function Util(serializer) +{ + if(typeof XMLSerializer != "undefined") + this.serializer = new XMLSerializer() + + jQuery("#info .fermer").click(function(){ + jQuery("#info").slideUp(50) + }) +} + +/** + * Affiche une boite de dialogue avec un message à l'intérieur. + * + */ +Util.prototype.messageDialogue = function(message, type, boutons) +{ + if (type == undefined) + type = messageType.informatif + + if (this.timeoutMessageDialogue != undefined) + clearTimeout(this.timeoutMessageDialogue) + + var fermer = function(){jQuery("#info").slideUp(100)} + fermer() + + jQuery("#info .message").html(message) + switch(type) + { + case messageType.informatif : jQuery("#info #icone").attr("class", "information"); break + case messageType.question : jQuery("#info #icone").attr("class", "interrogation"); break + case messageType.erreur : jQuery("#info #icone").attr("class", "exclamation"); break + } + jQuery("#info .boutons").html("") + for (var b in boutons) + jQuery("#info .boutons").append("
" + b + "
").find("div:last").click(boutons[b]).click(fermer) + + jQuery("#info").slideDown(200) + this.timeoutMessageDialogue = setTimeout(fermer, conf.tempsAffichageMessageDialogue) +} +var messageType = {informatif: 0, question: 1, erreur: 2} + +/* obsolète +Util.prototype.log = function(str) +{ +}*/ + +Util.prototype.serializeXML = function(documentXML) +{ + if (this.serializer) + return this.serializer.serializeToString(documentXML) + else + return documentXML.xml +} + +Util.prototype.creerDocumentXMLAction = function() +{ + if (document.implementation && document.implementation.createDocument) + { + return document.implementation.createDocument("", "action", null) + } + else if (window.ActiveXObject) + { + var doc = new ActiveXObject("MSXML2.DOMDocument") //("Microsoft.XMLDOM") + doc.appendChild(doc.createElement("action")); + //doc.loadXML("") + //alert(doc.documentElement) + //doc.createElement("action") + return doc + } +} + +Util.prototype.xmlVersAction = function(xml) +{ + return {action: this.to_utf8(this.serializeXML(xml /*, "UTF-8"*/))} +} + +// voir : http://homepage3.nifty.com/aokura/jscript/utf8.html +// et : http://www1.tip.nl/~t876506/utf8tbl.html +Util.prototype.to_utf8 = function(s) +{ + if (!s) return "" + + var c, d = "" + for (var i = 0; i < s.length; i++) + { + c = s.charCodeAt(i); + if (c <= 0x7f) { + d += s.charAt(i); + } else if (c >= 0x80 && c <= 0x7ff) { + d += String.fromCharCode(((c >> 6) & 0x1f) | 0xc0); + d += String.fromCharCode((c & 0x3f) | 0x80); + } else { + d += String.fromCharCode((c >> 12) | 0xe0); + d += String.fromCharCode(((c >> 6) & 0x3f) | 0x80); + d += String.fromCharCode((c & 0x3f) | 0x80); + } + } + return d; +} + +Util.prototype.md5 = function(chaine) +{ + return hex_md5(chaine) +} + +// pompé de http://www.faqts.com/knowledge_base/view.phtml/aid/13562/fid/130 +Util.prototype.setSelectionRange = function(input, selectionStart, selectionEnd) +{ + if (input.setSelectionRange) + { + input.focus() + input.setSelectionRange(selectionStart, selectionEnd) + } + else if (input.createTextRange) + { + var range = input.createTextRange() + range.collapse(true) + range.moveEnd('character', selectionEnd) + range.moveStart('character', selectionStart) + range.select() + } +} + +Util.prototype.setCaretToEnd = function(input) +{ + this.setSelectionRange(input, input.value.length, input.value.length) +} +Util.prototype.setCaretToBegin = function(input) +{ + this.setSelectionRange(input, 0, 0) +} +Util.prototype.setCaretToPos = function(input, pos) +{ + this.setSelectionRange(input, pos, pos) +} +Util.prototype.selectString = function(input, string) +{ + var match = new RegExp(string, "i").exec(input.value) + if (match) + { + this.setSelectionRange (input, match.index, match.index + match[0].length) + } +} +Util.prototype.replaceSelection = function(input, replaceString) { + if (input.setSelectionRange) + { + var selectionStart = input.selectionStart + var selectionEnd = input.selectionEnd + input.value = input.value.substring(0, selectionStart) + replaceString + input.value.substring(selectionEnd) + + if (selectionStart != selectionEnd) // has there been a selection + this.setSelectionRange(input, selectionStart, selectionStart + replaceString.length) + else // set caret + this.setCaretToPos(input, selectionStart + replaceString.length) + } + else if (document.selection) + { + var range = document.selection.createRange(); + if (range.parentElement() == input) + { + var isCollapsed = range.text == '' + range.text = replaceString + if (!isCollapsed) + { + // there has been a selection + // it appears range.select() should select the newly + // inserted text but that fails with IE + range.moveStart('character', -replaceString.length); + range.select(); + } + } + } +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// + +function Pages() +{ + this.pageCourante = null + this.pages = {} +} + +Pages.prototype.ajouterPage = function(page) +{ + page.pages = this // la magie des langages dynamiques : le foutoire + this.pages[page.nom] = page +} + +Pages.prototype.afficherPage = function(nomPage, forcerChargement) +{ + if (forcerChargement == undefined) forcerChargement = false + + var page = this.pages[nomPage] + if (page == undefined || (!forcerChargement && page == this.pageCourante)) return + + if (this.pageCourante != null && this.pageCourante.decharger) + this.pageCourante.decharger() + + jQuery("#menu div").removeClass("courante") + jQuery("#menu div." + nomPage).addClass("courante") + + this.pageCourante = page + jQuery("#page").html(this.pageCourante.contenu()).removeClass().addClass(this.pageCourante.nom) + + if (this.pageCourante.charger) + this.pageCourante.charger() +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// + +function Formateur() +{ + this.smiles = conf.smiles + this.protocoles = "http|https|ed2k" + + this.regexUrl = new RegExp("(?:(?:" + this.protocoles + ")://|www\\.)[^ ]*", "gi") + this.regexImg = new RegExp("^.*?\\.(gif|jpg|png|jpeg|bmp|tiff)$", "i") + this.regexDomaine = new RegExp("^(?:(?:" + this.protocoles + ")://|www\\.).*?([^/.]+\\.[^/.]+)(?:$|/).*$", "i") + this.regexTestProtocoleExiste = new RegExp("^(?:" + this.protocoles + ")://.*$", "i") + this.regexNomProtocole = new RegExp("^(.*?)://") +} + +/** + * Formate un pseudo saise par l'utilisateur. + * @param pseudo le pseudo brut + * @return le pseudo filtré + */ +Formateur.prototype.filtrerInputPseudo = function(pseudo) +{ + return pseudo.replace(/{|}/g, "").trim() +} + +Formateur.prototype.getSmilesHTML = function() +{ + var XHTML = "" + for (var sNom in this.smiles) + { + XHTML += "" + } + return XHTML +} + +Formateur.prototype.traitementComplet = function(M, pseudo) +{ + return this.traiterSmiles(this.traiterURL(this.remplacerBalisesHTML(M), pseudo)) +} + +/** + * FIXME : Cette méthode est attrocement lourde !! + */ +Formateur.prototype.traiterSmiles = function(M) +{ + for (var sNom in this.smiles) + { + ss = this.smiles[sNom] + for (var i = 0; i < ss.length; i++) + M = M.replace(ss[i], "") + } + return M +} + +Formateur.prototype.remplacerBalisesHTML = function(M) +{ + return M.replace(//g, ">") +} + +Formateur.prototype.traiterURL = function(M, pseudo) +{ + thisFormateur = this + + if (pseudo == undefined) + pseudo = "" + + var traitementUrl = function(url) + { + // si ya pas de protocole on rajoute "http://" + if (!thisFormateur.regexTestProtocoleExiste.test(url)) + url = "http://" + url + var extension = thisFormateur.getShort(url) + return "[" + extension[0] + "]" + } + return M.replace(this.regexUrl, traitementUrl) +} + +/** + * Renvoie une version courte de l'url. + * par exemple : http://en.wikipedia.org/wiki/Yakov_Smirnoff devient wikipedia.org + */ +Formateur.prototype.getShort = function(url) +{ + var estUneImage = false + var versionShort = null + var rechercheImg = this.regexImg.exec(url) + //alert(url) + if (rechercheImg != null) + { + versionShort = rechercheImg[1].toLowerCase() + if (versionShort == "jpeg") versionShort = "jpg" // jpeg -> jpg + estUneImage = true + } + else + { + var rechercheDomaine = this.regexDomaine.exec(url) + if (rechercheDomaine != null && rechercheDomaine.length >= 2) + versionShort = rechercheDomaine[1] + else + { + var nomProtocole = this.regexNomProtocole.exec(url) + if (nomProtocole != null && nomProtocole.length >= 2) + versionShort = nomProtocole[1] + } + } + + return [versionShort == null ? "url" : versionShort, estUneImage] + } + +/** + * Traite les pseudo et messages à être affiché dans le titre d'une image visualisé avec lightbox. + */ +Formateur.prototype.traiterPourFenetreLightBox = function(M, urlCourante) +{ + thisFormateur = this + var traitementUrl = function(url) + { + return "[" + thisFormateur.getShort(url)[0] + (urlCourante == url ? ": image courante" : "") + "]" + } + + return this.remplacerBalisesHTML(M).replace(this.regexUrl, traitementUrl) +} + + +/////////////////////////////////////////////////////////////////////////////////////////////////// + +var statutType = {enregistre: 0, identifie: 1, non_identifie: 2} + +function Client(util) +{ + this.util = util + + this.cookie = null + this.regexCookie = new RegExp("^cookie=([^;]*)") + + // Obsolète + //this.captchaCrypt = null + + // données personnels + this.resetDonneesPersonnelles() + + this.setStatut(statutType.non_identifie) + + // le dernier message d'erreur recut du serveur (par exemple une connexion foireuse : "login impossible") + this.dernierMessageErreur = "" +} + +Client.prototype.resetDonneesPersonnelles = function() +{ + this.pseudo = conf.pseudoDefaut + this.login = "" + this.password = "" + this.email = "" + this.css = jQuery("link#cssPrincipale").attr("href") +} + +Client.prototype.setCss = function(css) +{ + if (this.css == css) + return + + this.css = css + jQuery("link#cssPrincipale").attr("href", this.css) + this.majMenu() + + /* enregistement automatique.. + if (!this.identifie()) + if (!this.enregistrement()) + return + */ + if (this.identifie()) + this.flush() +} + +Client.prototype.getXMLlogin = function(login, password) +{ + var XMLDocument = this.util.creerDocumentXMLAction() + XMLDocument.documentElement.setAttribute("name", "login") + + var nodeLogin = XMLDocument.createElement("login") + nodeLogin.appendChild(XMLDocument.createTextNode(login)) + XMLDocument.documentElement.appendChild(nodeLogin) + + var nodePassword = XMLDocument.createElement("password") + nodePassword.appendChild(XMLDocument.createTextNode(password)) + XMLDocument.documentElement.appendChild(nodePassword) + + return XMLDocument +} + +Client.prototype.getXMLloginCookie = function() +{ + var XMLDocument = this.util.creerDocumentXMLAction() + XMLDocument.documentElement.setAttribute("name", "login") + + var nodeCookie = XMLDocument.createElement("cookie") + nodeCookie.appendChild(XMLDocument.createTextNode(this.cookie)) + XMLDocument.documentElement.appendChild(nodeCookie) + + return XMLDocument +} + +/* Obsolète +Client.prototype.getXMLloginCaptcha = function(captchaCrypt, captchaInput) +{ + var XMLDocument = this.util.creerDocumentXMLAction() + XMLDocument.documentElement.setAttribute("name", "loginCaptcha") + + var nodecaptchaCrypt = XMLDocument.createElement("captchaCrypt") + nodecaptchaCrypt.appendChild(XMLDocument.createTextNode(captchaCrypt)) + XMLDocument.documentElement.appendChild(nodecaptchaCrypt) + + var nodecaptchaInput = XMLDocument.createElement("captchaInput") + nodecaptchaInput.appendChild(XMLDocument.createTextNode(captchaInput)) + XMLDocument.documentElement.appendChild(nodecaptchaInput) + + return XMLDocument +}*/ + +/* Obsolète +Client.prototype.getXMLgenerationCaptcha = function() +{ + var XMLDocument = this.util.creerDocumentXMLAction() + XMLDocument.documentElement.setAttribute("name", "generationCaptcha") + + return XMLDocument +}*/ + +Client.prototype.getXMLEnregistrement = function(login, password) +{ + var XMLDocument = this.util.creerDocumentXMLAction() + XMLDocument.documentElement.setAttribute("name", "register") + + var nodeLogin = XMLDocument.createElement("login") + nodeLogin.appendChild(XMLDocument.createTextNode(login)) + XMLDocument.documentElement.appendChild(nodeLogin) + + var nodePassword = XMLDocument.createElement("password") + nodePassword.appendChild(XMLDocument.createTextNode(password)) + XMLDocument.documentElement.appendChild(nodePassword) + + return XMLDocument +} + +Client.prototype.getXMLProfile = function() +{ + var XMLDocument = this.util.creerDocumentXMLAction() + XMLDocument.documentElement.setAttribute("name", "profile") + + var nodeCookie = XMLDocument.createElement("cookie") + nodeCookie.appendChild(XMLDocument.createTextNode(this.cookie)) + XMLDocument.documentElement.appendChild(nodeCookie) + + var nodeLogin = XMLDocument.createElement("login") + nodeLogin.appendChild(XMLDocument.createTextNode(this.login)) + XMLDocument.documentElement.appendChild(nodeLogin) + + var nodePassword = XMLDocument.createElement("password") + nodePassword.appendChild(XMLDocument.createTextNode(this.password)) + XMLDocument.documentElement.appendChild(nodePassword) + + var nodePseudo = XMLDocument.createElement("pseudo") + nodePseudo.appendChild(XMLDocument.createTextNode(this.pseudo)) + XMLDocument.documentElement.appendChild(nodePseudo) + + var nodeEmail = XMLDocument.createElement("email") + nodeEmail.appendChild(XMLDocument.createTextNode(this.email)) + XMLDocument.documentElement.appendChild(nodeEmail) + + var nodeCSS = XMLDocument.createElement("css") + nodeCSS.appendChild(XMLDocument.createTextNode(this.css)) + XMLDocument.documentElement.appendChild(nodeCSS) + + return XMLDocument +} + +/** + * Renvoie null si pas définit. + */ +Client.prototype.getCookie = function() +{ + var cookie = this.regexCookie.exec(document.cookie) + if (cookie == null) this.cookie = null + else this.cookie = cookie[1] +} + +Client.prototype.delCookie = function() +{ + document.cookie = "cookie=; max-age=0" +} + +Client.prototype.setCookie = function(cookie) +{ + if (this.cookie == null) + return + + document.cookie = + "cookie="+this.cookie+ + "; max-age=" + (60 * 60 * 24 * 365) +} + +Client.prototype.identifie = function() +{ + return this.statut == statutType.enregistre || this.statut == statutType.identifie +} + +Client.prototype.setStatut = function(statut) +{ + if(typeof(statut) == "string") + { + statut = + statut == "enregistre" ? + statutType.enregistre : (statut == "identifie" ? statutType.identifie : statutType.non_identifie) + } + + if (statut == this.statut) return + + this.statut = statut + this.majMenu() +} + +/** + * Demande la génération d'un captcha au serveur et l'affiche. + */ + /* Obsolète +Client.prototype.afficherCaptcha = function(query) +{ + var thisClient = this + + $.post("request", this.util.xmlVersAction(this.getXMLgenerationCaptcha()), + function(data, textStatus) + { + var chemin = jQuery("chemin", data.documentElement).text() + thisClient.captchaCrypt = jQuery("captchaCrypt", data.documentElement).text() + jQuery(query).prepend( + "

Es-tu un bot ? " + + "

" + ) + } + ) +} + +Client.prototype.cacherCaptcha = function() +{ + jQuery("#captcha").remove() +}*/ + +/** + * Effectue la connexion vers le serveur. + * Cette fonction est bloquante tant que la connexion n'a pas été établie. + * S'il existe un cookie en local on s'authentifie directement avec lui. + * Si il n'est pas possible de s'authentifier alors on affiche un captcha anti-bot. + */ +Client.prototype.connexionCookie = function() +{ + this.getCookie() + if (this.cookie == null) return false; + return this.connexion(this.util.xmlVersAction(this.getXMLloginCookie())) +} + +Client.prototype.connexionLogin = function(login, password) +{ + return this.connexion(this.util.xmlVersAction(this.getXMLlogin(login, password))) +} + +/* Obsolète +Client.prototype.connexionCaptcha = function() +{ + return this.connexion(this.util.xmlVersAction(this.getXMLloginCaptcha(this.captchaCrypt, jQuery("#captcha input").val()))) +}*/ + +Client.prototype.enregistrement = function(login, password) +{ + if (this.identifie()) + { + this.login = login + this.password = password + if(this.flush()) + this.setStatut(statutType.enregistre) + return true + } + else + { + if (login == undefined) login = "" + if (password == undefined) password = "" + return this.connexion(this.util.xmlVersAction(this.getXMLEnregistrement(login, password))) + } +} + +Client.prototype.connexion = function(action) +{ + thisClient = this + jQuery.ajax( + { + async: false, + type: "POST", + url: "request", + dataType: "xml", + data: action, + success: + function(data) + { + thisClient.chargerDonnees(data) + } + } + ) + return this.identifie() +} + +Client.prototype.deconnexion = function() +{ + this.setStatut(statutType.non_identifie) // deconnexion + this.resetDonneesPersonnelles() + this.delCookie () +} + +Client.prototype.chargerDonnees = function(data) +{ + this.setStatut(jQuery("statut", data.documentElement).text()) + + if (this.identifie()) + { + this.cookie = jQuery("cookie", data.documentElement).text() + this.setCookie() + + this.login = jQuery("login", data.documentElement).text() + this.pseudo = jQuery("pseudo", data.documentElement).text() + this.email = jQuery("email", data.documentElement).text() + this.css = jQuery("css", data.documentElement).text() + // met à jour la css + if (this.css != "") + { + jQuery("link#cssPrincipale").attr("href", this.css) + this.majMenu() + } + } + this.dernierMessageErreur = jQuery("information", data.documentElement).text() +} + +/** + * Met à jour les données personne sur serveur. + */ +Client.prototype.flush = function() +{ + thisClient = this + //thisClient.util.log(this.util.xmlVersAction(this.getXMLProfile()).action) + jQuery.ajax( + { + async: true, + type: "POST", + url: "request", + dataType: "xml", + data: this.util.xmlVersAction(this.getXMLProfile()), + success: + function(data) + { + //thisClient.util.log(thisClient.util.serializer.serializeToString(data)) + } + } + ) + // TODO : retourner false si un problème est survenu lors de l'update du profile + return true +} + +Client.prototype.majMenu = function() +{ + var displayType = this.css == "css/3/euphorik.css" ? "block" : "inline" //this.client + + // met à jour le menu + if (this.statut == statutType.enregistre) + { + jQuery("#menu .profile").css("display", displayType).text("profile") + jQuery("#menu .logout").css("display", displayType) + jQuery("#menu .register").css("display", "none") + } + else if (this.statut == statutType.identifie) + { + jQuery("#menu .profile").css("display", "none") + jQuery("#menu .logout").css("display", displayType) + jQuery("#menu .register").css("display", displayType) + } + else + { + jQuery("#menu .profile").css("display", displayType).text("login") + jQuery("#menu .logout").css("display", "none") + jQuery("#menu .register").css("display", displayType) + } +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// + +jQuery.noConflict() + + +// le main +jQuery(document).ready( + function() + { + + var util = new Util() + var client = new Client(util) + var pages = new Pages() + var formateur = new Formateur() + + // connexion vers le serveur (utilise un cookie qui traine) + client.connexionCookie() + + // les styles css + for (var i = 1; i <= 3; i++) + { + jQuery("#css"+i).click(function(){ + client.setCss("css/" + jQuery(this).attr("id").charAt(3) + "/euphorik.css") + }) + } + + jQuery("#menu .minichat").click(function(){ pages.afficherPage("minichat") }) + jQuery("#menu .profile").click(function(){ pages.afficherPage("profile") }) + jQuery("#menu .logout").click(function(){ + util.messageDialogue("Êtes-vous sur de vouloir vous délogger ?", messageType.question, + {"Oui" : function() + { + client.deconnexion(); + pages.afficherPage("minichat", true) + }, + "Non" : function(){} + } + ) + }) + jQuery("#menu .register").click(function(){ pages.afficherPage("register") }) + + pages.ajouterPage(new PageMinichat(client, formateur, util)) + pages.ajouterPage(new PageProfile(client, formateur, util)) + pages.ajouterPage(new PageRegister(client, formateur, util)) + pages.afficherPage("minichat") + } +) + diff --git a/js/jquery.js b/js/jquery.js new file mode 100755 index 0000000..d646859 --- /dev/null +++ b/js/jquery.js @@ -0,0 +1,11 @@ +/* + * jQuery 1.2.1 - New Wave Javascript + * + * Copyright (c) 2007 John Resig (jquery.com) + * Dual licensed under the MIT (MIT-LICENSE.txt) + * and GPL (GPL-LICENSE.txt) licenses. + * + * $Date: 2007-09-16 23:42:06 -0400 (Sun, 16 Sep 2007) $ + * $Rev: 3353 $ + */ +eval(function(p,a,c,k,e,r){e=function(c){return(c35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(G(){9(1m E!="W")H w=E;H E=18.15=G(a,b){I 6 7u E?6.5N(a,b):1u E(a,b)};9(1m $!="W")H D=$;18.$=E;H u=/^[^<]*(<(.|\\s)+>)[^>]*$|^#(\\w+)$/;E.1b=E.3A={5N:G(c,a){c=c||U;9(1m c=="1M"){H m=u.2S(c);9(m&&(m[1]||!a)){9(m[1])c=E.4D([m[1]],a);J{H b=U.3S(m[3]);9(b)9(b.22!=m[3])I E().1Y(c);J{6[0]=b;6.K=1;I 6}J c=[]}}J I 1u E(a).1Y(c)}J 9(E.1n(c))I 1u E(U)[E.1b.2d?"2d":"39"](c);I 6.6v(c.1c==1B&&c||(c.4c||c.K&&c!=18&&!c.1y&&c[0]!=W&&c[0].1y)&&E.2h(c)||[c])},4c:"1.2.1",7Y:G(){I 6.K},K:0,21:G(a){I a==W?E.2h(6):6[a]},2o:G(a){H b=E(a);b.4Y=6;I b},6v:G(a){6.K=0;1B.3A.1a.16(6,a);I 6},N:G(a,b){I E.N(6,a,b)},4I:G(a){H b=-1;6.N(G(i){9(6==a)b=i});I b},1x:G(f,d,e){H c=f;9(f.1c==3X)9(d==W)I 6.K&&E[e||"1x"](6[0],f)||W;J{c={};c[f]=d}I 6.N(G(a){L(H b 1i c)E.1x(e?6.R:6,b,E.1e(6,c[b],e,a,b))})},17:G(b,a){I 6.1x(b,a,"3C")},2g:G(e){9(1m e!="5i"&&e!=S)I 6.4n().3g(U.6F(e));H t="";E.N(e||6,G(){E.N(6.3j,G(){9(6.1y!=8)t+=6.1y!=1?6.6x:E.1b.2g([6])})});I t},5m:G(b){9(6[0])E(b,6[0].3H).6u().3d(6[0]).1X(G(){H a=6;1W(a.1w)a=a.1w;I a}).3g(6);I 6},8m:G(a){I 6.N(G(){E(6).6q().5m(a)})},8d:G(a){I 6.N(G(){E(6).5m(a)})},3g:G(){I 6.3z(1q,Q,1,G(a){6.58(a)})},6j:G(){I 6.3z(1q,Q,-1,G(a){6.3d(a,6.1w)})},6g:G(){I 6.3z(1q,P,1,G(a){6.12.3d(a,6)})},50:G(){I 6.3z(1q,P,-1,G(a){6.12.3d(a,6.2q)})},2D:G(){I 6.4Y||E([])},1Y:G(t){H b=E.1X(6,G(a){I E.1Y(t,a)});I 6.2o(/[^+>] [^+>]/.14(t)||t.1g("..")>-1?E.4V(b):b)},6u:G(e){H f=6.1X(G(){I 6.67?E(6.67)[0]:6.4R(Q)});H d=f.1Y("*").4O().N(G(){9(6[F]!=W)6[F]=S});9(e===Q)6.1Y("*").4O().N(G(i){H c=E.M(6,"2P");L(H a 1i c)L(H b 1i c[a])E.1j.1f(d[i],a,c[a][b],c[a][b].M)});I f},1E:G(t){I 6.2o(E.1n(t)&&E.2W(6,G(b,a){I t.16(b,[a])})||E.3m(t,6))},5V:G(t){I 6.2o(t.1c==3X&&E.3m(t,6,Q)||E.2W(6,G(a){I(t.1c==1B||t.4c)?E.2A(a,t)<0:a!=t}))},1f:G(t){I 6.2o(E.1R(6.21(),t.1c==3X?E(t).21():t.K!=W&&(!t.11||E.11(t,"2Y"))?t:[t]))},3t:G(a){I a?E.3m(a,6).K>0:P},7c:G(a){I 6.3t("."+a)},3i:G(b){9(b==W){9(6.K){H c=6[0];9(E.11(c,"24")){H e=c.4Z,a=[],Y=c.Y,2G=c.O=="24-2G";9(e<0)I S;L(H i=2G?e:0,33=2G?e+1:Y.K;i<33;i++){H d=Y[i];9(d.26){H b=E.V.1h&&!d.9V["1Q"].9L?d.2g:d.1Q;9(2G)I b;a.1a(b)}}I a}J I 6[0].1Q.1p(/\\r/g,"")}}J I 6.N(G(){9(b.1c==1B&&/4k|5j/.14(6.O))6.2Q=(E.2A(6.1Q,b)>=0||E.2A(6.2H,b)>=0);J 9(E.11(6,"24")){H a=b.1c==1B?b:[b];E("9h",6).N(G(){6.26=(E.2A(6.1Q,a)>=0||E.2A(6.2g,a)>=0)});9(!a.K)6.4Z=-1}J 6.1Q=b})},4o:G(a){I a==W?(6.K?6[0].3O:S):6.4n().3g(a)},6H:G(a){I 6.50(a).28()},6E:G(i){I 6.2J(i,i+1)},2J:G(){I 6.2o(1B.3A.2J.16(6,1q))},1X:G(b){I 6.2o(E.1X(6,G(a,i){I b.2O(a,i,a)}))},4O:G(){I 6.1f(6.4Y)},3z:G(f,d,g,e){H c=6.K>1,a;I 6.N(G(){9(!a){a=E.4D(f,6.3H);9(g<0)a.8U()}H b=6;9(d&&E.11(6,"1I")&&E.11(a[0],"4m"))b=6.4l("1K")[0]||6.58(U.5B("1K"));E.N(a,G(){H a=c?6.4R(Q):6;9(!5A(0,a))e.2O(b,a)})})}};G 5A(i,b){H a=E.11(b,"1J");9(a){9(b.3k)E.3G({1d:b.3k,3e:P,1V:"1J"});J E.5f(b.2g||b.6s||b.3O||"");9(b.12)b.12.3b(b)}J 9(b.1y==1)E("1J",b).N(5A);I a}E.1k=E.1b.1k=G(){H c=1q[0]||{},a=1,2c=1q.K,5e=P;9(c.1c==8o){5e=c;c=1q[1]||{}}9(2c==1){c=6;a=0}H b;L(;a<2c;a++)9((b=1q[a])!=S)L(H i 1i b){9(c==b[i])6r;9(5e&&1m b[i]==\'5i\'&&c[i])E.1k(c[i],b[i]);J 9(b[i]!=W)c[i]=b[i]}I c};H F="15"+(1u 3D()).3B(),6p=0,5c={};E.1k({8a:G(a){18.$=D;9(a)18.15=w;I E},1n:G(a){I!!a&&1m a!="1M"&&!a.11&&a.1c!=1B&&/G/i.14(a+"")},4a:G(a){I a.2V&&!a.1G||a.37&&a.3H&&!a.3H.1G},5f:G(a){a=E.36(a);9(a){9(18.6l)18.6l(a);J 9(E.V.1N)18.56(a,0);J 3w.2O(18,a)}},11:G(b,a){I b.11&&b.11.27()==a.27()},1L:{},M:G(c,d,b){c=c==18?5c:c;H a=c[F];9(!a)a=c[F]=++6p;9(d&&!E.1L[a])E.1L[a]={};9(b!=W)E.1L[a][d]=b;I d?E.1L[a][d]:a},30:G(c,b){c=c==18?5c:c;H a=c[F];9(b){9(E.1L[a]){2E E.1L[a][b];b="";L(b 1i E.1L[a])1T;9(!b)E.30(c)}}J{2a{2E c[F]}29(e){9(c.53)c.53(F)}2E E.1L[a]}},N:G(a,b,c){9(c){9(a.K==W)L(H i 1i a)b.16(a[i],c);J L(H i=0,48=a.K;i<48;i++)9(b.16(a[i],c)===P)1T}J{9(a.K==W)L(H i 1i a)b.2O(a[i],i,a[i]);J L(H i=0,48=a.K,3i=a[0];i<48&&b.2O(3i,i,3i)!==P;3i=a[++i]){}}I a},1e:G(c,b,d,e,a){9(E.1n(b))b=b.2O(c,[e]);H f=/z-?4I|7T-?7Q|1r|69|7P-?1H/i;I b&&b.1c==4W&&d=="3C"&&!f.14(a)?b+"2T":b},1o:{1f:G(b,c){E.N((c||"").2l(/\\s+/),G(i,a){9(!E.1o.3K(b.1o,a))b.1o+=(b.1o?" ":"")+a})},28:G(b,c){b.1o=c!=W?E.2W(b.1o.2l(/\\s+/),G(a){I!E.1o.3K(c,a)}).66(" "):""},3K:G(t,c){I E.2A(c,(t.1o||t).3s().2l(/\\s+/))>-1}},2k:G(e,o,f){L(H i 1i o){e.R["3r"+i]=e.R[i];e.R[i]=o[i]}f.16(e,[]);L(H i 1i o)e.R[i]=e.R["3r"+i]},17:G(e,p){9(p=="1H"||p=="2N"){H b={},42,41,d=["7J","7I","7G","7F"];E.N(d,G(){b["7C"+6]=0;b["7B"+6+"5Z"]=0});E.2k(e,b,G(){9(E(e).3t(\':3R\')){42=e.7A;41=e.7w}J{e=E(e.4R(Q)).1Y(":4k").5W("2Q").2D().17({4C:"1P",2X:"4F",19:"2Z",7o:"0",1S:"0"}).5R(e.12)[0];H a=E.17(e.12,"2X")||"3V";9(a=="3V")e.12.R.2X="7g";42=e.7e;41=e.7b;9(a=="3V")e.12.R.2X="3V";e.12.3b(e)}});I p=="1H"?42:41}I E.3C(e,p)},3C:G(h,j,i){H g,2w=[],2k=[];G 3n(a){9(!E.V.1N)I P;H b=U.3o.3Z(a,S);I!b||b.4y("3n")==""}9(j=="1r"&&E.V.1h){g=E.1x(h.R,"1r");I g==""?"1":g}9(j.1t(/4u/i))j=y;9(!i&&h.R[j])g=h.R[j];J 9(U.3o&&U.3o.3Z){9(j.1t(/4u/i))j="4u";j=j.1p(/([A-Z])/g,"-$1").2p();H d=U.3o.3Z(h,S);9(d&&!3n(h))g=d.4y(j);J{L(H a=h;a&&3n(a);a=a.12)2w.4w(a);L(a=0;a<2w.K;a++)9(3n(2w[a])){2k[a]=2w[a].R.19;2w[a].R.19="2Z"}g=j=="19"&&2k[2w.K-1]!=S?"2s":U.3o.3Z(h,S).4y(j)||"";L(a=0;a<2k.K;a++)9(2k[a]!=S)2w[a].R.19=2k[a]}9(j=="1r"&&g=="")g="1"}J 9(h.3Q){H f=j.1p(/\\-(\\w)/g,G(m,c){I c.27()});g=h.3Q[j]||h.3Q[f];9(!/^\\d+(2T)?$/i.14(g)&&/^\\d/.14(g)){H k=h.R.1S;H e=h.4v.1S;h.4v.1S=h.3Q.1S;h.R.1S=g||0;g=h.R.71+"2T";h.R.1S=k;h.4v.1S=e}}I g},4D:G(a,e){H r=[];e=e||U;E.N(a,G(i,d){9(!d)I;9(d.1c==4W)d=d.3s();9(1m d=="1M"){d=d.1p(/(<(\\w+)[^>]*?)\\/>/g,G(m,a,b){I b.1t(/^(70|6Z|6Y|9Q|4t|9N|9K|3a|9G|9E)$/i)?m:a+">"});H s=E.36(d).2p(),1s=e.5B("1s"),2x=[];H c=!s.1g("<9y")&&[1,"<24>",""]||!s.1g("<9w")&&[1,"<6T>",""]||s.1t(/^<(9u|1K|9t|9r|9p)/)&&[1,"<1I>",""]||!s.1g("<4m")&&[2,"<1I><1K>",""]||(!s.1g("<9m")||!s.1g("<9k"))&&[3,"<1I><1K><4m>",""]||!s.1g("<6Y")&&[2,"<1I><1K><6L>",""]||E.V.1h&&[1,"1s<1s>",""]||[0,"",""];1s.3O=c[1]+d+c[2];1W(c[0]--)1s=1s.5p;9(E.V.1h){9(!s.1g("<1I")&&s.1g("<1K")<0)2x=1s.1w&&1s.1w.3j;J 9(c[1]=="<1I>"&&s.1g("<1K")<0)2x=1s.3j;L(H n=2x.K-1;n>=0;--n)9(E.11(2x[n],"1K")&&!2x[n].3j.K)2x[n].12.3b(2x[n]);9(/^\\s/.14(d))1s.3d(e.6F(d.1t(/^\\s*/)[0]),1s.1w)}d=E.2h(1s.3j)}9(0===d.K&&(!E.11(d,"2Y")&&!E.11(d,"24")))I;9(d[0]==W||E.11(d,"2Y")||d.Y)r.1a(d);J r=E.1R(r,d)});I r},1x:G(c,d,a){H e=E.4a(c)?{}:E.5o;9(d=="26"&&E.V.1N)c.12.4Z;9(e[d]){9(a!=W)c[e[d]]=a;I c[e[d]]}J 9(E.V.1h&&d=="R")I E.1x(c.R,"9e",a);J 9(a==W&&E.V.1h&&E.11(c,"2Y")&&(d=="9d"||d=="9a"))I c.97(d).6x;J 9(c.37){9(a!=W){9(d=="O"&&E.11(c,"4t")&&c.12)6G"O 94 93\'t 92 91";c.90(d,a)}9(E.V.1h&&/6C|3k/.14(d)&&!E.4a(c))I c.4p(d,2);I c.4p(d)}J{9(d=="1r"&&E.V.1h){9(a!=W){c.69=1;c.1E=(c.1E||"").1p(/6O\\([^)]*\\)/,"")+(3I(a).3s()=="8S"?"":"6O(1r="+a*6A+")")}I c.1E?(3I(c.1E.1t(/1r=([^)]*)/)[1])/6A).3s():""}d=d.1p(/-([a-z])/8Q,G(z,b){I b.27()});9(a!=W)c[d]=a;I c[d]}},36:G(t){I(t||"").1p(/^\\s+|\\s+$/g,"")},2h:G(a){H r=[];9(1m a!="8P")L(H i=0,2c=a.K;i<2c;i++)r.1a(a[i]);J r=a.2J(0);I r},2A:G(b,a){L(H i=0,2c=a.K;i<2c;i++)9(a[i]==b)I i;I-1},1R:G(a,b){9(E.V.1h){L(H i=0;b[i];i++)9(b[i].1y!=8)a.1a(b[i])}J L(H i=0;b[i];i++)a.1a(b[i]);I a},4V:G(b){H r=[],2f={};2a{L(H i=0,6y=b.K;i<6y;i++){H a=E.M(b[i]);9(!2f[a]){2f[a]=Q;r.1a(b[i])}}}29(e){r=b}I r},2W:G(b,a,c){9(1m a=="1M")a=3w("P||G(a,i){I "+a+"}");H d=[];L(H i=0,4g=b.K;i<4g;i++)9(!c&&a(b[i],i)||c&&!a(b[i],i))d.1a(b[i]);I d},1X:G(c,b){9(1m b=="1M")b=3w("P||G(a){I "+b+"}");H d=[];L(H i=0,4g=c.K;i<4g;i++){H a=b(c[i],i);9(a!==S&&a!=W){9(a.1c!=1B)a=[a];d=d.8M(a)}}I d}});H v=8K.8I.2p();E.V={4s:(v.1t(/.+(?:8F|8E|8C|8B)[\\/: ]([\\d.]+)/)||[])[1],1N:/6w/.14(v),34:/34/.14(v),1h:/1h/.14(v)&&!/34/.14(v),35:/35/.14(v)&&!/(8z|6w)/.14(v)};H y=E.V.1h?"4h":"5h";E.1k({5g:!E.V.1h||U.8y=="8x",4h:E.V.1h?"4h":"5h",5o:{"L":"8w","8v":"1o","4u":y,5h:y,4h:y,3O:"3O",1o:"1o",1Q:"1Q",3c:"3c",2Q:"2Q",8u:"8t",26:"26",8s:"8r"}});E.N({1D:"a.12",8q:"15.4e(a,\'12\')",8p:"15.2I(a,2,\'2q\')",8n:"15.2I(a,2,\'4d\')",8l:"15.4e(a,\'2q\')",8k:"15.4e(a,\'4d\')",8j:"15.5d(a.12.1w,a)",8i:"15.5d(a.1w)",6q:"15.11(a,\'8h\')?a.8f||a.8e.U:15.2h(a.3j)"},G(i,n){E.1b[i]=G(a){H b=E.1X(6,n);9(a&&1m a=="1M")b=E.3m(a,b);I 6.2o(E.4V(b))}});E.N({5R:"3g",8c:"6j",3d:"6g",8b:"50",89:"6H"},G(i,n){E.1b[i]=G(){H a=1q;I 6.N(G(){L(H j=0,2c=a.K;j<2c;j++)E(a[j])[n](6)})}});E.N({5W:G(a){E.1x(6,a,"");6.53(a)},88:G(c){E.1o.1f(6,c)},87:G(c){E.1o.28(6,c)},86:G(c){E.1o[E.1o.3K(6,c)?"28":"1f"](6,c)},28:G(a){9(!a||E.1E(a,[6]).r.K){E.30(6);6.12.3b(6)}},4n:G(){E("*",6).N(G(){E.30(6)});1W(6.1w)6.3b(6.1w)}},G(i,n){E.1b[i]=G(){I 6.N(n,1q)}});E.N(["85","5Z"],G(i,a){H n=a.2p();E.1b[n]=G(h){I 6[0]==18?E.V.1N&&3y["84"+a]||E.5g&&38.33(U.2V["5a"+a],U.1G["5a"+a])||U.1G["5a"+a]:6[0]==U?38.33(U.1G["6n"+a],U.1G["6m"+a]):h==W?(6.K?E.17(6[0],n):S):6.17(n,h.1c==3X?h:h+"2T")}});H C=E.V.1N&&3x(E.V.4s)<83?"(?:[\\\\w*57-]|\\\\\\\\.)":"(?:[\\\\w\\82-\\81*57-]|\\\\\\\\.)",6k=1u 47("^>\\\\s*("+C+"+)"),6i=1u 47("^("+C+"+)(#)("+C+"+)"),6h=1u 47("^([#.]?)("+C+"*)");E.1k({55:{"":"m[2]==\'*\'||15.11(a,m[2])","#":"a.4p(\'22\')==m[2]",":":{80:"im[3]-0",2I:"m[3]-0==i",6E:"m[3]-0==i",3v:"i==0",3u:"i==r.K-1",6f:"i%2==0",6e:"i%2","3v-46":"a.12.4l(\'*\')[0]==a","3u-46":"15.2I(a.12.5p,1,\'4d\')==a","7X-46":"!15.2I(a.12.5p,2,\'4d\')",1D:"a.1w",4n:"!a.1w",7W:"(a.6s||a.7V||15(a).2g()||\'\').1g(m[3])>=0",3R:\'"1P"!=a.O&&15.17(a,"19")!="2s"&&15.17(a,"4C")!="1P"\',1P:\'"1P"==a.O||15.17(a,"19")=="2s"||15.17(a,"4C")=="1P"\',7U:"!a.3c",3c:"a.3c",2Q:"a.2Q",26:"a.26||15.1x(a,\'26\')",2g:"\'2g\'==a.O",4k:"\'4k\'==a.O",5j:"\'5j\'==a.O",54:"\'54\'==a.O",52:"\'52\'==a.O",51:"\'51\'==a.O",6d:"\'6d\'==a.O",6c:"\'6c\'==a.O",2r:\'"2r"==a.O||15.11(a,"2r")\',4t:"/4t|24|6b|2r/i.14(a.11)",3K:"15.1Y(m[3],a).K",7S:"/h\\\\d/i.14(a.11)",7R:"15.2W(15.32,G(1b){I a==1b.T;}).K"}},6a:[/^(\\[) *@?([\\w-]+) *([!*$^~=]*) *(\'?"?)(.*?)\\4 *\\]/,/^(:)([\\w-]+)\\("?\'?(.*?(\\(.*?\\))?[^(]*?)"?\'?\\)/,1u 47("^([:.#]*)("+C+"+)")],3m:G(a,c,b){H d,2b=[];1W(a&&a!=d){d=a;H f=E.1E(a,c,b);a=f.t.1p(/^\\s*,\\s*/,"");2b=b?c=f.r:E.1R(2b,f.r)}I 2b},1Y:G(t,o){9(1m t!="1M")I[t];9(o&&!o.1y)o=S;o=o||U;H d=[o],2f=[],3u;1W(t&&3u!=t){H r=[];3u=t;t=E.36(t);H l=P;H g=6k;H m=g.2S(t);9(m){H p=m[1].27();L(H i=0;d[i];i++)L(H c=d[i].1w;c;c=c.2q)9(c.1y==1&&(p=="*"||c.11.27()==p.27()))r.1a(c);d=r;t=t.1p(g,"");9(t.1g(" ")==0)6r;l=Q}J{g=/^([>+~])\\s*(\\w*)/i;9((m=g.2S(t))!=S){r=[];H p=m[2],1R={};m=m[1];L(H j=0,31=d.K;j<31;j++){H n=m=="~"||m=="+"?d[j].2q:d[j].1w;L(;n;n=n.2q)9(n.1y==1){H h=E.M(n);9(m=="~"&&1R[h])1T;9(!p||n.11.27()==p.27()){9(m=="~")1R[h]=Q;r.1a(n)}9(m=="+")1T}}d=r;t=E.36(t.1p(g,""));l=Q}}9(t&&!l){9(!t.1g(",")){9(o==d[0])d.44();2f=E.1R(2f,d);r=d=[o];t=" "+t.68(1,t.K)}J{H k=6i;H m=k.2S(t);9(m){m=[0,m[2],m[3],m[1]]}J{k=6h;m=k.2S(t)}m[2]=m[2].1p(/\\\\/g,"");H f=d[d.K-1];9(m[1]=="#"&&f&&f.3S&&!E.4a(f)){H q=f.3S(m[2]);9((E.V.1h||E.V.34)&&q&&1m q.22=="1M"&&q.22!=m[2])q=E(\'[@22="\'+m[2]+\'"]\',f)[0];d=r=q&&(!m[3]||E.11(q,m[3]))?[q]:[]}J{L(H i=0;d[i];i++){H a=m[1]=="#"&&m[3]?m[3]:m[1]!=""||m[0]==""?"*":m[2];9(a=="*"&&d[i].11.2p()=="5i")a="3a";r=E.1R(r,d[i].4l(a))}9(m[1]==".")r=E.4X(r,m[2]);9(m[1]=="#"){H e=[];L(H i=0;r[i];i++)9(r[i].4p("22")==m[2]){e=[r[i]];1T}r=e}d=r}t=t.1p(k,"")}}9(t){H b=E.1E(t,r);d=r=b.r;t=E.36(b.t)}}9(t)d=[];9(d&&o==d[0])d.44();2f=E.1R(2f,d);I 2f},4X:G(r,m,a){m=" "+m+" ";H c=[];L(H i=0;r[i];i++){H b=(" "+r[i].1o+" ").1g(m)>=0;9(!a&&b||a&&!b)c.1a(r[i])}I c},1E:G(t,r,h){H d;1W(t&&t!=d){d=t;H p=E.6a,m;L(H i=0;p[i];i++){m=p[i].2S(t);9(m){t=t.7O(m[0].K);m[2]=m[2].1p(/\\\\/g,"");1T}}9(!m)1T;9(m[1]==":"&&m[2]=="5V")r=E.1E(m[3],r,Q).r;J 9(m[1]==".")r=E.4X(r,m[2],h);J 9(m[1]=="["){H g=[],O=m[3];L(H i=0,31=r.K;i<31;i++){H a=r[i],z=a[E.5o[m[2]]||m[2]];9(z==S||/6C|3k|26/.14(m[2]))z=E.1x(a,m[2])||\'\';9((O==""&&!!z||O=="="&&z==m[5]||O=="!="&&z!=m[5]||O=="^="&&z&&!z.1g(m[5])||O=="$="&&z.68(z.K-m[5].K)==m[5]||(O=="*="||O=="~=")&&z.1g(m[5])>=0)^h)g.1a(a)}r=g}J 9(m[1]==":"&&m[2]=="2I-46"){H e={},g=[],14=/(\\d*)n\\+?(\\d*)/.2S(m[3]=="6f"&&"2n"||m[3]=="6e"&&"2n+1"||!/\\D/.14(m[3])&&"n+"+m[3]||m[3]),3v=(14[1]||1)-0,d=14[2]-0;L(H i=0,31=r.K;i<31;i++){H j=r[i],12=j.12,22=E.M(12);9(!e[22]){H c=1;L(H n=12.1w;n;n=n.2q)9(n.1y==1)n.4U=c++;e[22]=Q}H b=P;9(3v==1){9(d==0||j.4U==d)b=Q}J 9((j.4U+d)%3v==0)b=Q;9(b^h)g.1a(j)}r=g}J{H f=E.55[m[1]];9(1m f!="1M")f=E.55[m[1]][m[2]];f=3w("P||G(a,i){I "+f+"}");r=E.2W(r,f,h)}}I{r:r,t:t}},4e:G(b,c){H d=[];H a=b[c];1W(a&&a!=U){9(a.1y==1)d.1a(a);a=a[c]}I d},2I:G(a,e,c,b){e=e||1;H d=0;L(;a;a=a[c])9(a.1y==1&&++d==e)1T;I a},5d:G(n,a){H r=[];L(;n;n=n.2q){9(n.1y==1&&(!a||n!=a))r.1a(n)}I r}});E.1j={1f:G(g,e,c,h){9(E.V.1h&&g.4j!=W)g=18;9(!c.2u)c.2u=6.2u++;9(h!=W){H d=c;c=G(){I d.16(6,1q)};c.M=h;c.2u=d.2u}H i=e.2l(".");e=i[0];c.O=i[1];H b=E.M(g,"2P")||E.M(g,"2P",{});H f=E.M(g,"2t",G(){H a;9(1m E=="W"||E.1j.4T)I a;a=E.1j.2t.16(g,1q);I a});H j=b[e];9(!j){j=b[e]={};9(g.4S)g.4S(e,f,P);J g.7N("43"+e,f)}j[c.2u]=c;6.1Z[e]=Q},2u:1,1Z:{},28:G(d,c,b){H e=E.M(d,"2P"),2L,4I;9(1m c=="1M"){H a=c.2l(".");c=a[0]}9(e){9(c&&c.O){b=c.4Q;c=c.O}9(!c){L(c 1i e)6.28(d,c)}J 9(e[c]){9(b)2E e[c][b.2u];J L(b 1i e[c])9(!a[1]||e[c][b].O==a[1])2E e[c][b];L(2L 1i e[c])1T;9(!2L){9(d.4P)d.4P(c,E.M(d,"2t"),P);J d.7M("43"+c,E.M(d,"2t"));2L=S;2E e[c]}}L(2L 1i e)1T;9(!2L){E.30(d,"2P");E.30(d,"2t")}}},1F:G(d,b,e,c,f){b=E.2h(b||[]);9(!e){9(6.1Z[d])E("*").1f([18,U]).1F(d,b)}J{H a,2L,1b=E.1n(e[d]||S),4N=!b[0]||!b[0].2M;9(4N)b.4w(6.4M({O:d,2m:e}));b[0].O=d;9(E.1n(E.M(e,"2t")))a=E.M(e,"2t").16(e,b);9(!1b&&e["43"+d]&&e["43"+d].16(e,b)===P)a=P;9(4N)b.44();9(f&&f.16(e,b)===P)a=P;9(1b&&c!==P&&a!==P&&!(E.11(e,\'a\')&&d=="4L")){6.4T=Q;e[d]()}6.4T=P}I a},2t:G(d){H a;d=E.1j.4M(d||18.1j||{});H b=d.O.2l(".");d.O=b[0];H c=E.M(6,"2P")&&E.M(6,"2P")[d.O],3q=1B.3A.2J.2O(1q,1);3q.4w(d);L(H j 1i c){3q[0].4Q=c[j];3q[0].M=c[j].M;9(!b[1]||c[j].O==b[1]){H e=c[j].16(6,3q);9(a!==P)a=e;9(e===P){d.2M();d.3p()}}}9(E.V.1h)d.2m=d.2M=d.3p=d.4Q=d.M=S;I a},4M:G(c){H a=c;c=E.1k({},a);c.2M=G(){9(a.2M)a.2M();a.7L=P};c.3p=G(){9(a.3p)a.3p();a.7K=Q};9(!c.2m&&c.65)c.2m=c.65;9(E.V.1N&&c.2m.1y==3)c.2m=a.2m.12;9(!c.4K&&c.4J)c.4K=c.4J==c.2m?c.7H:c.4J;9(c.64==S&&c.63!=S){H e=U.2V,b=U.1G;c.64=c.63+(e&&e.2R||b.2R||0);c.7E=c.7D+(e&&e.2B||b.2B||0)}9(!c.3Y&&(c.61||c.60))c.3Y=c.61||c.60;9(!c.5F&&c.5D)c.5F=c.5D;9(!c.3Y&&c.2r)c.3Y=(c.2r&1?1:(c.2r&2?3:(c.2r&4?2:0)));I c}};E.1b.1k({3W:G(c,a,b){I c=="5Y"?6.2G(c,a,b):6.N(G(){E.1j.1f(6,c,b||a,b&&a)})},2G:G(d,b,c){I 6.N(G(){E.1j.1f(6,d,G(a){E(6).5X(a);I(c||b).16(6,1q)},c&&b)})},5X:G(a,b){I 6.N(G(){E.1j.28(6,a,b)})},1F:G(c,a,b){I 6.N(G(){E.1j.1F(c,a,6,Q,b)})},7x:G(c,a,b){9(6[0])I E.1j.1F(c,a,6[0],P,b)},25:G(){H a=1q;I 6.4L(G(e){6.4H=0==6.4H?1:0;e.2M();I a[6.4H].16(6,[e])||P})},7v:G(f,g){G 4G(e){H p=e.4K;1W(p&&p!=6)2a{p=p.12}29(e){p=6};9(p==6)I P;I(e.O=="4x"?f:g).16(6,[e])}I 6.4x(4G).5U(4G)},2d:G(f){5T();9(E.3T)f.16(U,[E]);J E.3l.1a(G(){I f.16(6,[E])});I 6}});E.1k({3T:P,3l:[],2d:G(){9(!E.3T){E.3T=Q;9(E.3l){E.N(E.3l,G(){6.16(U)});E.3l=S}9(E.V.35||E.V.34)U.4P("5S",E.2d,P);9(!18.7t.K)E(18).39(G(){E("#4E").28()})}}});E.N(("7s,7r,39,7q,6n,5Y,4L,7p,"+"7n,7m,7l,4x,5U,7k,24,"+"51,7j,7i,7h,3U").2l(","),G(i,o){E.1b[o]=G(f){I f?6.3W(o,f):6.1F(o)}});H x=P;G 5T(){9(x)I;x=Q;9(E.V.35||E.V.34)U.4S("5S",E.2d,P);J 9(E.V.1h){U.7f("<7d"+"7y 22=4E 7z=Q "+"3k=//:><\\/1J>");H a=U.3S("4E");9(a)a.62=G(){9(6.2C!="1l")I;E.2d()};a=S}J 9(E.V.1N)E.4B=4j(G(){9(U.2C=="5Q"||U.2C=="1l"){4A(E.4B);E.4B=S;E.2d()}},10);E.1j.1f(18,"39",E.2d)}E.1b.1k({39:G(g,d,c){9(E.1n(g))I 6.3W("39",g);H e=g.1g(" ");9(e>=0){H i=g.2J(e,g.K);g=g.2J(0,e)}c=c||G(){};H f="4z";9(d)9(E.1n(d)){c=d;d=S}J{d=E.3a(d);f="5P"}H h=6;E.3G({1d:g,O:f,M:d,1l:G(a,b){9(b=="1C"||b=="5O")h.4o(i?E("<1s/>").3g(a.40.1p(/<1J(.|\\s)*?\\/1J>/g,"")).1Y(i):a.40);56(G(){h.N(c,[a.40,b,a])},13)}});I 6},7a:G(){I E.3a(6.5M())},5M:G(){I 6.1X(G(){I E.11(6,"2Y")?E.2h(6.79):6}).1E(G(){I 6.2H&&!6.3c&&(6.2Q||/24|6b/i.14(6.11)||/2g|1P|52/i.14(6.O))}).1X(G(i,c){H b=E(6).3i();I b==S?S:b.1c==1B?E.1X(b,G(a,i){I{2H:c.2H,1Q:a}}):{2H:c.2H,1Q:b}}).21()}});E.N("5L,5K,6t,5J,5I,5H".2l(","),G(i,o){E.1b[o]=G(f){I 6.3W(o,f)}});H B=(1u 3D).3B();E.1k({21:G(d,b,a,c){9(E.1n(b)){a=b;b=S}I E.3G({O:"4z",1d:d,M:b,1C:a,1V:c})},78:G(b,a){I E.21(b,S,a,"1J")},77:G(c,b,a){I E.21(c,b,a,"45")},76:G(d,b,a,c){9(E.1n(b)){a=b;b={}}I E.3G({O:"5P",1d:d,M:b,1C:a,1V:c})},75:G(a){E.1k(E.59,a)},59:{1Z:Q,O:"4z",2z:0,5G:"74/x-73-2Y-72",6o:Q,3e:Q,M:S},49:{},3G:G(s){H f,2y=/=(\\?|%3F)/g,1v,M;s=E.1k(Q,s,E.1k(Q,{},E.59,s));9(s.M&&s.6o&&1m s.M!="1M")s.M=E.3a(s.M);9(s.1V=="4b"){9(s.O.2p()=="21"){9(!s.1d.1t(2y))s.1d+=(s.1d.1t(/\\?/)?"&":"?")+(s.4b||"5E")+"=?"}J 9(!s.M||!s.M.1t(2y))s.M=(s.M?s.M+"&":"")+(s.4b||"5E")+"=?";s.1V="45"}9(s.1V=="45"&&(s.M&&s.M.1t(2y)||s.1d.1t(2y))){f="4b"+B++;9(s.M)s.M=s.M.1p(2y,"="+f);s.1d=s.1d.1p(2y,"="+f);s.1V="1J";18[f]=G(a){M=a;1C();1l();18[f]=W;2a{2E 18[f]}29(e){}}}9(s.1V=="1J"&&s.1L==S)s.1L=P;9(s.1L===P&&s.O.2p()=="21")s.1d+=(s.1d.1t(/\\?/)?"&":"?")+"57="+(1u 3D()).3B();9(s.M&&s.O.2p()=="21"){s.1d+=(s.1d.1t(/\\?/)?"&":"?")+s.M;s.M=S}9(s.1Z&&!E.5b++)E.1j.1F("5L");9(!s.1d.1g("8g")&&s.1V=="1J"){H h=U.4l("9U")[0];H g=U.5B("1J");g.3k=s.1d;9(!f&&(s.1C||s.1l)){H j=P;g.9R=g.62=G(){9(!j&&(!6.2C||6.2C=="5Q"||6.2C=="1l")){j=Q;1C();1l();h.3b(g)}}}h.58(g);I}H k=P;H i=18.6X?1u 6X("9P.9O"):1u 6W();i.9M(s.O,s.1d,s.3e);9(s.M)i.5C("9J-9I",s.5G);9(s.5y)i.5C("9H-5x-9F",E.49[s.1d]||"9D, 9C 9B 9A 5v:5v:5v 9z");i.5C("X-9x-9v","6W");9(s.6U)s.6U(i);9(s.1Z)E.1j.1F("5H",[i,s]);H c=G(a){9(!k&&i&&(i.2C==4||a=="2z")){k=Q;9(d){4A(d);d=S}1v=a=="2z"&&"2z"||!E.6S(i)&&"3U"||s.5y&&E.6R(i,s.1d)&&"5O"||"1C";9(1v=="1C"){2a{M=E.6Q(i,s.1V)}29(e){1v="5k"}}9(1v=="1C"){H b;2a{b=i.5s("6P-5x")}29(e){}9(s.5y&&b)E.49[s.1d]=b;9(!f)1C()}J E.5r(s,i,1v);1l();9(s.3e)i=S}};9(s.3e){H d=4j(c,13);9(s.2z>0)56(G(){9(i){i.9q();9(!k)c("2z")}},s.2z)}2a{i.9o(s.M)}29(e){E.5r(s,i,S,e)}9(!s.3e)c();I i;G 1C(){9(s.1C)s.1C(M,1v);9(s.1Z)E.1j.1F("5I",[i,s])}G 1l(){9(s.1l)s.1l(i,1v);9(s.1Z)E.1j.1F("6t",[i,s]);9(s.1Z&&!--E.5b)E.1j.1F("5K")}},5r:G(s,a,b,e){9(s.3U)s.3U(a,b,e);9(s.1Z)E.1j.1F("5J",[a,s,e])},5b:0,6S:G(r){2a{I!r.1v&&9n.9l=="54:"||(r.1v>=6N&&r.1v<9j)||r.1v==6M||E.V.1N&&r.1v==W}29(e){}I P},6R:G(a,c){2a{H b=a.5s("6P-5x");I a.1v==6M||b==E.49[c]||E.V.1N&&a.1v==W}29(e){}I P},6Q:G(r,b){H c=r.5s("9i-O");H d=b=="6K"||!b&&c&&c.1g("6K")>=0;H a=d?r.9g:r.40;9(d&&a.2V.37=="5k")6G"5k";9(b=="1J")E.5f(a);9(b=="45")a=3w("("+a+")");I a},3a:G(a){H s=[];9(a.1c==1B||a.4c)E.N(a,G(){s.1a(3f(6.2H)+"="+3f(6.1Q))});J L(H j 1i a)9(a[j]&&a[j].1c==1B)E.N(a[j],G(){s.1a(3f(j)+"="+3f(6))});J s.1a(3f(j)+"="+3f(a[j]));I s.66("&").1p(/%20/g,"+")}});E.1b.1k({1A:G(b,a){I b?6.1U({1H:"1A",2N:"1A",1r:"1A"},b,a):6.1E(":1P").N(G(){6.R.19=6.3h?6.3h:"";9(E.17(6,"19")=="2s")6.R.19="2Z"}).2D()},1z:G(b,a){I b?6.1U({1H:"1z",2N:"1z",1r:"1z"},b,a):6.1E(":3R").N(G(){6.3h=6.3h||E.17(6,"19");9(6.3h=="2s")6.3h="2Z";6.R.19="2s"}).2D()},6J:E.1b.25,25:G(a,b){I E.1n(a)&&E.1n(b)?6.6J(a,b):a?6.1U({1H:"25",2N:"25",1r:"25"},a,b):6.N(G(){E(6)[E(6).3t(":1P")?"1A":"1z"]()})},9c:G(b,a){I 6.1U({1H:"1A"},b,a)},9b:G(b,a){I 6.1U({1H:"1z"},b,a)},99:G(b,a){I 6.1U({1H:"25"},b,a)},98:G(b,a){I 6.1U({1r:"1A"},b,a)},96:G(b,a){I 6.1U({1r:"1z"},b,a)},95:G(c,a,b){I 6.1U({1r:a},c,b)},1U:G(k,i,h,g){H j=E.6D(i,h,g);I 6[j.3L===P?"N":"3L"](G(){j=E.1k({},j);H f=E(6).3t(":1P"),3y=6;L(H p 1i k){9(k[p]=="1z"&&f||k[p]=="1A"&&!f)I E.1n(j.1l)&&j.1l.16(6);9(p=="1H"||p=="2N"){j.19=E.17(6,"19");j.2U=6.R.2U}}9(j.2U!=S)6.R.2U="1P";j.3M=E.1k({},k);E.N(k,G(c,a){H e=1u E.2j(3y,j,c);9(/25|1A|1z/.14(a))e[a=="25"?f?"1A":"1z":a](k);J{H b=a.3s().1t(/^([+-]=)?([\\d+-.]+)(.*)$/),1O=e.2b(Q)||0;9(b){H d=3I(b[2]),2i=b[3]||"2T";9(2i!="2T"){3y.R[c]=(d||1)+2i;1O=((d||1)/e.2b(Q))*1O;3y.R[c]=1O+2i}9(b[1])d=((b[1]=="-="?-1:1)*d)+1O;e.3N(1O,d,2i)}J e.3N(1O,a,"")}});I Q})},3L:G(a,b){9(E.1n(a)){b=a;a="2j"}9(!a||(1m a=="1M"&&!b))I A(6[0],a);I 6.N(G(){9(b.1c==1B)A(6,a,b);J{A(6,a).1a(b);9(A(6,a).K==1)b.16(6)}})},9f:G(){H a=E.32;I 6.N(G(){L(H i=0;i-8O?r:3I(E.17(6.T,6.1e))||0},3N:G(c,b,e){6.5u=(1u 3D()).3B();6.1O=c;6.2D=b;6.2i=e||6.2i||"2T";6.2v=6.1O;6.4q=6.4i=0;6.4r();H f=6;G t(){I f.2F()}t.T=6.T;E.32.1a(t);9(E.32.K==1){H d=4j(G(){H a=E.32;L(H i=0;i6.Y.2e+6.5u){6.2v=6.2D;6.4q=6.4i=1;6.4r();6.Y.3M[6.1e]=Q;H a=Q;L(H i 1i 6.Y.3M)9(6.Y.3M[i]!==Q)a=P;9(a){9(6.Y.19!=S){6.T.R.2U=6.Y.2U;6.T.R.19=6.Y.19;9(E.17(6.T,"19")=="2s")6.T.R.19="2Z"}9(6.Y.1z)6.T.R.19="2s";9(6.Y.1z||6.Y.1A)L(H p 1i 6.Y.3M)E.1x(6.T.R,p,6.Y.3P[p])}9(a&&E.1n(6.Y.1l))6.Y.1l.16(6.T);I P}J{H n=t-6.5u;6.4i=n/6.Y.2e;6.4q=E.3J[6.Y.3J||(E.3J.5q?"5q":"6B")](6.4i,n,0,1,6.Y.2e);6.2v=6.1O+((6.2D-6.1O)*6.4q);6.4r()}I Q}};E.2j.2F={2R:G(a){a.T.2R=a.2v},2B:G(a){a.T.2B=a.2v},1r:G(a){E.1x(a.T.R,"1r",a.2v)},6z:G(a){a.T.R[a.1e]=a.2v+a.2i}};E.1b.6m=G(){H c=0,3E=0,T=6[0],5t;9(T)8L(E.V){H b=E.17(T,"2X")=="4F",1D=T.12,23=T.23,2K=T.3H,4f=1N&&3x(4s)<8J;9(T.6V){5w=T.6V();1f(5w.1S+38.33(2K.2V.2R,2K.1G.2R),5w.3E+38.33(2K.2V.2B,2K.1G.2B));9(1h){H d=E("4o").17("8H");d=(d=="8G"||E.5g&&3x(4s)>=7)&&2||d;1f(-d,-d)}}J{1f(T.5l,T.5z);1W(23){1f(23.5l,23.5z);9(35&&/^t[d|h]$/i.14(1D.37)||!4f)d(23);9(4f&&!b&&E.17(23,"2X")=="4F")b=Q;23=23.23}1W(1D.37&&!/^1G|4o$/i.14(1D.37)){9(!/^8D|1I-9S.*$/i.14(E.17(1D,"19")))1f(-1D.2R,-1D.2B);9(35&&E.17(1D,"2U")!="3R")d(1D);1D=1D.12}9(4f&&b)1f(-2K.1G.5l,-2K.1G.5z)}5t={3E:3E,1S:c}}I 5t;G d(a){1f(E.17(a,"9T"),E.17(a,"8A"))}G 1f(l,t){c+=3x(l)||0;3E+=3x(t)||0}}})();',62,616,'||||||this|||if|||||||||||||||||||||||||||||||||function|var|return|else|length|for|data|each|type|false|true|style|null|elem|document|browser|undefined||options|||nodeName|parentNode||test|jQuery|apply|css|window|display|push|fn|constructor|url|prop|add|indexOf|msie|in|event|extend|complete|typeof|isFunction|className|replace|arguments|opacity|div|match|new|status|firstChild|attr|nodeType|hide|show|Array|success|parent|filter|trigger|body|height|table|script|tbody|cache|string|safari|start|hidden|value|merge|left|break|animate|dataType|while|map|find|global||get|id|offsetParent|select|toggle|selected|toUpperCase|remove|catch|try|cur|al|ready|duration|done|text|makeArray|unit|fx|swap|split|target||pushStack|toLowerCase|nextSibling|button|none|handle|guid|now|stack|tb|jsre|timeout|inArray|scrollTop|readyState|end|delete|step|one|name|nth|slice|doc|ret|preventDefault|width|call|events|checked|scrollLeft|exec|px|overflow|documentElement|grep|position|form|block|removeData|rl|timers|max|opera|mozilla|trim|tagName|Math|load|param|removeChild|disabled|insertBefore|async|encodeURIComponent|append|oldblock|val|childNodes|src|readyList|multiFilter|color|defaultView|stopPropagation|args|old|toString|is|last|first|eval|parseInt|self|domManip|prototype|getTime|curCSS|Date|top||ajax|ownerDocument|parseFloat|easing|has|queue|curAnim|custom|innerHTML|orig|currentStyle|visible|getElementById|isReady|error|static|bind|String|which|getComputedStyle|responseText|oWidth|oHeight|on|shift|json|child|RegExp|ol|lastModified|isXMLDoc|jsonp|jquery|previousSibling|dir|safari2|el|styleFloat|state|setInterval|radio|getElementsByTagName|tr|empty|html|getAttribute|pos|update|version|input|float|runtimeStyle|unshift|mouseover|getPropertyValue|GET|clearInterval|safariTimer|visibility|clean|__ie_init|absolute|handleHover|lastToggle|index|fromElement|relatedTarget|click|fix|evt|andSelf|removeEventListener|handler|cloneNode|addEventListener|triggered|nodeIndex|unique|Number|classFilter|prevObject|selectedIndex|after|submit|password|removeAttribute|file|expr|setTimeout|_|appendChild|ajaxSettings|client|active|win|sibling|deep|globalEval|boxModel|cssFloat|object|checkbox|parsererror|offsetLeft|wrapAll|dequeue|props|lastChild|swing|handleError|getResponseHeader|results|startTime|00|box|Modified|ifModified|offsetTop|evalScript|createElement|setRequestHeader|ctrlKey|callback|metaKey|contentType|ajaxSend|ajaxSuccess|ajaxError|ajaxStop|ajaxStart|serializeArray|init|notmodified|POST|loaded|appendTo|DOMContentLoaded|bindReady|mouseout|not|removeAttr|unbind|unload|Width|keyCode|charCode|onreadystatechange|clientX|pageX|srcElement|join|outerHTML|substr|zoom|parse|textarea|reset|image|odd|even|before|quickClass|quickID|prepend|quickChild|execScript|offset|scroll|processData|uuid|contents|continue|textContent|ajaxComplete|clone|setArray|webkit|nodeValue|fl|_default|100|linear|href|speed|eq|createTextNode|throw|replaceWith|splice|_toggle|xml|colgroup|304|200|alpha|Last|httpData|httpNotModified|httpSuccess|fieldset|beforeSend|getBoundingClientRect|XMLHttpRequest|ActiveXObject|col|br|abbr|pixelLeft|urlencoded|www|application|ajaxSetup|post|getJSON|getScript|elements|serialize|clientWidth|hasClass|scr|clientHeight|write|relative|keyup|keypress|keydown|change|mousemove|mouseup|mousedown|right|dblclick|resize|focus|blur|frames|instanceof|hover|offsetWidth|triggerHandler|ipt|defer|offsetHeight|border|padding|clientY|pageY|Left|Right|toElement|Bottom|Top|cancelBubble|returnValue|detachEvent|attachEvent|substring|line|weight|animated|header|font|enabled|innerText|contains|only|size|gt|lt|uFFFF|u0128|417|inner|Height|toggleClass|removeClass|addClass|replaceAll|noConflict|insertAfter|prependTo|wrap|contentWindow|contentDocument|http|iframe|children|siblings|prevAll|nextAll|wrapInner|prev|Boolean|next|parents|maxLength|maxlength|readOnly|readonly|class|htmlFor|CSS1Compat|compatMode|compatible|borderTopWidth|ie|ra|inline|it|rv|medium|borderWidth|userAgent|522|navigator|with|concat|1px|10000|array|ig|PI|NaN|400|reverse|fast|600|slow|Function|Object|setAttribute|changed|be|can|property|fadeTo|fadeOut|getAttributeNode|fadeIn|slideToggle|method|slideUp|slideDown|action|cssText|stop|responseXML|option|content|300|th|protocol|td|location|send|cap|abort|colg|cos|tfoot|thead|With|leg|Requested|opt|GMT|1970|Jan|01|Thu|area|Since|hr|If|Type|Content|meta|specified|open|link|XMLHTTP|Microsoft|img|onload|row|borderLeftWidth|head|attributes'.split('|'),0,{})) \ No newline at end of file diff --git a/js/md5.js b/js/md5.js new file mode 100755 index 0000000..36fc1c2 --- /dev/null +++ b/js/md5.js @@ -0,0 +1,256 @@ +/* + * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message + * Digest Algorithm, as defined in RFC 1321. + * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002. + * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet + * Distributed under the BSD License + * See http://pajhome.org.uk/crypt/md5 for more info. + */ + +/* + * Configurable variables. You may need to tweak these to be compatible with + * the server-side, but the defaults work in most cases. + */ +var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */ +var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */ +var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */ + +/* + * These are the functions you'll usually want to call + * They take string arguments and return either hex or base-64 encoded strings + */ +function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));} +function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));} +function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));} +function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); } +function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); } +function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); } + +/* + * Perform a simple self-test to see if the VM is working + */ +function md5_vm_test() +{ + return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72"; +} + +/* + * Calculate the MD5 of an array of little-endian words, and a bit length + */ +function core_md5(x, len) +{ + /* append padding */ + x[len >> 5] |= 0x80 << ((len) % 32); + x[(((len + 64) >>> 9) << 4) + 14] = len; + + var a = 1732584193; + var b = -271733879; + var c = -1732584194; + var d = 271733878; + + for(var i = 0; i < x.length; i += 16) + { + var olda = a; + var oldb = b; + var oldc = c; + var oldd = d; + + a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936); + d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586); + c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819); + b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330); + a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897); + d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426); + c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341); + b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983); + a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416); + d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417); + c = md5_ff(c, d, a, b, x[i+10], 17, -42063); + b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162); + a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682); + d = md5_ff(d, a, b, c, x[i+13], 12, -40341101); + c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290); + b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329); + + a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510); + d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632); + c = md5_gg(c, d, a, b, x[i+11], 14, 643717713); + b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302); + a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691); + d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083); + c = md5_gg(c, d, a, b, x[i+15], 14, -660478335); + b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848); + a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438); + d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690); + c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961); + b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501); + a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467); + d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784); + c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473); + b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734); + + a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558); + d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463); + c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562); + b = md5_hh(b, c, d, a, x[i+14], 23, -35309556); + a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060); + d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353); + c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632); + b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640); + a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174); + d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222); + c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979); + b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189); + a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487); + d = md5_hh(d, a, b, c, x[i+12], 11, -421815835); + c = md5_hh(c, d, a, b, x[i+15], 16, 530742520); + b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651); + + a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844); + d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415); + c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905); + b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055); + a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571); + d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606); + c = md5_ii(c, d, a, b, x[i+10], 15, -1051523); + b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799); + a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359); + d = md5_ii(d, a, b, c, x[i+15], 10, -30611744); + c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380); + b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649); + a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070); + d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379); + c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259); + b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551); + + a = safe_add(a, olda); + b = safe_add(b, oldb); + c = safe_add(c, oldc); + d = safe_add(d, oldd); + } + return Array(a, b, c, d); + +} + +/* + * These functions implement the four basic operations the algorithm uses. + */ +function md5_cmn(q, a, b, x, s, t) +{ + return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b); +} +function md5_ff(a, b, c, d, x, s, t) +{ + return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t); +} +function md5_gg(a, b, c, d, x, s, t) +{ + return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t); +} +function md5_hh(a, b, c, d, x, s, t) +{ + return md5_cmn(b ^ c ^ d, a, b, x, s, t); +} +function md5_ii(a, b, c, d, x, s, t) +{ + return md5_cmn(c ^ (b | (~d)), a, b, x, s, t); +} + +/* + * Calculate the HMAC-MD5, of a key and some data + */ +function core_hmac_md5(key, data) +{ + var bkey = str2binl(key); + if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz); + + var ipad = Array(16), opad = Array(16); + for(var i = 0; i < 16; i++) + { + ipad[i] = bkey[i] ^ 0x36363636; + opad[i] = bkey[i] ^ 0x5C5C5C5C; + } + + var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz); + return core_md5(opad.concat(hash), 512 + 128); +} + +/* + * Add integers, wrapping at 2^32. This uses 16-bit operations internally + * to work around bugs in some JS interpreters. + */ +function safe_add(x, y) +{ + var lsw = (x & 0xFFFF) + (y & 0xFFFF); + var msw = (x >> 16) + (y >> 16) + (lsw >> 16); + return (msw << 16) | (lsw & 0xFFFF); +} + +/* + * Bitwise rotate a 32-bit number to the left. + */ +function bit_rol(num, cnt) +{ + return (num << cnt) | (num >>> (32 - cnt)); +} + +/* + * Convert a string to an array of little-endian words + * If chrsz is ASCII, characters >255 have their hi-byte silently ignored. + */ +function str2binl(str) +{ + var bin = Array(); + var mask = (1 << chrsz) - 1; + for(var i = 0; i < str.length * chrsz; i += chrsz) + bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32); + return bin; +} + +/* + * Convert an array of little-endian words to a string + */ +function binl2str(bin) +{ + var str = ""; + var mask = (1 << chrsz) - 1; + for(var i = 0; i < bin.length * 32; i += chrsz) + str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask); + return str; +} + +/* + * Convert an array of little-endian words to a hex string. + */ +function binl2hex(binarray) +{ + var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef"; + var str = ""; + for(var i = 0; i < binarray.length * 4; i++) + { + str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) + + hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF); + } + return str; +} + +/* + * Convert an array of little-endian words to a base-64 string + */ +function binl2b64(binarray) +{ + var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + var str = ""; + for(var i = 0; i < binarray.length * 4; i += 3) + { + var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16) + | (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 ) + | ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF); + for(var j = 0; j < 4; j++) + { + if(i * 8 + j * 6 > binarray.length * 32) str += b64pad; + else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F); + } + } + return str; +} diff --git a/js/pageMinichat.js b/js/pageMinichat.js new file mode 100755 index 0000000..ce0bcf0 --- /dev/null +++ b/js/pageMinichat.js @@ -0,0 +1,588 @@ +// coding: utf-8 + +function PageMinichat(client, formateur, util) +{ + this.nom = "minichat" + + this.client = client + this.formateur = formateur + this.util = util + + this.regexMessageTagMatch = /\{.*?\}>/g + this.regexMessageTagReplace = /^(.*?\{.*?\}>)*/ + + this.messages = new Messages(this.client, this.formateur, this.util) +} + +PageMinichat.prototype.contenu = function() +{ + return '\ +
\ +
\ +

\ + \ + \ + \ + \ +

\ +
\ +
\ +
' +} + +PageMinichat.prototype.charger = function() +{ + thisPage = this + + jQuery("form input.pseudo").val(this.client.pseudo) + + this.messages.rafraichirMessages(true) + + this.util.setCaretToEnd(jQuery("form input.message")[0]) + + jQuery("#messages").hover( + function(){}, + function(event) + { + jQuery("#messages .message").removeClass("cache") + thisPage.messages.messageOver = null + } + ) + + // affichage des smiles + jQuery("#smiles").html(this.formateur.getSmilesHTML()).children().each( + function(i) + { + var opacityBase = jQuery(this).css("opacity") + jQuery(this).click( + function(event) + { + thisPage.util.replaceSelection(jQuery("form input.message")[0], thisPage.formateur.smiles[jQuery(this).attr("class")][0].source.replace(/\\/g, "")) + } + ) + .hover( + function() + { + jQuery(this).animate( + { + opacity: 1 + }, 200 + ) + }, + function() + { + jQuery(this).animate( + { + opacity: opacityBase + }, 200 + ) + } + ) + } + ) + + /// événements + jQuery("form button.return").click( + function() + { + // captcha anti bot + if (jQuery("form input.captcha").val() != "") return + + thisPage.messages.allerSurLaPage(1) + + thisPage.envoyerMessage( + jQuery("form input.pseudo").val(), + jQuery("form input.message").val() + ) + + jQuery("form input.message")[0].focus() + } + ) + // interdiction de submiter le formulaire + jQuery("form").submit(function(){return false}) + + jQuery("input.pseudo").click( + function() + { + var input = jQuery("input.pseudo")[0] + if (input.value == conf.pseudoDefaut) + input.value = "" + } + ) +} + +PageMinichat.prototype.decharger = function() +{ + if (this.attenteCourante != null) + this.attenteCourante.abort() +} + +PageMinichat.prototype.getXMLMessage = function(pseudo, message, repondA) +{ + var XMLDocument = this.util.creerDocumentXMLAction() + XMLDocument.documentElement.setAttribute("name", "message") + + var nodeCookie = XMLDocument.createElement("cookie") + nodeCookie.appendChild(XMLDocument.createTextNode(this.client.cookie)) + XMLDocument.documentElement.appendChild(nodeCookie) + + var nodePseudo = XMLDocument.createElement("pseudo") + nodePseudo.appendChild(XMLDocument.createTextNode(pseudo)) + XMLDocument.documentElement.appendChild(nodePseudo) + + var nodeContenu = XMLDocument.createElement("contenu") + nodeContenu.appendChild(XMLDocument.createTextNode(message)) + XMLDocument.documentElement.appendChild(nodeContenu) + + if (repondA.length > 0) + { + var nodeReponses = XMLDocument.createElement("reponses") + XMLDocument.documentElement.appendChild(nodeReponses) + for (var i = 0; i < repondA.length; i++) + { + var nodeReponse = XMLDocument.createElement("reponse") + nodeReponse.setAttribute("id", repondA[i]) + nodeReponses.appendChild(nodeReponse) + } + } + + return XMLDocument +} + +PageMinichat.prototype.envoyerMessage = function(pseudo, message) +{ + // (un pseudo vide est autorisé) + pseudo = this.formateur.filtrerInputPseudo(pseudo) + + // extraction des id des messages (en base 36 évidemment) auquels le user répond + var repondA = [] + var tags = message.match(this.regexMessageTagMatch) + if (tags != null) + { + for(var i = 0; i < tags.length; i++) + repondA.push(/\{(.*?)\}>/.exec(tags[i])[1]) + message = message.replace(this.regexMessageTagReplace, "") + + // met à jour la classe des messages auquel repond celui ci (c'est un peu de la triche) + for (var i = 0; i < repondA.length; i++) + { + jQuery("#messages div#" + repondA[i]).addClass("repondu") + for (var m = 0; m < this.messages.messages.length; m++) + this.messages.messages[m].clientARepondu = true + } + } + + message = message.trim() + if (message == "") + { + this.util.messageDialogue("Le message est vide") + return + } + + if (!this.client.identifie()) + if (!this.client.enregistrement()) + { + this.util.messageDialogue("login impossible") + return + } + + //this.util.log(this.util.xmlVersAction(this.getXMLmessage(pseudo, message, repondA)).action) + //alert(this.util.xmlVersAction(this.getXMLMessage(pseudo, message, repondA)).action) + jQuery.post("request", this.util.xmlVersAction(this.getXMLMessage(pseudo, message, repondA)), + function(data, textStatus) + { + // TODO : traiter les erreurs + //alert(data) + jQuery("form input.message").val("") + } + ) +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// + +function Reponse(id, pseudo, login) +{ + this.id = id + this.pseudo = pseudo + this.login = login + + if (this.pseudo == undefined) + this.pseudo = "" + + if (this.login == undefined) + this.login = "" +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// + +/** + * Représente un message. + * @param id (string) + * @param date (string) + * @param pseudo + * @param contenu + */ +function Message(id, date, pseudo, contenu) +{ + this.id = id + this.date = date + this.pseudo = pseudo + this.contenu = contenu + + this.appartientAuClient = false + this.clientARepondu = false + this.estUneReponse = false + + this.systeme = false // est-ce un message 'système' ? + + this.repondA = {} // un ensemble de reponse (voir Reponse) indexé par l'id du message de la reponses +} + +/** + * + */ +Message.prototype.setRepondA = function(element) +{ + this.repondA = {} + + var thisMessage = this + + jQuery("id", element).each ( + function() + { + var reponse = new Reponse(jQuery(this).attr("id"), jQuery(this).attr("pseudo"), jQuery(this).attr("login")) + thisMessage.repondA[reponse.id] = reponse + } + ) +} + +/** + * @return les id des messages qui ont été mis en evidence sous la forme d'un objet + */ +Message.prototype.afficherConversation = function(messages) +{ + // les messages faisant partie de la conversation + var messagesEnEvidence = {} + + messagesEnEvidence[this.id] = true + + // recherche les réponses (O(n)) + for (var i = 0; i < messages.messages.length; i++) + if (messages.messages[i].repondA.hasOwnProperty(this.id)) + messagesEnEvidence[messages.messages[i].id] = true + + var f = function(tabIds) + { + for(var id in tabIds) + { + var message = messages.messagesParId[id] + if (message != undefined) + { + messagesEnEvidence[id] = true + f (message.repondA) + } + } + } + f(this.repondA) + + return messagesEnEvidence +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// + +/** + * Représente l'ensemble des messages affichés. + */ +function Messages(client, formateur, util) +{ + this.client = client + this.formateur = formateur + this.util = util + + this.nbMessageMax = conf.nbMessageAffiche // Le nombre de message affiché par page + this.idDernierMesssage = null // l'id du dernier message connu + this.page = 1 // par défaut on se trouve sur la première page + + this.messages = new Array() + this.messagesParId = new Object() + + // l'objet XMLHttpRequest représentant la connexion d'attente + this.attenteCourante = null + + var messageOver = null // element +} + +/** + * Crée un document XML contenant le message demandant un rafraichissement. + */ +Messages.prototype.getXMLrafraichirMessages = function() +{ + var XMLDocument = this.util.creerDocumentXMLAction() + XMLDocument.documentElement.setAttribute("name", "refreshMessages") + + //alert(this.util.serializer.serializeToString(XMLDocument)) + + if (this.client.identifie()) + { + var nodeCookie= XMLDocument.createElement("cookie") + nodeCookie.appendChild(XMLDocument.createTextNode(this.client.cookie)) + XMLDocument.documentElement.appendChild(nodeCookie) + } + + if (this.idDernierMesssage != null) + { + var nodeDernierMessageId = XMLDocument.createElement("dernierMessageId") + nodeDernierMessageId.appendChild(XMLDocument.createTextNode(this.idDernierMesssage)) + XMLDocument.documentElement.appendChild(nodeDernierMessageId) + } + + var nodeNombreMessage = XMLDocument.createElement("nombreMessage") + nodeNombreMessage.appendChild(XMLDocument.createTextNode(this.nbMessageMax)) + XMLDocument.documentElement.appendChild(nodeNombreMessage) + + var nodePage = XMLDocument.createElement("page") + nodePage.appendChild(XMLDocument.createTextNode(this.page)) + XMLDocument.documentElement.appendChild(nodePage) + + return XMLDocument; +} + +/** + * Création d'un nouveau message. + * Les message sont données dans l'ordre de leur id. + * Met directement à jour l'affichage. + * @param element un element xml représentant le message + * @param autoFlush si oui alors le message est directement ajouté à la vue + */ +Messages.prototype.ajouterMessage = function(element, autoFlush) +{ + if (autoFlush == undefined) autoFlush = true // valeur par défaut + + // pas d'utilisation de jquery pour des raisons de performance + this.idDernierMesssage = element.getAttribute("id") + + var message = new Message( + this.idDernierMesssage, + jQuery("date", element).text(), + jQuery("pseudo", element).text(), + jQuery("contenu", element).text() + ) + + message.appartientAuClient = jQuery("proprietaire", element).text() == "true" + message.clientARepondu = jQuery("repondu", element).text() == "true" + message.estUneReponse = jQuery("reponse", element).text() == "true" + message.systeme = jQuery("systeme", element).text() == "true" + message.setRepondA(jQuery("repondA", element)) + + this.messages.push(message) + this.messagesParId[message.id] = message + if (this.messages.length > this.nbMessageMax) + delete this.messagesParId[this.messages.shift().id] + + if (autoFlush) + this.flush() +} + +Messages.prototype.flush = function() +{ + var thisMessages = this + + var idDernierMessageAffiche = jQuery("#messages div:first").attr("id") + if (idDernierMessageAffiche == undefined) idDernierMessageAffiche = "0" + + var XHTML = "" + for (var i = this.messages.length - 1; i >= 0; i--) + if (parseInt(this.messages[i].id, 36) > parseInt(idDernierMessageAffiche, 36)) + { + var message = this.messages[i] + var XHTMLrepondA = "" + for (var id in message.repondA) + XHTMLrepondA += this.formateur.traitementComplet(message.repondA[id].pseudo) + "> " + XHTMLrepondA = "
" + XHTMLrepondA + "
" + + XHTML += + "
" + + "[
" + message.date + "
]" + + "
" + this.formateur.traitementComplet(message.pseudo) + "
:" + + XHTMLrepondA + + "
" + (message.systeme ? this.formateur.remplacerBalisesHTML(message.contenu) : this.formateur.traitementComplet(message.contenu, message.pseudo))+ "
" + + "
" + } + jQuery("#messages").prepend(XHTML) + + if (myLightbox != null) + myLightbox.updateImageList() + + var nbMessagesAffiche = jQuery("#messages .message").size() + if (nbMessagesAffiche > this.nbMessageMax) + jQuery("#messages .message").slice(this.nbMessageMax, nbMessagesAffiche).empty(); + + jQuery("#messages .message").filter(function(){return parseInt(jQuery(this).attr("id"), 36) > parseInt(idDernierMessageAffiche, 36)}).each( + function() + { + jQuery(this).click( + function(event) + { + if (jQuery(event.target).is("a")) return + + var valCourant = jQuery("input.message").val() + if (valCourant == undefined) valCourant = "" + var tag = jQuery(".pseudo", this).text() + "{" + jQuery(this).attr("id") + "}" + ">" + if (valCourant.indexOf(tag, 0) == -1) + jQuery("input.message").val(tag + " " + valCourant) + thisMessages.util.setCaretToEnd(jQuery("form input.message")[0]) + } + ) + // Q : pourquoi pas un .hover ? + // R : simplement pour éviter que lorsqu'un message arrive cela n'affecte la conversation actuellement mise en évidence + .mousemove( + function(e) + { + if (this !== thisMessages.messageOver) + { + thisMessages.afficherConversation(this) + thisMessages.messageOver = this + } + } + ) + } + ) +} + +/** + * Etablit une liste des messages à mettre en evidence et des messages à cacher. + * Puis applique un plan diabolique. + * @param element un message de la liste des messages + */ +Messages.prototype.afficherConversation = function(element) +{ + // cherche le message selectionné + var id = jQuery(element).attr("id") + var message = this.messagesParId[id] + if (message == undefined) return + + mess = message.afficherConversation(this) + + // FIXME : cet appel est très lent + jQuery("#messages .message").each( + function() + { + var jq = jQuery(this) + if (!mess.hasOwnProperty(jq.attr("id"))) + jq.addClass("cache") + else + jq.removeClass("cache") + } + ) +} + +Messages.prototype.viderMessages = function() +{ + this.idDernierMesssage = null + this.messages = new Array() + jQuery("#messages").empty() +} + +/** + * Met à jour les messages de manière continue. + * (AJAX-Comet-style proof) + * @param vider vide tous les messages avant d'afficher les nouveaux + */ +Messages.prototype.rafraichirMessages = function(vider) +{ + if (this.attenteCourante != null) + this.attenteCourante.abort() + + if (vider == undefined) + vider = false + + if (vider) + { + this.idDernierMesssage = null + this.messages = new Array() + } + + var thisMessages = this // caisupair javacrypte + + //this.util.log(this.util.serializer.serializeToString(this.getXMLrafraichirMessages())) + this.attenteCourante = jQuery.ajax({ + type: "POST", + url: "request", + dataType: "xml", + data: this.util.xmlVersAction(this.getXMLrafraichirMessages()), + success: + function(data) + { + //thisMessages.util.log(thisMessages.util.serializer.serializeToString(data)) + + if (vider) + thisMessages.viderMessages() + + thisMessages.MAJPages(parseInt(jQuery("nbPage", data.documentElement).text())) + + reponse = jQuery("message", data.documentElement).each( + function(i) + { + thisMessages.ajouterMessage(this, false) + } + ) + thisMessages.flush() + setTimeout(function(){ thisMessages.rafraichirMessages() }, 100); + }, + error: + function(XMLHttpRequest, textStatus, errorThrown) + { + setTimeout(function(){ thisMessages.rafraichirMessages() }, 1000); + } + } + ) +} + +Messages.prototype.MAJPages = function(nbPage) +{ + //alert(nbPage) + + var thisMessages = this + + var nbPageActuel = jQuery("#pages span").size() + + for(var p = nbPageActuel + 1; p <= nbPage && p <= 3; p++) + { + jQuery("#pages").append("" + p + "").click( + function(event) + { + var target = jQuery(event.target) + + if(!target.is("span")) + return + + thisMessages.allerSurLaPage(parseInt(jQuery(event.target).text())) + } + ) + } +} + +Messages.prototype.allerSurLaPage = function(page) +{ + if (page == this.page) + return + this.page = page + + var thisMessages = this + + //jQuery("#pages span").removeClass("pageCourante") + jQuery("#pages span").each( + function(i) + { + if (jQuery(this).text() == thisMessages.page) + jQuery(this).addClass("pageCourante") + else + jQuery(this).removeClass("pageCourante") + } + ) + + this.rafraichirMessages(true) +} + diff --git a/js/pageProfile.js b/js/pageProfile.js new file mode 100755 index 0000000..7270c23 --- /dev/null +++ b/js/pageProfile.js @@ -0,0 +1,118 @@ +// coding: utf-8 + +function PageProfile(client, formateur, util) +{ + this.nom = "profile" + + this.client = client + this.formateur = formateur + this.util = util +} + +PageProfile.prototype.contenu = function() +{ + return "" +} + +PageProfile.prototype.charger = function() +{ + jQuery("#page").html(this.getHTML()) + + // en fonction du statut + if (this.client.identifie()) + this.chargerProfile() + else + this.chargerLogin() + + jQuery("#page form#profile").submit(function(){return false}) +} + +PageProfile.prototype.chargerProfile = function() +{ + var thisPage = this + + jQuery("form#profile input.login").val(this.client.login) + jQuery("form#profile input.pseudo").val(this.client.pseudo) + jQuery("form#profile input.email").val(this.client.email) + + jQuery("#page form#profile button").click( + function() + { + thisPage.client.pseudo = thisPage.formateur.filtrerInputPseudo(jQuery("form#profile input.pseudo").val()) + thisPage.client.email = jQuery("form#profile input.email").val() + + var password = jQuery("form#profile input.password").val() + var passwordRe = jQuery("form#profile input.passwordRe").val() + if (password != "" || passwordRe != "") + { + if (password != passwordRe) + { + thisPage.util.messageDialogue("Les mots de passes ne correspondent pas") + return + } + thisPage.client.password = thisPage.util.md5(password) + } + + if(!thisPage.client.flush()) + thisPage.util.messageDialogue("Impossible de mettre à jour votre profile, causes inconnues", messageType.erreur) + else + { + thisPage.util.messageDialogue("Votre profile a été mis à jour") + //thisPage.pages.afficherPage("minichat") + } + } + ) +} + +PageProfile.prototype.chargerLogin = function() +{ + var thisPage = this + + jQuery("#page form#profile button").click( + function() + { + if(!thisPage.client.connexionLogin(jQuery("form#profile input.login").val(), thisPage.util.md5(jQuery("form#profile input.password").val()))) + thisPage.util.messageDialogue("Couple login/pass introuvable") + else + { + // TODO afficher un message "ok" + thisPage.pages.afficherPage("minichat") + } + } + ) +} + +PageProfile.prototype.getHTML = function() +{ +return '\ +
\ + \ + \ + \ + \ + \ + \ + \ + \ + ' + + (this.client.identifie() ? '\ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + ' : '') + '\ + \ + \ + \ +
login
password
password re
pseudo
e-mail
\ +
\ +
' +} \ No newline at end of file diff --git a/js/pageRegister.js b/js/pageRegister.js new file mode 100755 index 0000000..30d1790 --- /dev/null +++ b/js/pageRegister.js @@ -0,0 +1,70 @@ +// coding: utf-8 + +function PageRegister(client, formateur, util) +{ + this.nom = "register" + + this.client = client + this.formateur = formateur + this.util = util +} + +PageRegister.prototype.contenu = function() +{ + return '\ +
\ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ +
login\
password
password re
\ +
\ +' +} + +PageRegister.prototype.charger = function() +{ + jQuery("#page form#register").submit(function(){return false}) + + var thisPage = this + + jQuery("#page form#register button").click( + function() + { + if (jQuery("#page form#register input.captcha").val() != "") return + + var login = jQuery("#page form#register input.login").val().trim() + var password = jQuery("#page form#register input.password").val() + var passwordRe = jQuery("#page form#register input.passwordRe").val() + + if (login == "") + thisPage.util.messageDialogue("Le login ne doit pas être vide") + else if (password == "" && passwordRe == "") + thisPage.util.messageDialogue("Un mot de passe est obligatoire") + else if (password != passwordRe) + thisPage.util.messageDialogue("Les mots de passes ne correspondent pas") + else if(!thisPage.client.enregistrement(login, thisPage.util.md5(password))) + { + thisPage.util.messageDialogue(thisPage.client.dernierMessageErreur, messageType.erreur) + } + else + { + // TODO : avertir que l'enregistrement s'est bien déroulé + thisPage.client.majMenu() + thisPage.pages.afficherPage("minichat") + } + } + ) +} \ No newline at end of file diff --git a/lightbox/css/lightbox.css b/lightbox/css/lightbox.css new file mode 100755 index 0000000..9eb74be --- /dev/null +++ b/lightbox/css/lightbox.css @@ -0,0 +1,79 @@ +#lightbox{ + position: absolute; + left: 0; + width: 100%; + z-index: 100; + text-align: center; + line-height: 0; + } + +#lightbox a img{ border: none; } + +#outerImageContainer{ + position: relative; + background-color: #fff; + width: 250px; + height: 250px; + margin: 0 auto; + } + +#imageContainer{ + padding: 10px; + } + +#loading{ + position: absolute; + top: 40%; + left: 0%; + height: 25%; + width: 100%; + text-align: center; + line-height: 0; + } +#hoverNav{ + position: absolute; + top: 0; + left: 0; + height: 100%; + width: 100%; + z-index: 10; + } +#imageContainer>#hoverNav{ left: 0;} +#hoverNav a{ outline: none;} + +#prevLink, #nextLink{ + width: 49%; + height: 100%; + background: transparent url(../images/blank.gif) no-repeat; /* Trick IE into showing hover */ + display: block; + } +#prevLink { left: 0; float: left;} +#nextLink { right: 0; float: right;} +#prevLink:hover, #prevLink:visited:hover { background: url(../images/prevlabel.gif) left 15% no-repeat; } +#nextLink:hover, #nextLink:visited:hover { background: url(../images/nextlabel.gif) right 15% no-repeat; } + + +#imageDataContainer{ + font: 10px Verdana, Helvetica, sans-serif; + background-color: #fff; + margin: 0 auto; + line-height: 1.4em; + overflow: auto; + width: 100% + } + +#imageData{ padding:0 10px; color: #666; } +#imageData #imageDetails{ width: 70%; float: left; text-align: left; } +#imageData #caption{ font-weight: bold; } +#imageData #numberDisplay{ display: block; clear: left; padding-bottom: 1.0em; } +#imageData #bottomNavClose{ width: 66px; float: right; padding-bottom: 0.7em; } + +#overlay{ + position: absolute; + top: 0; + left: 0; + z-index: 90; + width: 100%; + height: 500px; + background-color: #000; + } \ No newline at end of file diff --git a/lightbox/images/blank.gif b/lightbox/images/blank.gif new file mode 100755 index 0000000..1d11fa9 Binary files /dev/null and b/lightbox/images/blank.gif differ diff --git a/lightbox/images/close.gif b/lightbox/images/close.gif new file mode 100755 index 0000000..ca517b6 Binary files /dev/null and b/lightbox/images/close.gif differ diff --git a/lightbox/images/closelabel.gif b/lightbox/images/closelabel.gif new file mode 100755 index 0000000..87b4f8b Binary files /dev/null and b/lightbox/images/closelabel.gif differ diff --git a/lightbox/images/loading.gif b/lightbox/images/loading.gif new file mode 100755 index 0000000..f864d5f Binary files /dev/null and b/lightbox/images/loading.gif differ diff --git a/lightbox/images/next.gif b/lightbox/images/next.gif new file mode 100755 index 0000000..1fe6ca1 Binary files /dev/null and b/lightbox/images/next.gif differ diff --git a/lightbox/images/nextlabel.gif b/lightbox/images/nextlabel.gif new file mode 100755 index 0000000..6c40e51 Binary files /dev/null and b/lightbox/images/nextlabel.gif differ diff --git a/lightbox/images/prev.gif b/lightbox/images/prev.gif new file mode 100755 index 0000000..aefa804 Binary files /dev/null and b/lightbox/images/prev.gif differ diff --git a/lightbox/images/prevlabel.gif b/lightbox/images/prevlabel.gif new file mode 100755 index 0000000..51a31c2 Binary files /dev/null and b/lightbox/images/prevlabel.gif differ diff --git a/lightbox/js/effects.js b/lightbox/js/effects.js new file mode 100755 index 0000000..d3940a8 --- /dev/null +++ b/lightbox/js/effects.js @@ -0,0 +1,903 @@ +// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) +// Contributors: +// Justin Palmer (http://encytemedia.com/) +// Mark Pilgrim (http://diveintomark.org/) +// Martin Bialasinki +// +// See scriptaculous.js for full license. + +/* ------------- element ext -------------- */ + +// converts rgb() and #xxx to #xxxxxx format, +// returns self (or first argument) if not convertable +String.prototype.parseColor = function() { + var color = '#'; + if(this.slice(0,4) == 'rgb(') { + var cols = this.slice(4,this.length-1).split(','); + var i=0; do { color += parseInt(cols[i]).toColorPart() } while (++i<3); + } else { + if(this.slice(0,1) == '#') { + if(this.length==4) for(var i=1;i<4;i++) color += (this.charAt(i) + this.charAt(i)).toLowerCase(); + if(this.length==7) color = this.toLowerCase(); + } + } + return(color.length==7 ? color : (arguments[0] || this)); +} + +Element.collectTextNodes = function(element) { + return $A($(element).childNodes).collect( function(node) { + return (node.nodeType==3 ? node.nodeValue : + (node.hasChildNodes() ? Element.collectTextNodes(node) : '')); + }).flatten().join(''); +} + +Element.collectTextNodesIgnoreClass = function(element, className) { + return $A($(element).childNodes).collect( function(node) { + return (node.nodeType==3 ? node.nodeValue : + ((node.hasChildNodes() && !Element.hasClassName(node,className)) ? + Element.collectTextNodes(node) : '')); + }).flatten().join(''); +} + +Element.setStyle = function(element, style) { + element = $(element); + for(k in style) element.style[k.camelize()] = style[k]; +} + +Element.setContentZoom = function(element, percent) { + Element.setStyle(element, {fontSize: (percent/100) + 'em'}); + if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0); +} + +Element.getOpacity = function(element){ + var opacity; + if (opacity = Element.getStyle(element, 'opacity')) + return parseFloat(opacity); + if (opacity = (Element.getStyle(element, 'filter') || '').match(/alpha\(opacity=(.*)\)/)) + if(opacity[1]) return parseFloat(opacity[1]) / 100; + return 1.0; +} + +Element.setOpacity = function(element, value){ + element= $(element); + if (value == 1){ + Element.setStyle(element, { opacity: + (/Gecko/.test(navigator.userAgent) && !/Konqueror|Safari|KHTML/.test(navigator.userAgent)) ? + 0.999999 : null }); + if(/MSIE/.test(navigator.userAgent)) + Element.setStyle(element, {filter: Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'')}); + } else { + if(value < 0.00001) value = 0; + Element.setStyle(element, {opacity: value}); + if(/MSIE/.test(navigator.userAgent)) + Element.setStyle(element, + { filter: Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'') + + 'alpha(opacity='+value*100+')' }); + } +} + +Element.getInlineOpacity = function(element){ + return $(element).style.opacity || ''; +} + +Element.childrenWithClassName = function(element, className) { + return $A($(element).getElementsByTagName('*')).select( + function(c) { return Element.hasClassName(c, className) }); +} + +Array.prototype.call = function() { + var args = arguments; + this.each(function(f){ f.apply(this, args) }); +} + +/*--------------------------------------------------------------------------*/ + +var Effect = { + tagifyText: function(element) { + var tagifyStyle = 'position:relative'; + if(/MSIE/.test(navigator.userAgent)) tagifyStyle += ';zoom:1'; + element = $(element); + $A(element.childNodes).each( function(child) { + if(child.nodeType==3) { + child.nodeValue.toArray().each( function(character) { + element.insertBefore( + Builder.node('span',{style: tagifyStyle}, + character == ' ' ? String.fromCharCode(160) : character), + child); + }); + Element.remove(child); + } + }); + }, + multiple: function(element, effect) { + var elements; + if(((typeof element == 'object') || + (typeof element == 'function')) && + (element.length)) + elements = element; + else + elements = $(element).childNodes; + + var options = Object.extend({ + speed: 0.1, + delay: 0.0 + }, arguments[2] || {}); + var masterDelay = options.delay; + + $A(elements).each( function(element, index) { + new effect(element, Object.extend(options, { delay: index * options.speed + masterDelay })); + }); + }, + PAIRS: { + 'slide': ['SlideDown','SlideUp'], + 'blind': ['BlindDown','BlindUp'], + 'appear': ['Appear','Fade'] + }, + toggle: function(element, effect) { + element = $(element); + effect = (effect || 'appear').toLowerCase(); + var options = Object.extend({ + queue: { position:'end', scope:(element.id || 'global') } + }, arguments[2] || {}); + Effect[Element.visible(element) ? + Effect.PAIRS[effect][1] : Effect.PAIRS[effect][0]](element, options); + } +}; + +var Effect2 = Effect; // deprecated + +/* ------------- transitions ------------- */ + +Effect.Transitions = {} + +Effect.Transitions.linear = function(pos) { + return pos; +} +Effect.Transitions.sinoidal = function(pos) { + return (-Math.cos(pos*Math.PI)/2) + 0.5; +} +Effect.Transitions.reverse = function(pos) { + return 1-pos; +} +Effect.Transitions.flicker = function(pos) { + return ((-Math.cos(pos*Math.PI)/4) + 0.75) + Math.random()/4; +} +Effect.Transitions.wobble = function(pos) { + return (-Math.cos(pos*Math.PI*(9*pos))/2) + 0.5; +} +Effect.Transitions.pulse = function(pos) { + return (Math.floor(pos*10) % 2 == 0 ? + (pos*10-Math.floor(pos*10)) : 1-(pos*10-Math.floor(pos*10))); +} +Effect.Transitions.none = function(pos) { + return 0; +} +Effect.Transitions.full = function(pos) { + return 1; +} + +/* ------------- core effects ------------- */ + +Effect.ScopedQueue = Class.create(); +Object.extend(Object.extend(Effect.ScopedQueue.prototype, Enumerable), { + initialize: function() { + this.effects = []; + this.interval = null; + }, + _each: function(iterator) { + this.effects._each(iterator); + }, + add: function(effect) { + var timestamp = new Date().getTime(); + + var position = (typeof effect.options.queue == 'string') ? + effect.options.queue : effect.options.queue.position; + + switch(position) { + case 'front': + // move unstarted effects after this effect + this.effects.findAll(function(e){ return e.state=='idle' }).each( function(e) { + e.startOn += effect.finishOn; + e.finishOn += effect.finishOn; + }); + break; + case 'end': + // start effect after last queued effect has finished + timestamp = this.effects.pluck('finishOn').max() || timestamp; + break; + } + + effect.startOn += timestamp; + effect.finishOn += timestamp; + this.effects.push(effect); + if(!this.interval) + this.interval = setInterval(this.loop.bind(this), 40); + }, + remove: function(effect) { + this.effects = this.effects.reject(function(e) { return e==effect }); + if(this.effects.length == 0) { + clearInterval(this.interval); + this.interval = null; + } + }, + loop: function() { + var timePos = new Date().getTime(); + this.effects.invoke('loop', timePos); + } +}); + +Effect.Queues = { + instances: $H(), + get: function(queueName) { + if(typeof queueName != 'string') return queueName; + + if(!this.instances[queueName]) + this.instances[queueName] = new Effect.ScopedQueue(); + + return this.instances[queueName]; + } +} +Effect.Queue = Effect.Queues.get('global'); + +Effect.DefaultOptions = { + transition: Effect.Transitions.sinoidal, + duration: 1.0, // seconds + fps: 25.0, // max. 25fps due to Effect.Queue implementation + sync: false, // true for combining + from: 0.0, + to: 1.0, + delay: 0.0, + queue: 'parallel' +} + +Effect.Base = function() {}; +Effect.Base.prototype = { + position: null, + start: function(options) { + this.options = Object.extend(Object.extend({},Effect.DefaultOptions), options || {}); + this.currentFrame = 0; + this.state = 'idle'; + this.startOn = this.options.delay*1000; + this.finishOn = this.startOn + (this.options.duration*1000); + this.event('beforeStart'); + if(!this.options.sync) + Effect.Queues.get(typeof this.options.queue == 'string' ? + 'global' : this.options.queue.scope).add(this); + }, + loop: function(timePos) { + if(timePos >= this.startOn) { + if(timePos >= this.finishOn) { + this.render(1.0); + this.cancel(); + this.event('beforeFinish'); + if(this.finish) this.finish(); + this.event('afterFinish'); + return; + } + var pos = (timePos - this.startOn) / (this.finishOn - this.startOn); + var frame = Math.round(pos * this.options.fps * this.options.duration); + if(frame > this.currentFrame) { + this.render(pos); + this.currentFrame = frame; + } + } + }, + render: function(pos) { + if(this.state == 'idle') { + this.state = 'running'; + this.event('beforeSetup'); + if(this.setup) this.setup(); + this.event('afterSetup'); + } + if(this.state == 'running') { + if(this.options.transition) pos = this.options.transition(pos); + pos *= (this.options.to-this.options.from); + pos += this.options.from; + this.position = pos; + this.event('beforeUpdate'); + if(this.update) this.update(pos); + this.event('afterUpdate'); + } + }, + cancel: function() { + if(!this.options.sync) + Effect.Queues.get(typeof this.options.queue == 'string' ? + 'global' : this.options.queue.scope).remove(this); + this.state = 'finished'; + }, + event: function(eventName) { + if(this.options[eventName + 'Internal']) this.options[eventName + 'Internal'](this); + if(this.options[eventName]) this.options[eventName](this); + }, + inspect: function() { + return '#'; + } +} + +Effect.Parallel = Class.create(); +Object.extend(Object.extend(Effect.Parallel.prototype, Effect.Base.prototype), { + initialize: function(effects) { + this.effects = effects || []; + this.start(arguments[1]); + }, + update: function(position) { + this.effects.invoke('render', position); + }, + finish: function(position) { + this.effects.each( function(effect) { + effect.render(1.0); + effect.cancel(); + effect.event('beforeFinish'); + if(effect.finish) effect.finish(position); + effect.event('afterFinish'); + }); + } +}); + +Effect.Opacity = Class.create(); +Object.extend(Object.extend(Effect.Opacity.prototype, Effect.Base.prototype), { + initialize: function(element) { + this.element = $(element); + // make this work on IE on elements without 'layout' + if(/MSIE/.test(navigator.userAgent) && (!this.element.hasLayout)) + Element.setStyle(this.element, {zoom: 1}); + var options = Object.extend({ + from: Element.getOpacity(this.element) || 0.0, + to: 1.0 + }, arguments[1] || {}); + this.start(options); + }, + update: function(position) { + Element.setOpacity(this.element, position); + } +}); + +Effect.Move = Class.create(); +Object.extend(Object.extend(Effect.Move.prototype, Effect.Base.prototype), { + initialize: function(element) { + this.element = $(element); + var options = Object.extend({ + x: 0, + y: 0, + mode: 'relative' + }, arguments[1] || {}); + this.start(options); + }, + setup: function() { + // Bug in Opera: Opera returns the "real" position of a static element or + // relative element that does not have top/left explicitly set. + // ==> Always set top and left for position relative elements in your stylesheets + // (to 0 if you do not need them) + Element.makePositioned(this.element); + this.originalLeft = parseFloat(Element.getStyle(this.element,'left') || '0'); + this.originalTop = parseFloat(Element.getStyle(this.element,'top') || '0'); + if(this.options.mode == 'absolute') { + // absolute movement, so we need to calc deltaX and deltaY + this.options.x = this.options.x - this.originalLeft; + this.options.y = this.options.y - this.originalTop; + } + }, + update: function(position) { + Element.setStyle(this.element, { + left: this.options.x * position + this.originalLeft + 'px', + top: this.options.y * position + this.originalTop + 'px' + }); + } +}); + +// for backwards compatibility +Effect.MoveBy = function(element, toTop, toLeft) { + return new Effect.Move(element, + Object.extend({ x: toLeft, y: toTop }, arguments[3] || {})); +}; + +Effect.Scale = Class.create(); +Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), { + initialize: function(element, percent) { + this.element = $(element) + var options = Object.extend({ + scaleX: true, + scaleY: true, + scaleContent: true, + scaleFromCenter: false, + scaleMode: 'box', // 'box' or 'contents' or {} with provided values + scaleFrom: 100.0, + scaleTo: percent + }, arguments[2] || {}); + this.start(options); + }, + setup: function() { + this.restoreAfterFinish = this.options.restoreAfterFinish || false; + this.elementPositioning = Element.getStyle(this.element,'position'); + + this.originalStyle = {}; + ['top','left','width','height','fontSize'].each( function(k) { + this.originalStyle[k] = this.element.style[k]; + }.bind(this)); + + this.originalTop = this.element.offsetTop; + this.originalLeft = this.element.offsetLeft; + + var fontSize = Element.getStyle(this.element,'font-size') || '100%'; + ['em','px','%'].each( function(fontSizeType) { + if(fontSize.indexOf(fontSizeType)>0) { + this.fontSize = parseFloat(fontSize); + this.fontSizeType = fontSizeType; + } + }.bind(this)); + + this.factor = (this.options.scaleTo - this.options.scaleFrom)/100; + + this.dims = null; + if(this.options.scaleMode=='box') + this.dims = [this.element.offsetHeight, this.element.offsetWidth]; + if(/^content/.test(this.options.scaleMode)) + this.dims = [this.element.scrollHeight, this.element.scrollWidth]; + if(!this.dims) + this.dims = [this.options.scaleMode.originalHeight, + this.options.scaleMode.originalWidth]; + }, + update: function(position) { + var currentScale = (this.options.scaleFrom/100.0) + (this.factor * position); + if(this.options.scaleContent && this.fontSize) + Element.setStyle(this.element, {fontSize: this.fontSize * currentScale + this.fontSizeType }); + this.setDimensions(this.dims[0] * currentScale, this.dims[1] * currentScale); + }, + finish: function(position) { + if (this.restoreAfterFinish) Element.setStyle(this.element, this.originalStyle); + }, + setDimensions: function(height, width) { + var d = {}; + if(this.options.scaleX) d.width = width + 'px'; + if(this.options.scaleY) d.height = height + 'px'; + if(this.options.scaleFromCenter) { + var topd = (height - this.dims[0])/2; + var leftd = (width - this.dims[1])/2; + if(this.elementPositioning == 'absolute') { + if(this.options.scaleY) d.top = this.originalTop-topd + 'px'; + if(this.options.scaleX) d.left = this.originalLeft-leftd + 'px'; + } else { + if(this.options.scaleY) d.top = -topd + 'px'; + if(this.options.scaleX) d.left = -leftd + 'px'; + } + } + Element.setStyle(this.element, d); + } +}); + +Effect.Highlight = Class.create(); +Object.extend(Object.extend(Effect.Highlight.prototype, Effect.Base.prototype), { + initialize: function(element) { + this.element = $(element); + var options = Object.extend({ startcolor: '#ffff99' }, arguments[1] || {}); + this.start(options); + }, + setup: function() { + // Prevent executing on elements not in the layout flow + if(Element.getStyle(this.element, 'display')=='none') { this.cancel(); return; } + // Disable background image during the effect + this.oldStyle = { + backgroundImage: Element.getStyle(this.element, 'background-image') }; + Element.setStyle(this.element, {backgroundImage: 'none'}); + if(!this.options.endcolor) + this.options.endcolor = Element.getStyle(this.element, 'background-color').parseColor('#ffffff'); + if(!this.options.restorecolor) + this.options.restorecolor = Element.getStyle(this.element, 'background-color'); + // init color calculations + this._base = $R(0,2).map(function(i){ return parseInt(this.options.startcolor.slice(i*2+1,i*2+3),16) }.bind(this)); + this._delta = $R(0,2).map(function(i){ return parseInt(this.options.endcolor.slice(i*2+1,i*2+3),16)-this._base[i] }.bind(this)); + }, + update: function(position) { + Element.setStyle(this.element,{backgroundColor: $R(0,2).inject('#',function(m,v,i){ + return m+(Math.round(this._base[i]+(this._delta[i]*position)).toColorPart()); }.bind(this)) }); + }, + finish: function() { + Element.setStyle(this.element, Object.extend(this.oldStyle, { + backgroundColor: this.options.restorecolor + })); + } +}); + +Effect.ScrollTo = Class.create(); +Object.extend(Object.extend(Effect.ScrollTo.prototype, Effect.Base.prototype), { + initialize: function(element) { + this.element = $(element); + this.start(arguments[1] || {}); + }, + setup: function() { + Position.prepare(); + var offsets = Position.cumulativeOffset(this.element); + if(this.options.offset) offsets[1] += this.options.offset; + var max = window.innerHeight ? + window.height - window.innerHeight : + document.body.scrollHeight - + (document.documentElement.clientHeight ? + document.documentElement.clientHeight : document.body.clientHeight); + this.scrollStart = Position.deltaY; + this.delta = (offsets[1] > max ? max : offsets[1]) - this.scrollStart; + }, + update: function(position) { + Position.prepare(); + window.scrollTo(Position.deltaX, + this.scrollStart + (position*this.delta)); + } +}); + +/* ------------- combination effects ------------- */ + +Effect.Fade = function(element) { + var oldOpacity = Element.getInlineOpacity(element); + var options = Object.extend({ + from: Element.getOpacity(element) || 1.0, + to: 0.0, + afterFinishInternal: function(effect) { with(Element) { + if(effect.options.to!=0) return; + hide(effect.element); + setStyle(effect.element, {opacity: oldOpacity}); }} + }, arguments[1] || {}); + return new Effect.Opacity(element,options); +} + +Effect.Appear = function(element) { + var options = Object.extend({ + from: (Element.getStyle(element, 'display') == 'none' ? 0.0 : Element.getOpacity(element) || 0.0), + to: 1.0, + beforeSetup: function(effect) { with(Element) { + setOpacity(effect.element, effect.options.from); + show(effect.element); }} + }, arguments[1] || {}); + return new Effect.Opacity(element,options); +} + +Effect.Puff = function(element) { + element = $(element); + var oldStyle = { opacity: Element.getInlineOpacity(element), position: Element.getStyle(element, 'position') }; + return new Effect.Parallel( + [ new Effect.Scale(element, 200, + { sync: true, scaleFromCenter: true, scaleContent: true, restoreAfterFinish: true }), + new Effect.Opacity(element, { sync: true, to: 0.0 } ) ], + Object.extend({ duration: 1.0, + beforeSetupInternal: function(effect) { with(Element) { + setStyle(effect.effects[0].element, {position: 'absolute'}); }}, + afterFinishInternal: function(effect) { with(Element) { + hide(effect.effects[0].element); + setStyle(effect.effects[0].element, oldStyle); }} + }, arguments[1] || {}) + ); +} + +Effect.BlindUp = function(element) { + element = $(element); + Element.makeClipping(element); + return new Effect.Scale(element, 0, + Object.extend({ scaleContent: false, + scaleX: false, + restoreAfterFinish: true, + afterFinishInternal: function(effect) { with(Element) { + [hide, undoClipping].call(effect.element); }} + }, arguments[1] || {}) + ); +} + +Effect.BlindDown = function(element) { + element = $(element); + var oldHeight = Element.getStyle(element, 'height'); + var elementDimensions = Element.getDimensions(element); + return new Effect.Scale(element, 100, + Object.extend({ scaleContent: false, + scaleX: false, + scaleFrom: 0, + scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width}, + restoreAfterFinish: true, + afterSetup: function(effect) { with(Element) { + makeClipping(effect.element); + setStyle(effect.element, {height: '0px'}); + show(effect.element); + }}, + afterFinishInternal: function(effect) { with(Element) { + undoClipping(effect.element); + setStyle(effect.element, {height: oldHeight}); + }} + }, arguments[1] || {}) + ); +} + +Effect.SwitchOff = function(element) { + element = $(element); + var oldOpacity = Element.getInlineOpacity(element); + return new Effect.Appear(element, { + duration: 0.4, + from: 0, + transition: Effect.Transitions.flicker, + afterFinishInternal: function(effect) { + new Effect.Scale(effect.element, 1, { + duration: 0.3, scaleFromCenter: true, + scaleX: false, scaleContent: false, restoreAfterFinish: true, + beforeSetup: function(effect) { with(Element) { + [makePositioned,makeClipping].call(effect.element); + }}, + afterFinishInternal: function(effect) { with(Element) { + [hide,undoClipping,undoPositioned].call(effect.element); + setStyle(effect.element, {opacity: oldOpacity}); + }} + }) + } + }); +} + +Effect.DropOut = function(element) { + element = $(element); + var oldStyle = { + top: Element.getStyle(element, 'top'), + left: Element.getStyle(element, 'left'), + opacity: Element.getInlineOpacity(element) }; + return new Effect.Parallel( + [ new Effect.Move(element, {x: 0, y: 100, sync: true }), + new Effect.Opacity(element, { sync: true, to: 0.0 }) ], + Object.extend( + { duration: 0.5, + beforeSetup: function(effect) { with(Element) { + makePositioned(effect.effects[0].element); }}, + afterFinishInternal: function(effect) { with(Element) { + [hide, undoPositioned].call(effect.effects[0].element); + setStyle(effect.effects[0].element, oldStyle); }} + }, arguments[1] || {})); +} + +Effect.Shake = function(element) { + element = $(element); + var oldStyle = { + top: Element.getStyle(element, 'top'), + left: Element.getStyle(element, 'left') }; + return new Effect.Move(element, + { x: 20, y: 0, duration: 0.05, afterFinishInternal: function(effect) { + new Effect.Move(effect.element, + { x: -40, y: 0, duration: 0.1, afterFinishInternal: function(effect) { + new Effect.Move(effect.element, + { x: 40, y: 0, duration: 0.1, afterFinishInternal: function(effect) { + new Effect.Move(effect.element, + { x: -40, y: 0, duration: 0.1, afterFinishInternal: function(effect) { + new Effect.Move(effect.element, + { x: 40, y: 0, duration: 0.1, afterFinishInternal: function(effect) { + new Effect.Move(effect.element, + { x: -20, y: 0, duration: 0.05, afterFinishInternal: function(effect) { with(Element) { + undoPositioned(effect.element); + setStyle(effect.element, oldStyle); + }}}) }}) }}) }}) }}) }}); +} + +Effect.SlideDown = function(element) { + element = $(element); + Element.cleanWhitespace(element); + // SlideDown need to have the content of the element wrapped in a container element with fixed height! + var oldInnerBottom = Element.getStyle(element.firstChild, 'bottom'); + var elementDimensions = Element.getDimensions(element); + return new Effect.Scale(element, 100, Object.extend({ + scaleContent: false, + scaleX: false, + scaleFrom: 0, + scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width}, + restoreAfterFinish: true, + afterSetup: function(effect) { with(Element) { + makePositioned(effect.element); + makePositioned(effect.element.firstChild); + if(window.opera) setStyle(effect.element, {top: ''}); + makeClipping(effect.element); + setStyle(effect.element, {height: '0px'}); + show(element); }}, + afterUpdateInternal: function(effect) { with(Element) { + setStyle(effect.element.firstChild, {bottom: + (effect.dims[0] - effect.element.clientHeight) + 'px' }); }}, + afterFinishInternal: function(effect) { with(Element) { + undoClipping(effect.element); + undoPositioned(effect.element.firstChild); + undoPositioned(effect.element); + setStyle(effect.element.firstChild, {bottom: oldInnerBottom}); }} + }, arguments[1] || {}) + ); +} + +Effect.SlideUp = function(element) { + element = $(element); + Element.cleanWhitespace(element); + var oldInnerBottom = Element.getStyle(element.firstChild, 'bottom'); + return new Effect.Scale(element, 0, + Object.extend({ scaleContent: false, + scaleX: false, + scaleMode: 'box', + scaleFrom: 100, + restoreAfterFinish: true, + beforeStartInternal: function(effect) { with(Element) { + makePositioned(effect.element); + makePositioned(effect.element.firstChild); + if(window.opera) setStyle(effect.element, {top: ''}); + makeClipping(effect.element); + show(element); }}, + afterUpdateInternal: function(effect) { with(Element) { + setStyle(effect.element.firstChild, {bottom: + (effect.dims[0] - effect.element.clientHeight) + 'px' }); }}, + afterFinishInternal: function(effect) { with(Element) { + [hide, undoClipping].call(effect.element); + undoPositioned(effect.element.firstChild); + undoPositioned(effect.element); + setStyle(effect.element.firstChild, {bottom: oldInnerBottom}); }} + }, arguments[1] || {}) + ); +} + +// Bug in opera makes the TD containing this element expand for a instance after finish +Effect.Squish = function(element) { + return new Effect.Scale(element, window.opera ? 1 : 0, + { restoreAfterFinish: true, + beforeSetup: function(effect) { with(Element) { + makeClipping(effect.element); }}, + afterFinishInternal: function(effect) { with(Element) { + hide(effect.element); + undoClipping(effect.element); }} + }); +} + +Effect.Grow = function(element) { + element = $(element); + var options = Object.extend({ + direction: 'center', + moveTransistion: Effect.Transitions.sinoidal, + scaleTransition: Effect.Transitions.sinoidal, + opacityTransition: Effect.Transitions.full + }, arguments[1] || {}); + var oldStyle = { + top: element.style.top, + left: element.style.left, + height: element.style.height, + width: element.style.width, + opacity: Element.getInlineOpacity(element) }; + + var dims = Element.getDimensions(element); + var initialMoveX, initialMoveY; + var moveX, moveY; + + switch (options.direction) { + case 'top-left': + initialMoveX = initialMoveY = moveX = moveY = 0; + break; + case 'top-right': + initialMoveX = dims.width; + initialMoveY = moveY = 0; + moveX = -dims.width; + break; + case 'bottom-left': + initialMoveX = moveX = 0; + initialMoveY = dims.height; + moveY = -dims.height; + break; + case 'bottom-right': + initialMoveX = dims.width; + initialMoveY = dims.height; + moveX = -dims.width; + moveY = -dims.height; + break; + case 'center': + initialMoveX = dims.width / 2; + initialMoveY = dims.height / 2; + moveX = -dims.width / 2; + moveY = -dims.height / 2; + break; + } + + return new Effect.Move(element, { + x: initialMoveX, + y: initialMoveY, + duration: 0.01, + beforeSetup: function(effect) { with(Element) { + hide(effect.element); + makeClipping(effect.element); + makePositioned(effect.element); + }}, + afterFinishInternal: function(effect) { + new Effect.Parallel( + [ new Effect.Opacity(effect.element, { sync: true, to: 1.0, from: 0.0, transition: options.opacityTransition }), + new Effect.Move(effect.element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition }), + new Effect.Scale(effect.element, 100, { + scaleMode: { originalHeight: dims.height, originalWidth: dims.width }, + sync: true, scaleFrom: window.opera ? 1 : 0, transition: options.scaleTransition, restoreAfterFinish: true}) + ], Object.extend({ + beforeSetup: function(effect) { with(Element) { + setStyle(effect.effects[0].element, {height: '0px'}); + show(effect.effects[0].element); }}, + afterFinishInternal: function(effect) { with(Element) { + [undoClipping, undoPositioned].call(effect.effects[0].element); + setStyle(effect.effects[0].element, oldStyle); }} + }, options) + ) + } + }); +} + +Effect.Shrink = function(element) { + element = $(element); + var options = Object.extend({ + direction: 'center', + moveTransistion: Effect.Transitions.sinoidal, + scaleTransition: Effect.Transitions.sinoidal, + opacityTransition: Effect.Transitions.none + }, arguments[1] || {}); + var oldStyle = { + top: element.style.top, + left: element.style.left, + height: element.style.height, + width: element.style.width, + opacity: Element.getInlineOpacity(element) }; + + var dims = Element.getDimensions(element); + var moveX, moveY; + + switch (options.direction) { + case 'top-left': + moveX = moveY = 0; + break; + case 'top-right': + moveX = dims.width; + moveY = 0; + break; + case 'bottom-left': + moveX = 0; + moveY = dims.height; + break; + case 'bottom-right': + moveX = dims.width; + moveY = dims.height; + break; + case 'center': + moveX = dims.width / 2; + moveY = dims.height / 2; + break; + } + + return new Effect.Parallel( + [ new Effect.Opacity(element, { sync: true, to: 0.0, from: 1.0, transition: options.opacityTransition }), + new Effect.Scale(element, window.opera ? 1 : 0, { sync: true, transition: options.scaleTransition, restoreAfterFinish: true}), + new Effect.Move(element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition }) + ], Object.extend({ + beforeStartInternal: function(effect) { with(Element) { + [makePositioned, makeClipping].call(effect.effects[0].element) }}, + afterFinishInternal: function(effect) { with(Element) { + [hide, undoClipping, undoPositioned].call(effect.effects[0].element); + setStyle(effect.effects[0].element, oldStyle); }} + }, options) + ); +} + +Effect.Pulsate = function(element) { + element = $(element); + var options = arguments[1] || {}; + var oldOpacity = Element.getInlineOpacity(element); + var transition = options.transition || Effect.Transitions.sinoidal; + var reverser = function(pos){ return transition(1-Effect.Transitions.pulse(pos)) }; + reverser.bind(transition); + return new Effect.Opacity(element, + Object.extend(Object.extend({ duration: 3.0, from: 0, + afterFinishInternal: function(effect) { Element.setStyle(effect.element, {opacity: oldOpacity}); } + }, options), {transition: reverser})); +} + +Effect.Fold = function(element) { + element = $(element); + var oldStyle = { + top: element.style.top, + left: element.style.left, + width: element.style.width, + height: element.style.height }; + Element.makeClipping(element); + return new Effect.Scale(element, 5, Object.extend({ + scaleContent: false, + scaleX: false, + afterFinishInternal: function(effect) { + new Effect.Scale(element, 1, { + scaleContent: false, + scaleY: false, + afterFinishInternal: function(effect) { with(Element) { + [hide, undoClipping].call(effect.element); + setStyle(effect.element, oldStyle); + }} }); + }}, arguments[1] || {})); +} diff --git a/lightbox/js/lightbox.js b/lightbox/js/lightbox.js new file mode 100755 index 0000000..3b2ecf4 --- /dev/null +++ b/lightbox/js/lightbox.js @@ -0,0 +1,815 @@ +// ----------------------------------------------------------------------------------- +// +// Lightbox v2.03.3 +// by Lokesh Dhakar - http://www.huddletogether.com +// 5/21/06 +// +// For more information on this script, visit: +// http://huddletogether.com/projects/lightbox2/ +// +// Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/ +// +// Credit also due to those who have helped, inspired, and made their code available to the public. +// Including: Scott Upton(uptonic.com), Peter-Paul Koch(quirksmode.com), Thomas Fuchs(mir.aculo.us), and others. +// +// +// ----------------------------------------------------------------------------------- +/* + + Table of Contents + ----------------- + Configuration + Global Variables + + Extending Built-in Objects + - Object.extend(Element) + - Array.prototype.removeDuplicates() + - Array.prototype.empty() + + Lightbox Class Declaration + - initialize() + - updateImageList() + - start() + - changeImage() + - resizeImageContainer() + - showImage() + - updateDetails() + - updateNav() + - enableKeyboardNav() + - disableKeyboardNav() + - keyboardAction() + - preloadNeighborImages() + - end() + + Miscellaneous Functions + - getPageScroll() + - getPageSize() + - getKey() + - listenKey() + - showSelectBoxes() + - hideSelectBoxes() + - showFlash() + - hideFlash() + - pause() + - initLightbox() + + Function Calls + - addLoadEvent(initLightbox) + +*/ +// ----------------------------------------------------------------------------------- + +// +// Configuration +// +var fileLoadingImage = "lightbox/images/loading.gif"; +var fileBottomNavCloseImage = "lightbox/images/closelabel.gif"; + +var overlayOpacity = 0.8; // controls transparency of shadow overlay + +var animate = true; // toggles resizing animations +var resizeSpeed = 8; // controls the speed of the image resizing animations (1=slowest and 10=fastest) + +var borderSize = 10; //if you adjust the padding in the CSS, you will need to update this variable + +// ----------------------------------------------------------------------------------- + +// +// Global Variables +// +var imageArray = new Array; +var activeImage; + +if(animate == true){ + overlayDuration = 0.2; // shadow fade in/out duration + if(resizeSpeed > 10){ resizeSpeed = 10;} + if(resizeSpeed < 1){ resizeSpeed = 1;} + resizeDuration = (11 - resizeSpeed) * 0.15; +} else { + overlayDuration = 0; + resizeDuration = 0; +} + +// ----------------------------------------------------------------------------------- + +// +// Additional methods for Element added by SU, Couloir +// - further additions by Lokesh Dhakar (huddletogether.com) +// +Object.extend(Element, { + getWidth: function(element) { + element = $(element); + return element.offsetWidth; + }, + setWidth: function(element,w) { + element = $(element); + element.style.width = w +"px"; + }, + setHeight: function(element,h) { + element = $(element); + element.style.height = h +"px"; + }, + setTop: function(element,t) { + element = $(element); + element.style.top = t +"px"; + }, + setLeft: function(element,l) { + element = $(element); + element.style.left = l +"px"; + }, + setSrc: function(element,src) { + element = $(element); + element.src = src; + }, + setHref: function(element,href) { + element = $(element); + element.href = href; + }, + setInnerHTML: function(element,content) { + element = $(element); + element.innerHTML = content; + } +}); + +// ----------------------------------------------------------------------------------- + +// +// Extending built-in Array object +// - array.removeDuplicates() +// - array.empty() +// +Array.prototype.removeDuplicates = function () { + for(i = 0; i < this.length; i++){ + for(j = this.length-1; j>i; j--){ + if(this[i][0] == this[j][0]){ + this.splice(j,1); + } + } + } +} + +// ----------------------------------------------------------------------------------- + +Array.prototype.empty = function () { + for(i = 0; i <= this.length; i++){ + this.shift(); + } +} + +// ----------------------------------------------------------------------------------- + +// +// Lightbox Class Declaration +// - initialize() +// - start() +// - changeImage() +// - resizeImageContainer() +// - showImage() +// - updateDetails() +// - updateNav() +// - enableKeyboardNav() +// - disableKeyboardNav() +// - keyboardNavAction() +// - preloadNeighborImages() +// - end() +// +// Structuring of code inspired by Scott Upton (http://www.uptonic.com/) +// +var Lightbox = Class.create(); + +Lightbox.prototype = { + + // initialize() + // Constructor runs on completion of the DOM loading. Calls updateImageList and then + // the function inserts html at the bottom of the page which is used to display the shadow + // overlay and the image container. + // + initialize: function() { + + this.updateImageList(); + + // Code inserts html at the bottom of the page that looks similar to this: + // + //
+ // + + + var objBody = document.getElementsByTagName("body").item(0); + + var objOverlay = document.createElement("div"); + objOverlay.setAttribute('id','overlay'); + objOverlay.style.display = 'none'; + objOverlay.onclick = function() { myLightbox.end(); } + objBody.appendChild(objOverlay); + + var objLightbox = document.createElement("div"); + objLightbox.setAttribute('id','lightbox'); + objLightbox.style.display = 'none'; + objLightbox.onclick = function(e) { // close Lightbox is user clicks shadow overlay + if (!e) var e = window.event; + var clickObj = Event.element(e).id; + if ( clickObj == 'lightbox') { + myLightbox.end(); + } + }; + objBody.appendChild(objLightbox); + + var objOuterImageContainer = document.createElement("div"); + objOuterImageContainer.setAttribute('id','outerImageContainer'); + objLightbox.appendChild(objOuterImageContainer); + + // When Lightbox starts it will resize itself from 250 by 250 to the current image dimension. + // If animations are turned off, it will be hidden as to prevent a flicker of a + // white 250 by 250 box. + if(animate){ + Element.setWidth('outerImageContainer', 250); + Element.setHeight('outerImageContainer', 250); + } else { + Element.setWidth('outerImageContainer', 1); + Element.setHeight('outerImageContainer', 1); + } + + var objImageContainer = document.createElement("div"); + objImageContainer.setAttribute('id','imageContainer'); + objOuterImageContainer.appendChild(objImageContainer); + + var objLightboxImage = document.createElement("img"); + objLightboxImage.setAttribute('id','lightboxImage'); + objImageContainer.appendChild(objLightboxImage); + + var objHoverNav = document.createElement("div"); + objHoverNav.setAttribute('id','hoverNav'); + objImageContainer.appendChild(objHoverNav); + + var objPrevLink = document.createElement("a"); + objPrevLink.setAttribute('id','prevLink'); + objPrevLink.setAttribute('href','#'); + objHoverNav.appendChild(objPrevLink); + + var objNextLink = document.createElement("a"); + objNextLink.setAttribute('id','nextLink'); + objNextLink.setAttribute('href','#'); + objHoverNav.appendChild(objNextLink); + + var objLoading = document.createElement("div"); + objLoading.setAttribute('id','loading'); + objImageContainer.appendChild(objLoading); + + var objLoadingLink = document.createElement("a"); + objLoadingLink.setAttribute('id','loadingLink'); + objLoadingLink.setAttribute('href','#'); + objLoadingLink.onclick = function() { myLightbox.end(); return false; } + objLoading.appendChild(objLoadingLink); + + var objLoadingImage = document.createElement("img"); + objLoadingImage.setAttribute('src', fileLoadingImage); + objLoadingLink.appendChild(objLoadingImage); + + var objImageDataContainer = document.createElement("div"); + objImageDataContainer.setAttribute('id','imageDataContainer'); + objLightbox.appendChild(objImageDataContainer); + + var objImageData = document.createElement("div"); + objImageData.setAttribute('id','imageData'); + objImageDataContainer.appendChild(objImageData); + + var objImageDetails = document.createElement("div"); + objImageDetails.setAttribute('id','imageDetails'); + objImageData.appendChild(objImageDetails); + + var objCaption = document.createElement("span"); + objCaption.setAttribute('id','caption'); + objImageDetails.appendChild(objCaption); + + var objNumberDisplay = document.createElement("span"); + objNumberDisplay.setAttribute('id','numberDisplay'); + objImageDetails.appendChild(objNumberDisplay); + + var objBottomNav = document.createElement("div"); + objBottomNav.setAttribute('id','bottomNav'); + objImageData.appendChild(objBottomNav); + + var objBottomNavCloseLink = document.createElement("a"); + objBottomNavCloseLink.setAttribute('id','bottomNavClose'); + objBottomNavCloseLink.setAttribute('href','#'); + objBottomNavCloseLink.onclick = function() { myLightbox.end(); return false; } + objBottomNav.appendChild(objBottomNavCloseLink); + + var objBottomNavCloseImage = document.createElement("img"); + objBottomNavCloseImage.setAttribute('src', fileBottomNavCloseImage); + objBottomNavCloseLink.appendChild(objBottomNavCloseImage); + }, + + + // + // updateImageList() + // Loops through anchor tags looking for 'lightbox' references and applies onclick + // events to appropriate links. You can rerun after dynamically adding images w/ajax. + // + updateImageList: function() { + if (!document.getElementsByTagName){ return; } + var anchors = document.getElementsByTagName('a'); + var areas = document.getElementsByTagName('area'); + + // loop through all anchor tags + for (var i=0; i 1){ + Element.show('numberDisplay'); + Element.setInnerHTML( 'numberDisplay', "Image " + eval(activeImage + 1) + " of " + imageArray.length); + } + + new Effect.Parallel( + [ new Effect.SlideDown( 'imageDataContainer', { sync: true, duration: resizeDuration, from: 0.0, to: 1.0 }), + new Effect.Appear('imageDataContainer', { sync: true, duration: resizeDuration }) ], + { duration: resizeDuration, afterFinish: function() { + // update overlay size and update nav + var arrayPageSize = getPageSize(); + Element.setHeight('overlay', arrayPageSize[1]); + myLightbox.updateNav(); + } + } + ); + }, + + // + // updateNav() + // Display appropriate previous and next hover navigation. + // + updateNav: function() { + + Element.show('hoverNav'); + + // if not first image in set, display prev image button + if(activeImage != 0){ + Element.show('prevLink'); + document.getElementById('prevLink').onclick = function() { + myLightbox.changeImage(activeImage - 1); return false; + } + } + + // if not last image in set, display next image button + if(activeImage != (imageArray.length - 1)){ + Element.show('nextLink'); + document.getElementById('nextLink').onclick = function() { + myLightbox.changeImage(activeImage + 1); return false; + } + } + + this.enableKeyboardNav(); + }, + + // + // enableKeyboardNav() + // + enableKeyboardNav: function() { + document.onkeydown = this.keyboardAction; + }, + + // + // disableKeyboardNav() + // + disableKeyboardNav: function() { + document.onkeydown = ''; + }, + + // + // keyboardAction() + // + keyboardAction: function(e) { + if (e == null) { // ie + keycode = event.keyCode; + escapeKey = 27; + } else { // mozilla + keycode = e.keyCode; + escapeKey = e.DOM_VK_ESCAPE; + } + + key = String.fromCharCode(keycode).toLowerCase(); + + if((key == 'x') || (key == 'o') || (key == 'c') || (keycode == escapeKey)){ // close lightbox + myLightbox.end(); + } else if((key == 'p') || (keycode == 37)){ // display previous image + if(activeImage != 0){ + myLightbox.disableKeyboardNav(); + myLightbox.changeImage(activeImage - 1); + } + } else if((key == 'n') || (keycode == 39)){ // display next image + if(activeImage != (imageArray.length - 1)){ + myLightbox.disableKeyboardNav(); + myLightbox.changeImage(activeImage + 1); + } + } + + }, + + // + // preloadNeighborImages() + // Preload previous and next images. + // + preloadNeighborImages: function(){ + + if((imageArray.length - 1) > activeImage){ + preloadNextImage = new Image(); + preloadNextImage.src = imageArray[activeImage + 1][0]; + } + if(activeImage > 0){ + preloadPrevImage = new Image(); + preloadPrevImage.src = imageArray[activeImage - 1][0]; + } + + }, + + // + // end() + // + end: function() { + this.disableKeyboardNav(); + Element.hide('lightbox'); + new Effect.Fade('overlay', { duration: overlayDuration}); + showSelectBoxes(); + showFlash(); + } +} + +// ----------------------------------------------------------------------------------- + +// +// getPageScroll() +// Returns array with x,y page scroll values. +// Core code from - quirksmode.com +// +function getPageScroll(){ + + var xScroll, yScroll; + + if (self.pageYOffset) { + yScroll = self.pageYOffset; + xScroll = self.pageXOffset; + } else if (document.documentElement && document.documentElement.scrollTop){ // Explorer 6 Strict + yScroll = document.documentElement.scrollTop; + xScroll = document.documentElement.scrollLeft; + } else if (document.body) {// all other Explorers + yScroll = document.body.scrollTop; + xScroll = document.body.scrollLeft; + } + + arrayPageScroll = new Array(xScroll,yScroll) + return arrayPageScroll; +} + +// ----------------------------------------------------------------------------------- + +// +// getPageSize() +// Returns array with page width, height and window width, height +// Core code from - quirksmode.com +// Edit for Firefox by pHaez +// +function getPageSize(){ + + var xScroll, yScroll; + + if (window.innerHeight && window.scrollMaxY) { + xScroll = window.innerWidth + window.scrollMaxX; + yScroll = window.innerHeight + window.scrollMaxY; + } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac + xScroll = document.body.scrollWidth; + yScroll = document.body.scrollHeight; + } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari + xScroll = document.body.offsetWidth; + yScroll = document.body.offsetHeight; + } + + var windowWidth, windowHeight; + +// console.log(self.innerWidth); +// console.log(document.documentElement.clientWidth); + + if (self.innerHeight) { // all except Explorer + if(document.documentElement.clientWidth){ + windowWidth = document.documentElement.clientWidth; + } else { + windowWidth = self.innerWidth; + } + windowHeight = self.innerHeight; + } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode + windowWidth = document.documentElement.clientWidth; + windowHeight = document.documentElement.clientHeight; + } else if (document.body) { // other Explorers + windowWidth = document.body.clientWidth; + windowHeight = document.body.clientHeight; + } + + // for small pages with total height less then height of the viewport + if(yScroll < windowHeight){ + pageHeight = windowHeight; + } else { + pageHeight = yScroll; + } + +// console.log("xScroll " + xScroll) +// console.log("windowWidth " + windowWidth) + + // for small pages with total width less then width of the viewport + if(xScroll < windowWidth){ + pageWidth = xScroll; + } else { + pageWidth = windowWidth; + } +// console.log("pageWidth " + pageWidth) + + arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) + return arrayPageSize; +} + +// ----------------------------------------------------------------------------------- + +// +// getKey(key) +// Gets keycode. If 'x' is pressed then it hides the lightbox. +// +function getKey(e){ + if (e == null) { // ie + keycode = event.keyCode; + } else { // mozilla + keycode = e.which; + } + key = String.fromCharCode(keycode).toLowerCase(); + + if(key == 'x'){ + } +} + +// ----------------------------------------------------------------------------------- + +// +// listenKey() +// +function listenKey () { document.onkeypress = getKey; } + +// --------------------------------------------------- + +function showSelectBoxes(){ + var selects = document.getElementsByTagName("select"); + for (i = 0; i != selects.length; i++) { + selects[i].style.visibility = "visible"; + } +} + +// --------------------------------------------------- + +function hideSelectBoxes(){ + var selects = document.getElementsByTagName("select"); + for (i = 0; i != selects.length; i++) { + selects[i].style.visibility = "hidden"; + } +} + +// --------------------------------------------------- + +function showFlash(){ + var flashObjects = document.getElementsByTagName("object"); + for (i = 0; i < flashObjects.length; i++) { + flashObjects[i].style.visibility = "visible"; + } + + var flashEmbeds = document.getElementsByTagName("embed"); + for (i = 0; i < flashEmbeds.length; i++) { + flashEmbeds[i].style.visibility = "visible"; + } +} + +// --------------------------------------------------- + +function hideFlash(){ + var flashObjects = document.getElementsByTagName("object"); + for (i = 0; i < flashObjects.length; i++) { + flashObjects[i].style.visibility = "hidden"; + } + + var flashEmbeds = document.getElementsByTagName("embed"); + for (i = 0; i < flashEmbeds.length; i++) { + flashEmbeds[i].style.visibility = "hidden"; + } + +} + + +// --------------------------------------------------- + +// +// pause(numberMillis) +// Pauses code execution for specified time. Uses busy code, not good. +// Help from Ran Bar-On [ran2103@gmail.com] +// + +function pause(ms){ + var date = new Date(); + curDate = null; + do{var curDate = new Date();} + while( curDate - date < ms); +} +/* +function pause(numberMillis) { + var curently = new Date().getTime() + sender; + while (new Date().getTime(); +} +*/ +// --------------------------------------------------- +var myLightbox = null +function initLightbox() { myLightbox = new Lightbox(); } +Event.observe(window, 'load', initLightbox, false); \ No newline at end of file diff --git a/lightbox/js/prototype.js b/lightbox/js/prototype.js new file mode 100755 index 0000000..e9ccd3c --- /dev/null +++ b/lightbox/js/prototype.js @@ -0,0 +1,1785 @@ +/* Prototype JavaScript framework, version 1.4.0 + * (c) 2005 Sam Stephenson + * + * THIS FILE IS AUTOMATICALLY GENERATED. When sending patches, please diff + * against the source tree, available from the Prototype darcs repository. + * + * Prototype is freely distributable under the terms of an MIT-style license. + * + * For details, see the Prototype web site: http://prototype.conio.net/ + * +/*--------------------------------------------------------------------------*/ + +var Prototype = { + Version: '1.4.0', + ScriptFragment: '(?:)((\n|\r|.)*?)(?:<\/script>)', + + emptyFunction: function() {}, + K: function(x) {return x} +} + +var Class = { + create: function() { + return function() { + this.initialize.apply(this, arguments); + } + } +} + +var Abstract = new Object(); + +Object.extend = function(destination, source) { + for (property in source) { + destination[property] = source[property]; + } + return destination; +} + +Object.inspect = function(object) { + try { + if (object == undefined) return 'undefined'; + if (object == null) return 'null'; + return object.inspect ? object.inspect() : object.toString(); + } catch (e) { + if (e instanceof RangeError) return '...'; + throw e; + } +} + +Function.prototype.bind = function() { + var __method = this, args = $A(arguments), object = args.shift(); + return function() { + return __method.apply(object, args.concat($A(arguments))); + } +} + +Function.prototype.bindAsEventListener = function(object) { + var __method = this; + return function(event) { + return __method.call(object, event || window.event); + } +} + +Object.extend(Number.prototype, { + toColorPart: function() { + var digits = this.toString(16); + if (this < 16) return '0' + digits; + return digits; + }, + + succ: function() { + return this + 1; + }, + + times: function(iterator) { + $R(0, this, true).each(iterator); + return this; + } +}); + +var Try = { + these: function() { + var returnValue; + + for (var i = 0; i < arguments.length; i++) { + var lambda = arguments[i]; + try { + returnValue = lambda(); + break; + } catch (e) {} + } + + return returnValue; + } +} + +/*--------------------------------------------------------------------------*/ + +var PeriodicalExecuter = Class.create(); +PeriodicalExecuter.prototype = { + initialize: function(callback, frequency) { + this.callback = callback; + this.frequency = frequency; + this.currentlyExecuting = false; + + this.registerCallback(); + }, + + registerCallback: function() { + setInterval(this.onTimerEvent.bind(this), this.frequency * 1000); + }, + + onTimerEvent: function() { + if (!this.currentlyExecuting) { + try { + this.currentlyExecuting = true; + this.callback(); + } finally { + this.currentlyExecuting = false; + } + } + } +} + +/*--------------------------------------------------------------------------*/ + +function $() { + var elements = new Array(); + + for (var i = 0; i < arguments.length; i++) { + var element = arguments[i]; + if (typeof element == 'string') + element = document.getElementById(element); + + if (arguments.length == 1) + return element; + + elements.push(element); + } + + return elements; +} +Object.extend(String.prototype, { + stripTags: function() { + return this.replace(/<\/?[^>]+>/gi, ''); + }, + + stripScripts: function() { + return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), ''); + }, + + extractScripts: function() { + var matchAll = new RegExp(Prototype.ScriptFragment, 'img'); + var matchOne = new RegExp(Prototype.ScriptFragment, 'im'); + return (this.match(matchAll) || []).map(function(scriptTag) { + return (scriptTag.match(matchOne) || ['', ''])[1]; + }); + }, + + evalScripts: function() { + return this.extractScripts().map(eval); + }, + + escapeHTML: function() { + var div = document.createElement('div'); + var text = document.createTextNode(this); + div.appendChild(text); + return div.innerHTML; + }, + + unescapeHTML: function() { + var div = document.createElement('div'); + div.innerHTML = this.stripTags(); + return div.childNodes[0] ? div.childNodes[0].nodeValue : ''; + }, + + toQueryParams: function() { + var pairs = this.match(/^\??(.*)$/)[1].split('&'); + return pairs.inject({}, function(params, pairString) { + var pair = pairString.split('='); + params[pair[0]] = pair[1]; + return params; + }); + }, + + toArray: function() { + return this.split(''); + }, + + camelize: function() { + var oStringList = this.split('-'); + if (oStringList.length == 1) return oStringList[0]; + + var camelizedString = this.indexOf('-') == 0 + ? oStringList[0].charAt(0).toUpperCase() + oStringList[0].substring(1) + : oStringList[0]; + + for (var i = 1, len = oStringList.length; i < len; i++) { + var s = oStringList[i]; + camelizedString += s.charAt(0).toUpperCase() + s.substring(1); + } + + return camelizedString; + }, + + inspect: function() { + return "'" + this.replace('\\', '\\\\').replace("'", '\\\'') + "'"; + } +}); + +String.prototype.parseQuery = String.prototype.toQueryParams; + +var $break = new Object(); +var $continue = new Object(); + +var Enumerable = { + each: function(iterator) { + var index = 0; + try { + this._each(function(value) { + try { + iterator(value, index++); + } catch (e) { + if (e != $continue) throw e; + } + }); + } catch (e) { + if (e != $break) throw e; + } + }, + + all: function(iterator) { + var result = true; + this.each(function(value, index) { + result = result && !!(iterator || Prototype.K)(value, index); + if (!result) throw $break; + }); + return result; + }, + + any: function(iterator) { + var result = true; + this.each(function(value, index) { + if (result = !!(iterator || Prototype.K)(value, index)) + throw $break; + }); + return result; + }, + + collect: function(iterator) { + var results = []; + this.each(function(value, index) { + results.push(iterator(value, index)); + }); + return results; + }, + + detect: function (iterator) { + var result; + this.each(function(value, index) { + if (iterator(value, index)) { + result = value; + throw $break; + } + }); + return result; + }, + + findAll: function(iterator) { + var results = []; + this.each(function(value, index) { + if (iterator(value, index)) + results.push(value); + }); + return results; + }, + + grep: function(pattern, iterator) { + var results = []; + this.each(function(value, index) { + var stringValue = value.toString(); + if (stringValue.match(pattern)) + results.push((iterator || Prototype.K)(value, index)); + }) + return results; + }, + + include: function(object) { + var found = false; + this.each(function(value) { + if (value == object) { + found = true; + throw $break; + } + }); + return found; + }, + + inject: function(memo, iterator) { + this.each(function(value, index) { + memo = iterator(memo, value, index); + }); + return memo; + }, + + invoke: function(method) { + var args = $A(arguments).slice(1); + return this.collect(function(value) { + return value[method].apply(value, args); + }); + }, + + max: function(iterator) { + var result; + this.each(function(value, index) { + value = (iterator || Prototype.K)(value, index); + if (value >= (result || value)) + result = value; + }); + return result; + }, + + min: function(iterator) { + var result; + this.each(function(value, index) { + value = (iterator || Prototype.K)(value, index); + if (value <= (result || value)) + result = value; + }); + return result; + }, + + partition: function(iterator) { + var trues = [], falses = []; + this.each(function(value, index) { + ((iterator || Prototype.K)(value, index) ? + trues : falses).push(value); + }); + return [trues, falses]; + }, + + pluck: function(property) { + var results = []; + this.each(function(value, index) { + results.push(value[property]); + }); + return results; + }, + + reject: function(iterator) { + var results = []; + this.each(function(value, index) { + if (!iterator(value, index)) + results.push(value); + }); + return results; + }, + + sortBy: function(iterator) { + return this.collect(function(value, index) { + return {value: value, criteria: iterator(value, index)}; + }).sort(function(left, right) { + var a = left.criteria, b = right.criteria; + return a < b ? -1 : a > b ? 1 : 0; + }).pluck('value'); + }, + + toArray: function() { + return this.collect(Prototype.K); + }, + + zip: function() { + var iterator = Prototype.K, args = $A(arguments); + if (typeof args.last() == 'function') + iterator = args.pop(); + + var collections = [this].concat(args).map($A); + return this.map(function(value, index) { + iterator(value = collections.pluck(index)); + return value; + }); + }, + + inspect: function() { + return '#'; + } +} + +Object.extend(Enumerable, { + map: Enumerable.collect, + find: Enumerable.detect, + select: Enumerable.findAll, + member: Enumerable.include, + entries: Enumerable.toArray +}); +var $A = Array.from = function(iterable) { + if (!iterable) return []; + if (iterable.toArray) { + return iterable.toArray(); + } else { + var results = []; + for (var i = 0; i < iterable.length; i++) + results.push(iterable[i]); + return results; + } +} + +Object.extend(Array.prototype, Enumerable); + +Array.prototype._reverse = Array.prototype.reverse; + +Object.extend(Array.prototype, { + _each: function(iterator) { + for (var i = 0; i < this.length; i++) + iterator(this[i]); + }, + + clear: function() { + this.length = 0; + return this; + }, + + first: function() { + return this[0]; + }, + + last: function() { + return this[this.length - 1]; + }, + + compact: function() { + return this.select(function(value) { + return value != undefined || value != null; + }); + }, + + flatten: function() { + return this.inject([], function(array, value) { + return array.concat(value.constructor == Array ? + value.flatten() : [value]); + }); + }, + + without: function() { + var values = $A(arguments); + return this.select(function(value) { + return !values.include(value); + }); + }, + + indexOf: function(object) { + for (var i = 0; i < this.length; i++) + if (this[i] == object) return i; + return -1; + }, + + reverse: function(inline) { + return (inline !== false ? this : this.toArray())._reverse(); + }, + + shift: function() { + var result = this[0]; + for (var i = 0; i < this.length - 1; i++) + this[i] = this[i + 1]; + this.length--; + return result; + }, + + inspect: function() { + return '[' + this.map(Object.inspect).join(', ') + ']'; + } +}); +var Hash = { + _each: function(iterator) { + for (key in this) { + var value = this[key]; + if (typeof value == 'function') continue; + + var pair = [key, value]; + pair.key = key; + pair.value = value; + iterator(pair); + } + }, + + keys: function() { + return this.pluck('key'); + }, + + values: function() { + return this.pluck('value'); + }, + + merge: function(hash) { + return $H(hash).inject($H(this), function(mergedHash, pair) { + mergedHash[pair.key] = pair.value; + return mergedHash; + }); + }, + + toQueryString: function() { + return this.map(function(pair) { + return pair.map(encodeURIComponent).join('='); + }).join('&'); + }, + + inspect: function() { + return '#'; + } +} + +function $H(object) { + var hash = Object.extend({}, object || {}); + Object.extend(hash, Enumerable); + Object.extend(hash, Hash); + return hash; +} +ObjectRange = Class.create(); +Object.extend(ObjectRange.prototype, Enumerable); +Object.extend(ObjectRange.prototype, { + initialize: function(start, end, exclusive) { + this.start = start; + this.end = end; + this.exclusive = exclusive; + }, + + _each: function(iterator) { + var value = this.start; + do { + iterator(value); + value = value.succ(); + } while (this.include(value)); + }, + + include: function(value) { + if (value < this.start) + return false; + if (this.exclusive) + return value < this.end; + return value <= this.end; + } +}); + +var $R = function(start, end, exclusive) { + return new ObjectRange(start, end, exclusive); +} + +var Ajax = { + getTransport: function() { + return Try.these( + function() {return new ActiveXObject('Msxml2.XMLHTTP')}, + function() {return new ActiveXObject('Microsoft.XMLHTTP')}, + function() {return new XMLHttpRequest()} + ) || false; + }, + + activeRequestCount: 0 +} + +Ajax.Responders = { + responders: [], + + _each: function(iterator) { + this.responders._each(iterator); + }, + + register: function(responderToAdd) { + if (!this.include(responderToAdd)) + this.responders.push(responderToAdd); + }, + + unregister: function(responderToRemove) { + this.responders = this.responders.without(responderToRemove); + }, + + dispatch: function(callback, request, transport, json) { + this.each(function(responder) { + if (responder[callback] && typeof responder[callback] == 'function') { + try { + responder[callback].apply(responder, [request, transport, json]); + } catch (e) {} + } + }); + } +}; + +Object.extend(Ajax.Responders, Enumerable); + +Ajax.Responders.register({ + onCreate: function() { + Ajax.activeRequestCount++; + }, + + onComplete: function() { + Ajax.activeRequestCount--; + } +}); + +Ajax.Base = function() {}; +Ajax.Base.prototype = { + setOptions: function(options) { + this.options = { + method: 'post', + asynchronous: true, + parameters: '' + } + Object.extend(this.options, options || {}); + }, + + responseIsSuccess: function() { + return this.transport.status == undefined + || this.transport.status == 0 + || (this.transport.status >= 200 && this.transport.status < 300); + }, + + responseIsFailure: function() { + return !this.responseIsSuccess(); + } +} + +Ajax.Request = Class.create(); +Ajax.Request.Events = + ['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete']; + +Ajax.Request.prototype = Object.extend(new Ajax.Base(), { + initialize: function(url, options) { + this.transport = Ajax.getTransport(); + this.setOptions(options); + this.request(url); + }, + + request: function(url) { + var parameters = this.options.parameters || ''; + if (parameters.length > 0) parameters += '&_='; + + try { + this.url = url; + if (this.options.method == 'get' && parameters.length > 0) + this.url += (this.url.match(/\?/) ? '&' : '?') + parameters; + + Ajax.Responders.dispatch('onCreate', this, this.transport); + + this.transport.open(this.options.method, this.url, + this.options.asynchronous); + + if (this.options.asynchronous) { + this.transport.onreadystatechange = this.onStateChange.bind(this); + setTimeout((function() {this.respondToReadyState(1)}).bind(this), 10); + } + + this.setRequestHeaders(); + + var body = this.options.postBody ? this.options.postBody : parameters; + this.transport.send(this.options.method == 'post' ? body : null); + + } catch (e) { + this.dispatchException(e); + } + }, + + setRequestHeaders: function() { + var requestHeaders = + ['X-Requested-With', 'XMLHttpRequest', + 'X-Prototype-Version', Prototype.Version]; + + if (this.options.method == 'post') { + requestHeaders.push('Content-type', + 'application/x-www-form-urlencoded'); + + /* Force "Connection: close" for Mozilla browsers to work around + * a bug where XMLHttpReqeuest sends an incorrect Content-length + * header. See Mozilla Bugzilla #246651. + */ + if (this.transport.overrideMimeType) + requestHeaders.push('Connection', 'close'); + } + + if (this.options.requestHeaders) + requestHeaders.push.apply(requestHeaders, this.options.requestHeaders); + + for (var i = 0; i < requestHeaders.length; i += 2) + this.transport.setRequestHeader(requestHeaders[i], requestHeaders[i+1]); + }, + + onStateChange: function() { + var readyState = this.transport.readyState; + if (readyState != 1) + this.respondToReadyState(this.transport.readyState); + }, + + header: function(name) { + try { + return this.transport.getResponseHeader(name); + } catch (e) {} + }, + + evalJSON: function() { + try { + return eval(this.header('X-JSON')); + } catch (e) {} + }, + + evalResponse: function() { + try { + return eval(this.transport.responseText); + } catch (e) { + this.dispatchException(e); + } + }, + + respondToReadyState: function(readyState) { + var event = Ajax.Request.Events[readyState]; + var transport = this.transport, json = this.evalJSON(); + + if (event == 'Complete') { + try { + (this.options['on' + this.transport.status] + || this.options['on' + (this.responseIsSuccess() ? 'Success' : 'Failure')] + || Prototype.emptyFunction)(transport, json); + } catch (e) { + this.dispatchException(e); + } + + if ((this.header('Content-type') || '').match(/^text\/javascript/i)) + this.evalResponse(); + } + + try { + (this.options['on' + event] || Prototype.emptyFunction)(transport, json); + Ajax.Responders.dispatch('on' + event, this, transport, json); + } catch (e) { + this.dispatchException(e); + } + + /* Avoid memory leak in MSIE: clean up the oncomplete event handler */ + if (event == 'Complete') + this.transport.onreadystatechange = Prototype.emptyFunction; + }, + + dispatchException: function(exception) { + (this.options.onException || Prototype.emptyFunction)(this, exception); + Ajax.Responders.dispatch('onException', this, exception); + } +}); + +Ajax.Updater = Class.create(); + +Object.extend(Object.extend(Ajax.Updater.prototype, Ajax.Request.prototype), { + initialize: function(container, url, options) { + this.containers = { + success: container.success ? $(container.success) : $(container), + failure: container.failure ? $(container.failure) : + (container.success ? null : $(container)) + } + + this.transport = Ajax.getTransport(); + this.setOptions(options); + + var onComplete = this.options.onComplete || Prototype.emptyFunction; + this.options.onComplete = (function(transport, object) { + this.updateContent(); + onComplete(transport, object); + }).bind(this); + + this.request(url); + }, + + updateContent: function() { + var receiver = this.responseIsSuccess() ? + this.containers.success : this.containers.failure; + var response = this.transport.responseText; + + if (!this.options.evalScripts) + response = response.stripScripts(); + + if (receiver) { + if (this.options.insertion) { + new this.options.insertion(receiver, response); + } else { + Element.update(receiver, response); + } + } + + if (this.responseIsSuccess()) { + if (this.onComplete) + setTimeout(this.onComplete.bind(this), 10); + } + } +}); + +Ajax.PeriodicalUpdater = Class.create(); +Ajax.PeriodicalUpdater.prototype = Object.extend(new Ajax.Base(), { + initialize: function(container, url, options) { + this.setOptions(options); + this.onComplete = this.options.onComplete; + + this.frequency = (this.options.frequency || 2); + this.decay = (this.options.decay || 1); + + this.updater = {}; + this.container = container; + this.url = url; + + this.start(); + }, + + start: function() { + this.options.onComplete = this.updateComplete.bind(this); + this.onTimerEvent(); + }, + + stop: function() { + this.updater.onComplete = undefined; + clearTimeout(this.timer); + (this.onComplete || Prototype.emptyFunction).apply(this, arguments); + }, + + updateComplete: function(request) { + if (this.options.decay) { + this.decay = (request.responseText == this.lastText ? + this.decay * this.options.decay : 1); + + this.lastText = request.responseText; + } + this.timer = setTimeout(this.onTimerEvent.bind(this), + this.decay * this.frequency * 1000); + }, + + onTimerEvent: function() { + this.updater = new Ajax.Updater(this.container, this.url, this.options); + } +}); +document.getElementsByClassName = function(className, parentElement) { + var children = ($(parentElement) || document.body).getElementsByTagName('*'); + return $A(children).inject([], function(elements, child) { + if (child.className.match(new RegExp("(^|\\s)" + className + "(\\s|$)"))) + elements.push(child); + return elements; + }); +} + +/*--------------------------------------------------------------------------*/ + +if (!window.Element) { + var Element = new Object(); +} + +Object.extend(Element, { + visible: function(element) { + return $(element).style.display != 'none'; + }, + + toggle: function() { + for (var i = 0; i < arguments.length; i++) { + var element = $(arguments[i]); + Element[Element.visible(element) ? 'hide' : 'show'](element); + } + }, + + hide: function() { + for (var i = 0; i < arguments.length; i++) { + var element = $(arguments[i]); + element.style.display = 'none'; + } + }, + + show: function() { + for (var i = 0; i < arguments.length; i++) { + var element = $(arguments[i]); + element.style.display = ''; + } + }, + + remove: function(element) { + element = $(element); + element.parentNode.removeChild(element); + }, + + update: function(element, html) { + $(element).innerHTML = html.stripScripts(); + setTimeout(function() {html.evalScripts()}, 10); + }, + + getHeight: function(element) { + element = $(element); + return element.offsetHeight; + }, + + classNames: function(element) { + return new Element.ClassNames(element); + }, + + hasClassName: function(element, className) { + if (!(element = $(element))) return; + return Element.classNames(element).include(className); + }, + + addClassName: function(element, className) { + if (!(element = $(element))) return; + return Element.classNames(element).add(className); + }, + + removeClassName: function(element, className) { + if (!(element = $(element))) return; + return Element.classNames(element).remove(className); + }, + + // removes whitespace-only text node children + cleanWhitespace: function(element) { + element = $(element); + for (var i = 0; i < element.childNodes.length; i++) { + var node = element.childNodes[i]; + if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) + Element.remove(node); + } + }, + + empty: function(element) { + return $(element).innerHTML.match(/^\s*$/); + }, + + scrollTo: function(element) { + element = $(element); + var x = element.x ? element.x : element.offsetLeft, + y = element.y ? element.y : element.offsetTop; + window.scrollTo(x, y); + }, + + getStyle: function(element, style) { + element = $(element); + var value = element.style[style.camelize()]; + if (!value) { + if (document.defaultView && document.defaultView.getComputedStyle) { + var css = document.defaultView.getComputedStyle(element, null); + value = css ? css.getPropertyValue(style) : null; + } else if (element.currentStyle) { + value = element.currentStyle[style.camelize()]; + } + } + + if (window.opera && ['left', 'top', 'right', 'bottom'].include(style)) + if (Element.getStyle(element, 'position') == 'static') value = 'auto'; + + return value == 'auto' ? null : value; + }, + + setStyle: function(element, style) { + element = $(element); + for (name in style) + element.style[name.camelize()] = style[name]; + }, + + getDimensions: function(element) { + element = $(element); + if (Element.getStyle(element, 'display') != 'none') + return {width: element.offsetWidth, height: element.offsetHeight}; + + // All *Width and *Height properties give 0 on elements with display none, + // so enable the element temporarily + var els = element.style; + var originalVisibility = els.visibility; + var originalPosition = els.position; + els.visibility = 'hidden'; + els.position = 'absolute'; + els.display = ''; + var originalWidth = element.clientWidth; + var originalHeight = element.clientHeight; + els.display = 'none'; + els.position = originalPosition; + els.visibility = originalVisibility; + return {width: originalWidth, height: originalHeight}; + }, + + makePositioned: function(element) { + element = $(element); + var pos = Element.getStyle(element, 'position'); + if (pos == 'static' || !pos) { + element._madePositioned = true; + element.style.position = 'relative'; + // Opera returns the offset relative to the positioning context, when an + // element is position relative but top and left have not been defined + if (window.opera) { + element.style.top = 0; + element.style.left = 0; + } + } + }, + + undoPositioned: function(element) { + element = $(element); + if (element._madePositioned) { + element._madePositioned = undefined; + element.style.position = + element.style.top = + element.style.left = + element.style.bottom = + element.style.right = ''; + } + }, + + makeClipping: function(element) { + element = $(element); + if (element._overflow) return; + element._overflow = element.style.overflow; + if ((Element.getStyle(element, 'overflow') || 'visible') != 'hidden') + element.style.overflow = 'hidden'; + }, + + undoClipping: function(element) { + element = $(element); + if (element._overflow) return; + element.style.overflow = element._overflow; + element._overflow = undefined; + } +}); + +var Toggle = new Object(); +Toggle.display = Element.toggle; + +/*--------------------------------------------------------------------------*/ + +Abstract.Insertion = function(adjacency) { + this.adjacency = adjacency; +} + +Abstract.Insertion.prototype = { + initialize: function(element, content) { + this.element = $(element); + this.content = content.stripScripts(); + + if (this.adjacency && this.element.insertAdjacentHTML) { + try { + this.element.insertAdjacentHTML(this.adjacency, this.content); + } catch (e) { + if (this.element.tagName.toLowerCase() == 'tbody') { + this.insertContent(this.contentFromAnonymousTable()); + } else { + throw e; + } + } + } else { + this.range = this.element.ownerDocument.createRange(); + if (this.initializeRange) this.initializeRange(); + this.insertContent([this.range.createContextualFragment(this.content)]); + } + + setTimeout(function() {content.evalScripts()}, 10); + }, + + contentFromAnonymousTable: function() { + var div = document.createElement('div'); + div.innerHTML = '' + this.content + '
'; + return $A(div.childNodes[0].childNodes[0].childNodes); + } +} + +var Insertion = new Object(); + +Insertion.Before = Class.create(); +Insertion.Before.prototype = Object.extend(new Abstract.Insertion('beforeBegin'), { + initializeRange: function() { + this.range.setStartBefore(this.element); + }, + + insertContent: function(fragments) { + fragments.each((function(fragment) { + this.element.parentNode.insertBefore(fragment, this.element); + }).bind(this)); + } +}); + +Insertion.Top = Class.create(); +Insertion.Top.prototype = Object.extend(new Abstract.Insertion('afterBegin'), { + initializeRange: function() { + this.range.selectNodeContents(this.element); + this.range.collapse(true); + }, + + insertContent: function(fragments) { + fragments.reverse(false).each((function(fragment) { + this.element.insertBefore(fragment, this.element.firstChild); + }).bind(this)); + } +}); + +Insertion.Bottom = Class.create(); +Insertion.Bottom.prototype = Object.extend(new Abstract.Insertion('beforeEnd'), { + initializeRange: function() { + this.range.selectNodeContents(this.element); + this.range.collapse(this.element); + }, + + insertContent: function(fragments) { + fragments.each((function(fragment) { + this.element.appendChild(fragment); + }).bind(this)); + } +}); + +Insertion.After = Class.create(); +Insertion.After.prototype = Object.extend(new Abstract.Insertion('afterEnd'), { + initializeRange: function() { + this.range.setStartAfter(this.element); + }, + + insertContent: function(fragments) { + fragments.each((function(fragment) { + this.element.parentNode.insertBefore(fragment, + this.element.nextSibling); + }).bind(this)); + } +}); + +/*--------------------------------------------------------------------------*/ + +Element.ClassNames = Class.create(); +Element.ClassNames.prototype = { + initialize: function(element) { + this.element = $(element); + }, + + _each: function(iterator) { + this.element.className.split(/\s+/).select(function(name) { + return name.length > 0; + })._each(iterator); + }, + + set: function(className) { + this.element.className = className; + }, + + add: function(classNameToAdd) { + if (this.include(classNameToAdd)) return; + this.set(this.toArray().concat(classNameToAdd).join(' ')); + }, + + remove: function(classNameToRemove) { + if (!this.include(classNameToRemove)) return; + this.set(this.select(function(className) { + return className != classNameToRemove; + }).join(' ')); + }, + + toString: function() { + return this.toArray().join(' '); + } +} + +Object.extend(Element.ClassNames.prototype, Enumerable); +var Field = { + clear: function() { + for (var i = 0; i < arguments.length; i++) + $(arguments[i]).value = ''; + }, + + focus: function(element) { + $(element).focus(); + }, + + present: function() { + for (var i = 0; i < arguments.length; i++) + if ($(arguments[i]).value == '') return false; + return true; + }, + + select: function(element) { + $(element).select(); + }, + + activate: function(element) { + element = $(element); + element.focus(); + if (element.select) + element.select(); + } +} + +/*--------------------------------------------------------------------------*/ + +var Form = { + serialize: function(form) { + var elements = Form.getElements($(form)); + var queryComponents = new Array(); + + for (var i = 0; i < elements.length; i++) { + var queryComponent = Form.Element.serialize(elements[i]); + if (queryComponent) + queryComponents.push(queryComponent); + } + + return queryComponents.join('&'); + }, + + getElements: function(form) { + form = $(form); + var elements = new Array(); + + for (tagName in Form.Element.Serializers) { + var tagElements = form.getElementsByTagName(tagName); + for (var j = 0; j < tagElements.length; j++) + elements.push(tagElements[j]); + } + return elements; + }, + + getInputs: function(form, typeName, name) { + form = $(form); + var inputs = form.getElementsByTagName('input'); + + if (!typeName && !name) + return inputs; + + var matchingInputs = new Array(); + for (var i = 0; i < inputs.length; i++) { + var input = inputs[i]; + if ((typeName && input.type != typeName) || + (name && input.name != name)) + continue; + matchingInputs.push(input); + } + + return matchingInputs; + }, + + disable: function(form) { + var elements = Form.getElements(form); + for (var i = 0; i < elements.length; i++) { + var element = elements[i]; + element.blur(); + element.disabled = 'true'; + } + }, + + enable: function(form) { + var elements = Form.getElements(form); + for (var i = 0; i < elements.length; i++) { + var element = elements[i]; + element.disabled = ''; + } + }, + + findFirstElement: function(form) { + return Form.getElements(form).find(function(element) { + return element.type != 'hidden' && !element.disabled && + ['input', 'select', 'textarea'].include(element.tagName.toLowerCase()); + }); + }, + + focusFirstElement: function(form) { + Field.activate(Form.findFirstElement(form)); + }, + + reset: function(form) { + $(form).reset(); + } +} + +Form.Element = { + serialize: function(element) { + element = $(element); + var method = element.tagName.toLowerCase(); + var parameter = Form.Element.Serializers[method](element); + + if (parameter) { + var key = encodeURIComponent(parameter[0]); + if (key.length == 0) return; + + if (parameter[1].constructor != Array) + parameter[1] = [parameter[1]]; + + return parameter[1].map(function(value) { + return key + '=' + encodeURIComponent(value); + }).join('&'); + } + }, + + getValue: function(element) { + element = $(element); + var method = element.tagName.toLowerCase(); + var parameter = Form.Element.Serializers[method](element); + + if (parameter) + return parameter[1]; + } +} + +Form.Element.Serializers = { + input: function(element) { + switch (element.type.toLowerCase()) { + case 'submit': + case 'hidden': + case 'password': + case 'text': + return Form.Element.Serializers.textarea(element); + case 'checkbox': + case 'radio': + return Form.Element.Serializers.inputSelector(element); + } + return false; + }, + + inputSelector: function(element) { + if (element.checked) + return [element.name, element.value]; + }, + + textarea: function(element) { + return [element.name, element.value]; + }, + + select: function(element) { + return Form.Element.Serializers[element.type == 'select-one' ? + 'selectOne' : 'selectMany'](element); + }, + + selectOne: function(element) { + var value = '', opt, index = element.selectedIndex; + if (index >= 0) { + opt = element.options[index]; + value = opt.value; + if (!value && !('value' in opt)) + value = opt.text; + } + return [element.name, value]; + }, + + selectMany: function(element) { + var value = new Array(); + for (var i = 0; i < element.length; i++) { + var opt = element.options[i]; + if (opt.selected) { + var optValue = opt.value; + if (!optValue && !('value' in opt)) + optValue = opt.text; + value.push(optValue); + } + } + return [element.name, value]; + } +} + +/*--------------------------------------------------------------------------*/ + +var $F = Form.Element.getValue; + +/*--------------------------------------------------------------------------*/ + +Abstract.TimedObserver = function() {} +Abstract.TimedObserver.prototype = { + initialize: function(element, frequency, callback) { + this.frequency = frequency; + this.element = $(element); + this.callback = callback; + + this.lastValue = this.getValue(); + this.registerCallback(); + }, + + registerCallback: function() { + setInterval(this.onTimerEvent.bind(this), this.frequency * 1000); + }, + + onTimerEvent: function() { + var value = this.getValue(); + if (this.lastValue != value) { + this.callback(this.element, value); + this.lastValue = value; + } + } +} + +Form.Element.Observer = Class.create(); +Form.Element.Observer.prototype = Object.extend(new Abstract.TimedObserver(), { + getValue: function() { + return Form.Element.getValue(this.element); + } +}); + +Form.Observer = Class.create(); +Form.Observer.prototype = Object.extend(new Abstract.TimedObserver(), { + getValue: function() { + return Form.serialize(this.element); + } +}); + +/*--------------------------------------------------------------------------*/ + +Abstract.EventObserver = function() {} +Abstract.EventObserver.prototype = { + initialize: function(element, callback) { + this.element = $(element); + this.callback = callback; + + this.lastValue = this.getValue(); + if (this.element.tagName.toLowerCase() == 'form') + this.registerFormCallbacks(); + else + this.registerCallback(this.element); + }, + + onElementEvent: function() { + var value = this.getValue(); + if (this.lastValue != value) { + this.callback(this.element, value); + this.lastValue = value; + } + }, + + registerFormCallbacks: function() { + var elements = Form.getElements(this.element); + for (var i = 0; i < elements.length; i++) + this.registerCallback(elements[i]); + }, + + registerCallback: function(element) { + if (element.type) { + switch (element.type.toLowerCase()) { + case 'checkbox': + case 'radio': + Event.observe(element, 'click', this.onElementEvent.bind(this)); + break; + case 'password': + case 'text': + case 'textarea': + case 'select-one': + case 'select-multiple': + Event.observe(element, 'change', this.onElementEvent.bind(this)); + break; + } + } + } +} + +Form.Element.EventObserver = Class.create(); +Form.Element.EventObserver.prototype = Object.extend(new Abstract.EventObserver(), { + getValue: function() { + return Form.Element.getValue(this.element); + } +}); + +Form.EventObserver = Class.create(); +Form.EventObserver.prototype = Object.extend(new Abstract.EventObserver(), { + getValue: function() { + return Form.serialize(this.element); + } +}); +if (!window.Event) { + var Event = new Object(); +} + +Object.extend(Event, { + KEY_BACKSPACE: 8, + KEY_TAB: 9, + KEY_RETURN: 13, + KEY_ESC: 27, + KEY_LEFT: 37, + KEY_UP: 38, + KEY_RIGHT: 39, + KEY_DOWN: 40, + KEY_DELETE: 46, + + element: function(event) { + return event.target || event.srcElement; + }, + + isLeftClick: function(event) { + return (((event.which) && (event.which == 1)) || + ((event.button) && (event.button == 1))); + }, + + pointerX: function(event) { + return event.pageX || (event.clientX + + (document.documentElement.scrollLeft || document.body.scrollLeft)); + }, + + pointerY: function(event) { + return event.pageY || (event.clientY + + (document.documentElement.scrollTop || document.body.scrollTop)); + }, + + stop: function(event) { + if (event.preventDefault) { + event.preventDefault(); + event.stopPropagation(); + } else { + event.returnValue = false; + event.cancelBubble = true; + } + }, + + // find the first node with the given tagName, starting from the + // node the event was triggered on; traverses the DOM upwards + findElement: function(event, tagName) { + var element = Event.element(event); + while (element.parentNode && (!element.tagName || + (element.tagName.toUpperCase() != tagName.toUpperCase()))) + element = element.parentNode; + return element; + }, + + observers: false, + + _observeAndCache: function(element, name, observer, useCapture) { + if (!this.observers) this.observers = []; + if (element.addEventListener) { + this.observers.push([element, name, observer, useCapture]); + element.addEventListener(name, observer, useCapture); + } else if (element.attachEvent) { + this.observers.push([element, name, observer, useCapture]); + element.attachEvent('on' + name, observer); + } + }, + + unloadCache: function() { + if (!Event.observers) return; + for (var i = 0; i < Event.observers.length; i++) { + Event.stopObserving.apply(this, Event.observers[i]); + Event.observers[i][0] = null; + } + Event.observers = false; + }, + + observe: function(element, name, observer, useCapture) { + var element = $(element); + useCapture = useCapture || false; + + if (name == 'keypress' && + (navigator.appVersion.match(/Konqueror|Safari|KHTML/) + || element.attachEvent)) + name = 'keydown'; + + this._observeAndCache(element, name, observer, useCapture); + }, + + stopObserving: function(element, name, observer, useCapture) { + var element = $(element); + useCapture = useCapture || false; + + if (name == 'keypress' && + (navigator.appVersion.match(/Konqueror|Safari|KHTML/) + || element.detachEvent)) + name = 'keydown'; + + if (element.removeEventListener) { + element.removeEventListener(name, observer, useCapture); + } else if (element.detachEvent) { + element.detachEvent('on' + name, observer); + } + } +}); + +/* prevent memory leaks in IE */ +Event.observe(window, 'unload', Event.unloadCache, false); +var Position = { + // set to true if needed, warning: firefox performance problems + // NOT neeeded for page scrolling, only if draggable contained in + // scrollable elements + includeScrollOffsets: false, + + // must be called before calling withinIncludingScrolloffset, every time the + // page is scrolled + prepare: function() { + this.deltaX = window.pageXOffset + || document.documentElement.scrollLeft + || document.body.scrollLeft + || 0; + this.deltaY = window.pageYOffset + || document.documentElement.scrollTop + || document.body.scrollTop + || 0; + }, + + realOffset: function(element) { + var valueT = 0, valueL = 0; + do { + valueT += element.scrollTop || 0; + valueL += element.scrollLeft || 0; + element = element.parentNode; + } while (element); + return [valueL, valueT]; + }, + + cumulativeOffset: function(element) { + var valueT = 0, valueL = 0; + do { + valueT += element.offsetTop || 0; + valueL += element.offsetLeft || 0; + element = element.offsetParent; + } while (element); + return [valueL, valueT]; + }, + + positionedOffset: function(element) { + var valueT = 0, valueL = 0; + do { + valueT += element.offsetTop || 0; + valueL += element.offsetLeft || 0; + element = element.offsetParent; + if (element) { + p = Element.getStyle(element, 'position'); + if (p == 'relative' || p == 'absolute') break; + } + } while (element); + return [valueL, valueT]; + }, + + offsetParent: function(element) { + if (element.offsetParent) return element.offsetParent; + if (element == document.body) return element; + + while ((element = element.parentNode) && element != document.body) + if (Element.getStyle(element, 'position') != 'static') + return element; + + return document.body; + }, + + // caches x/y coordinate pair to use with overlap + within: function(element, x, y) { + if (this.includeScrollOffsets) + return this.withinIncludingScrolloffsets(element, x, y); + this.xcomp = x; + this.ycomp = y; + this.offset = this.cumulativeOffset(element); + + return (y >= this.offset[1] && + y < this.offset[1] + element.offsetHeight && + x >= this.offset[0] && + x < this.offset[0] + element.offsetWidth); + }, + + withinIncludingScrolloffsets: function(element, x, y) { + var offsetcache = this.realOffset(element); + + this.xcomp = x + offsetcache[0] - this.deltaX; + this.ycomp = y + offsetcache[1] - this.deltaY; + this.offset = this.cumulativeOffset(element); + + return (this.ycomp >= this.offset[1] && + this.ycomp < this.offset[1] + element.offsetHeight && + this.xcomp >= this.offset[0] && + this.xcomp < this.offset[0] + element.offsetWidth); + }, + + // within must be called directly before + overlap: function(mode, element) { + if (!mode) return 0; + if (mode == 'vertical') + return ((this.offset[1] + element.offsetHeight) - this.ycomp) / + element.offsetHeight; + if (mode == 'horizontal') + return ((this.offset[0] + element.offsetWidth) - this.xcomp) / + element.offsetWidth; + }, + + clone: function(source, target) { + source = $(source); + target = $(target); + target.style.position = 'absolute'; + var offsets = this.cumulativeOffset(source); + target.style.top = offsets[1] + 'px'; + target.style.left = offsets[0] + 'px'; + target.style.width = source.offsetWidth + 'px'; + target.style.height = source.offsetHeight + 'px'; + }, + + page: function(forElement) { + var valueT = 0, valueL = 0; + + var element = forElement; + do { + valueT += element.offsetTop || 0; + valueL += element.offsetLeft || 0; + + // Safari fix + if (element.offsetParent==document.body) + if (Element.getStyle(element,'position')=='absolute') break; + + } while (element = element.offsetParent); + + element = forElement; + do { + valueT -= element.scrollTop || 0; + valueL -= element.scrollLeft || 0; + } while (element = element.parentNode); + + return [valueL, valueT]; + }, + + clone: function(source, target) { + var options = Object.extend({ + setLeft: true, + setTop: true, + setWidth: true, + setHeight: true, + offsetTop: 0, + offsetLeft: 0 + }, arguments[2] || {}) + + // find page position of source + source = $(source); + var p = Position.page(source); + + // find coordinate system to use + target = $(target); + var delta = [0, 0]; + var parent = null; + // delta [0,0] will do fine with position: fixed elements, + // position:absolute needs offsetParent deltas + if (Element.getStyle(target,'position') == 'absolute') { + parent = Position.offsetParent(target); + delta = Position.page(parent); + } + + // correct by body offsets (fixes Safari) + if (parent == document.body) { + delta[0] -= document.body.offsetLeft; + delta[1] -= document.body.offsetTop; + } + + // set position + if(options.setLeft) target.style.left = (p[0] - delta[0] + options.offsetLeft) + 'px'; + if(options.setTop) target.style.top = (p[1] - delta[1] + options.offsetTop) + 'px'; + if(options.setWidth) target.style.width = source.offsetWidth + 'px'; + if(options.setHeight) target.style.height = source.offsetHeight + 'px'; + }, + + absolutize: function(element) { + element = $(element); + if (element.style.position == 'absolute') return; + Position.prepare(); + + var offsets = Position.positionedOffset(element); + var top = offsets[1]; + var left = offsets[0]; + var width = element.clientWidth; + var height = element.clientHeight; + + element._originalLeft = left - parseFloat(element.style.left || 0); + element._originalTop = top - parseFloat(element.style.top || 0); + element._originalWidth = element.style.width; + element._originalHeight = element.style.height; + + element.style.position = 'absolute'; + element.style.top = top + 'px';; + element.style.left = left + 'px';; + element.style.width = width + 'px';; + element.style.height = height + 'px';; + }, + + relativize: function(element) { + element = $(element); + if (element.style.position == 'relative') return; + Position.prepare(); + + element.style.position = 'relative'; + var top = parseFloat(element.style.top || 0) - (element._originalTop || 0); + var left = parseFloat(element.style.left || 0) - (element._originalLeft || 0); + + element.style.top = top + 'px'; + element.style.left = left + 'px'; + element.style.height = element._originalHeight; + element.style.width = element._originalWidth; + } +} + +// Safari returns margins on body which is incorrect if the child is absolutely +// positioned. For performance reasons, redefine Position.cumulativeOffset for +// KHTML/WebKit only. +if (/Konqueror|Safari|KHTML/.test(navigator.userAgent)) { + Position.cumulativeOffset = function(element) { + var valueT = 0, valueL = 0; + do { + valueT += element.offsetTop || 0; + valueL += element.offsetLeft || 0; + if (element.offsetParent == document.body) + if (Element.getStyle(element, 'position') == 'absolute') break; + + element = element.offsetParent; + } while (element); + + return [valueL, valueT]; + } +} \ No newline at end of file diff --git a/lightbox/js/scriptaculous.js b/lightbox/js/scriptaculous.js new file mode 100755 index 0000000..dac1228 --- /dev/null +++ b/lightbox/js/scriptaculous.js @@ -0,0 +1,45 @@ +// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +var Scriptaculous = { + Version: '1.5.1', + require: function(libraryName) { + // inserting via DOM fails in Safari 2.0, so brute force approach + document.write(''); + }, + load: function() { + if((typeof Prototype=='undefined') || + parseFloat(Prototype.Version.split(".")[0] + "." + + Prototype.Version.split(".")[1]) < 1.4) + throw("script.aculo.us requires the Prototype JavaScript framework >= 1.4.0"); + + $A(document.getElementsByTagName("script")).findAll( function(s) { + return (s.src && s.src.match(/scriptaculous\.js(\?.*)?$/)) + }).each( function(s) { + var path = s.src.replace(/scriptaculous\.js(\?.*)?$/,''); + var includes = s.src.match(/\?.*load=([a-z,]*)/); + (includes ? includes[1] : 'builder,effects,dragdrop,controls,slider').split(',').each( + function(include) { Scriptaculous.require(path+include+'.js') }); + }); + } +} + +Scriptaculous.load(); \ No newline at end of file diff --git a/modules/Makefile b/modules/Makefile new file mode 100755 index 0000000..1675c83 --- /dev/null +++ b/modules/Makefile @@ -0,0 +1,52 @@ +# Répertoire dans lequel se trouve les modules compilés (beam) +rep_ebin = ebin + +# Répertoire dans lequel se trouve les fichiers sources +rep_erl = erl + +# Répertoire dans lequel se trouve les fichier hrl (définition de record) +rep_include = include + +# Paramètre du compilateur +erlc_params = -I $(rep_include) -o $(rep_ebin) $< + +# Compilation de toute l'application euphorik +all: $(rep_ebin)/euphorik_bd.beam \ +$(rep_ebin)/minichat.beam \ +$(rep_ebin)/euphorik_requests.beam \ +$(rep_ebin)/euphorik_protocole.beam \ +$(rep_ebin)/captcha.beam \ +$(rep_ebin)/euphorik_format.beam \ +$(rep_ebin)/euphorik_deamon.beam + +# Module pour la gestion de la BD, principalement la création +$(rep_ebin)/euphorik_bd.beam: $(rep_erl)/euphorik_bd.erl $(rep_include)/euphorik_bd.hrl + erlc $(erlc_params) + +# Module permettant l'ajout et la demande de message dans le minichat +$(rep_ebin)/minichat.beam: $(rep_erl)/minichat.erl $(rep_include)/euphorik_bd.hrl + erlc $(erlc_params) + +# Module traitant les requêtes AJAX du client javascript d'euphorik +$(rep_ebin)/euphorik_requests.beam: $(rep_erl)/euphorik_requests.erl + erlc $(erlc_params) + +# Module interpretant les messages XML du client +$(rep_ebin)/euphorik_protocole.beam: $(rep_erl)/euphorik_protocole.erl + erlc $(erlc_params) + +# Module pour la génération du captcha +$(rep_ebin)/captcha.beam: $(rep_erl)/captcha.erl + erlc $(erlc_params) + +# Module pour le formatage +$(rep_ebin)/euphorik_format.beam: $(rep_erl)/euphorik_format.erl + erlc $(erlc_params) + +# Module effectuant periodiquement certaines tâches +$(rep_ebin)/euphorik_deamon.beam: $(rep_erl)/euphorik_deamon.erl + erlc $(erlc_params) + +# Suppression des modules compilés +clean: + rm ebin/*.beam \ No newline at end of file diff --git a/modules/erl/captcha.erl b/modules/erl/captcha.erl new file mode 100755 index 0000000..e885239 --- /dev/null +++ b/modules/erl/captcha.erl @@ -0,0 +1,31 @@ +% Module permettant la génération de captcha. +% Dépend de la lib 'erlycairo', il faut que son c-node soit démarré. +% Auteur : G.Burri +% Date : 05.11.2007 + +-module(captcha). +-export([create/2]). + +-include("../include/euphorik_defines.hrl"). + + +% Crée un captcha de longueur L dans le dossier Dossier. +% renvoie {Mot crypté:string(), Nom du fichier:string()} +create(L, Dossier) -> + Mot = common:generer_mot(L), + Mot_crypt = common:crypt(Mot), + Nom_fichier = Mot_crypt ++ ".png", + erlycairo:new_image_blank(length(Mot) * 8, 14), + erlycairo:set_source_rgba(0, 0, 0, 1), + erlycairo:select_font_face("Courier", 0, 1), + erlycairo:set_font_size(12), + erlycairo:move_to(2, 10), + erlycairo:show_text(Mot), + erlycairo:move_to(2, 10), + erlycairo:line_to(length(Mot) * 8 - 2, 10), + erlycairo:set_line_width(1), + erlycairo:stroke(), + erlycairo:write_to_png(Dossier ++ "/" ++ Nom_fichier), + erlycairo:close_image(), + {Mot_crypt, Nom_fichier}. + \ No newline at end of file diff --git a/modules/erl/euphorik_bd.erl b/modules/erl/euphorik_bd.erl new file mode 100755 index 0000000..39825bd --- /dev/null +++ b/modules/erl/euphorik_bd.erl @@ -0,0 +1,75 @@ +% Module de création de la base de données euphorik. +% Auteur : G.Burri +% Date : 14.10.2007 + +-module(euphorik_bd). +-export([create/0, create_tables/0, vers_version2/0, vers_version3/0, peupler/0, tester/0]). + +-include("../include/euphorik_bd.hrl"). + + +create() -> + mnesia:stop(), + mnesia:delete_schema([node()]), + mnesia:create_schema([node()]), % nécessaire pour les tables sur disc + mnesia:start(), + create_tables(). + + +create_tables() -> + mnesia:create_table(counter, [ + {attributes, record_info(fields, counter)}, + {disc_copies, [yaws@overnux]} + ]), + mnesia:create_table(minichat, [ + {attributes, record_info(fields, minichat)}, + {index, [auteur_id]}, + {disc_copies, [yaws@overnux]} + ]), + mnesia:create_table(reponse_minichat, [ + {type, bag}, + {attributes, record_info(fields, reponse_minichat)}, + {index, [cible]}, + {disc_copies, [yaws@overnux]} + ]), + mnesia:create_table(user, [ + {attributes, record_info(fields, user)}, + {index, [cookie, login]}, + {disc_copies, [yaws@overnux]} + ]). + + +vers_version2() -> + mnesia:transform_table( + user, + fun({user, Id, Cookie, Pseudo, Date_creation, Date_derniere_connexion, Css}) -> + {user, Id, Cookie, Pseudo, "", "", "", Date_creation, Date_derniere_connexion, Css} + end, + record_info(fields, user), + user + ). + +vers_version3() -> + mnesia:transform_table( + user, + fun({user, Id, Cookie, Pseudo, Login, Password, Email, Date_creation, Date_derniere_connexion, Css}) -> + {user, Id, Cookie, Pseudo, Login, Password, Email, Date_creation, Date_derniere_connexion, Css, 0} + end, + record_info(fields, user), + user + ). + + +% exemple de peuplage de la BD, utilisé pour les tests +peupler() -> + mnesia:transaction( + fun() -> + mnesia:write({minichat, now(), "Pierre", "Salut tout le monde"}), + mnesia:write({minichat, now(), "Paul", "Salut à toi !"}) + end + ). + + +tester() -> + ok. + diff --git a/modules/erl/euphorik_deamon.erl b/modules/erl/euphorik_deamon.erl new file mode 100755 index 0000000..a957475 --- /dev/null +++ b/modules/erl/euphorik_deamon.erl @@ -0,0 +1,25 @@ +% Module tournant en background s'occupant periodiquement de certaines tâches. +% Auteur : G.Burri +% Date : 05.11.2007 + +-module(euphorik_deamon). +-export([start/1]). + +% L'age max que peut avoir les fichier se trouvant dans le dossier 'tmp' (en second) +-define(AGE_MAX_TMP, 86400). % 24 heures + +% Démarre le démon +start(A) -> + loop(A). + + +loop(A) -> + verifier_tmp_captcha(), + timer:sleep(100000), % attend 100 secondes + loop(A). + + +% Vérifie le repertoire tmp où se trouve les captcha et efface les plus vieux. +verifier_tmp_captcha() -> + ok. + \ No newline at end of file diff --git a/modules/erl/euphorik_format.erl b/modules/erl/euphorik_format.erl new file mode 100755 index 0000000..3d60eb1 --- /dev/null +++ b/modules/erl/euphorik_format.erl @@ -0,0 +1,67 @@ +% Attention : Ce module n'est plus utilisé, les fonctions ont été déportées vers le client +% Ce module permet de formater le contenu d'un message : +% - Ajout de balise HTML pour les URL +% - Substitution des smiles par des images +% - Cleanage du contenu des balises HTML +% +% Auteur : G.Burri +% Date : 12.11.2007 + +-module(euphorik_format). +-export([smiles/0, formater_contenu_message/1]). + + +smiles() -> + [ + {":\\)", "smile"}, + {":D", "bigsmile"}, + {"\\[:argn\\]", "argn"}, + {"\\[:lapin\\]", "bunny"}, + {"\\[:chat\\]", "chat"}, + {";\\)", "clin"}, + {"8\\)", "cool"}, + {":P", "eheheh"}, + {"\\[:lol\\]", "lol"}, + {":o", "oh"}, + {">\\(", "pascontent"}, + {"\\[:renne\\]", "renne"}, + {":\\(", "sniff"}, + {"\\[:spliff\\]", "spliff"}, + {"\\[:star\\]", "star"}, + {"\\[:triste\\]", "triste"} + ]. + + +traiter_smiles(M) -> + lists:foldr( + fun({Symbole, Nom}, A) -> + case regexp:gsub(A, Symbole, "") of + {ok, R, _} -> R; + _ -> "ERREUR" + end + end, + M, + smiles() + ). + + + +virer_balises_html(M) -> + case regexp:gsub(M, "]*>", "") of + {ok, R, _} -> R; + _ -> erreur + end. + + +traiter_url(M) -> + case regexp:gsub(M, "http://[^ ]*", "[url]") of + {ok, R, _} -> R; + _ -> erreur + end. + + +formater_contenu_message(M) -> + string:strip(traiter_smiles(traiter_url(virer_balises_html(M)))). + + + diff --git a/modules/erl/euphorik_protocole.erl b/modules/erl/euphorik_protocole.erl new file mode 100755 index 0000000..66555e0 --- /dev/null +++ b/modules/erl/euphorik_protocole.erl @@ -0,0 +1,362 @@ +% coding: utf-8 +% Ce module gére les différents message envoyé par le client (javascript) +% Par exemple le client peut demander les derniers messages du minichat. +% Les messages sont au format XML, la plus part des fonctions accepte un xmlDocument() et renvoie un string() +% qui est la réponse XML. +% Example XML : http://www.erlang.org/doc/apps/xmerl/xmerl_ug.html +% Auteur : G.Burri +% Date : 29.10.2007 + +-module(euphorik_protocole). +-export([ + generation_captcha/1, + nouveau_user_captcha/1, + nouveau_user_login/1, + login/1, + logout/1, + profile/1, + refreshMessage/1, + message/1 +]). +-include_lib("xmerl/include/xmerl.hrl"). +-include("../include/euphorik_bd.hrl"). +-include("../include/euphorik_defines.hrl"). +%-compile(export_all). + + +% Génère un nouveau captchat dans ?DOSSIER_CAPTCHA +generation_captcha(_) -> + {Mot_crypt, Nom_fichier} = captcha:create(5, ?DOSSIER_CAPTCHA), + simple_xml_to_string(xml_reponse_generation_captcha(?DOSSIER_CAPTCHA_RELATIF "/" ++ Nom_fichier, Mot_crypt)). + + +% Un nouvel utilisateur doit être créé +% Action est un xmlElement() +nouveau_user_captcha(Action) -> + simple_xml_to_string( + case {xmerl_xpath:string("captchaCrypt", Action), xmerl_xpath:string("captchaInput", Action)} of + {[#xmlElement{content = [#xmlText{value = C1}]}], [#xmlElement{content = [#xmlText{value = C2}]}]} -> + C2_crypt = common:crypt(C2), + if C1 =:= C2_crypt -> + Cookie = generer_cookie(), + User = minichat:nouveau_user("Paul", Cookie), + xml_reponse_login_ok(User); + true -> + xml_reponse_login_pas_ok("Captcha incorrect") + end; + _ -> + xml_reponse_login_pas_ok("XML malformé") + end + ). + +nouveau_user_login(Action) -> + {Login, Password, Login_deja_pris} = case {xmerl_xpath:string("login", Action), xmerl_xpath:string("password", Action)} of + {[#xmlElement{content = [#xmlText{value = L}]}], [#xmlElement{content = [#xmlText{value = P}]}]} -> + {L, P, case minichat:get_user_by_login(L) of {ok, _} -> true; _ -> false end}; + _ -> {[], [], false} + end, + simple_xml_to_string( + if Login_deja_pris-> + xml_reponse_login_pas_ok("Login déjà pris"); + true -> + Cookie = generer_cookie(), + User = minichat:nouveau_user(Login, Password, Cookie), + xml_reponse_login_ok(User) + end + ). + + +% Un utilisateur se logge +login(Action) -> + case xmerl_xpath:string("cookie", Action) of + [#xmlElement{content = [#xmlText{value = Cookie}]}] -> + loginUser(minichat:get_user_by_cookie(Cookie)); + _ -> + case {xmerl_xpath:string("login", Action), xmerl_xpath:string("password", Action)} of + {[#xmlElement{content = [#xmlText{value = Login}]}], [#xmlElement{content = [#xmlText{value = Password}]}]} -> + loginUser(minichat:get_user_by_login_password(Login, Password)); + _ -> + simple_xml_to_string(xml_reponse_login_pas_ok("XML malformé")) + end + end. +loginUser({ok, User}) -> + minichat:update_date_derniere_connexion(User#user.id), + simple_xml_to_string(xml_reponse_login_ok(User)); +loginUser(_) -> + simple_xml_to_string(xml_reponse_login_pas_ok("Erreur de login")). + + +% Renvoie un string() représentant un cookie en base 36. Il y a 10^32 possibillités. +generer_cookie() -> + {A1,A2,A3} = now(), + random:seed(A1, A2, A3), + erlang:integer_to_list(random:uniform(math:pow(10, 32)), 36). + + +% Un utilisateur se délogge. +logout(_) -> + do_nothing. + + +% Modification du profile. +profile(Action) -> + simple_xml_to_string( + case xmerl_xpath:string("cookie", Action) of + [#xmlElement{content = [#xmlText{value = Cookie}]}] -> + Login = case xmerl_xpath:string("login", Action) of [#xmlElement{content = [#xmlText{value = L}]}] -> L; _ -> undefined end, + Password = case xmerl_xpath:string("password", Action) of [#xmlElement{content = [#xmlText{value = P}]}] -> P; _ -> undefined end, + Pseudo = case xmerl_xpath:string("pseudo", Action) of [#xmlElement{content = [#xmlText{value = P2}]}] -> P2; _ -> Login end, + Email = case xmerl_xpath:string("email", Action) of [#xmlElement{content = [#xmlText{value = E}]}] -> E; _ -> undefined end, + Css = case xmerl_xpath:string("css", Action) of [#xmlElement{content = [#xmlText{value = C}]}] -> C; _ -> undefined end, + case minichat:set_profile(Cookie, Login, Password, Pseudo, Email, Css) of + ok -> + xml_reponse_profile_ok(); + login_deja_pris -> + xml_reponse_profile_pas_ok("Login déjà pris"); + _ -> + xml_reponse_profile_pas_ok("Impossible de mettre à jour le profile") + end; + _ -> + xml_reponse_profile_pas_ok("XML malformé") + end + ). + + +% Renvoie les messages appropriés. +refreshMessage(Action) -> + simple_xml_to_string( + case { + xmerl_xpath:string("nombreMessage", Action), % le nombre de message qu'affiche le client + xmerl_xpath:string("page", Action) % la page désiré, la première (les derniers messages) étant la 1 + } of + { + [#xmlElement{content = [#xmlText{value = Nb_message_str}]}], + [#xmlElement{content = [#xmlText{value = Page_str}]}] + } -> + Nb_message = list_to_integer(Nb_message_str), + Page = list_to_integer(Page_str), + Dernier_id = case xmerl_xpath:string("dernierMessageId", Action) of % l'id du dernier message que connait le client + [#xmlElement{content = [#xmlText{value = D}]}] -> erlang:list_to_integer(D, 36); + _ -> 0 + end, + User = case xmerl_xpath:string("cookie", Action) of + [#xmlElement{content = [#xmlText{value = Cookie}]}] -> + case minichat:get_user_by_cookie(Cookie) of + {ok, U} -> U; + _ -> inconnu + end; + _ -> inconnu + end, + % accrochez-vous ca va siouxer ;) + Mess = lists:map( + fun(Mess) -> + Est_proprietaire = User =/= inconnu andalso User#user.id =:= Mess#minichat.auteur_id, + A_repondu_a_message = User =/= inconnu andalso minichat:a_repondu_a_message(User#user.id, Mess#minichat.id), + Est_une_reponse_a_user = User =/= inconnu andalso minichat:est_une_reponse_a_user(User#user.id, Mess#minichat.id), + User_mess = if Mess#minichat.auteur_id =:= 0 -> inconnu; true -> + {ok, U2} = minichat:get_user_by_id(Mess#minichat.auteur_id), + U2 + end, + {message, [{id, erlang:integer_to_list(Mess#minichat.id, 36)}], + [ + {date, [], [format_date(Mess#minichat.date)]}, + {systeme, [], [atom_to_list(Mess#minichat.auteur_id =:= 0)]}, + {proprietaire, [], [atom_to_list(Est_proprietaire)]}, + {repondu, [], [atom_to_list(A_repondu_a_message)]}, + {reponse, [], [atom_to_list(Est_une_reponse_a_user)]}, + {pseudo, [], [Mess#minichat.pseudo]}, + {login, [], [if User_mess =:= inconnu -> Mess#minichat.pseudo; true -> User_mess#user.login end]}, + {contenu, [], [Mess#minichat.contenu]}, + {repondA, [], xml_repond_a(Mess#minichat.id)} + ] + } + end, + get_dernieres_messages(Dernier_id, Nb_message, Page) + ), + [{reponse, [{name, "refreshMessages"}], + % la fonction get_nb_page DOIT être évalué après get_dernieres_messages (merci les effets de bord) + [{nbPage, [], [integer_to_list(minichat:get_nb_page(Nb_message))]} | Mess] + }]; + _ -> + [{reponse, [{name, "refreshMessages"}], [{erreur, [], ["erreur"]}]}] + end + ). + + +% Renvoie les dernies messages, s'il n'y en a pas on effectue une attente. +get_dernieres_messages(Dernier_id, Nb_message, Page) -> + Messages = minichat:messages(Dernier_id, Nb_message, Page), + if Messages =:= [] -> + minichat:attends_nouveau_messages(), + minichat:messages(Dernier_id, Nb_message, Page); + true -> + Messages + end. + +% Prend une liste de xml text node et en resort un string() +% xmerl : "test & test" devient deux fragments de texte : "test " et "& test", il faut donc rassembler les morceaux... +defragmenter(Text_nodes) -> + lists:foldl(fun(Node, Acc) -> #xmlText{value = V} = Node, Acc ++ V end, [], Text_nodes). + + +% Un utilisateur envoie un message +message(Action) -> + simple_xml_to_string( + case { + xmerl_xpath:string("cookie", Action), + xmerl_xpath:string("pseudo", Action), + xmerl_xpath:string("contenu", Action) + } of + { + [#xmlElement{content = [#xmlText{value = Cookie}]}], + [#xmlElement{content = Pseudo_fragments}], + [#xmlElement{content = Contenu_fragments}] + } -> + case minichat:get_user_by_cookie(Cookie) of + {ok, U} -> + Pseudo = defragmenter(Pseudo_fragments), + Contenu = defragmenter(Contenu_fragments), + % met à jour le pseudo du user + minichat:update_pseudo_user(U#user.id, Pseudo), + Reponses = case xmerl_xpath:string("reponses", Action) of + [#xmlElement{content = C}] -> + lists:map( + fun (Reponse) -> + #xmlElement{attributes = [#xmlAttribute{name = id, value = Id_reponse}]} = Reponse, + erlang:list_to_integer(Id_reponse, 36) + end + , C); + _ -> [] + end, + Contenu_strip = string:strip(Contenu), + if Contenu_strip =:= [] -> xml_reponse_message(pas_ok); + true -> + case minichat:nouveau_message(Contenu, U#user.id, Reponses) of + erreur -> xml_reponse_message(pas_ok); + _ -> xml_reponse_message(ok) + end + end; + _ -> xml_reponse_message(pas_ok) + end; + _ -> + xml_reponse_message(pas_ok) + end + ). + + +% Formatage d'une heure +% local_time() -> string +format_date(Date) -> + DateLocal = calendar:now_to_local_time(Date), + DateNowLocal = calendar:local_time(), + {{Annee, Mois, Jour}, {Heure, Minute, Seconde}} = DateLocal, + {{AnneeNow, _, _}, {_, _, _}} = DateNowLocal, + Hier = calendar:date_to_gregorian_days(element(1, DateLocal)) =:= calendar:date_to_gregorian_days(element(1, DateNowLocal)) - 1, + if element(1, DateLocal) =:= element(1, DateNowLocal) -> + ""; + Hier -> + "Hier "; + Annee =:= AnneeNow -> + io_lib:format("~2.10.0B/~2.10.0B ", [Jour, Mois]); + true -> + io_lib:format("~2.10.0B/~2.10.0B/~B ", [Jour, Mois, Annee]) + end ++ + io_lib:format("~2.10.0B:~2.10.0B:~2.10.0B", [Heure, Minute, Seconde]). + + +%%%%%%%%% %%%%%%%%% +simple_xml_to_string(XML) -> + lists:flatten(xmerl:export_simple(XML, xmerl_xml, [{prolog, ["\n"]}])). + + +% Construit une réponse positive à un login +% si Enregistre vaut true alors cela veut dire que la personne s'est enregistré (elle possède au moins un login et un password) +xml_reponse_login_ok(User) -> + [{reponse, [{name, "login"}], + [ + {statut, [if (User#user.password =/= []) and (User#user.login =/= []) -> "enregistre"; true -> "identifie" end]}, + {cookie, [User#user.cookie]}, + {id, [erlang:integer_to_list(User#user.id, 36)]}, + {pseudo, [User#user.pseudo]}, + {login, [User#user.login]}, + {email, [User#user.email]}, + {css, [User#user.css]} + ] + }]. + + +% Construit un réponse négative à un login +xml_reponse_login_pas_ok(Message) -> + [{reponse, [{name, "login"}], + [ + {statut, ["erreur"]}, + {information, [Message]} + ] + }]. + + +xml_reponse_profile_ok() -> + [{reponse, [{name, "profile"}], + [ + {statut, ["ok"]} + ] + }]. + + +xml_reponse_profile_pas_ok(Message) -> + [{reponse, [{name, "profile"}], + [ + {statut, ["pas ok"]}, + {information, [Message]} + ] + }]. + + +% Pas utilisé +%~ xml_conversation(Mess_id, Nb) -> + %~ {Mess_id, Conversation} = minichat:conversation(Mess_id, Nb), + %~ xml_conversation(Conversation). +%~ xml_conversation([]) -> []; +%~ xml_conversation(Liste_id) -> + %~ lists:map( + %~ fun({Id, Sous_liste}) -> + %~ {id, [{id, erlang:integer_to_list(Id, 36)}], xml_conversation(Sous_liste)} + %~ end, + %~ Liste_id + %~ ). + + +% Renvoie un element XML representant une liste de messages auquel le message M_id repond +xml_repond_a(Mess_id) -> + lists:map( + fun(M) -> + {ok, User} = minichat:get_user_by_id(M#minichat.auteur_id), + {id, [{id, erlang:integer_to_list(M#minichat.id, 36)}, {pseudo, M#minichat.pseudo}, {login, User#user.login}], []} + end, + minichat:repond_a(Mess_id) + ). + + +xml_reponse_message(Ok) -> + [ + {reponse, [{name, "message"}], + [ + {statut, [], [case Ok of ok -> "ok"; pas_ok -> "pas ok" end]} + ] + } + ]. + +xml_reponse_generation_captcha(Chemin, Captcha) -> + [ + {reponse, [{name, "generationCaptcha"}], + [ + {chemin, [], [Chemin]}, + {captchaCrypt, [], [Captcha]} + ] + } + ]. +%%%%%%%%% %%%%%%%%% + + + + diff --git a/modules/erl/euphorik_requests.erl b/modules/erl/euphorik_requests.erl new file mode 100755 index 0000000..a289f0d --- /dev/null +++ b/modules/erl/euphorik_requests.erl @@ -0,0 +1,82 @@ +% coding: utf-8 +% Ce module est fait pour répondre à des requêtes 'AJAX'. +% Auteur : G.Burri +% Date : 22.10.2007 + +-module(euphorik_requests). +-export([ + tester/0, + out/1 +]). + +-include_lib("xmerl/include/xmerl.hrl"). +-include_lib("yaws/include/yaws_api.hrl"). + +% Test du module +tester() -> + %~ {XML, _} = xmerl_scan:string( + %~ "" + %~ " b1b1b4e72e6f3d00e477cf37cced5851" + %~ " LKJDLA" + %~ ""), + %~ io:format("Nouvel user : ~p~n", [nouveau_user(XML)]). + + {XML2, _} = xmerl_scan:string( + "" + " 5DZQ2HCRO7JIX3QCSWRNL" + ""), + io:format("Login : ~p~n", [euphorik_protocole:login(XML2)]). + + %~ {XML, _} = xmerl_scan:string( + %~ "" + %~ "5" + %~ "1" + %~ ""), + %~ io:format("Messages de la premières page : ~p~n", [euphorik_protocole:refreshMessage(XML)]). + + %~ traiter_xml("" + %~ "4UDUSY6Z2IZNTQO484S8X" + %~ "Pifou" + %~ "test & plop" + %~ ""). + %~ traiter_xml( + %~ "" + %~ ""). + +% il faut catcher toutes les exceptions possibles +out(A) -> + %inet:setopts(A#arg.clisock, inet:getopts(A#arg.clisock, [active])), + {value, {_, Contenu}} = lists:keysearch("action", 1, yaws_api:parse_post(A)), + Ret = traiter_xml(Contenu), + {content, "text/xml", Ret}. + + +traiter_xml(Contenu) -> + {XML, _} = xmerl_scan:string(Contenu), + traiter_action(XML#xmlElement.attributes, XML). + + +% un client demande la génération d'un captcha +traiter_action([#xmlAttribute{value="generationCaptcha"}], XML) -> + euphorik_protocole:generation_captcha(XML); +% un client se log pour la première fois +traiter_action([#xmlAttribute{value="loginCaptcha"}], XML) -> + euphorik_protocole:nouveau_user_captcha(XML); +% un client s'enregistre (pseudo + password) +traiter_action([#xmlAttribute{value="register"}], XML) -> + euphorik_protocole:nouveau_user_login(XML); +% authentification d'un client +traiter_action([#xmlAttribute{value="login"}], XML) -> + euphorik_protocole:login(XML); +% modification du profile +traiter_action([#xmlAttribute{value="profile"}], XML) -> + euphorik_protocole:profile(XML); +% le client désire les messages +traiter_action([#xmlAttribute{value="refreshMessages"}], XML) -> + euphorik_protocole:refreshMessage(XML); +% envoie d'un message +traiter_action([#xmlAttribute{value="message"}], XML) -> + euphorik_protocole:message(XML). + + + diff --git a/modules/erl/minichat.erl b/modules/erl/minichat.erl new file mode 100755 index 0000000..29fb4d7 --- /dev/null +++ b/modules/erl/minichat.erl @@ -0,0 +1,445 @@ +% coding: utf-8 +% Ce module permet de gérer les données persistantes lié au minichat d'euphorik.ch +% Il permet d'ajouter des message, de demande les messages sur une page donnée, etc.. +% Ce module utilise la base mnesia créée par le module euphorik_bd. +% Auteur : G.Burri +% Date : 22.10.2007 + +-module(minichat). +-export([ + connect/0, + % get : + messages/1, + messages/2, + messages/3, + conversation/2, + reponses/0, + repond_a/1, + get_nb_page/1, + users/0, + get_user_by_cookie/1, + get_user_by_id/1, + get_user_by_login/1, + get_user_by_login_password/2, + possede_message/2, + a_repondu_a_message/2, + est_une_reponse_a_user/2, + % set : + update_pseudo_user/2, + set_profile/6, + update_date_derniere_connexion/1, + nouveau_user/2, + nouveau_user/3, + nouveau_message/3, + % autre : + attends_nouveau_messages/0, + tester/0, + reset/0]). + +-include("../include/euphorik_bd.hrl"). +-include_lib("stdlib/include/qlc.hrl"). + +% Un message est considéré comme du spam s'il est posté 1 seconde ou moins après le dernier posté +-define(DUREE_SPAM, 1000). % ms + +% Lorsque l'indice de spam d'un utilisateur atteind cette valeur alors il ne peut plus poster pendant un moment +-define(INDICE_SPAM_MAX, 6). + +% Un utilisateur ayant trop spamé est bloqué pendant ce temps +-define(DUREE_BLOCAGE_SPAM, 20000). % ms + + +% Quelques tests du modules. +tester() -> + aplu. + + +% Connexion à la base de données de yaws sur overnux +connect() -> + mnesia:start(), + mnesia:change_config(extra_db_nodes, [yaws@overnux]). + + +% Efface tous les users, minichat_reponse et minichat. +reset() -> + mnesia:clear_table(counter), + mnesia:clear_table(user), + mnesia:clear_table(reponse_minichat), + mnesia:clear_table(minichat), + % crée l'utilisateur root + mnesia:transaction(fun() -> + User = #user{id = 0, pseudo = "Sys", login = "Sys", date_creation = now(), date_derniere_connexion = now()}, + mnesia:write(User), + User + end). + + +% Est-ce qu'un utilisateur existe en fonction de son cookie ? +% Renvoie {ok, User} ou erreur +get_user_by_cookie(Cookie) -> + resultat_transaction(mnesia:transaction( + fun() -> + Users = qlc:e(qlc:q([E || E <- mnesia:table(user), E#user.cookie =:= Cookie])), + case Users of + [User] -> {ok, User}; + _ -> erreur + end + end + )). + + +get_user_by_id(ID) -> + resultat_transaction(mnesia:transaction( + fun() -> + Users = qlc:e(qlc:q([E || E <- mnesia:table(user), E#user.id =:= ID])), + case Users of + [User] -> {ok, User}; + _ -> erreur + end + end + )). + + +get_user_by_login(Login) -> + resultat_transaction(mnesia:transaction( + fun() -> + Users = qlc:e(qlc:q([E || E <- mnesia:table(user), E#user.login =:= Login])), + case Users of + [User] -> {ok, User}; + _ -> erreur + end + end + )). + + +get_user_by_login_password(Login, Password) -> + resultat_transaction(mnesia:transaction( + fun() -> + Users = qlc:e(qlc:q([E || E <- mnesia:table(user), E#user.login =:= Login, E#user.password =:= Password])), + case Users of + [User] -> {ok, User}; + _ -> erreur + end + end + )). + + +% Renvoie l'utilisateur root +get_root() -> + {ok, User} = get_user_by_id(0), + User. + + +% Est-ce que Id_user possède Id_mess ? +possede_message(Id_user, Id_mess) -> + case mnesia:transaction( + fun() -> + qlc:e(qlc:q([E#minichat.auteur_id || E <- mnesia:table(minichat), E#minichat.id =:= Id_mess])) + end + ) of + {atomic, [Id_user | []]} -> true; + _ -> false + end. + + +% Est-ce que Id_user à répondu au message Id_mess +a_repondu_a_message(Id_user, Id_mess) -> + case mnesia:transaction( + fun() -> + qlc:e(qlc:q([ + M#minichat.auteur_id || M <- mnesia:table(minichat), R <- mnesia:table(reponse_minichat), + R#reponse_minichat.cible =:= Id_mess, R#reponse_minichat.repondant =:= M#minichat.id, M#minichat.auteur_id =:= Id_user + ]), [{unique_all, true}]) + end + ) of + {atomic, [_]} -> true; + _ -> false + end. + + +% Est-ce que le message Id_mess est une réponse d'une message de Id_user ? +est_une_reponse_a_user(Id_user, Id_mess) -> + case mnesia:transaction( + fun() -> + qlc:e(qlc:q([ + M#minichat.auteur_id || M <- mnesia:table(minichat), R <- mnesia:table(reponse_minichat), + M#minichat.auteur_id =:= Id_user, M#minichat.id =:= R#reponse_minichat.cible, R#reponse_minichat.repondant =:= Id_mess + ]), [{unique_all, true}]) + end + ) of + {atomic, [_]} -> true; + _ -> false + end. + + +% Met à jour le pseudo du user +update_pseudo_user(UserId, Pseudo) -> + mnesia:transaction( + fun() -> + case mnesia:wread({user, UserId}) of + [User] when User#user.pseudo =/= Pseudo -> + mnesia:write(User#user{pseudo = Pseudo}); + _ -> + mnesia:abort("update_pseudo_user: User inconnu ou pseudo deja à jour") + end + end + ). + + +% Mise à par Cookie les autres peuvent être undefined ce qui veut dire qu'ils ne seront pas modifié. +set_profile(Cookie, Login, Password, Pseudo, Email, Css) -> + resultat_transaction(mnesia:transaction( + fun() -> + case get_user_by_cookie(Cookie) of + {ok, User} -> + case get_user_by_login(Login) of + {ok, U} when U#user.id =/= User#user.id -> + login_deja_pris; + _ -> + User_modifie = User#user{ + login = if is_list(Login) -> Login; true -> User#user.login end, + password = if is_list(Password) -> Password; true -> User#user.password end, + pseudo = if is_list(Pseudo) -> Pseudo; true -> User#user.pseudo end, + email = if is_list(Email) -> Email; true -> User#user.email end, + css = if is_list(Css) -> Css; true -> User#user.css end + }, + mnesia:write(User_modifie), + ok + end; + _ -> erreur + end + end + )). + + +% Met à jour la date de la dernière connexion d'un utilisateur à maintenant +update_date_derniere_connexion(UserId) -> + mnesia:transaction( + fun() -> + case mnesia:wread({user, UserId}) of + [User] -> + mnesia:write(User#user{date_derniere_connexion = now()}); + _ -> + mnesia:abort("update_date_derniere_connexion: User inconnu") + end + end + ). + + +% Ajoute un nouveau user et le renvoie +nouveau_user(Pseudo, Cookie) -> + F = fun() -> + Id = get_nouvel_id(user), + User = #user{id = Id, cookie = Cookie, pseudo = Pseudo, date_creation = now(), date_derniere_connexion = now()}, + mnesia:write(User), + User + end, + resultat_transaction(mnesia:transaction(F)). + + +% Ajoute un nouveau user et le renvoie +nouveau_user(Login, Password, Cookie) -> + F = fun() -> + Id = get_nouvel_id(user), + User = #user{id = Id, cookie = Cookie, pseudo = Login, login = Login, password = Password, date_creation = now(), date_derniere_connexion = now()}, + mnesia:write(User), + User + end, + resultat_transaction(mnesia:transaction(F)). + + +% Ajoute un message. Repond_A est une liste d'id auquel le message répond +% retourne soit l'id du message soit erreur. +nouveau_message(Mess, Auteur_id, Repond_A) -> + % regarde si les id 'Repond_A' existent + F = fun() -> + Nb_id_trouve = length(qlc:e(qlc:q([E#minichat.id || E <- mnesia:table(minichat), lists:member(E#minichat.id, Repond_A)]))), + % est-ce que l'auteur existe ? + Auteur = case qlc:e(qlc:q([E || E <- mnesia:table(user), E#user.id =:= Auteur_id])) of + [A] -> A; + _ -> throw("L'auteur du message est introuvable") + end, + if Nb_id_trouve =/= length(Repond_A) -> throw("Un ou plusieurs messages introuvable"); + true -> ok + end, + Id = get_nouvel_id(minichat), + % compare les dernière + Delta = delta_date_ms(Auteur#user.date_derniere_connexion, now()), + Nouvel_indice_flood = Auteur#user.indice_flood + if Delta =< ?DUREE_SPAM -> 2; true -> -1 end, + Auteur_maj = Auteur#user{ + indice_flood = if Nouvel_indice_flood > ?INDICE_SPAM_MAX -> ?INDICE_SPAM_MAX; Nouvel_indice_flood < 0 -> 0; true -> Nouvel_indice_flood end, + date_derniere_connexion = now() + }, + % est-ce que l'auteur à trop floodé ? + if Auteur#user.indice_flood =/= ?INDICE_SPAM_MAX, Auteur_maj#user.indice_flood =:= ?INDICE_SPAM_MAX, Delta =< ?DUREE_BLOCAGE_SPAM -> + Root = get_root(), + mnesia:write(Auteur#user{indice_flood = Auteur_maj#user.indice_flood}), + mnesia:write(#minichat{id=Id, auteur_id=Root#user.id, date=now(), pseudo=Root#user.pseudo, contenu=Auteur#user.pseudo ++ "(" ++ Auteur#user.login ++ ") est bloqué pour " ++ integer_to_list(trunc(?DUREE_BLOCAGE_SPAM / 1000)) ++ " secondes pour cause de flood.."}), + Id; + Auteur#user.indice_flood =:= ?INDICE_SPAM_MAX, Delta =< ?DUREE_BLOCAGE_SPAM -> + erreur; + true -> + mnesia:write(Auteur_maj), + inserer_reponses(Id, Repond_A), + mnesia:write(#minichat{id=Id, auteur_id=Auteur#user.id, date=now(), pseudo=Auteur#user.pseudo, contenu=Mess}), + Id + end + end, + resultat_transaction(mnesia:transaction(F)). + + +% Retourne la difference entre deux timestamp (erlang:now()) en miliseconde +delta_date_ms(D1, D2) -> + 1000000000 * abs(element(1, D1) - element(1, D2)) + 1000 * abs(element(2, D1) - element(2, D2)) + trunc(abs(element(3, D1) - element(3, D2)) / 1000). + + +% Définit Id_repondant comme étant la réponse à Ids. Ids est une liste d'id. +inserer_reponses(Id_repondant, [Id_mess | Reste]) -> + mnesia:write(#reponse_minichat{repondant = Id_repondant, cible = Id_mess}), + inserer_reponses(Id_repondant, Reste); +inserer_reponses(_, []) -> + ok. + + +% Renvoie un nouvel id pour une table donnée +get_nouvel_id(Table) -> + mnesia:dirty_update_counter(counter, Table, 1). + + +% Attend qu'au moins un nouveau message arrive, function bloquante. +attends_nouveau_messages() -> + case mnesia:subscribe({table, minichat, simple}) of + {error, _} = E -> E; + _ -> + %{ok, F} = file:open("/tmp/log_euphorik_" ++ pid_to_list(self()) ++ ".txt", [write]), + %io:format(F, "Test2~n", []), + attends_nouveau_messages2() + end. +attends_nouveau_messages2() -> + %io:format(F, "En attente d'un message !~n", []), + receive % attente d'un post + {mnesia_table_event, {write, _, _}} -> + mnesia:unsubscribe({table, minichat, simple}); + %io:format(F, "Debloquage !~n", []), + %file:close(F); + %~ {tcp_closed, _} -> + %~ mnesia:unsubscribe({table, minichat, simple}); + _ -> + %io:format(F, "~p~n", [M]), + attends_nouveau_messages2() + % 60 minutes de timeout (le cas ou il n'y a que des consultations et jamais de post) + % Après 60 minutes de connexion, le client doit donc reétablir une connexion + % TODO : pour être mieux : quand le socket se ferme alors un message devrait être envoyé et débloquer ce receive (demande en cours sur la mailing list de yaws) + after 1000 * 60 * 60 -> + mnesia:unsubscribe({table, minichat, simple}) + end. + + +% Renvoie les messages manquants pour la page P en sachant qu'il y a N message +% par page et que le dernier message que l'on possède est Id +messages(Id, N, P) -> + lists:filter(fun (M) -> M#minichat.id > Id end, messages(N, P)). + + +% Renvoie N messages se trouvant sur la page P +messages(N, P) -> + F = fun() -> + C = qlc:cursor(qlc:q([E || E <- qlc:keysort(2, mnesia:table(minichat), [{order, descending}])])), + if P > 1 -> qlc:next_answers(C, N * (P - 1)); + true -> ok + end, + R = qlc:next_answers(C, N), + qlc:delete_cursor(C), + lists:reverse(R) + end, + resultat_transaction(mnesia:transaction(F)). + + +% Renvoie N messages se trouvant sur la première page +messages(N) -> + messages(N, 1). + + +% Renvoie les messages auquels répond M. M est l'id du message. +% La réponse est sous la forme d'un arbre, par exemple : {M, [{3, [{1, []}]},{4, []}]} +% ce qui signifie : M répond à 3 et à 4, 3 répond à 1. +% N est le nombre de message sur une page +conversation(M, N) -> + P = page(M, N), + {M, get_liste_cibles(M, N, P)}. + + +% Renvoie la liste des cibles d'un message M, c'est à dire des messages auquel M répond. N étant le nombre de message par page et +% P la page à laquelle se limite la recherche. +% Voir 'conversation/2' pour plus de détail sur la structure retournée. +get_liste_cibles(M, N, P) -> + resultat_transaction(mnesia:transaction(fun() -> + Cibles = qlc:e(qlc:q([E#reponse_minichat.cible || E <- mnesia:table(reponse_minichat), E#reponse_minichat.repondant =:= M])), + lists:foldl( + fun(E, A) -> + PageE = page(E, N), + if PageE =:= P -> % si E fait partit de la page de l'élément de base alors on le prend + [{E, get_liste_cibles(E, N, P)}| A]; + true -> + A + end + end, [], Cibles) + end)). + + +% Renvoie le nombre de page total en fonction du nombre de message par page N +% TODO : ya pas un moyen moins pourri pour avoir le nombre de record d'une table ? +get_nb_page(N) -> + resultat_transaction(mnesia:transaction(fun() -> + ceiling(length(qlc:e(qlc:q([E#minichat.id || E <- mnesia:table(minichat)]))) / N) + end)). + + +% Renvoie le numéro de la page sur lequel se trouve le message M en sachant qu'il y a N messages par page. +page(M, N) -> + resultat_transaction(mnesia:transaction(fun() -> + ceiling((length(qlc:e(qlc:q([E || E <- mnesia:table(minichat), E#minichat.id >= M])))) / N) + end)). + + +% Bizarre, cette fonction n'existe pas dans la stdlib. +ceiling(X) -> + T = trunc(X), + case (X - T) of + Neg when Neg < 0 -> T; + Pos when Pos > 0 -> T + 1; + _ -> T + end. + + +% Renvoie tous les users. +users() -> + resultat_transaction(mnesia:transaction(fun() -> + qlc:e(qlc:q([E || E <- mnesia:table(user)])) + end)). + + +% Renvoie les reponses (utilisé normalement uniquement pendant le debug). +reponses() -> + F = fun() -> + qlc:e(qlc:q([E || E <- mnesia:table(reponse_minichat)])) + end, + resultat_transaction(mnesia:transaction(F)). + +% Renvoie les messages auquel M_id répond. +repond_a(M_id) -> + resultat_transaction(mnesia:transaction( + fun() -> + qlc:e(qlc:q( + [M || E <- mnesia:table(reponse_minichat), + M <- mnesia:table(minichat), + E#reponse_minichat.repondant =:= M_id, + M#minichat.id =:= E#reponse_minichat.cible])) + end + )). + + +% Renvoie le résultat d'une transaction (en décomposant le tuple fournit) +resultat_transaction({_, T}) -> + T. + \ No newline at end of file diff --git a/modules/include/euphorik_bd.hrl b/modules/include/euphorik_bd.hrl new file mode 100755 index 0000000..7ffeae4 --- /dev/null +++ b/modules/include/euphorik_bd.hrl @@ -0,0 +1,45 @@ +% Auteur : GBurri +% Version 2 + +% Pour générer des id +-record(counter, + { + key, + value + }). + +% décrit un enregistrement d'un message +-record(minichat, + { + id, % integer + auteur_id, % -> user.id + date, % erlang:now() + pseudo, % chaine de caractère + contenu % chaine de caractère + }). + + +% type bag +% 'repondant' repond à 'cible' +-record(reponse_minichat, + { + repondant, % -> minichat.id + cible % -> minichat.id + }). + + +-record(user, + { + id, + cookie, % string() + pseudo = [], % string() + login = [], % string() + password = [], % string() (md5) + email = [], % string() + date_creation, % erlang:now() + date_derniere_connexion, % erlang:now(), est mis à jour lors de n'importe quelle activitée (envoie de message par exemple) + css = [], % string() + indice_flood = 0 % integer() est incrémenté lorsque l'utilisateur envoie trop rapidement des messages. + }). + + \ No newline at end of file diff --git a/modules/include/euphorik_defines.hrl b/modules/include/euphorik_defines.hrl new file mode 100755 index 0000000..42026b6 --- /dev/null +++ b/modules/include/euphorik_defines.hrl @@ -0,0 +1,3 @@ +-define(DOSSIER_CAPTCHA_RELATIF, "img/tmp"). +-define(DOSSIER_CAPTCHA, "/var/www/euphorik/" ?DOSSIER_CAPTCHA_RELATIF). + diff --git a/pages/faq.html b/pages/faq.html new file mode 100755 index 0000000..ca60b9a --- /dev/null +++ b/pages/faq.html @@ -0,0 +1,11 @@ +FAQ + +Pourquoi les couleurs du site font mal aux yeux ? +Le daltonisme du webmaster n'y est surement pas étranger. Il est possible de choisir parmis d'autres styles via le menu en haut à droite. + +Quels-sont les navigateurs supporté ? +Le site a été testé avec succès sous "firefox 2", "safari 3", "Opera 9" et "Konqueror". +Il est déconseillé d'utiliser Microsoft Internet Explorer pour des raisons d'incompatibilités. + +Le site se bloque sous Microsoft Internet Explorer 7 ! +Internet Explorer gère assez mal les connexions persitantes de type Comet/AJAX. Il est conseillé d'utiliser un vrai navigateur comme ceux cités au point précédent. \ No newline at end of file