1 /***************************************************************************
2 * Copyright (C) 2003-2011 Polytechnique.org *
3 * http://opensource.polytechnique.org/ *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software *
18 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
19 ***************************************************************************/
21 var is_IE
= $.browser
.msie
;
23 // {{{ function getNow()
24 var days
= ['Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'];
25 var months
= ['janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet',
26 'août', 'septembre', 'octobre', 'novembre', 'décembre']
31 var mh
= dt
.getMonth();
32 var wd
= dt
.getDate();
33 var yr
= dt
.getYear();
34 if (yr
<1000) yr
+= 1900;
35 var hr
= dt
.getHours();
36 var mi
= dt
.getMinutes();
40 var se
= dt
.getSeconds();
45 $(".date-heure").html(days
[dy
] + ' ' + wd
+ ' ' + months
[mh
] + ' ' + yr
+ '<br />'
46 + hr
+ ':' + mi
+ ':' + se
);
52 function canAddSearchEngine()
54 if (((typeof window
.sidebar
== "object") && $.isFunction(window
.sidebar
.addSearchEngine
))
55 || ((typeof window
.external
== "object") && $.isFunction(window
.external
.AddSearchProvider
))) {
61 function addSearchEngine()
63 var searchURI
= "http://www.polytechnique.org/xorg.opensearch.xml";
64 if ((typeof window
.sidebar
== "object") && $.isFunction(window
.sidebar
.addSearchEngine
)) {
65 window
.sidebar
.addSearchEngine(
67 "http://www.polytechnique.org/images/xorg.png",
68 "Annuaire Polytechnique.org",
72 window
.external
.AddSearchProvider(searchURI
);
74 alert("Impossible d'installer la barre de recherche");
81 /***************************************************************************
85 // {{{ function goodiesPopup()
87 var __goodies_active
= true;
89 var __goodies_ical
= {
90 default_title
: 'Calendrier iCal',
93 'img': 'images/icons/calendar_view_day.gif',
94 'title': 'Calendrier iCal'},
95 {'url_prefix': 'http://www.google.com/calendar/render?cid=',
96 'img': 'images/goodies/add-google-calendar.gif',
97 'title': 'Ajouter à Google Calendar'},
98 {'url_prefix': 'https://www.google.com/calendar/hosted/polytechnique.org/render?cid=',
99 'img': 'images/goodies/add-google-calendar.gif',
100 'title': 'Ajouter à Google Apps / Calendar'}
104 var __goodies_rss
= {
105 default_title
: 'Fils RSS',
108 'img': 'images/icons/feed.gif',
110 {'url_prefix': 'http://fusion.google.com/add?feedurl=',
111 'img': 'images/goodies/add-google.gif',
112 'alt': 'Add to Google',
113 'title': 'Ajouter à iGoogle/Google Reader'},
114 {'url_prefix': 'http://www.netvibes.com/subscribe.php?url=',
115 'img': 'images/goodies/add-netvibes.gif',
116 'title': 'Ajouter à Netvibes'},
117 {'url_prefix': 'http://add.my.yahoo.com/content?.intl=fr&url=',
118 'img': 'images/goodies/add-yahoo.gif',
119 'alt': 'Add to My Yahoo!',
120 'title': 'Ajouter à My Yahoo!'}
124 function disableGoodiesPopups() {
125 __goodies_active
= false;
128 function goodiesPopup(node
, goodies
) {
129 var text
= '<div style="text-align: center; line-height: 2.2">';
130 for (var site
in goodies
.sites
) {
131 var entry
= goodies
.sites
[site
];
132 var s_alt
= entry
["alt"] ? entry
["alt"] : "";
133 var s_img
= entry
["img"];
134 var s_title
= entry
["title"] ? entry
["title"] : "";
135 var s_url
= entry
["url_prefix"].length
> 0 ? entry
["url_prefix"] + escape(this.href
) : this.href
;
137 text
+= '<a href="' + s_url
+ '"><img src="' + s_img
+ '" title="' + s_title
+ '" alt="' + s_alt
+ '"></a><br />';
139 text
+= '<a href="https://www.polytechnique.org/Xorg/Goodies">Plus de bonus</a> ...</div>';
141 var title
= node
.title
? node
.title
: goodies
.default_title
;
146 if (__goodies_active
) {
147 return overlib(text
, CAPTION
, title
, CLOSETEXT
, 'Fermer', DELAY
, 800, STICKY
, WIDTH
, 150);
155 // {{{ function auto_links()
157 function auto_links() {
158 var url
= document
.URL
;
159 var fqdn
= url
.replace(/^https?:\/\/([^\/]*)\/.*$/,'$1');
160 var light
= (url
.indexOf('display=light') > url
.indexOf('?'));
161 var resource_page
= (url
.indexOf('rss') > -1 || url
.indexOf('ical') > -1);
163 $("a,link").each(function(i
) {
165 var href
= this.href
;
166 if(!href
|| node
.hasClass('xdx')
167 || href
.indexOf('mailto:') > -1 || href
.indexOf('javascript:') > -1) {
170 if ((href
.indexOf(fqdn
) < 0 && this.className
.indexOf('popup') < 0) || node
.hasClass('popup')) {
171 node
.click(function () {
176 if (href
.indexOf(fqdn
) > -1 && light
) {
177 href
= href
.replace(/([^\#\?]*)\??([^\#]*)(\#.*)?/, "$1?display=light&$2$3");
180 var rss
= href
.indexOf('rss') > -1;
181 var ical
= href
.indexOf('ical') > -1;
183 if (href
.indexOf('http') < 0) {
184 href
= 'http://' + fqdn + '/' + href
;
187 if (this.nodeName
.toLowerCase() == 'a' && !resource_page
) {
188 if (rss
&& href
.indexOf('prefs/rss') < 0 && (href
.indexOf('xml') > -1 || href
.indexOf('hash'))) {
189 goodiesPopup(this, __goodies_rss
);
191 goodiesPopup(this, __goodies_ical
);
194 if(matches
= (/^popup_([0-9]*)x([0-9]*)$/).exec(this.className
)) {
195 var w
= matches
[1], h
= matches
[2];
199 $('.popup2').popWin(840, 600);
200 $('.popup3').popWin(640, 800);
206 /***************************************************************************
210 // {{{ function checkPassword
212 function getType(c
) {
213 if (c
>= 'a' && c
<= 'z') {
215 } else if (c
>= 'A' && c
<= 'Z') {
217 } else if (c
>= '0' && c
<= '9') {
224 function differentTypes(password
) {
227 for (i
= 0 ; i
< password
.length
; ++i
) {
228 var type
= getType(password
.charAt(i
));
229 if (prev
!= 0 && prev
!= type
) {
237 function passwordStrength(password
) {
240 var firstType
= true;
241 var types
= Array(0, 0, 0, 0, 0);
243 for (i
= 0 ; i
< password
.length
; ++i
) {
244 var type
= getType(password
.charAt(i
));
245 if (prev
!= 0 && prev
!= type
) {
250 if (types
[type
] == 0 && !firstType
) {
256 if (password
.length
< 6) {
264 } else if (prop
< 0) {
271 function checkPassword(box
, okLabel
) {
272 var password
= box
.value
;
273 var prop
= passwordStrength(password
);
279 } else if (prop
>= 35) {
288 $("#passwords_measure")
290 .animate({ width
: prop
+ "%",
291 backgroundColor
: color
294 .animate({ backgroundColor
: bgcolor
}, 750);
295 var submitButton
= $(":submit[name='" + passwordprompt_submit
+ "']");
296 if (ok
&& password
.length
>= 6 && differentTypes(password
)) {
297 submitButton
.attr("value", okLabel
);
298 submitButton
.removeAttr("disabled");
300 submitButton
.attr("value", "Mot de passe trop faible");
301 submitButton
.attr("disabled", "disabled");
306 // {{{ send test email
308 function sendTestEmail(token
, hruid
)
310 var url
= 'emails/test';
311 var msg
= "Un email a été envoyé avec succès";
314 msg
+= " sur l'adresse de " + hruid
+ ".";
316 msg
+= " sur ton addresse.";
318 $('#mail_sent').successMessage($url
+ '?token=' + token
, msg
);
325 /***************************************************************************
332 setInterval(getNow
, 1000);
335 if ($(this).val() === 'Recherche dans l\'annuaire') {
338 $("#quick_button").show();
341 $("#quick_button").hide();
343 $("#quick_button").click(function() {
344 if ($("#quick").val() === 'Recherche dans l\'annuaire'
345 || $("#quick").val() === '') {
352 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: