532e696a1defbcc09023b27f3d5e5a5468f6ad8f
1 /***************************************************************************
2 * Copyright (C) 2003-2010 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");
82 function dynpost(action
, values
)
84 var form
= document
.createElement('form');
88 $('body').get(0).appendChild(form
);
90 for (var k
in values
) {
91 var input
= document
.createElement('input');
92 input
.type
= 'hidden';
94 input
.value
= values
[k
];
95 form
.appendChild(input
);
102 function dynpostkv(action
, k
, v
)
106 dynpost(action
, dict
);
110 // {{{ function RegExp.escape()
112 RegExp
.escape
= function(text
) {
113 if (!arguments
.callee
.sRE
) {
115 '/', '.', '*', '+', '?', '|',
116 '(', ')', '[', ']', '{', '}',
119 arguments
.callee
.sRE
= new RegExp(
120 '(\\' + specials
.join('|\\') + ')', 'g'
123 return text
.replace(arguments
.callee
.sRE
, '\\$1');
128 /***************************************************************************
132 // {{{ function popWin()
134 function popWin(theNode
, w
, h
) {
135 window
.open(theNode
.href
, '_blank',
136 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width='+w
+',height='+h
);
141 // {{{ function goodiesPopup()
143 var __goodies_active
= true;
145 var __goodies_ical
= {
146 default_title
: 'Calendrier iCal',
149 'img': 'images/icons/calendar_view_day.gif',
150 'title': 'Calendrier iCal'},
151 {'url_prefix': 'http://www.google.com/calendar/render?cid=',
152 'img': 'images/goodies/add-google-calendar.gif',
153 'title': 'Ajouter à Google Calendar'},
154 {'url_prefix': 'https://www.google.com/calendar/hosted/polytechnique.org/render?cid=',
155 'img': 'images/goodies/add-google-calendar.gif',
156 'title': 'Ajouter à Google Apps / Calendar'}
160 var __goodies_rss
= {
161 default_title
: 'Fils RSS',
164 'img': 'images/icons/feed.gif',
166 {'url_prefix': 'http://fusion.google.com/add?feedurl=',
167 'img': 'images/goodies/add-google.gif',
168 'alt': 'Add to Google',
169 'title': 'Ajouter à iGoogle/Google Reader'},
170 {'url_prefix': 'http://www.netvibes.com/subscribe.php?url=',
171 'img': 'images/goodies/add-netvibes.gif',
172 'title': 'Ajouter à Netvibes'},
173 {'url_prefix': 'http://add.my.yahoo.com/content?.intl=fr&url=',
174 'img': 'images/goodies/add-yahoo.gif',
175 'alt': 'Add to My Yahoo!',
176 'title': 'Ajouter à My Yahoo!'}
180 function disableGoodiesPopups() {
181 __goodies_active
= false;
184 function goodiesPopup(node
, goodies
) {
185 var text
= '<div style="text-align: center; line-height: 2.2">';
186 for (var site
in goodies
.sites
) {
187 var entry
= goodies
.sites
[site
];
188 var s_alt
= entry
["alt"] ? entry
["alt"] : "";
189 var s_img
= entry
["img"];
190 var s_title
= entry
["title"] ? entry
["title"] : "";
191 var s_url
= entry
["url_prefix"].length
> 0 ? entry
["url_prefix"] + escape(this.href
) : this.href
;
193 text
+= '<a href="' + s_url
+ '"><img src="' + s_img
+ '" title="' + s_title
+ '" alt="' + s_alt
+ '"></a><br />';
195 text
+= '<a href="https://www.polytechnique.org/Xorg/Goodies">Plus de bonus</a> ...</div>';
197 var title
= node
.title
? node
.title
: goodies
.default_title
;
202 if (__goodies_active
) {
203 return overlib(text
, CAPTION
, title
, CLOSETEXT
, 'Fermer', DELAY
, 800, STICKY
, WIDTH
, 150);
211 // {{{ function auto_links()
213 function auto_links() {
214 var url
= document
.URL
;
215 var fqdn
= url
.replace(/^https?:\/\/([^\/]*)\/.*$/,'$1');
216 var light
= (url
.indexOf('display=light') > url
.indexOf('?'));
217 var resource_page
= (url
.indexOf('rss') > -1 || url
.indexOf('ical') > -1);
223 if(!href
|| node
.hasClass('xdx')
224 || href
.indexOf('mailto:') > -1 || href
.indexOf('javascript:') > -1) {
227 if ((href
.indexOf(fqdn
) < 0 && this.className
.indexOf('popup') < 0) || node
.hasClass('popup')) {
228 node
.click(function () { window
.open(this.href
); return false; });
230 if (href
.indexOf(fqdn
) > -1 && light
) {
231 href
= href
.replace(/([^\#\?]*)\??([^\#]*)(\#.*)?/, "$1?display=light&$2$3");
234 rss
= href
.indexOf('rss') > -1;
235 ical
= href
.indexOf('ical') > -1;
237 if (href
.indexOf('http') < 0) {
238 href
= 'http://' + fqdn + '/' + href
;
241 if (this.nodeName
.toLowerCase() == 'a' && !resource_page
) {
242 if (rss
&& href
.indexOf('prefs/rss') < 0 && (href
.indexOf('xml') > -1 || href
.indexOf('hash'))) {
243 goodiesPopup(this, __goodies_rss
);
245 goodiesPopup(this, __goodies_ical
);
248 if(matches
= (/^popup_([0-9]*)x([0-9]*)$/).exec(this.className
)) {
249 var w
= matches
[1], h
= matches
[2];
250 node
.click(function() { return popWin(this, w
, h
); });
254 $('.popup2').click(function() { return popWin(this, 840, 600); });
255 $('.popup3').click(function() { return popWin(this, 640, 800); });
262 /***************************************************************************
266 // {{{ function checkPassword
268 function getType(c
) {
269 if (c
>= 'a' && c
<= 'z') {
271 } else if (c
>= 'A' && c
<= 'Z') {
273 } else if (c
>= '0' && c
<= '9') {
280 function differentTypes(password
) {
283 for (i
= 0 ; i
< password
.length
; ++i
) {
284 var type
= getType(password
.charAt(i
));
285 if (prev
!= 0 && prev
!= type
) {
293 function passwordStrength(password
) {
296 var firstType
= true;
297 var types
= Array(0, 0, 0, 0, 0);
299 for (i
= 0 ; i
< password
.length
; ++i
) {
300 var type
= getType(password
.charAt(i
));
301 if (prev
!= 0 && prev
!= type
) {
306 if (types
[type
] == 0 && !firstType
) {
312 if (password
.length
< 6) {
320 } else if (prop
< 0) {
327 function checkPassword(box
, okLabel
) {
328 var password
= box
.value
;
329 var prop
= passwordStrength(password
);
335 } else if (prop
>= 35) {
344 $("#passwords_measure")
346 .animate({ width
: prop
+ "%",
347 backgroundColor
: color
350 .animate({ backgroundColor
: bgcolor
}, 750);
351 var submitButton
= $(":submit[name='" + passwordprompt_submit
+ "']");
352 if (ok
&& password
.length
>= 6 && differentTypes(password
)) {
353 submitButton
.attr("value", okLabel
);
354 submitButton
.removeAttr("disabled");
356 submitButton
.attr("value", "Mot de passe trop faible");
357 submitButton
.attr("disabled", "disabled");
364 /***************************************************************************
368 $(document
).ready(function() {
371 setInterval(getNow
, 1000);
374 if ($(this).val() === 'Recherche dans l\'annuaire') {
377 $("#quick_button").show();
380 $("#quick_button").hide();
382 $("#quick_button").click(function() {
383 if ($("#quick").val() === 'Recherche dans l\'annuaire'
384 || $("#quick").val() === '') {
391 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: